faxforagents-mcp 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { createHash } from "crypto";
13
13
  import { z as z3 } from "zod";
14
14
 
15
15
  // src/version.ts
16
- var VERSION = "0.5.2";
16
+ var VERSION = "0.5.4";
17
17
 
18
18
  // src/api.ts
19
19
  var DEFAULT_BASE_URL = "https://api.faxforagents.com";
@@ -150,6 +150,8 @@ An empty result cannot prove no fax was sent. Never replace an uncertain send wi
150
150
  10 minutes and is used by exactly one send. The quote carries the policy verdict under
151
151
  policy: decision (allow or deny), the first failing rule, and approval_required, which says
152
152
  whether a person must approve it. It is the same evaluation the server runs at send time.
153
+ With a test key under no policy the decision is allow and policy_id is null: the sandbox
154
+ sends without an approval.
153
155
  4. send_approved_fax(quote_id, approval_id?): queues the fax. The answer says queued, never
154
156
  delivered: a fax is delivered only when the carrier's evidence is on the attempt. A quote that
155
157
  needs authorization is sent with an approval_id (see approvals) or under a delegated policy
@@ -174,7 +176,7 @@ human reconcile. cancel_fax works while the fax is queued; once sending it is be
174
176
  - partial: the call dropped after some pages; pages_sent says how many. Those pages were
175
177
  charged, the rest released. No automatic retransmit: a human decides whether to resend.
176
178
  - failed: nothing arrived (failure_code says why: busy, no_answer, invalid_number, canceled).
177
- The hold was released. Busy and no answer were already tried three times in all.
179
+ The hold was released. Busy and no answer were already tried up to three times in all.
178
180
  - unknown: the carrier gave no outcome (timeout or missing callback). The fax may have arrived.
179
181
  Nothing retransmits on its own; the hold stays until a reconcile. Say exactly that.`,
180
182
  errors: `error_code values and what to do:
@@ -182,7 +184,10 @@ human reconcile. cancel_fax works while the fax is queued; once sending it is be
182
184
  - invalid_token: the key was rejected. Over HTTP send Authorization: Bearer ffa_test_... (or
183
185
  X-API-Key) on every request; over stdio set FAXFORAGENTS_API_KEY in the client's environment.
184
186
  - scope_missing (details.scope): ask the key's owner for a key with that scope.
185
- - not_found: not an id of your organization, or it was deleted.
187
+ - invalid_input: an argument is missing, has the wrong type or is not one the tool takes. The
188
+ message names it and, for a near miss, the argument that was meant. Nothing was done.
189
+ - not_found: not an id of your organization, or it was deleted. quote_fax says which of
190
+ document_id and from_number it was.
186
191
  - invalid_destination / unsupported_destination: fix the number (E.164), or the route is not on
187
192
  the rate card or is excluded by policy. get_fax_capabilities lists the routes in force.
188
193
  - unsupported_format, encrypted_pdf, conversion_failed, page_limit_exceeded: fix the input
@@ -686,6 +691,19 @@ var output_schemas_default = {
686
691
  default: null,
687
692
  title: "Amount Micro"
688
693
  },
694
+ authorized_at: {
695
+ anyOf: [
696
+ {
697
+ type: "string"
698
+ },
699
+ {
700
+ type: "null"
701
+ }
702
+ ],
703
+ default: null,
704
+ description: "On a receipt: when the card was held.",
705
+ title: "Authorized At"
706
+ },
689
707
  captured_micro: {
690
708
  anyOf: [
691
709
  {
@@ -722,10 +740,52 @@ var output_schemas_default = {
722
740
  description: "The pages of the order's document. The cover sheet is not counted.",
723
741
  title: "Document Pages"
724
742
  },
743
+ email: {
744
+ anyOf: [
745
+ {
746
+ type: "string"
747
+ },
748
+ {
749
+ type: "null"
750
+ }
751
+ ],
752
+ default: null,
753
+ description: "On a receipt: the address the order was made with.",
754
+ title: "Email"
755
+ },
756
+ failure_code: {
757
+ anyOf: [
758
+ {
759
+ type: "string"
760
+ },
761
+ {
762
+ type: "null"
763
+ }
764
+ ],
765
+ default: null,
766
+ description: "On a receipt: why the order ended unpaid.",
767
+ title: "Failure Code"
768
+ },
725
769
  order_id: {
726
770
  title: "Order Id",
727
771
  type: "string"
728
772
  },
773
+ price: {
774
+ anyOf: [
775
+ {
776
+ additionalProperties: {
777
+ type: "integer"
778
+ },
779
+ type: "object"
780
+ },
781
+ {
782
+ type: "null"
783
+ }
784
+ ],
785
+ default: null,
786
+ description: "On a receipt: flat_micro, included_pages and extra_page_micro the amount follows from.",
787
+ title: "Price"
788
+ },
729
789
  refunded_micro: {
730
790
  anyOf: [
731
791
  {
@@ -739,6 +799,32 @@ var output_schemas_default = {
739
799
  description: "What was refunded to the card after the charge, in micro-units.",
740
800
  title: "Refunded Micro"
741
801
  },
802
+ sender_name: {
803
+ anyOf: [
804
+ {
805
+ type: "string"
806
+ },
807
+ {
808
+ type: "null"
809
+ }
810
+ ],
811
+ default: null,
812
+ description: "On a receipt: the sender's name.",
813
+ title: "Sender Name"
814
+ },
815
+ settled_at: {
816
+ anyOf: [
817
+ {
818
+ type: "string"
819
+ },
820
+ {
821
+ type: "null"
822
+ }
823
+ ],
824
+ default: null,
825
+ description: "On a receipt: when the payment provider confirmed the charge, or the release.",
826
+ title: "Settled At"
827
+ },
742
828
  status: {
743
829
  anyOf: [
744
830
  {
@@ -1807,6 +1893,19 @@ var output_schemas_default = {
1807
1893
  default: null,
1808
1894
  title: "Amount Micro"
1809
1895
  },
1896
+ authorized_at: {
1897
+ anyOf: [
1898
+ {
1899
+ type: "string"
1900
+ },
1901
+ {
1902
+ type: "null"
1903
+ }
1904
+ ],
1905
+ default: null,
1906
+ description: "On a receipt: when the card was held.",
1907
+ title: "Authorized At"
1908
+ },
1810
1909
  captured_micro: {
1811
1910
  anyOf: [
1812
1911
  {
@@ -1843,10 +1942,52 @@ var output_schemas_default = {
1843
1942
  description: "The pages of the order's document. The cover sheet is not counted.",
1844
1943
  title: "Document Pages"
1845
1944
  },
1945
+ email: {
1946
+ anyOf: [
1947
+ {
1948
+ type: "string"
1949
+ },
1950
+ {
1951
+ type: "null"
1952
+ }
1953
+ ],
1954
+ default: null,
1955
+ description: "On a receipt: the address the order was made with.",
1956
+ title: "Email"
1957
+ },
1958
+ failure_code: {
1959
+ anyOf: [
1960
+ {
1961
+ type: "string"
1962
+ },
1963
+ {
1964
+ type: "null"
1965
+ }
1966
+ ],
1967
+ default: null,
1968
+ description: "On a receipt: why the order ended unpaid.",
1969
+ title: "Failure Code"
1970
+ },
1846
1971
  order_id: {
1847
1972
  title: "Order Id",
1848
1973
  type: "string"
1849
1974
  },
1975
+ price: {
1976
+ anyOf: [
1977
+ {
1978
+ additionalProperties: {
1979
+ type: "integer"
1980
+ },
1981
+ type: "object"
1982
+ },
1983
+ {
1984
+ type: "null"
1985
+ }
1986
+ ],
1987
+ default: null,
1988
+ description: "On a receipt: flat_micro, included_pages and extra_page_micro the amount follows from.",
1989
+ title: "Price"
1990
+ },
1850
1991
  refunded_micro: {
1851
1992
  anyOf: [
1852
1993
  {
@@ -1860,6 +2001,32 @@ var output_schemas_default = {
1860
2001
  description: "What was refunded to the card after the charge, in micro-units.",
1861
2002
  title: "Refunded Micro"
1862
2003
  },
2004
+ sender_name: {
2005
+ anyOf: [
2006
+ {
2007
+ type: "string"
2008
+ },
2009
+ {
2010
+ type: "null"
2011
+ }
2012
+ ],
2013
+ default: null,
2014
+ description: "On a receipt: the sender's name.",
2015
+ title: "Sender Name"
2016
+ },
2017
+ settled_at: {
2018
+ anyOf: [
2019
+ {
2020
+ type: "string"
2021
+ },
2022
+ {
2023
+ type: "null"
2024
+ }
2025
+ ],
2026
+ default: null,
2027
+ description: "On a receipt: when the payment provider confirmed the charge, or the release.",
2028
+ title: "Settled At"
2029
+ },
1863
2030
  status: {
1864
2031
  anyOf: [
1865
2032
  {
@@ -2058,6 +2225,12 @@ var output_schemas_default = {
2058
2225
  title: "Environment",
2059
2226
  type: "string"
2060
2227
  },
2228
+ held_jobs: {
2229
+ default: 0,
2230
+ description: "How many fax jobs still have their hold in place: queued, sending, or ended unknown and waiting for a reconcile. Their holds add up to held_micro.",
2231
+ title: "Held Jobs",
2232
+ type: "integer"
2233
+ },
2061
2234
  held_micro: {
2062
2235
  title: "Held Micro",
2063
2236
  type: "integer"
@@ -2154,10 +2327,26 @@ var output_schemas_default = {
2154
2327
  Capabilities: {
2155
2328
  additionalProperties: true,
2156
2329
  properties: {
2330
+ admin_scopes: {
2331
+ description: "The scopes that administer the organization: keys, webhooks, billing, members, policies, agents, approval decisions and number purchases. An agent's own key never carries one.",
2332
+ items: {
2333
+ type: "string"
2334
+ },
2335
+ title: "Admin Scopes",
2336
+ type: "array"
2337
+ },
2157
2338
  approvals: {
2158
2339
  title: "Approvals",
2159
2340
  type: "boolean"
2160
2341
  },
2342
+ default_scopes: {
2343
+ description: "The scopes a key gets when POST /v1/api-keys names none.",
2344
+ items: {
2345
+ type: "string"
2346
+ },
2347
+ title: "Default Scopes",
2348
+ type: "array"
2349
+ },
2161
2350
  environment: {
2162
2351
  enum: [
2163
2352
  "live",
@@ -2232,6 +2421,7 @@ var output_schemas_default = {
2232
2421
  type: "array"
2233
2422
  },
2234
2423
  scopes: {
2424
+ description: "Every scope the platform defines, the list a new key is made from. It is not what the calling credential holds: GET /v1/me returns that under scopes.",
2235
2425
  items: {
2236
2426
  type: "string"
2237
2427
  },
@@ -2327,7 +2517,8 @@ var output_schemas_default = {
2327
2517
  type: "null"
2328
2518
  }
2329
2519
  ],
2330
- default: null
2520
+ default: null,
2521
+ description: "What the server offers. capabilities.scopes is every scope the platform defines, not what this credential holds."
2331
2522
  },
2332
2523
  details: {
2333
2524
  default: null,
@@ -2355,7 +2546,8 @@ var output_schemas_default = {
2355
2546
  type: "null"
2356
2547
  }
2357
2548
  ],
2358
- default: null
2549
+ default: null,
2550
+ description: "The calling credential. me.scopes is what it may do."
2359
2551
  },
2360
2552
  message: {
2361
2553
  title: "Message",
@@ -2399,6 +2591,18 @@ var output_schemas_default = {
2399
2591
  title: "Content Type",
2400
2592
  type: "string"
2401
2593
  },
2594
+ converted_from: {
2595
+ anyOf: [
2596
+ {
2597
+ type: "string"
2598
+ },
2599
+ {
2600
+ type: "null"
2601
+ }
2602
+ ],
2603
+ default: null,
2604
+ title: "Converted From"
2605
+ },
2402
2606
  created_at: {
2403
2607
  title: "Created At",
2404
2608
  type: "string"
@@ -2445,6 +2649,17 @@ var output_schemas_default = {
2445
2649
  title: "Page Count",
2446
2650
  type: "integer"
2447
2651
  },
2652
+ received: {
2653
+ anyOf: [
2654
+ {
2655
+ $ref: "#/$defs/DocumentReceived"
2656
+ },
2657
+ {
2658
+ type: "null"
2659
+ }
2660
+ ],
2661
+ default: null
2662
+ },
2448
2663
  render_reason: {
2449
2664
  anyOf: [
2450
2665
  {
@@ -2558,6 +2773,38 @@ var output_schemas_default = {
2558
2773
  title: "DocumentPages",
2559
2774
  type: "object"
2560
2775
  },
2776
+ DocumentReceived: {
2777
+ additionalProperties: true,
2778
+ description: "The received fax a document is the file of.",
2779
+ properties: {
2780
+ from: {
2781
+ anyOf: [
2782
+ {
2783
+ type: "string"
2784
+ },
2785
+ {
2786
+ type: "null"
2787
+ }
2788
+ ],
2789
+ default: null,
2790
+ title: "From"
2791
+ },
2792
+ inbox_item_id: {
2793
+ title: "Inbox Item Id",
2794
+ type: "string"
2795
+ },
2796
+ received_at: {
2797
+ title: "Received At",
2798
+ type: "string"
2799
+ }
2800
+ },
2801
+ required: [
2802
+ "inbox_item_id",
2803
+ "received_at"
2804
+ ],
2805
+ title: "DocumentReceived",
2806
+ type: "object"
2807
+ },
2561
2808
  PagePreview: {
2562
2809
  additionalProperties: true,
2563
2810
  properties: {
@@ -3101,6 +3348,19 @@ var output_schemas_default = {
3101
3348
  default: null,
3102
3349
  title: "Amount Micro"
3103
3350
  },
3351
+ authorized_at: {
3352
+ anyOf: [
3353
+ {
3354
+ type: "string"
3355
+ },
3356
+ {
3357
+ type: "null"
3358
+ }
3359
+ ],
3360
+ default: null,
3361
+ description: "On a receipt: when the card was held.",
3362
+ title: "Authorized At"
3363
+ },
3104
3364
  captured_micro: {
3105
3365
  anyOf: [
3106
3366
  {
@@ -3137,10 +3397,52 @@ var output_schemas_default = {
3137
3397
  description: "The pages of the order's document. The cover sheet is not counted.",
3138
3398
  title: "Document Pages"
3139
3399
  },
3400
+ email: {
3401
+ anyOf: [
3402
+ {
3403
+ type: "string"
3404
+ },
3405
+ {
3406
+ type: "null"
3407
+ }
3408
+ ],
3409
+ default: null,
3410
+ description: "On a receipt: the address the order was made with.",
3411
+ title: "Email"
3412
+ },
3413
+ failure_code: {
3414
+ anyOf: [
3415
+ {
3416
+ type: "string"
3417
+ },
3418
+ {
3419
+ type: "null"
3420
+ }
3421
+ ],
3422
+ default: null,
3423
+ description: "On a receipt: why the order ended unpaid.",
3424
+ title: "Failure Code"
3425
+ },
3140
3426
  order_id: {
3141
3427
  title: "Order Id",
3142
3428
  type: "string"
3143
3429
  },
3430
+ price: {
3431
+ anyOf: [
3432
+ {
3433
+ additionalProperties: {
3434
+ type: "integer"
3435
+ },
3436
+ type: "object"
3437
+ },
3438
+ {
3439
+ type: "null"
3440
+ }
3441
+ ],
3442
+ default: null,
3443
+ description: "On a receipt: flat_micro, included_pages and extra_page_micro the amount follows from.",
3444
+ title: "Price"
3445
+ },
3144
3446
  refunded_micro: {
3145
3447
  anyOf: [
3146
3448
  {
@@ -3154,6 +3456,32 @@ var output_schemas_default = {
3154
3456
  description: "What was refunded to the card after the charge, in micro-units.",
3155
3457
  title: "Refunded Micro"
3156
3458
  },
3459
+ sender_name: {
3460
+ anyOf: [
3461
+ {
3462
+ type: "string"
3463
+ },
3464
+ {
3465
+ type: "null"
3466
+ }
3467
+ ],
3468
+ default: null,
3469
+ description: "On a receipt: the sender's name.",
3470
+ title: "Sender Name"
3471
+ },
3472
+ settled_at: {
3473
+ anyOf: [
3474
+ {
3475
+ type: "string"
3476
+ },
3477
+ {
3478
+ type: "null"
3479
+ }
3480
+ ],
3481
+ default: null,
3482
+ description: "On a receipt: when the payment provider confirmed the charge, or the release.",
3483
+ title: "Settled At"
3484
+ },
3157
3485
  status: {
3158
3486
  anyOf: [
3159
3487
  {
@@ -3349,6 +3677,56 @@ var output_schemas_default = {
3349
3677
  },
3350
3678
  get_review_status: {
3351
3679
  $defs: {
3680
+ ApprovalDocument: {
3681
+ additionalProperties: true,
3682
+ properties: {
3683
+ filename: {
3684
+ anyOf: [
3685
+ {
3686
+ type: "string"
3687
+ },
3688
+ {
3689
+ type: "null"
3690
+ }
3691
+ ],
3692
+ description: "The file's name; null when the document row is gone.",
3693
+ title: "Filename"
3694
+ },
3695
+ id: {
3696
+ title: "Id",
3697
+ type: "string"
3698
+ },
3699
+ page_count: {
3700
+ anyOf: [
3701
+ {
3702
+ type: "integer"
3703
+ },
3704
+ {
3705
+ type: "null"
3706
+ }
3707
+ ],
3708
+ title: "Page Count"
3709
+ },
3710
+ state: {
3711
+ description: "available: the document is the one the request binds. deleted: it was deleted. changed: its sha256 is no longer the bound one. A send with this approval is refused in the last two.",
3712
+ enum: [
3713
+ "available",
3714
+ "deleted",
3715
+ "changed"
3716
+ ],
3717
+ title: "State",
3718
+ type: "string"
3719
+ }
3720
+ },
3721
+ required: [
3722
+ "id",
3723
+ "filename",
3724
+ "page_count",
3725
+ "state"
3726
+ ],
3727
+ title: "ApprovalDocument",
3728
+ type: "object"
3729
+ },
3352
3730
  ReviewRequest: {
3353
3731
  additionalProperties: true,
3354
3732
  description: "The approval request row as request_human_review returns it: kind send (bound to a quote) or help.",
@@ -3395,6 +3773,31 @@ var output_schemas_default = {
3395
3773
  ],
3396
3774
  title: "Decided By"
3397
3775
  },
3776
+ decided_by_name: {
3777
+ anyOf: [
3778
+ {
3779
+ type: "string"
3780
+ },
3781
+ {
3782
+ type: "null"
3783
+ }
3784
+ ],
3785
+ default: null,
3786
+ description: "The decider, named the same way.",
3787
+ title: "Decided By Name"
3788
+ },
3789
+ document: {
3790
+ anyOf: [
3791
+ {
3792
+ $ref: "#/$defs/ApprovalDocument"
3793
+ },
3794
+ {
3795
+ type: "null"
3796
+ }
3797
+ ],
3798
+ default: null,
3799
+ description: "The document a send request binds (bound.document_id). null for a help request."
3800
+ },
3398
3801
  expires_at: {
3399
3802
  anyOf: [
3400
3803
  {
@@ -3481,6 +3884,19 @@ var output_schemas_default = {
3481
3884
  title: "Requested By",
3482
3885
  type: "string"
3483
3886
  },
3887
+ requested_by_name: {
3888
+ anyOf: [
3889
+ {
3890
+ type: "string"
3891
+ },
3892
+ {
3893
+ type: "null"
3894
+ }
3895
+ ],
3896
+ default: null,
3897
+ description: "The requester as people read it: the key's label, the agent's name, the connected app's name or the person's address. null when the actor has no row in the organization any more.",
3898
+ title: "Requested By Name"
3899
+ },
3484
3900
  status: {
3485
3901
  enum: [
3486
3902
  "pending",
@@ -3898,39 +4314,111 @@ var output_schemas_default = {
3898
4314
  amount_micro: {
3899
4315
  anyOf: [
3900
4316
  {
3901
- type: "integer"
4317
+ type: "integer"
4318
+ },
4319
+ {
4320
+ type: "null"
4321
+ }
4322
+ ],
4323
+ default: null,
4324
+ title: "Amount Micro"
4325
+ },
4326
+ authorized_at: {
4327
+ anyOf: [
4328
+ {
4329
+ type: "string"
4330
+ },
4331
+ {
4332
+ type: "null"
4333
+ }
4334
+ ],
4335
+ default: null,
4336
+ description: "On a receipt: when the card was held.",
4337
+ title: "Authorized At"
4338
+ },
4339
+ captured_micro: {
4340
+ anyOf: [
4341
+ {
4342
+ type: "integer"
4343
+ },
4344
+ {
4345
+ type: "null"
4346
+ }
4347
+ ],
4348
+ default: null,
4349
+ title: "Captured Micro"
4350
+ },
4351
+ card: {
4352
+ anyOf: [
4353
+ {
4354
+ $ref: "#/$defs/OneTimeCard"
4355
+ },
4356
+ {
4357
+ type: "null"
4358
+ }
4359
+ ],
4360
+ default: null
4361
+ },
4362
+ document_pages: {
4363
+ anyOf: [
4364
+ {
4365
+ type: "integer"
4366
+ },
4367
+ {
4368
+ type: "null"
4369
+ }
4370
+ ],
4371
+ default: null,
4372
+ description: "The pages of the order's document. The cover sheet is not counted.",
4373
+ title: "Document Pages"
4374
+ },
4375
+ email: {
4376
+ anyOf: [
4377
+ {
4378
+ type: "string"
3902
4379
  },
3903
4380
  {
3904
4381
  type: "null"
3905
4382
  }
3906
4383
  ],
3907
4384
  default: null,
3908
- title: "Amount Micro"
4385
+ description: "On a receipt: the address the order was made with.",
4386
+ title: "Email"
3909
4387
  },
3910
- captured_micro: {
4388
+ failure_code: {
3911
4389
  anyOf: [
3912
4390
  {
3913
- type: "integer"
4391
+ type: "string"
3914
4392
  },
3915
4393
  {
3916
4394
  type: "null"
3917
4395
  }
3918
4396
  ],
3919
4397
  default: null,
3920
- title: "Captured Micro"
4398
+ description: "On a receipt: why the order ended unpaid.",
4399
+ title: "Failure Code"
3921
4400
  },
3922
- card: {
4401
+ order_id: {
4402
+ title: "Order Id",
4403
+ type: "string"
4404
+ },
4405
+ price: {
3923
4406
  anyOf: [
3924
4407
  {
3925
- $ref: "#/$defs/OneTimeCard"
4408
+ additionalProperties: {
4409
+ type: "integer"
4410
+ },
4411
+ type: "object"
3926
4412
  },
3927
4413
  {
3928
4414
  type: "null"
3929
4415
  }
3930
4416
  ],
3931
- default: null
4417
+ default: null,
4418
+ description: "On a receipt: flat_micro, included_pages and extra_page_micro the amount follows from.",
4419
+ title: "Price"
3932
4420
  },
3933
- document_pages: {
4421
+ refunded_micro: {
3934
4422
  anyOf: [
3935
4423
  {
3936
4424
  type: "integer"
@@ -3940,25 +4428,34 @@ var output_schemas_default = {
3940
4428
  }
3941
4429
  ],
3942
4430
  default: null,
3943
- description: "The pages of the order's document. The cover sheet is not counted.",
3944
- title: "Document Pages"
4431
+ description: "What was refunded to the card after the charge, in micro-units.",
4432
+ title: "Refunded Micro"
3945
4433
  },
3946
- order_id: {
3947
- title: "Order Id",
3948
- type: "string"
4434
+ sender_name: {
4435
+ anyOf: [
4436
+ {
4437
+ type: "string"
4438
+ },
4439
+ {
4440
+ type: "null"
4441
+ }
4442
+ ],
4443
+ default: null,
4444
+ description: "On a receipt: the sender's name.",
4445
+ title: "Sender Name"
3949
4446
  },
3950
- refunded_micro: {
4447
+ settled_at: {
3951
4448
  anyOf: [
3952
4449
  {
3953
- type: "integer"
4450
+ type: "string"
3954
4451
  },
3955
4452
  {
3956
4453
  type: "null"
3957
4454
  }
3958
4455
  ],
3959
4456
  default: null,
3960
- description: "What was refunded to the card after the charge, in micro-units.",
3961
- title: "Refunded Micro"
4457
+ description: "On a receipt: when the payment provider confirmed the charge, or the release.",
4458
+ title: "Settled At"
3962
4459
  },
3963
4460
  status: {
3964
4461
  anyOf: [
@@ -4240,6 +4737,18 @@ var output_schemas_default = {
4240
4737
  title: "Content Type",
4241
4738
  type: "string"
4242
4739
  },
4740
+ converted_from: {
4741
+ anyOf: [
4742
+ {
4743
+ type: "string"
4744
+ },
4745
+ {
4746
+ type: "null"
4747
+ }
4748
+ ],
4749
+ default: null,
4750
+ title: "Converted From"
4751
+ },
4243
4752
  created_at: {
4244
4753
  title: "Created At",
4245
4754
  type: "string"
@@ -4286,6 +4795,17 @@ var output_schemas_default = {
4286
4795
  title: "Page Count",
4287
4796
  type: "integer"
4288
4797
  },
4798
+ received: {
4799
+ anyOf: [
4800
+ {
4801
+ $ref: "#/$defs/DocumentReceived"
4802
+ },
4803
+ {
4804
+ type: "null"
4805
+ }
4806
+ ],
4807
+ default: null
4808
+ },
4289
4809
  render_reason: {
4290
4810
  anyOf: [
4291
4811
  {
@@ -4354,6 +4874,38 @@ var output_schemas_default = {
4354
4874
  ],
4355
4875
  title: "Document",
4356
4876
  type: "object"
4877
+ },
4878
+ DocumentReceived: {
4879
+ additionalProperties: true,
4880
+ description: "The received fax a document is the file of.",
4881
+ properties: {
4882
+ from: {
4883
+ anyOf: [
4884
+ {
4885
+ type: "string"
4886
+ },
4887
+ {
4888
+ type: "null"
4889
+ }
4890
+ ],
4891
+ default: null,
4892
+ title: "From"
4893
+ },
4894
+ inbox_item_id: {
4895
+ title: "Inbox Item Id",
4896
+ type: "string"
4897
+ },
4898
+ received_at: {
4899
+ title: "Received At",
4900
+ type: "string"
4901
+ }
4902
+ },
4903
+ required: [
4904
+ "inbox_item_id",
4905
+ "received_at"
4906
+ ],
4907
+ title: "DocumentReceived",
4908
+ type: "object"
4357
4909
  }
4358
4910
  },
4359
4911
  additionalProperties: false,
@@ -4557,6 +5109,12 @@ var output_schemas_default = {
4557
5109
  title: "Route Label",
4558
5110
  type: "string"
4559
5111
  },
5112
+ route_paused: {
5113
+ default: false,
5114
+ description: "An operator has paused sends on this quote's route. A fax sent now is accepted and stays queued until the route is resumed. Read when the quote is answered, not stored.",
5115
+ title: "Route Paused",
5116
+ type: "boolean"
5117
+ },
4560
5118
  sender_name: {
4561
5119
  anyOf: [
4562
5120
  {
@@ -4616,6 +5174,7 @@ var output_schemas_default = {
4616
5174
  type: "boolean"
4617
5175
  },
4618
5176
  decision: {
5177
+ description: "allow: send_approved_fax takes this quote as it is. deny: no policy allows it, and approval_required says whether a person can still approve it. With a test key and no policy the decision is allow and policy_id is null: the sandbox needs no approval.",
4619
5178
  enum: [
4620
5179
  "allow",
4621
5180
  "deny"
@@ -5450,6 +6009,56 @@ var output_schemas_default = {
5450
6009
  },
5451
6010
  request_human_review: {
5452
6011
  $defs: {
6012
+ ApprovalDocument: {
6013
+ additionalProperties: true,
6014
+ properties: {
6015
+ filename: {
6016
+ anyOf: [
6017
+ {
6018
+ type: "string"
6019
+ },
6020
+ {
6021
+ type: "null"
6022
+ }
6023
+ ],
6024
+ description: "The file's name; null when the document row is gone.",
6025
+ title: "Filename"
6026
+ },
6027
+ id: {
6028
+ title: "Id",
6029
+ type: "string"
6030
+ },
6031
+ page_count: {
6032
+ anyOf: [
6033
+ {
6034
+ type: "integer"
6035
+ },
6036
+ {
6037
+ type: "null"
6038
+ }
6039
+ ],
6040
+ title: "Page Count"
6041
+ },
6042
+ state: {
6043
+ description: "available: the document is the one the request binds. deleted: it was deleted. changed: its sha256 is no longer the bound one. A send with this approval is refused in the last two.",
6044
+ enum: [
6045
+ "available",
6046
+ "deleted",
6047
+ "changed"
6048
+ ],
6049
+ title: "State",
6050
+ type: "string"
6051
+ }
6052
+ },
6053
+ required: [
6054
+ "id",
6055
+ "filename",
6056
+ "page_count",
6057
+ "state"
6058
+ ],
6059
+ title: "ApprovalDocument",
6060
+ type: "object"
6061
+ },
5453
6062
  ReviewRequest: {
5454
6063
  additionalProperties: true,
5455
6064
  description: "The approval request row as request_human_review returns it: kind send (bound to a quote) or help.",
@@ -5496,6 +6105,31 @@ var output_schemas_default = {
5496
6105
  ],
5497
6106
  title: "Decided By"
5498
6107
  },
6108
+ decided_by_name: {
6109
+ anyOf: [
6110
+ {
6111
+ type: "string"
6112
+ },
6113
+ {
6114
+ type: "null"
6115
+ }
6116
+ ],
6117
+ default: null,
6118
+ description: "The decider, named the same way.",
6119
+ title: "Decided By Name"
6120
+ },
6121
+ document: {
6122
+ anyOf: [
6123
+ {
6124
+ $ref: "#/$defs/ApprovalDocument"
6125
+ },
6126
+ {
6127
+ type: "null"
6128
+ }
6129
+ ],
6130
+ default: null,
6131
+ description: "The document a send request binds (bound.document_id). null for a help request."
6132
+ },
5499
6133
  expires_at: {
5500
6134
  anyOf: [
5501
6135
  {
@@ -5582,6 +6216,19 @@ var output_schemas_default = {
5582
6216
  title: "Requested By",
5583
6217
  type: "string"
5584
6218
  },
6219
+ requested_by_name: {
6220
+ anyOf: [
6221
+ {
6222
+ type: "string"
6223
+ },
6224
+ {
6225
+ type: "null"
6226
+ }
6227
+ ],
6228
+ default: null,
6229
+ description: "The requester as people read it: the key's label, the agent's name, the connected app's name or the person's address. null when the actor has no row in the organization any more.",
6230
+ title: "Requested By Name"
6231
+ },
5585
6232
  status: {
5586
6233
  enum: [
5587
6234
  "pending",
@@ -5995,6 +6642,19 @@ var output_schemas_default = {
5995
6642
  default: null,
5996
6643
  title: "Amount Micro"
5997
6644
  },
6645
+ authorized_at: {
6646
+ anyOf: [
6647
+ {
6648
+ type: "string"
6649
+ },
6650
+ {
6651
+ type: "null"
6652
+ }
6653
+ ],
6654
+ default: null,
6655
+ description: "On a receipt: when the card was held.",
6656
+ title: "Authorized At"
6657
+ },
5998
6658
  captured_micro: {
5999
6659
  anyOf: [
6000
6660
  {
@@ -6031,10 +6691,52 @@ var output_schemas_default = {
6031
6691
  description: "The pages of the order's document. The cover sheet is not counted.",
6032
6692
  title: "Document Pages"
6033
6693
  },
6694
+ email: {
6695
+ anyOf: [
6696
+ {
6697
+ type: "string"
6698
+ },
6699
+ {
6700
+ type: "null"
6701
+ }
6702
+ ],
6703
+ default: null,
6704
+ description: "On a receipt: the address the order was made with.",
6705
+ title: "Email"
6706
+ },
6707
+ failure_code: {
6708
+ anyOf: [
6709
+ {
6710
+ type: "string"
6711
+ },
6712
+ {
6713
+ type: "null"
6714
+ }
6715
+ ],
6716
+ default: null,
6717
+ description: "On a receipt: why the order ended unpaid.",
6718
+ title: "Failure Code"
6719
+ },
6034
6720
  order_id: {
6035
6721
  title: "Order Id",
6036
6722
  type: "string"
6037
6723
  },
6724
+ price: {
6725
+ anyOf: [
6726
+ {
6727
+ additionalProperties: {
6728
+ type: "integer"
6729
+ },
6730
+ type: "object"
6731
+ },
6732
+ {
6733
+ type: "null"
6734
+ }
6735
+ ],
6736
+ default: null,
6737
+ description: "On a receipt: flat_micro, included_pages and extra_page_micro the amount follows from.",
6738
+ title: "Price"
6739
+ },
6038
6740
  refunded_micro: {
6039
6741
  anyOf: [
6040
6742
  {
@@ -6048,6 +6750,32 @@ var output_schemas_default = {
6048
6750
  description: "What was refunded to the card after the charge, in micro-units.",
6049
6751
  title: "Refunded Micro"
6050
6752
  },
6753
+ sender_name: {
6754
+ anyOf: [
6755
+ {
6756
+ type: "string"
6757
+ },
6758
+ {
6759
+ type: "null"
6760
+ }
6761
+ ],
6762
+ default: null,
6763
+ description: "On a receipt: the sender's name.",
6764
+ title: "Sender Name"
6765
+ },
6766
+ settled_at: {
6767
+ anyOf: [
6768
+ {
6769
+ type: "string"
6770
+ },
6771
+ {
6772
+ type: "null"
6773
+ }
6774
+ ],
6775
+ default: null,
6776
+ description: "On a receipt: when the payment provider confirmed the charge, or the release.",
6777
+ title: "Settled At"
6778
+ },
6051
6779
  status: {
6052
6780
  anyOf: [
6053
6781
  {
@@ -6278,7 +7006,8 @@ var tool_definitions_default = {
6278
7006
  }
6279
7007
  },
6280
7008
  title: "get_guideArguments",
6281
- type: "object"
7009
+ type: "object",
7010
+ additionalProperties: false
6282
7011
  },
6283
7012
  annotations: {
6284
7013
  title: "Get guide",
@@ -6291,11 +7020,12 @@ var tool_definitions_default = {
6291
7020
  get_fax_capabilities: {
6292
7021
  name: "get_fax_capabilities",
6293
7022
  title: "Get fax capabilities",
6294
- description: "Read account limits, routes, formats, prices and credential scopes. Use before preparing a fax. Use quote_fax for one send's price and policy verdict, or get_fax_balance for available funds. Returns capabilities and account identity without changes or charges. extraction_pricing holds the per-page price of extract_fax_data. Repeated reads are safe. Scope: account:read.",
7023
+ description: "Read account limits, routes, formats, prices and credential scopes. Use before preparing a fax. Use quote_fax for one send's price and policy verdict, or get_fax_balance for available funds. Returns capabilities and account identity without changes or charges. me.scopes is what this credential may do. capabilities.scopes is every scope the platform defines, not what this credential holds. extraction_pricing holds the per-page price of extract_fax_data. Repeated reads are safe. Scope: account:read.",
6295
7024
  inputSchema: {
6296
7025
  properties: {},
6297
7026
  title: "get_fax_capabilitiesArguments",
6298
- type: "object"
7027
+ type: "object",
7028
+ additionalProperties: false
6299
7029
  },
6300
7030
  annotations: {
6301
7031
  title: "Get fax capabilities",
@@ -6411,7 +7141,8 @@ var tool_definitions_default = {
6411
7141
  }
6412
7142
  },
6413
7143
  title: "prepare_faxArguments",
6414
- type: "object"
7144
+ type: "object",
7145
+ additionalProperties: false
6415
7146
  },
6416
7147
  annotations: {
6417
7148
  title: "Prepare fax",
@@ -6441,7 +7172,8 @@ var tool_definitions_default = {
6441
7172
  "document_id"
6442
7173
  ],
6443
7174
  title: "get_fax_documentArguments",
6444
- type: "object"
7175
+ type: "object",
7176
+ additionalProperties: false
6445
7177
  },
6446
7178
  annotations: {
6447
7179
  title: "Get fax document",
@@ -6626,7 +7358,8 @@ var tool_definitions_default = {
6626
7358
  "to"
6627
7359
  ],
6628
7360
  title: "quote_faxArguments",
6629
- type: "object"
7361
+ type: "object",
7362
+ additionalProperties: false
6630
7363
  },
6631
7364
  annotations: {
6632
7365
  title: "Quote fax",
@@ -6705,7 +7438,8 @@ var tool_definitions_default = {
6705
7438
  "quote_id"
6706
7439
  ],
6707
7440
  title: "send_approved_faxArguments",
6708
- type: "object"
7441
+ type: "object",
7442
+ additionalProperties: false
6709
7443
  },
6710
7444
  annotations: {
6711
7445
  title: "Send approved fax",
@@ -6735,7 +7469,8 @@ var tool_definitions_default = {
6735
7469
  "fax_id"
6736
7470
  ],
6737
7471
  title: "get_fax_statusArguments",
6738
- type: "object"
7472
+ type: "object",
7473
+ additionalProperties: false
6739
7474
  },
6740
7475
  annotations: {
6741
7476
  title: "Get fax status",
@@ -6811,7 +7546,8 @@ var tool_definitions_default = {
6811
7546
  }
6812
7547
  },
6813
7548
  title: "list_faxesArguments",
6814
- type: "object"
7549
+ type: "object",
7550
+ additionalProperties: false
6815
7551
  },
6816
7552
  annotations: {
6817
7553
  title: "List faxes",
@@ -6828,7 +7564,8 @@ var tool_definitions_default = {
6828
7564
  inputSchema: {
6829
7565
  properties: {},
6830
7566
  title: "get_fax_balanceArguments",
6831
- type: "object"
7567
+ type: "object",
7568
+ additionalProperties: false
6832
7569
  },
6833
7570
  annotations: {
6834
7571
  title: "Get fax balance",
@@ -6858,7 +7595,8 @@ var tool_definitions_default = {
6858
7595
  "fax_id"
6859
7596
  ],
6860
7597
  title: "cancel_faxArguments",
6861
- type: "object"
7598
+ type: "object",
7599
+ additionalProperties: false
6862
7600
  },
6863
7601
  annotations: {
6864
7602
  title: "Cancel fax",
@@ -6963,7 +7701,8 @@ var tool_definitions_default = {
6963
7701
  "cover_from_name"
6964
7702
  ],
6965
7703
  title: "request_card_paymentArguments",
6966
- type: "object"
7704
+ type: "object",
7705
+ additionalProperties: false
6967
7706
  },
6968
7707
  annotations: {
6969
7708
  title: "Request card payment",
@@ -6993,7 +7732,8 @@ var tool_definitions_default = {
6993
7732
  "order_id"
6994
7733
  ],
6995
7734
  title: "get_card_payment_statusArguments",
6996
- type: "object"
7735
+ type: "object",
7736
+ additionalProperties: false
6997
7737
  },
6998
7738
  annotations: {
6999
7739
  title: "Get card payment status",
@@ -7073,7 +7813,8 @@ var tool_definitions_default = {
7073
7813
  "message"
7074
7814
  ],
7075
7815
  title: "request_human_reviewArguments",
7076
- type: "object"
7816
+ type: "object",
7817
+ additionalProperties: false
7077
7818
  },
7078
7819
  annotations: {
7079
7820
  title: "Request human review",
@@ -7103,7 +7844,8 @@ var tool_definitions_default = {
7103
7844
  "review_request_id"
7104
7845
  ],
7105
7846
  title: "get_review_statusArguments",
7106
- type: "object"
7847
+ type: "object",
7848
+ additionalProperties: false
7107
7849
  },
7108
7850
  annotations: {
7109
7851
  title: "Get review status",
@@ -7146,7 +7888,8 @@ var tool_definitions_default = {
7146
7888
  }
7147
7889
  },
7148
7890
  title: "list_inboxArguments",
7149
- type: "object"
7891
+ type: "object",
7892
+ additionalProperties: false
7150
7893
  },
7151
7894
  annotations: {
7152
7895
  title: "List inbox",
@@ -7176,7 +7919,8 @@ var tool_definitions_default = {
7176
7919
  "inbox_id"
7177
7920
  ],
7178
7921
  title: "read_inbound_faxArguments",
7179
- type: "object"
7922
+ type: "object",
7923
+ additionalProperties: false
7180
7924
  },
7181
7925
  annotations: {
7182
7926
  title: "Read inbound fax",
@@ -7265,7 +8009,8 @@ var tool_definitions_default = {
7265
8009
  }
7266
8010
  },
7267
8011
  title: "extract_fax_dataArguments",
7268
- type: "object"
8012
+ type: "object",
8013
+ additionalProperties: false
7269
8014
  },
7270
8015
  annotations: {
7271
8016
  title: "Extract fax data",
@@ -7278,6 +8023,110 @@ var tool_definitions_default = {
7278
8023
  }
7279
8024
  };
7280
8025
 
8026
+ // src/unknown-arguments.ts
8027
+ var ALIASES = /* @__PURE__ */ new Map([
8028
+ ["from", "from_number"],
8029
+ ["sender", "from_number"],
8030
+ ["from_", "from_number"],
8031
+ ["to_number", "to"],
8032
+ ["destination", "to"],
8033
+ ["status", "state"],
8034
+ ["document", "document_id"],
8035
+ ["doc_id", "document_id"],
8036
+ ["quote", "quote_id"],
8037
+ ["fax", "fax_id"],
8038
+ ["fax_job_id", "fax_id"],
8039
+ ["job_id", "fax_id"],
8040
+ ["approval", "approval_id"],
8041
+ ["inbox_item_id", "inbox_id"],
8042
+ ["inbox_id", "inbox_item_id"],
8043
+ ["item_id", "inbox_id"],
8044
+ ["id", ""],
8045
+ ["key", "idempotency_key"],
8046
+ ["idempotency-key", "idempotency_key"],
8047
+ ["idempotencyKey", "idempotency_key"],
8048
+ ["page_size", "limit"],
8049
+ ["per_page", "limit"]
8050
+ ]);
8051
+ var CLIENT_KEYS = /* @__PURE__ */ new Set(["sessionId", "action", "chatInput", "toolCallId"]);
8052
+ var NAME = /^[A-Za-z_][A-Za-z0-9_-]{0,39}$/;
8053
+ var MAX_NAMED = 5;
8054
+ var CUTOFF = 0.8;
8055
+ function matching(a, b, alo = 0, ahi = a.length, blo = 0, bhi = b.length) {
8056
+ let besti = alo;
8057
+ let bestj = blo;
8058
+ let bestsize = 0;
8059
+ let previous = /* @__PURE__ */ new Map();
8060
+ for (let i = alo; i < ahi; i++) {
8061
+ const current = /* @__PURE__ */ new Map();
8062
+ for (let j = blo; j < bhi; j++) {
8063
+ if (a[i] !== b[j]) continue;
8064
+ const k = (previous.get(j - 1) ?? 0) + 1;
8065
+ current.set(j, k);
8066
+ if (k > bestsize) {
8067
+ besti = i - k + 1;
8068
+ bestj = j - k + 1;
8069
+ bestsize = k;
8070
+ }
8071
+ }
8072
+ previous = current;
8073
+ }
8074
+ if (!bestsize) return 0;
8075
+ return bestsize + matching(a, b, alo, besti, blo, bestj) + matching(a, b, besti + bestsize, ahi, bestj + bestsize, bhi);
8076
+ }
8077
+ function ratio(a, b) {
8078
+ const total = a.length + b.length;
8079
+ return total ? 2 * matching(a, b) / total : 1;
8080
+ }
8081
+ function meant(name, properties) {
8082
+ const alias = ALIASES.get(name);
8083
+ if (alias && properties.includes(alias)) return alias;
8084
+ if (name === "id") {
8085
+ const ids = properties.filter((p) => p.endsWith("_id"));
8086
+ return ids.length === 1 ? ids[0] : null;
8087
+ }
8088
+ const lowered = new Map(properties.map((p) => [p.toLowerCase().replaceAll("-", "_"), p]));
8089
+ const folded = name.replace(/(?<=[a-z0-9])(?=[A-Z])/g, "_").toLowerCase().replaceAll("-", "_");
8090
+ const exact = lowered.get(folded);
8091
+ if (exact) return exact;
8092
+ let best = null;
8093
+ for (const candidate of lowered.keys()) {
8094
+ const score = ratio(candidate, folded);
8095
+ if (score < CUTOFF) continue;
8096
+ if (!best || score > best[0] || score === best[0] && candidate > best[1]) best = [score, candidate];
8097
+ }
8098
+ return best ? lowered.get(best[1]) : null;
8099
+ }
8100
+ function unknownArguments(args, declared) {
8101
+ if (!args || typeof args !== "object" || Array.isArray(args)) return null;
8102
+ const properties = Object.keys(declared);
8103
+ const unknown = Object.keys(args).filter((name) => !Object.hasOwn(declared, name) && !CLIENT_KEYS.has(name));
8104
+ if (!unknown.length) return null;
8105
+ const named = unknown.filter((name) => NAME.test(name)).slice(0, MAX_NAMED);
8106
+ const parts = named.map((name) => {
8107
+ const target = meant(name, properties);
8108
+ return target ? `${name} (did you mean ${target}?)` : name;
8109
+ });
8110
+ const rest = unknown.length - named.length;
8111
+ let listed;
8112
+ if (parts.length && rest) listed = `${parts.join(", ")} and ${rest} more`;
8113
+ else if (parts.length) listed = parts.join(", ");
8114
+ else listed = `${rest} of the names sent`;
8115
+ const s = unknown.length !== 1 ? "s" : "";
8116
+ const accepted = [...properties].sort();
8117
+ const message = `This tool does not take the argument${s} ${listed}. It takes: ${accepted.join(", ") || "none"}. Nothing was done. Correct the argument${s} and try again.`;
8118
+ return {
8119
+ content: [{ type: "text", text: message }],
8120
+ structuredContent: {
8121
+ ok: false,
8122
+ error_code: "invalid_input",
8123
+ message,
8124
+ details: { unknown_arguments: named, accepted_arguments: accepted }
8125
+ },
8126
+ isError: true
8127
+ };
8128
+ }
8129
+
7281
8130
  // src/tool-dispatch.ts
7282
8131
  var ID_PREFIXES = {
7283
8132
  upload_id: "up",
@@ -7325,6 +8174,8 @@ function toolDispatch(server) {
7325
8174
  listed.set(name, () => registered.enabled ? advertised : void 0);
7326
8175
  calls.set(name, async (args) => {
7327
8176
  if (!registered.enabled) throw new McpError(ErrorCode.InvalidParams, `Tool ${name} disabled`);
8177
+ const unknown = unknownArguments(args, definition.inputSchema.properties ?? {});
8178
+ if (unknown) return unknown;
7328
8179
  const parsed = input.safeParse(args);
7329
8180
  let response;
7330
8181
  if (!parsed.success) {
@@ -7369,7 +8220,7 @@ function toolDispatch(server) {
7369
8220
  }
7370
8221
 
7371
8222
  // src/server.ts
7372
- var STDIO_HINT = "No API key configured. Set FAXFORAGENTS_API_KEY in the environment of the MCP client that launches faxforagents-mcp (never on the command line). Keys are created in the dashboard or with the ffa CLI.";
8223
+ var STDIO_HINT = "No API key configured. Set FAXFORAGENTS_API_KEY in the environment of the MCP client that launches faxforagents-mcp (never on the command line). Keys are created in the dashboard, under API keys.";
7373
8224
  var HARD_REFUSALS = /* @__PURE__ */ new Set([
7374
8225
  "invalid_token",
7375
8226
  "scope_missing",
@@ -7403,7 +8254,7 @@ function refusal(exc) {
7403
8254
  const remedies = {
7404
8255
  invalid_token: "The API key was rejected. Send a live ffa_live_... or ffa_test_... key as Authorization: Bearer (HTTP) or FAXFORAGENTS_API_KEY (stdio).",
7405
8256
  scope_missing: `This key lacks the scope ${String(d.scope ?? "required")}. Ask the key's owner for a key that has it.`,
7406
- not_found: "No such id in your organization, or it was deleted.",
8257
+ not_found: notFoundRemedy(d.field),
7407
8258
  approval_required: "No approval and no policy allows this send. Call request_human_review with the quote_id, poll get_review_status until a person approves it, then send_approved_fax with the approval_id. Paying by card does not replace the approval: request_card_payment takes the same approval_id." + (policy ? ` Policy: ${String(policy.reason)}.` : ""),
7408
8259
  approval_expired: "The approval expired with its quote. Quote again and request a new approval.",
7409
8260
  approval_mismatch: `The approval was given for a different ${String(d.field ?? "send")}. Quote again and request a new approval for exactly this send.`,
@@ -7432,6 +8283,14 @@ function refusal(exc) {
7432
8283
  isError: HARD_REFUSALS.has(exc.code)
7433
8284
  };
7434
8285
  }
8286
+ var NOT_FOUND_FIELDS = {
8287
+ document_id: "document_id is not a document of your organization, or it was deleted. Prepare the document again with prepare_fax.",
8288
+ from: "from_number is not a fax number of your organization. Leave from_number out to send from the shared pool."
8289
+ };
8290
+ function notFoundRemedy(field) {
8291
+ const name = String(field);
8292
+ return Object.hasOwn(NOT_FOUND_FIELDS, name) ? NOT_FOUND_FIELDS[name] : "No such id in your organization, or it was deleted.";
8293
+ }
7435
8294
  var usd = (micro) => `$${(Number(micro) / 1e6).toFixed(2)}`;
7436
8295
  function cardPointer(offer) {
7437
8296
  if (!offer || typeof offer !== "object" || Array.isArray(offer)) return "";
@@ -7561,6 +8420,8 @@ function describeQuotePath(quote) {
7561
8420
  }
7562
8421
  const ev = quote.policy_evaluation && typeof quote.policy_evaluation === "object" ? quote.policy_evaluation : null;
7563
8422
  if (ev && ev.decision === "allow") {
8423
+ if (ev.managed === "connected_apps")
8424
+ return "allowed by your organization's auto-send setting: send_approved_fax sends it as is";
7564
8425
  const name = ev.policy_name ?? ev.policy_id ?? "unnamed";
7565
8426
  return `allowed by policy ${String(name)} v${String(ev.version)}: send_approved_fax sends it as is`;
7566
8427
  }
@@ -7568,16 +8429,18 @@ function describeQuotePath(quote) {
7568
8429
  return "sandbox, not charged: a test key sends it as is";
7569
8430
  return "no approval needed: send_approved_fax sends it as is";
7570
8431
  }
8432
+ function noApprovalReason(quote) {
8433
+ if (quote.environment === "test")
8434
+ return "sandbox: a test API key sends without an approval, and no policy was evaluated";
8435
+ return "no approval is needed for this credential, and no policy was evaluated";
8436
+ }
7571
8437
  function quotePolicy(quote) {
7572
- const ev = quote.policy_evaluation && typeof quote.policy_evaluation === "object" ? quote.policy_evaluation : {
8438
+ const stored = quote.policy_evaluation && typeof quote.policy_evaluation === "object" ? quote.policy_evaluation : null;
8439
+ const ev = stored ?? (quote.authorization_required ? {
7573
8440
  decision: "deny",
7574
8441
  rule: null,
7575
- reason: "no policy applies to this key",
7576
- policy_id: null,
7577
- policy_version_id: null,
7578
- policy_name: null,
7579
- version: null
7580
- };
8442
+ reason: "no policy applies to this agent, key or connected app"
8443
+ } : { decision: "allow", rule: null, reason: noApprovalReason(quote) });
7581
8444
  return {
7582
8445
  decision: ev.decision ?? null,
7583
8446
  rule: ev.rule ?? null,
@@ -7586,6 +8449,7 @@ function quotePolicy(quote) {
7586
8449
  policy_version_id: ev.policy_version_id ?? null,
7587
8450
  policy_name: ev.policy_name ?? null,
7588
8451
  version: ev.version ?? null,
8452
+ managed: ev.managed ?? null,
7589
8453
  approval_required: Boolean(quote.authorization_required)
7590
8454
  };
7591
8455
  }
@@ -7761,7 +8625,7 @@ function createServer(opts = {}) {
7761
8625
  const ocr = caps.extraction_pricing && typeof caps.extraction_pricing === "object" ? caps.extraction_pricing : {};
7762
8626
  const extraction = ocr.page_micro !== null && ocr.page_micro !== void 0 ? ` extract_fax_data costs ${String(ocr.page_micro)} micro a page, plus ${String(ocr.escalated_page_micro)} for a page read again, up to ${String(ocr.max_pages)} pages` + (caps.environment === "test" ? " (free in the sandbox)." : ".") : "";
7763
8627
  return {
7764
- text: `${String(caps.provider)} provider, ${String(caps.environment)} environment, routes ${routes}, up to ${String(caps.max_pages)} pages. Key scopes: ${scopes}.${extraction}`,
8628
+ text: `${String(caps.provider)} provider, ${String(caps.environment)} environment, routes ${routes}, up to ${String(caps.max_pages)} pages. This key's scopes (me.scopes): ${scopes}. capabilities.scopes lists every scope that exists, not this key's.${extraction}`,
7765
8629
  data: { capabilities: caps, me }
7766
8630
  };
7767
8631
  })
@@ -8338,7 +9202,7 @@ function registerPrompts(server) {
8338
9202
  Do it in this order and stop when a step refuses.
8339
9203
  1. prepare_fax: turn the content into a document (text, markdown, html or a completed upload_id). Nothing is sent.
8340
9204
  2. quote_fax(document_id, to="${to}"): the exact price and the policy verdict: policy.decision (allow or deny, with the first failing rule) and policy.approval_required.
8341
- 3. If approval is required, call request_human_review(message, quote_id), then poll get_review_status(review_request_id) until it is approved and carries an approval_id. You cannot approve it yourself. When policy.decision is allow, a delegated policy lets the send go as is.
9205
+ 3. If approval is required, call request_human_review(message, quote_id), then poll get_review_status(review_request_id) until it is approved and carries an approval_id. You cannot approve it yourself. When policy.decision is allow, the send goes as it is. A delegated policy allows it, or the API key is a test key in the sandbox.
8342
9206
  4. send_approved_fax(quote_id, approval_id?) with one idempotency_key. The answer is queued, never delivered.
8343
9207
  5. get_fax_status(fax_id) until the state is delivered, partial, failed or unknown. Only delivered with evidence counts as delivered. On partial or unknown do not send again: tell the person and let a human reconcile.
8344
9208
  In the sandbox all of this is a simulation. Nothing reaches the number, and the answers say so. Tell the person the same. If the wallet does not cover a live send, the refusal carries the link where a person adds funds. It names request_card_payment when one fax can be paid by card.`