@primitivedotdev/cli 3.0.0-preview.15 → 3.0.0-preview.17

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.
@@ -1,4 +1,4 @@
1
- import { $t as getOwnGrant, B as awaitingRejectedError, G as isAwaitingRejectedError, J as EMAIL_RULE_OBJECTION_EVENT_TYPES, Kn as sdk_gen_exports, R as ReplyStateUnsupportedError, V as ensureSearchReportsReplyState, Wt as getEmail, X as SENT_EMAIL_EVENT_TYPES, Y as EMAIL_RULE_REQUEST_EVENT_TYPES, Z as WEBHOOK_EVENT_TYPES, at as AutomatedFilterUnsupportedError, ct as automatedSurfaceForOperation, ft as isAutomatedRejectedError, lt as ensureSearchReportsAutomated, ot as assertAutomatedVerdict, q as replyStateSurfaceForOperation, rn as getThread, st as automatedRejectedError, ut as expectedAutomatedVerdicts, vn as listEndpoints, y as parseRetryAfter, z as assertAwaitingFilterRows } from "./repeats-Dj_o6c-X-C1y88ZwJ.js";
1
+ import { $t as getOwnGrant, B as awaitingRejectedError, G as isAwaitingRejectedError, J as EMAIL_RULE_OBJECTION_EVENT_TYPES, R as ReplyStateUnsupportedError, V as ensureSearchReportsReplyState, Wt as getEmail, X as SENT_EMAIL_EVENT_TYPES, Y as EMAIL_RULE_REQUEST_EVENT_TYPES, Z as WEBHOOK_EVENT_TYPES, at as AutomatedFilterUnsupportedError, ct as automatedSurfaceForOperation, ft as isAutomatedRejectedError, lt as ensureSearchReportsAutomated, ot as assertAutomatedVerdict, q as replyStateSurfaceForOperation, qn as sdk_gen_exports, rn as getThread, st as automatedRejectedError, ut as expectedAutomatedVerdicts, y as parseRetryAfter, yn as listEndpoints, z as assertAwaitingFilterRows } from "./repeats-Dj_o6c-X-DlfpQiUq.js";
2
2
  import { C as saveCliCredentials, F as agentProfilesDirectory, H as requireDefaultLoginProfile, N as agentProfileDirectory, R as loadConnectedAgentProfile, S as resolveCliAuth, W as PrimitiveApiClient, _ as deleteCliCredentials, b as loadCliCredentials, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, i as loadCliConfig, j as AGENT_PROFILE_ENV, m as cliAccessTokenExpiresAt, p as acquireCliCredentialsLock, w as saveSignupCredentials, x as normalizeApiBaseUrl, y as detectPrimitiveKeyEnvMisname } from "./cli-config-Ms_0vNjq.js";
3
3
  import "./oclif/global-org-flag.js";
4
4
  import { a as thrownErrorBody } from "./json-output-ch756TXV.js";
@@ -780,7 +780,7 @@ const operationManifest = [
780
780
  "binaryResponse": false,
781
781
  "bodyRequired": false,
782
782
  "command": "list-activity-objects",
783
- "description": "The objects the caller created, newest first, each with where it stands now, including ones since disabled, deleted or revoked where the object keeps a row: Functions, endpoints, Function triggers, pull subscriptions, recipient routes, filters, wake schedules, repeating sends and scheduled sends. An API key, an app or an agent sees what it created itself; a webhook given to an API key lists under that key. A person (a dashboard session, or their own Primitive CLI or app login) sees what they created through any credential of theirs, each item naming it, and also their API keys, personal agents, email rules, rule requests and objections to rules over their mail (objections only on the dashboard or the Primitive CLI). Each kind is listed only if the caller could list it through that kind's own route; a kind it could not is named in withheld, with no count. Ids, names and states only: never a webhook URL or mail content. Needs activity:read_self. With relation=asked it lists instead what other members asked of the person, open or answered: the rule requests made to them, and the objections to rules they wrote, under their current membership, each naming the member who asked or objected in created_through. A key, an app or an agent has none, and gets both kinds in withheld. With relation=concerning it lists instead what other members did that concerns the person's own mail: each time a rule started covering one of their mailboxes, saved a new version, or changed who receives its matches while covering it, named as the rule was then, naming its author in created_through, under their current membership; only on the dashboard or the Primitive CLI. A key, an app or an agent has none, and gets email_rule_coverage in withheld. A notice never reads as ended. Notices are written by a periodic job and can lag: until the notices record a rule starting to cover you, the first page lists that rule as pending (pending_complete says whether that check finished), and as_of says about when the notices last looked. For what covers you now, read GET /email-rules/covering-me.",
783
+ "description": "The objects the caller created, newest first, each with where it stands now, including ones since disabled, deleted or revoked where the object keeps a row: Functions, endpoints, Function triggers, pull subscriptions, recipient routes, filters, wake schedules, repeating sends and scheduled sends. An API key, an app or an agent sees what it created itself; a webhook given to an API key lists under that key. A person (a dashboard session, or their own Primitive CLI or app login) sees what they created through any credential of theirs, each item naming it, and also their API keys, personal agents, email rules, rule requests and objections to rules over their mail (objections only on the dashboard or the Primitive CLI). Each kind is listed only if the caller could list it through that kind's own route; a kind it could not is named in withheld, with no count. Ids, names and states only: never a webhook URL or mail content. Needs activity:read_self. With relation=asked it lists instead what other members asked of the person, open or answered: the rule requests made to them, and the objections to rules they wrote, under their current membership, each naming the member who asked or objected in created_through. A key, an app or an agent has none, and gets both kinds in withheld. With relation=concerning it lists instead what other members did that concerns the person's own mail: each time a rule started covering one of their mailboxes, saved a new version while covering it, or stopped covering it, named as the rule was then, naming its author in created_through, under their current membership; only on the dashboard or the Primitive CLI. A key, an app or an agent has none, and gets email_rule_coverage in withheld. A notice never reads as ended. Notices are written by a periodic job and can lag: until the notices record a rule starting to cover you, the first page lists that rule as pending (pending_complete says whether that check finished), and as_of says about when the notices last looked. For what covers you now, read GET /email-rules/covering-me.",
784
784
  "hasJsonBody": false,
785
785
  "method": "GET",
786
786
  "operationId": "listActivityObjects",
@@ -858,12 +858,12 @@ const operationManifest = [
858
858
  },
859
859
  "id": { "type": "string" },
860
860
  "name": {
861
- "description": "The name the object is known by: an endpoint's display name, a route's or filter's pattern, a Function's name, a send's From address, a wake schedule's command and the address it wakes, an API key's name, an agent's address, a rule's or rule request's name, and for an objection or a coverage notice the name its rule had then. Never a webhook URL and never mail content.",
861
+ "description": "The name the object is known by: an endpoint's display name, a route's or filter's pattern, a Function's name, a send's From address, a wake schedule's command and the address it wakes, an API key's name, an agent's address, a rule's or rule request's name, and for an objection or a coverage notice the name its rule had then (for a stopped notice, when you were last told of it, or while it last covered you). Never a webhook URL and never mail content.",
862
862
  "type": ["string", "null"]
863
863
  },
864
864
  "state": {
865
865
  "type": "string",
866
- "description": "Where it stands now: enabled, disabled, deleted or replaced (endpoints and routes), enabled or disabled (filters, wake schedules), live, suspended or deleted (Functions), active, paused or ended (repeating sends), scheduled (scheduled sends), active, suspended, expired or revoked (API keys), pending, claimed, connected or revoked (agents), draft, observe or active (email rules), pending, accepted, declined or withdrawn (rule requests and objections), and for a coverage notice what it told: started (a rule was made or turned active over your mailboxes, or an active rule came to reach you; once per rule, not per mailbox), new_version, receivers_changed (who receives an active rule's matches changed: its keys, webhooks or share), or baseline (it already covered you when notices began). pending: a rule started covering your mailbox and the notices have not recorded that start yet (a restart within an hour of the last start notice is recorded without a new one); its id is then the rule's, and created_at when the rule last changed."
866
+ "description": "Where it stands now: enabled, disabled, deleted or replaced (endpoints and routes), enabled or disabled (filters, wake schedules), live, suspended or deleted (Functions), active, paused or ended (repeating sends), scheduled (scheduled sends), active, suspended, expired or revoked (API keys), pending, claimed, connected or revoked (agents), draft, observe or active (email rules), pending, accepted, declined or withdrawn (rule requests and objections; an objection may also be amended), and for a coverage notice what it told: started (a rule was made or turned active over your mailboxes, or an active rule came to reach you; once per rule, not per mailbox), new_version, stopped (it no longer covers you, why in stop_reason), or baseline (it already covered you when notices began). pending: a rule started covering your mailbox and the notices have not recorded that start yet (a restart within an hour of the last start notice, or within 5 minutes of the notices finding the rule stopped, is recorded without a new one, unless you were told it stopped since); its id is then the rule's, and created_at when the rule last changed."
867
867
  },
868
868
  "created_at": {
869
869
  "type": "string",
@@ -872,7 +872,7 @@ const operationManifest = [
872
872
  "ended_at": {
873
873
  "type": ["string", "null"],
874
874
  "format": "date-time",
875
- "description": "When it was deleted, replaced or revoked, when an API key expired, when a repeating send stopped, or when a rule request or objection was decided (accepted, declined or withdrawn); null otherwise, as on every coverage notice (rule_now marks one whose rule was deleted)."
875
+ "description": "When it was deleted, replaced or revoked, when an API key expired, when a repeating send stopped, or when a rule request or objection was decided (accepted, declined, withdrawn or, for an objection, amended); null otherwise, as on every coverage notice (rule_now marks one whose rule was deleted)."
876
876
  },
877
877
  "owned_now": {
878
878
  "type": "string",
@@ -973,6 +973,15 @@ const operationManifest = [
973
973
  }
974
974
  },
975
975
  "required": ["before", "after"]
976
+ },
977
+ "stop_reason": {
978
+ "description": "For a stopped notice: deleted, turned_off (no longer active), or no_longer_covers (active, reaching none of your mailboxes now).",
979
+ "type": "string",
980
+ "enum": [
981
+ "deleted",
982
+ "turned_off",
983
+ "no_longer_covers"
984
+ ]
976
985
  }
977
986
  },
978
987
  "required": [
@@ -1019,7 +1028,7 @@ const operationManifest = [
1019
1028
  "as_of": {
1020
1029
  "type": ["string", "null"],
1021
1030
  "format": "date-time",
1022
- "description": "With relation=concerning only: about when the notices last looked at your organization; null if never or unread. Coverage since may have no notice yet. They look only while one of its rules could cover someone, so this stops moving while none could."
1031
+ "description": "With relation=concerning only: about when the notices last looked at your organization; null if never or unread. Coverage since may have no notice yet. They look only while one of its rules could cover someone, or a stopped notice is still to be told, so this stops moving while neither."
1023
1032
  },
1024
1033
  "pending_complete": {
1025
1034
  "description": "With relation=concerning, on the first page only: whether the check for rules that started covering you without their start notice (state pending, listed ahead of the notices and beyond limit) was finished. false: some may be missing. Absent where there is nothing to check.",
@@ -6460,7 +6469,7 @@ const operationManifest = [
6460
6469
  },
6461
6470
  "webhook_attempt_count": {
6462
6471
  "type": "integer",
6463
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. Its attempts."
6472
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. Its attempts."
6464
6473
  },
6465
6474
  "thread_id": {
6466
6475
  "type": ["string", "null"],
@@ -9366,6 +9375,7 @@ const operationManifest = [
9366
9375
  "items": { "type": "string" }
9367
9376
  },
9368
9377
  "rules": {
9378
+ "description": "Email rule ids: the key also reads the emails these rules granted. An address listed beside them is read in full, so rules beside a domain, a retired address or the address of a member other than the key's holder (its creator, or whoever it was transferred to) are refused (400 validation_error, details.reason rules_beside_domain or rules_beside_personal_mailbox). A rule shared with you goes here by its share's id, from your dashboard session only.",
9369
9379
  "maxItems": 20,
9370
9380
  "type": "array",
9371
9381
  "items": { "type": "string" }
@@ -11238,6 +11248,7 @@ const operationManifest = [
11238
11248
  "items": { "type": "string" }
11239
11249
  },
11240
11250
  "rules": {
11251
+ "description": "Email rule ids: the key also reads the emails these rules granted. An address listed beside them is read in full, so rules beside a domain, a retired address or the address of a member other than the key's holder (its creator, or whoever it was transferred to) are refused (400 validation_error, details.reason rules_beside_domain or rules_beside_personal_mailbox). A rule shared with you goes here by its share's id, from your dashboard session only.",
11241
11252
  "maxItems": 20,
11242
11253
  "type": "array",
11243
11254
  "items": { "type": "string" }
@@ -13607,9 +13618,10 @@ const operationManifest = [
13607
13618
  "pending",
13608
13619
  "accepted",
13609
13620
  "declined",
13610
- "withdrawn"
13621
+ "withdrawn",
13622
+ "amended"
13611
13623
  ],
13612
- "description": "pending until the rule's author accepts it (turning the rule off) or declines it, or the member who made it withdraws it; never changes after."
13624
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
13613
13625
  },
13614
13626
  "rule": {
13615
13627
  "type": "object",
@@ -13622,9 +13634,22 @@ const operationManifest = [
13622
13634
  "name": {
13623
13635
  "type": "string",
13624
13636
  "description": "Its name when the objection was made."
13637
+ },
13638
+ "objected_version": {
13639
+ "type": ["integer", "null"],
13640
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
13641
+ },
13642
+ "amended_version": {
13643
+ "type": ["integer", "null"],
13644
+ "description": "The rule's version when its author answered amended; null otherwise."
13625
13645
  }
13626
13646
  },
13627
- "required": ["id", "name"]
13647
+ "required": [
13648
+ "id",
13649
+ "name",
13650
+ "objected_version",
13651
+ "amended_version"
13652
+ ]
13628
13653
  },
13629
13654
  "objector": {
13630
13655
  "type": "object",
@@ -13680,6 +13705,10 @@ const operationManifest = [
13680
13705
  "description": "The author's answer when declining, which the objector sees; null when none was given.",
13681
13706
  "type": ["string", "null"]
13682
13707
  },
13708
+ "amend_note": {
13709
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
13710
+ "type": ["string", "null"]
13711
+ },
13683
13712
  "created_at": {
13684
13713
  "type": "string",
13685
13714
  "format": "date-time"
@@ -13703,6 +13732,7 @@ const operationManifest = [
13703
13732
  "is_author",
13704
13733
  "message",
13705
13734
  "decline_reason",
13735
+ "amend_note",
13706
13736
  "created_at",
13707
13737
  "decided_at",
13708
13738
  "decided_by_user_id"
@@ -13713,11 +13743,185 @@ const operationManifest = [
13713
13743
  "tag": "Email Rule Oversight",
13714
13744
  "tagCommand": "email-rule-oversight"
13715
13745
  },
13746
+ {
13747
+ "binaryResponse": false,
13748
+ "bodyRequired": false,
13749
+ "command": "amend-email-rule-objection",
13750
+ "description": "Answers a pending objection to a rule you wrote by saying you changed the rule: save a new version first (PATCH /email-rules/{id}), then answer amended, optionally with a note the member who objected sees. Records the version the rule has now (rule.amended_version). Refused unless the rule's current version is newer than when the objection was made (rule.objected_version). Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
13751
+ "hasJsonBody": true,
13752
+ "method": "POST",
13753
+ "operationId": "amendEmailRuleObjection",
13754
+ "path": "/email-rule-objections/{id}/amend",
13755
+ "pathParams": [{
13756
+ "description": "The objection id.",
13757
+ "enum": null,
13758
+ "name": "id",
13759
+ "required": true,
13760
+ "type": "string"
13761
+ }],
13762
+ "queryParams": [],
13763
+ "headerParams": [{
13764
+ "description": "Optional, and not used to deduplicate: this operation stores no result by the key, so a retry with the same key runs the request again. Operations that need a credential refuse a key that is empty, longer than 255 characters or not printable ASCII with 400 `validation_error` and echo a valid one in the Idempotency-Key response header; operations that need none ignore it.",
13765
+ "enum": null,
13766
+ "name": "Idempotency-Key",
13767
+ "required": false,
13768
+ "type": "string"
13769
+ }],
13770
+ "permissions": ["mail:read"],
13771
+ "access": null,
13772
+ "requestSchema": {
13773
+ "type": "object",
13774
+ "properties": { "note": {
13775
+ "type": ["string", "null"],
13776
+ "minLength": 1,
13777
+ "maxLength": 500,
13778
+ "description": "What you changed, up to 500 characters; null or absent for none. The member who objected sees it."
13779
+ } },
13780
+ "additionalProperties": false
13781
+ },
13782
+ "responseSchema": {
13783
+ "type": "object",
13784
+ "properties": {
13785
+ "id": {
13786
+ "type": "string",
13787
+ "format": "uuid"
13788
+ },
13789
+ "status": {
13790
+ "type": "string",
13791
+ "enum": [
13792
+ "pending",
13793
+ "accepted",
13794
+ "declined",
13795
+ "withdrawn",
13796
+ "amended"
13797
+ ],
13798
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
13799
+ },
13800
+ "rule": {
13801
+ "type": "object",
13802
+ "properties": {
13803
+ "id": {
13804
+ "type": ["string", "null"],
13805
+ "format": "uuid",
13806
+ "description": "Null once the rule was deleted outright."
13807
+ },
13808
+ "name": {
13809
+ "type": "string",
13810
+ "description": "Its name when the objection was made."
13811
+ },
13812
+ "objected_version": {
13813
+ "type": ["integer", "null"],
13814
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
13815
+ },
13816
+ "amended_version": {
13817
+ "type": ["integer", "null"],
13818
+ "description": "The rule's version when its author answered amended; null otherwise."
13819
+ }
13820
+ },
13821
+ "required": [
13822
+ "id",
13823
+ "name",
13824
+ "objected_version",
13825
+ "amended_version"
13826
+ ]
13827
+ },
13828
+ "objector": {
13829
+ "type": "object",
13830
+ "properties": {
13831
+ "user_id": {
13832
+ "type": "string",
13833
+ "format": "uuid"
13834
+ },
13835
+ "name": { "type": ["string", "null"] },
13836
+ "email": {
13837
+ "description": "Sign-in email; null unless you can list member emails or this is you.",
13838
+ "type": ["string", "null"]
13839
+ }
13840
+ },
13841
+ "required": [
13842
+ "user_id",
13843
+ "name",
13844
+ "email"
13845
+ ]
13846
+ },
13847
+ "author": {
13848
+ "type": "object",
13849
+ "properties": {
13850
+ "user_id": {
13851
+ "type": "string",
13852
+ "format": "uuid"
13853
+ },
13854
+ "name": { "type": ["string", "null"] },
13855
+ "email": {
13856
+ "description": "Sign-in email; null unless you can list member emails or this is you.",
13857
+ "type": ["string", "null"]
13858
+ }
13859
+ },
13860
+ "required": [
13861
+ "user_id",
13862
+ "name",
13863
+ "email"
13864
+ ]
13865
+ },
13866
+ "is_objector": {
13867
+ "type": "boolean",
13868
+ "description": "Whether you made it, in your current membership."
13869
+ },
13870
+ "is_author": {
13871
+ "type": "boolean",
13872
+ "description": "Whether it is to a rule you wrote, in your current membership."
13873
+ },
13874
+ "message": {
13875
+ "description": "Why they object and what they ask (to turn the rule off, narrow it, or explain who receives it); null when none was given, or once withdrawn.",
13876
+ "type": ["string", "null"]
13877
+ },
13878
+ "decline_reason": {
13879
+ "description": "The author's answer when declining, which the objector sees; null when none was given.",
13880
+ "type": ["string", "null"]
13881
+ },
13882
+ "amend_note": {
13883
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
13884
+ "type": ["string", "null"]
13885
+ },
13886
+ "created_at": {
13887
+ "type": "string",
13888
+ "format": "date-time"
13889
+ },
13890
+ "decided_at": {
13891
+ "type": ["string", "null"],
13892
+ "format": "date-time"
13893
+ },
13894
+ "decided_by_user_id": {
13895
+ "type": ["string", "null"],
13896
+ "format": "uuid"
13897
+ }
13898
+ },
13899
+ "required": [
13900
+ "id",
13901
+ "status",
13902
+ "rule",
13903
+ "objector",
13904
+ "author",
13905
+ "is_objector",
13906
+ "is_author",
13907
+ "message",
13908
+ "decline_reason",
13909
+ "amend_note",
13910
+ "created_at",
13911
+ "decided_at",
13912
+ "decided_by_user_id"
13913
+ ]
13914
+ },
13915
+ "sdkName": "amendEmailRuleObjection",
13916
+ "summary": "Answer an objection to your rule as amended",
13917
+ "tag": "Email Rule Oversight",
13918
+ "tagCommand": "email-rule-oversight"
13919
+ },
13716
13920
  {
13717
13921
  "binaryResponse": false,
13718
13922
  "bodyRequired": true,
13719
13923
  "command": "create-email-rule-objection",
13720
- "description": "Objects to a rule that covers one of your own mailboxes now: say in the message what you ask its author, to turn it off, narrow it, or explain who receives what it matches. The author answers by accepting, which turns it off, or by declining, optionally with a reason you see; the rule keeps running unless they accept. Only a rule that covers you now: one you see only because it once decided on your mail cannot be objected to. An objection is seen by the member who made it, the rule's author and the organization's owners and admins. It stays pending until the rule's author accepts it, turning the rule off, or declines it (optionally with a reason the objector sees), or the member who made it withdraws it, which clears its message. It never changes after that. You may have one pending objection per rule and 50 in all, and object to the same rule again only 10 minutes after you last did, whatever became of it. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
13924
+ "description": "Objects to a rule that covers one of your own mailboxes now: say in the message what you ask its author, to turn it off, narrow it, or explain who receives what it matches. The author answers by accepting, which turns it off, or by declining, optionally with a reason you see; the rule keeps running unless they accept. Only a rule that covers you now: one you see only because it once decided on your mail cannot be objected to. An objection is seen by the member who made it, the rule's author and the organization's owners and admins. It stays pending until the rule's author accepts it, turning the rule off, declines it (optionally with a reason the objector sees), or answers it amended once they have saved a newer version of the rule, or the member who made it withdraws it, which clears its message (not from an email to the author already sent or being sent). It never changes after that. You may have one pending objection per rule and 50 in all, and object to the same rule again only 10 minutes after you last did, whatever became of it. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
13721
13925
  "hasJsonBody": true,
13722
13926
  "method": "POST",
13723
13927
  "operationId": "createEmailRuleObjection",
@@ -13745,7 +13949,7 @@ const operationManifest = [
13745
13949
  "type": ["string", "null"],
13746
13950
  "minLength": 1,
13747
13951
  "maxLength": 500,
13748
- "description": "Why you object and what you ask, up to 500 characters: to turn the rule off, to narrow it, or to explain who receives what it matches. Null or absent for none. The rule's author and the organization's owners and admins see it while it stands; withdrawing clears it."
13952
+ "description": "Why you object and what you ask, up to 500 characters: to turn the rule off, to narrow it, or to explain who receives what it matches. Null or absent for none. The rule's author and the organization's owners and admins see it while it stands, and an email to the author about the objection quotes it. Withdrawing clears it from the objection, not from an email already sent or being sent."
13749
13953
  }
13750
13954
  },
13751
13955
  "required": ["rule_id"],
@@ -13764,9 +13968,10 @@ const operationManifest = [
13764
13968
  "pending",
13765
13969
  "accepted",
13766
13970
  "declined",
13767
- "withdrawn"
13971
+ "withdrawn",
13972
+ "amended"
13768
13973
  ],
13769
- "description": "pending until the rule's author accepts it (turning the rule off) or declines it, or the member who made it withdraws it; never changes after."
13974
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
13770
13975
  },
13771
13976
  "rule": {
13772
13977
  "type": "object",
@@ -13779,9 +13984,22 @@ const operationManifest = [
13779
13984
  "name": {
13780
13985
  "type": "string",
13781
13986
  "description": "Its name when the objection was made."
13987
+ },
13988
+ "objected_version": {
13989
+ "type": ["integer", "null"],
13990
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
13991
+ },
13992
+ "amended_version": {
13993
+ "type": ["integer", "null"],
13994
+ "description": "The rule's version when its author answered amended; null otherwise."
13782
13995
  }
13783
13996
  },
13784
- "required": ["id", "name"]
13997
+ "required": [
13998
+ "id",
13999
+ "name",
14000
+ "objected_version",
14001
+ "amended_version"
14002
+ ]
13785
14003
  },
13786
14004
  "objector": {
13787
14005
  "type": "object",
@@ -13837,6 +14055,10 @@ const operationManifest = [
13837
14055
  "description": "The author's answer when declining, which the objector sees; null when none was given.",
13838
14056
  "type": ["string", "null"]
13839
14057
  },
14058
+ "amend_note": {
14059
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
14060
+ "type": ["string", "null"]
14061
+ },
13840
14062
  "created_at": {
13841
14063
  "type": "string",
13842
14064
  "format": "date-time"
@@ -13860,6 +14082,7 @@ const operationManifest = [
13860
14082
  "is_author",
13861
14083
  "message",
13862
14084
  "decline_reason",
14085
+ "amend_note",
13863
14086
  "created_at",
13864
14087
  "decided_at",
13865
14088
  "decided_by_user_id"
@@ -13874,7 +14097,7 @@ const operationManifest = [
13874
14097
  "binaryResponse": false,
13875
14098
  "bodyRequired": false,
13876
14099
  "command": "decline-email-rule-objection",
13877
- "description": "Declines a pending objection to a rule you wrote, optionally saying why (reason), which the member who objected sees; the rule stays as it is. When its message asks you to narrow the rule or explain who receives it, the reason is your answer; narrow it with a new version as well if you agree. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
14100
+ "description": "Declines a pending objection to a rule you wrote, optionally saying why (reason), which the member who objected sees; the rule stays as it is. When its message asks you to explain who receives what the rule matches, the reason is your answer. If you changed the rule instead, answer amended. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
13878
14101
  "hasJsonBody": true,
13879
14102
  "method": "POST",
13880
14103
  "operationId": "declineEmailRuleObjection",
@@ -13902,7 +14125,7 @@ const operationManifest = [
13902
14125
  "type": ["string", "null"],
13903
14126
  "minLength": 1,
13904
14127
  "maxLength": 500,
13905
- "description": "Why you are declining, up to 500 characters; null or absent for none. The member who objected sees it: it is how to answer one that asks you to narrow the rule or explain who receives it."
14128
+ "description": "Why you are declining, up to 500 characters; null or absent for none. The member who objected sees it: it is how to answer one that asks you to explain who receives it. If you changed the rule instead, answer amended."
13906
14129
  } },
13907
14130
  "additionalProperties": false
13908
14131
  },
@@ -13919,9 +14142,10 @@ const operationManifest = [
13919
14142
  "pending",
13920
14143
  "accepted",
13921
14144
  "declined",
13922
- "withdrawn"
14145
+ "withdrawn",
14146
+ "amended"
13923
14147
  ],
13924
- "description": "pending until the rule's author accepts it (turning the rule off) or declines it, or the member who made it withdraws it; never changes after."
14148
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
13925
14149
  },
13926
14150
  "rule": {
13927
14151
  "type": "object",
@@ -13934,9 +14158,22 @@ const operationManifest = [
13934
14158
  "name": {
13935
14159
  "type": "string",
13936
14160
  "description": "Its name when the objection was made."
14161
+ },
14162
+ "objected_version": {
14163
+ "type": ["integer", "null"],
14164
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
14165
+ },
14166
+ "amended_version": {
14167
+ "type": ["integer", "null"],
14168
+ "description": "The rule's version when its author answered amended; null otherwise."
13937
14169
  }
13938
14170
  },
13939
- "required": ["id", "name"]
14171
+ "required": [
14172
+ "id",
14173
+ "name",
14174
+ "objected_version",
14175
+ "amended_version"
14176
+ ]
13940
14177
  },
13941
14178
  "objector": {
13942
14179
  "type": "object",
@@ -13992,6 +14229,10 @@ const operationManifest = [
13992
14229
  "description": "The author's answer when declining, which the objector sees; null when none was given.",
13993
14230
  "type": ["string", "null"]
13994
14231
  },
14232
+ "amend_note": {
14233
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
14234
+ "type": ["string", "null"]
14235
+ },
13995
14236
  "created_at": {
13996
14237
  "type": "string",
13997
14238
  "format": "date-time"
@@ -14015,6 +14256,7 @@ const operationManifest = [
14015
14256
  "is_author",
14016
14257
  "message",
14017
14258
  "decline_reason",
14259
+ "amend_note",
14018
14260
  "created_at",
14019
14261
  "decided_at",
14020
14262
  "decided_by_user_id"
@@ -14029,7 +14271,7 @@ const operationManifest = [
14029
14271
  "binaryResponse": false,
14030
14272
  "bodyRequired": false,
14031
14273
  "command": "get-email-rule-covering-me",
14032
- "description": "One rule that covers one of your own mailboxes, read-only, with its current version; or one that no longer does but decided on mail at your own mailbox (covers_now false), shown as the version that last decided on your mail, without its current name. You see its name, wording, current tree, state, kind and author, and which of your own mailboxes it reaches. Its wording and tree are shown as written, so they can name other addresses (a condition on who an email is from or to). While it covers you, you also see who receives what it matches (receivers): how many API keys, webhooks and shares, the member each belongs to (or the organization), and the sites the webhooks deliver to. You do not see which keys, webhooks or shares they are (no ids, names, prefixes, or URLs beyond the site), the other inboxes and domains its scope names, or its saved expectations. For what happened to one email of yours, every rule's decision on it and, for another member's rule covering you, who receives what it shares: GET /v1/emails/{id}/rule-results (primitive email-rules list-email-rule-results --email-id <email-id>). Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
14274
+ "description": "One rule that covers one of your own mailboxes, read-only, with its current version; or one that no longer does but decided on mail at your own mailbox (covers_now false), shown as the version that last decided on your mail, without its current name. You see its name, wording, current tree, state, kind and author, and which of your own mailboxes it reaches. Its wording and tree are shown as written, so they can name other addresses (a condition on who an email is from or to). While it covers you, you also see who receives what it matches (receivers): how many API keys, webhooks and shares, the member each belongs to (or the organization), and the sites the webhooks deliver to. You do not see which keys, webhooks or shares they are (no ids, names, prefixes, or URLs beyond the site), the other inboxes and domains its scope names, or its saved expectations. For what happened to one email of yours, every rule's decision on it and, for another member's rule covering you, who receives what it shares: GET /v1/emails/{id}/rule-results (primitive email-rules list-email-rule-results --email-id <email-id>). Whether a rule delivered the email by webhook is not in the rule results: on your own mail, rule_deliveries on GET /v1/emails/{id} (primitive emails get <email-id> --json) counts each rule's webhook deliveries; on another member's mail, GET /v1/webhooks/deliveries?email_id=<email-id> (primitive webhook-deliveries list --email-id <email-id>, with webhooks:read) lists them. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
14033
14275
  "hasJsonBody": false,
14034
14276
  "method": "GET",
14035
14277
  "operationId": "getEmailRuleCoveringMe",
@@ -14175,7 +14417,7 @@ const operationManifest = [
14175
14417
  "exclusiveMinimum": 0
14176
14418
  },
14177
14419
  "reads_in_full": {
14178
- "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches.",
14420
+ "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches. It counts what they can read, not whether any has read an email.",
14179
14421
  "type": "integer",
14180
14422
  "minimum": 0
14181
14423
  },
@@ -14346,7 +14588,7 @@ const operationManifest = [
14346
14588
  "exclusiveMinimum": 0
14347
14589
  },
14348
14590
  "reads_in_full": {
14349
- "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches.",
14591
+ "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches. It counts what they can read, not whether any has read an email.",
14350
14592
  "type": "integer",
14351
14593
  "minimum": 0
14352
14594
  },
@@ -14579,7 +14821,7 @@ const operationManifest = [
14579
14821
  "binaryResponse": false,
14580
14822
  "bodyRequired": false,
14581
14823
  "command": "get-email-rule-objection",
14582
- "description": "One objection you can see. An objection is seen by the member who made it, the rule's author and the organization's owners and admins. It stays pending until the rule's author accepts it, turning the rule off, or declines it (optionally with a reason the objector sees), or the member who made it withdraws it, which clears its message. It never changes after that. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
14824
+ "description": "One objection you can see. An objection is seen by the member who made it, the rule's author and the organization's owners and admins. It stays pending until the rule's author accepts it, turning the rule off, declines it (optionally with a reason the objector sees), or answers it amended once they have saved a newer version of the rule, or the member who made it withdraws it, which clears its message (not from an email to the author already sent or being sent). It never changes after that. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
14583
14825
  "hasJsonBody": false,
14584
14826
  "method": "GET",
14585
14827
  "operationId": "getEmailRuleObjection",
@@ -14609,9 +14851,10 @@ const operationManifest = [
14609
14851
  "pending",
14610
14852
  "accepted",
14611
14853
  "declined",
14612
- "withdrawn"
14854
+ "withdrawn",
14855
+ "amended"
14613
14856
  ],
14614
- "description": "pending until the rule's author accepts it (turning the rule off) or declines it, or the member who made it withdraws it; never changes after."
14857
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
14615
14858
  },
14616
14859
  "rule": {
14617
14860
  "type": "object",
@@ -14624,9 +14867,22 @@ const operationManifest = [
14624
14867
  "name": {
14625
14868
  "type": "string",
14626
14869
  "description": "Its name when the objection was made."
14870
+ },
14871
+ "objected_version": {
14872
+ "type": ["integer", "null"],
14873
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
14874
+ },
14875
+ "amended_version": {
14876
+ "type": ["integer", "null"],
14877
+ "description": "The rule's version when its author answered amended; null otherwise."
14627
14878
  }
14628
14879
  },
14629
- "required": ["id", "name"]
14880
+ "required": [
14881
+ "id",
14882
+ "name",
14883
+ "objected_version",
14884
+ "amended_version"
14885
+ ]
14630
14886
  },
14631
14887
  "objector": {
14632
14888
  "type": "object",
@@ -14682,6 +14938,10 @@ const operationManifest = [
14682
14938
  "description": "The author's answer when declining, which the objector sees; null when none was given.",
14683
14939
  "type": ["string", "null"]
14684
14940
  },
14941
+ "amend_note": {
14942
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
14943
+ "type": ["string", "null"]
14944
+ },
14685
14945
  "created_at": {
14686
14946
  "type": "string",
14687
14947
  "format": "date-time"
@@ -14705,6 +14965,7 @@ const operationManifest = [
14705
14965
  "is_author",
14706
14966
  "message",
14707
14967
  "decline_reason",
14968
+ "amend_note",
14708
14969
  "created_at",
14709
14970
  "decided_at",
14710
14971
  "decided_by_user_id"
@@ -14795,7 +15056,7 @@ const operationManifest = [
14795
15056
  "question_answers": {
14796
15057
  "type": "array",
14797
15058
  "items": {},
14798
- "description": "The answers to the rule's own questions, when they were asked."
15059
+ "description": "The answers to the rule's own questions, when they were asked: each with question, answer, confidence, the deprecated probability and, when unanswered, error_class, as a test gives them."
14799
15060
  },
14800
15061
  "detail_withheld": {
14801
15062
  "description": "Present, as true, when the email's content cannot be read: matched still says what the rule decided, and parts and question_answers are empty.",
@@ -14842,7 +15103,7 @@ const operationManifest = [
14842
15103
  "binaryResponse": false,
14843
15104
  "bodyRequired": false,
14844
15105
  "command": "list-email-rule-objections",
14845
- "description": "Objections you made and objections to rules you wrote (by default), only one of the two, or every objection you can see, newest first. An objection is seen by the member who made it, the rule's author and the organization's owners and admins. It stays pending until the rule's author accepts it, turning the rule off, or declines it (optionally with a reason the objector sees), or the member who made it withdraws it, which clears its message. It never changes after that. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
15106
+ "description": "Objections you made and objections to rules you wrote (by default), only one of the two, or every objection you can see, newest first. An objection is seen by the member who made it, the rule's author and the organization's owners and admins. It stays pending until the rule's author accepts it, turning the rule off, declines it (optionally with a reason the objector sees), or answers it amended once they have saved a newer version of the rule, or the member who made it withdraws it, which clears its message (not from an email to the author already sent or being sent). It never changes after that. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
14846
15107
  "hasJsonBody": false,
14847
15108
  "method": "GET",
14848
15109
  "operationId": "listEmailRuleObjections",
@@ -14911,9 +15172,10 @@ const operationManifest = [
14911
15172
  "pending",
14912
15173
  "accepted",
14913
15174
  "declined",
14914
- "withdrawn"
15175
+ "withdrawn",
15176
+ "amended"
14915
15177
  ],
14916
- "description": "pending until the rule's author accepts it (turning the rule off) or declines it, or the member who made it withdraws it; never changes after."
15178
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
14917
15179
  },
14918
15180
  "rule": {
14919
15181
  "type": "object",
@@ -14926,9 +15188,22 @@ const operationManifest = [
14926
15188
  "name": {
14927
15189
  "type": "string",
14928
15190
  "description": "Its name when the objection was made."
15191
+ },
15192
+ "objected_version": {
15193
+ "type": ["integer", "null"],
15194
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
15195
+ },
15196
+ "amended_version": {
15197
+ "type": ["integer", "null"],
15198
+ "description": "The rule's version when its author answered amended; null otherwise."
14929
15199
  }
14930
15200
  },
14931
- "required": ["id", "name"]
15201
+ "required": [
15202
+ "id",
15203
+ "name",
15204
+ "objected_version",
15205
+ "amended_version"
15206
+ ]
14932
15207
  },
14933
15208
  "objector": {
14934
15209
  "type": "object",
@@ -14984,6 +15259,10 @@ const operationManifest = [
14984
15259
  "description": "The author's answer when declining, which the objector sees; null when none was given.",
14985
15260
  "type": ["string", "null"]
14986
15261
  },
15262
+ "amend_note": {
15263
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
15264
+ "type": ["string", "null"]
15265
+ },
14987
15266
  "created_at": {
14988
15267
  "type": "string",
14989
15268
  "format": "date-time"
@@ -15007,6 +15286,7 @@ const operationManifest = [
15007
15286
  "is_author",
15008
15287
  "message",
15009
15288
  "decline_reason",
15289
+ "amend_note",
15010
15290
  "created_at",
15011
15291
  "decided_at",
15012
15292
  "decided_by_user_id"
@@ -15142,7 +15422,7 @@ const operationManifest = [
15142
15422
  "binaryResponse": false,
15143
15423
  "bodyRequired": false,
15144
15424
  "command": "list-email-rules-covering-me",
15145
- "description": "Every email rule that covers one of your own mailboxes now, yours included, newest first, in any state. A rule covers you when the scope it runs with now reaches one of your own mailboxes (your member mailbox, or a personal agent's address): one whose author reads all your mail (author scope, for an author who reads the organization's mail or holds an access entry for your mailbox), or one that names your mailbox or its domain (selected). Another member's own_mailboxes rule never covers you. You see its name, wording, current tree, state, kind and author, and which of your own mailboxes it reaches. Its wording and tree are shown as written, so they can name other addresses (a condition on who an email is from or to). While it covers you, you also see who receives what it matches (receivers): how many API keys, webhooks and shares, the member each belongs to (or the organization), and the sites the webhooks deliver to. You do not see which keys, webhooks or shares they are (no ids, names, prefixes, or URLs beyond the site), the other inboxes and domains its scope names, or its saved expectations. A page can hold fewer rules than limit, or none, and still carry a cursor (one request reads a bounded number of rules): keep reading until meta.cursor is null. For what happened to one email of yours, every rule's decision on it and, for another member's rule covering you, who receives what it shares: GET /v1/emails/{id}/rule-results (primitive email-rules list-email-rule-results --email-id <email-id>). Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
15425
+ "description": "Every email rule that covers one of your own mailboxes now, yours included, newest first, in any state. A rule covers you when the scope it runs with now reaches one of your own mailboxes (your member mailbox, or a personal agent's address), and covers.via says how: author_reach, it runs over everything its author can read, which includes your mail (an author who reads the organization's mail or holds an access entry for your mailbox); selected, it names your mailbox or its domain; own_mailboxes, it is your own rule over your own mail. Another member's own_mailboxes rule never covers you. You see its name, wording, current tree, state, kind and author, and which of your own mailboxes it reaches. Its wording and tree are shown as written, so they can name other addresses (a condition on who an email is from or to). While it covers you, you also see who receives what it matches (receivers): how many API keys, webhooks and shares, the member each belongs to (or the organization), and the sites the webhooks deliver to. You do not see which keys, webhooks or shares they are (no ids, names, prefixes, or URLs beyond the site), the other inboxes and domains its scope names, or its saved expectations. Each listed rule carries its current version's english and explanation; its tree is on GET /v1/email-rules/covering-me/{id}. A page can hold fewer rules than limit, or none, and still carry a cursor (one request reads a bounded number of rules): keep reading until meta.cursor is null. For what happened to one email of yours, every rule's decision on it and, for another member's rule covering you, who receives what it shares: GET /v1/emails/{id}/rule-results (primitive email-rules list-email-rule-results --email-id <email-id>). Whether a rule delivered the email by webhook is not in the rule results: on your own mail, rule_deliveries on GET /v1/emails/{id} (primitive emails get <email-id> --json) counts each rule's webhook deliveries; on another member's mail, GET /v1/webhooks/deliveries?email_id=<email-id> (primitive webhook-deliveries list --email-id <email-id>, with webhooks:read) lists them. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
15146
15426
  "hasJsonBody": false,
15147
15427
  "method": "GET",
15148
15428
  "operationId": "listEmailRulesCoveringMe",
@@ -15292,7 +15572,7 @@ const operationManifest = [
15292
15572
  "exclusiveMinimum": 0
15293
15573
  },
15294
15574
  "reads_in_full": {
15295
- "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches.",
15575
+ "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches. It counts what they can read, not whether any has read an email.",
15296
15576
  "type": "integer",
15297
15577
  "minimum": 0
15298
15578
  },
@@ -15463,7 +15743,7 @@ const operationManifest = [
15463
15743
  "exclusiveMinimum": 0
15464
15744
  },
15465
15745
  "reads_in_full": {
15466
- "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches.",
15746
+ "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches. It counts what they can read, not whether any has read an email.",
15467
15747
  "type": "integer",
15468
15748
  "minimum": 0
15469
15749
  },
@@ -15591,6 +15871,14 @@ const operationManifest = [
15591
15871
  "created_at": {
15592
15872
  "type": "string",
15593
15873
  "format": "date-time"
15874
+ },
15875
+ "english": {
15876
+ "description": "What its author asked for, in their words, at its current version. Null when it has no version, was deleted after the page was read, or the words could not be read in time; GET /v1/email-rules/covering-me/{id} shows them with its tree.",
15877
+ "type": ["string", "null"]
15878
+ },
15879
+ "explanation": {
15880
+ "description": "What its current version matches, as compiled. Null as english is.",
15881
+ "type": ["string", "null"]
15594
15882
  }
15595
15883
  },
15596
15884
  "required": [
@@ -15617,7 +15905,7 @@ const operationManifest = [
15617
15905
  "binaryResponse": false,
15618
15906
  "bodyRequired": false,
15619
15907
  "command": "withdraw-email-rule-objection",
15620
- "description": "Withdraws a pending objection you made, and clears its message. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
15908
+ "description": "Withdraws a pending objection you made, and clears its message; an email to the rule's author already sent or being sent keeps it. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token). Only on your own dashboard session or the Primitive CLI.",
15621
15909
  "hasJsonBody": false,
15622
15910
  "method": "POST",
15623
15911
  "operationId": "withdrawEmailRuleObjection",
@@ -15653,9 +15941,10 @@ const operationManifest = [
15653
15941
  "pending",
15654
15942
  "accepted",
15655
15943
  "declined",
15656
- "withdrawn"
15944
+ "withdrawn",
15945
+ "amended"
15657
15946
  ],
15658
- "description": "pending until the rule's author accepts it (turning the rule off) or declines it, or the member who made it withdraws it; never changes after."
15947
+ "description": "pending until the rule's author accepts it (turning the rule off), declines it, or answers it amended (they saved a newer version of the rule), or the member who made it withdraws it; never changes after."
15659
15948
  },
15660
15949
  "rule": {
15661
15950
  "type": "object",
@@ -15668,9 +15957,22 @@ const operationManifest = [
15668
15957
  "name": {
15669
15958
  "type": "string",
15670
15959
  "description": "Its name when the objection was made."
15960
+ },
15961
+ "objected_version": {
15962
+ "type": ["integer", "null"],
15963
+ "description": "The rule's version when the objection was made; null when it could not be told for an older objection."
15964
+ },
15965
+ "amended_version": {
15966
+ "type": ["integer", "null"],
15967
+ "description": "The rule's version when its author answered amended; null otherwise."
15671
15968
  }
15672
15969
  },
15673
- "required": ["id", "name"]
15970
+ "required": [
15971
+ "id",
15972
+ "name",
15973
+ "objected_version",
15974
+ "amended_version"
15975
+ ]
15674
15976
  },
15675
15977
  "objector": {
15676
15978
  "type": "object",
@@ -15726,6 +16028,10 @@ const operationManifest = [
15726
16028
  "description": "The author's answer when declining, which the objector sees; null when none was given.",
15727
16029
  "type": ["string", "null"]
15728
16030
  },
16031
+ "amend_note": {
16032
+ "description": "The author's note when answering amended, which the objector sees; null when none was given.",
16033
+ "type": ["string", "null"]
16034
+ },
15729
16035
  "created_at": {
15730
16036
  "type": "string",
15731
16037
  "format": "date-time"
@@ -15749,6 +16055,7 @@ const operationManifest = [
15749
16055
  "is_author",
15750
16056
  "message",
15751
16057
  "decline_reason",
16058
+ "amend_note",
15752
16059
  "created_at",
15753
16060
  "decided_at",
15754
16061
  "decided_by_user_id"
@@ -15938,6 +16245,43 @@ const operationManifest = [
15938
16245
  },
15939
16246
  "required": ["evaluation_scope", "scope_selection"]
15940
16247
  },
16248
+ "scope_warnings": {
16249
+ "description": "Ignored (the compile answer's scope_warnings).",
16250
+ "maxItems": 150,
16251
+ "type": "array",
16252
+ "items": {
16253
+ "type": "object",
16254
+ "properties": {
16255
+ "name": {
16256
+ "type": "string",
16257
+ "maxLength": 320
16258
+ },
16259
+ "kind": {
16260
+ "type": "string",
16261
+ "enum": ["address", "domain"]
16262
+ },
16263
+ "reason": {
16264
+ "type": "string",
16265
+ "enum": [
16266
+ "unknown_domain",
16267
+ "inactive_domain",
16268
+ "unknown_address"
16269
+ ],
16270
+ "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
16271
+ },
16272
+ "message": {
16273
+ "type": "string",
16274
+ "maxLength": 1e3
16275
+ }
16276
+ },
16277
+ "required": [
16278
+ "name",
16279
+ "kind",
16280
+ "reason",
16281
+ "message"
16282
+ ]
16283
+ }
16284
+ },
15941
16285
  "kind": {
15942
16286
  "description": "Only grant.",
15943
16287
  "type": "string",
@@ -16065,194 +16409,9 @@ const operationManifest = [
16065
16409
  "responseSchema": {
16066
16410
  "type": "object",
16067
16411
  "properties": {
16068
- "request": {
16069
- "type": "object",
16070
- "properties": {
16071
- "id": {
16072
- "type": "string",
16073
- "format": "uuid"
16074
- },
16075
- "status": {
16076
- "type": "string",
16077
- "enum": [
16078
- "pending",
16079
- "accepted",
16080
- "declined",
16081
- "withdrawn"
16082
- ]
16083
- },
16084
- "name": { "type": "string" },
16085
- "english": { "type": "string" },
16086
- "tree": {
16087
- "type": "object",
16088
- "properties": {
16089
- "version": {
16090
- "type": "number",
16091
- "const": 1
16092
- },
16093
- "vocabulary": {
16094
- "type": "string",
16095
- "description": "Vocabulary version, such as v1."
16096
- },
16097
- "when": {
16098
- "type": "object",
16099
- "propertyNames": { "type": "string" },
16100
- "additionalProperties": {},
16101
- "description": "A condition {column, op, value?, min_confidence?} (see GET /email-rules/vocabulary) or {all: [...]}, {any: [...]}, {not: ...}."
16102
- },
16103
- "questions": {
16104
- "type": "array",
16105
- "items": { "type": "string" },
16106
- "description": "Yes/no questions asked once the conditions match, over the email's text and attachment names, never attachment contents. A grant rule needs every one yes; a do_not_share rule matches on any yes."
16107
- }
16108
- },
16109
- "required": [
16110
- "version",
16111
- "vocabulary",
16112
- "when",
16113
- "questions"
16114
- ]
16115
- },
16116
- "explanation": { "type": "string" },
16117
- "assumptions": {
16118
- "type": "array",
16119
- "items": { "type": "string" }
16120
- },
16121
- "warnings": {
16122
- "type": "array",
16123
- "items": { "type": "string" },
16124
- "description": "As the member who asked sent them, normally from their compile, then every compiler note on the rule's tree and words they lack. The compiler's note that the rule matches nearly everything, in its own wording, counted that member's recent mail: anyone else reads it naming them."
16125
- },
16126
- "server_explanation": {
16127
- "description": "What the rule as asked actually does: Primitive's own reading of the request's tree, never the words of the member who asked or of a model. Null when the tree no longer reads as one.",
16128
- "type": ["string", "null"]
16129
- },
16130
- "server_notes": {
16131
- "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
16132
- "type": "array",
16133
- "items": { "type": "string" }
16134
- },
16135
- "compiled_by": { "type": "string" },
16136
- "vocabulary": { "type": "string" },
16137
- "proposed_via": {
16138
- "type": "string",
16139
- "enum": ["session", "oauth"],
16140
- "description": "session: the proposer's own session; oauth: an OAuth or CLI token acting for them."
16141
- },
16142
- "created_at": {
16143
- "type": "string",
16144
- "format": "date-time"
16145
- },
16146
- "decided_at": {
16147
- "type": ["string", "null"],
16148
- "format": "date-time"
16149
- },
16150
- "decided_by_user_id": {
16151
- "type": ["string", "null"],
16152
- "format": "uuid"
16153
- },
16154
- "proposer": {
16155
- "type": "object",
16156
- "properties": {
16157
- "user_id": {
16158
- "type": "string",
16159
- "format": "uuid"
16160
- },
16161
- "name": { "type": ["string", "null"] },
16162
- "email": {
16163
- "description": "Sign-in email; null unless you can list member emails, this is you, or they asked you.",
16164
- "type": ["string", "null"]
16165
- },
16166
- "active": {
16167
- "type": "boolean",
16168
- "description": "Still a member under the membership recorded (a request or share with someone who left no longer works)."
16169
- }
16170
- },
16171
- "required": [
16172
- "user_id",
16173
- "name",
16174
- "email",
16175
- "active"
16176
- ]
16177
- },
16178
- "target": {
16179
- "type": "object",
16180
- "properties": {
16181
- "user_id": {
16182
- "type": ["string", "null"],
16183
- "format": "uuid",
16184
- "description": "Null unless you can list members or this is you."
16185
- },
16186
- "name": {
16187
- "description": "Null unless you can list members or this is you.",
16188
- "type": ["string", "null"]
16189
- },
16190
- "email": {
16191
- "description": "Sign-in email; null unless you can list member emails or this is you.",
16192
- "type": ["string", "null"]
16193
- },
16194
- "active": {
16195
- "type": "boolean",
16196
- "description": "Still a member under the membership recorded (a request or share with someone who left no longer works)."
16197
- }
16198
- },
16199
- "required": [
16200
- "user_id",
16201
- "name",
16202
- "email",
16203
- "active"
16204
- ]
16205
- },
16206
- "target_address_typed": {
16207
- "description": "The address the proposer typed to name the target; null for anyone else, and when named by user id.",
16208
- "type": ["string", "null"]
16209
- },
16210
- "is_proposer": { "type": "boolean" },
16211
- "is_target": { "type": "boolean" },
16212
- "share_id": {
16213
- "type": ["string", "null"],
16214
- "format": "uuid",
16215
- "description": "The share accepting created, while it exists."
16216
- },
16217
- "message": {
16218
- "description": "What the member asking wrote about why; null when they wrote nothing.",
16219
- "type": ["string", "null"]
16220
- },
16221
- "decline_reason": {
16222
- "description": "Why the member asked declined it; null unless they gave a reason when declining.",
16223
- "type": ["string", "null"]
16224
- },
16225
- "edited_on_accept": {
16226
- "description": "Once accepted: whether the rule was changed first, as on the share. Null until then, or when unreadable.",
16227
- "type": ["boolean", "null"]
16228
- },
16229
- "notice": {
16230
- "description": "For the member asked, while pending: what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
16231
- "type": ["string", "null"]
16232
- }
16233
- },
16234
- "required": [
16235
- "id",
16236
- "status",
16237
- "name",
16238
- "english",
16239
- "tree",
16240
- "explanation",
16241
- "assumptions",
16242
- "warnings",
16243
- "compiled_by",
16244
- "vocabulary",
16245
- "proposed_via",
16246
- "created_at",
16247
- "decided_at",
16248
- "decided_by_user_id",
16249
- "proposer",
16250
- "target",
16251
- "target_address_typed",
16252
- "is_proposer",
16253
- "is_target",
16254
- "share_id"
16255
- ]
16412
+ "notice": {
16413
+ "description": "What is now shared, in words. When you changed the rule and it can now match mail the request left out by who it was sent to (such as mail where an address is only copied), that comes first; when you changed its english, tree or explanation (edited_on_accept; a new name alone is no change), that rule.current is what you agreed to and request what was asked.",
16414
+ "type": "string"
16256
16415
  },
16257
16416
  "rule": {
16258
16417
  "type": "object",
@@ -16491,11 +16650,11 @@ const operationManifest = [
16491
16650
  "rule_deleted",
16492
16651
  null
16493
16652
  ],
16494
- "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
16653
+ "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved, on a share that ended before new versions kept shares) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
16495
16654
  },
16496
16655
  "accepted_rule_version": {
16497
16656
  "type": "integer",
16498
- "description": "The version of the rule that was accepted. A new version of the rule ends the share."
16657
+ "description": "The version of the rule that was accepted. A later version keeps the share: what each version matches is shared from when it is saved."
16499
16658
  },
16500
16659
  "edited_on_accept": {
16501
16660
  "type": "boolean",
@@ -16509,6 +16668,44 @@ const operationManifest = [
16509
16668
  "description": "True when the rule is active and the share live but new email is not being shared now (what was shared stays visible); false when new email is shared. Null when it does not apply (share not live, rule not active, or you are not on the share) or could not be read.",
16510
16669
  "type": ["boolean", "null"]
16511
16670
  },
16671
+ "activity": {
16672
+ "description": "For the member it is shared with, on the dashboard or the Primitive CLI, while it is live and their access reads content: whether it is working, so a quiet mailbox can be told from a stopped share. Null otherwise.",
16673
+ "anyOf": [{
16674
+ "type": "object",
16675
+ "properties": {
16676
+ "rule_active": {
16677
+ "type": "boolean",
16678
+ "description": "Whether the rule is active now: only an active rule shares."
16679
+ },
16680
+ "last_decided_at": {
16681
+ "type": ["string", "null"],
16682
+ "format": "date-time",
16683
+ "description": "The start of the hour in which the rule last decided on any email in the sharing member's mailboxes since the share began, counting only hours that have ended and the hour of the newest email shared; null if none, or not read."
16684
+ },
16685
+ "shared_emails": {
16686
+ "type": ["integer", "null"],
16687
+ "minimum": 0,
16688
+ "description": "Emails this share has shared, counted up to 10,000; null when these could not be read."
16689
+ },
16690
+ "shared_emails_more": {
16691
+ "description": "Present when it has shared more than 10,000.",
16692
+ "type": "boolean",
16693
+ "const": true
16694
+ },
16695
+ "last_shared_at": {
16696
+ "type": ["string", "null"],
16697
+ "format": "date-time",
16698
+ "description": "When it last shared one; null if it has not, or not read."
16699
+ }
16700
+ },
16701
+ "required": [
16702
+ "rule_active",
16703
+ "last_decided_at",
16704
+ "shared_emails",
16705
+ "last_shared_at"
16706
+ ]
16707
+ }, { "type": "null" }]
16708
+ },
16512
16709
  "is_granter": {
16513
16710
  "type": "boolean",
16514
16711
  "description": "Whether you are the member sharing their mail."
@@ -16598,7 +16795,7 @@ const operationManifest = [
16598
16795
  "rule_id": {
16599
16796
  "type": ["string", "null"],
16600
16797
  "format": "uuid",
16601
- "description": "The rule itself. Only for the member sharing their mail; null for anyone else."
16798
+ "description": "The rule itself. Only for the member sharing their mail; null for anyone else. The member it is shared with lists this share's id in a key's grant.rules instead (from the dashboard), and their own webhooks receive what it shares."
16602
16799
  }
16603
16800
  },
16604
16801
  "required": [
@@ -16619,15 +16816,200 @@ const operationManifest = [
16619
16816
  "rule_id"
16620
16817
  ]
16621
16818
  },
16622
- "notice": {
16623
- "description": "What is now shared, in words. When you changed the rule and it can now match mail the request left out by who it was sent to (such as mail where an address is only copied), that comes first; when you changed its english, tree or explanation (edited_on_accept; a new name alone is no change), that rule.current is what you agreed to and request what was asked.",
16624
- "type": "string"
16819
+ "request": {
16820
+ "type": "object",
16821
+ "properties": {
16822
+ "id": {
16823
+ "type": "string",
16824
+ "format": "uuid"
16825
+ },
16826
+ "status": {
16827
+ "type": "string",
16828
+ "enum": [
16829
+ "pending",
16830
+ "accepted",
16831
+ "declined",
16832
+ "withdrawn"
16833
+ ]
16834
+ },
16835
+ "name": { "type": "string" },
16836
+ "english": { "type": "string" },
16837
+ "tree": {
16838
+ "type": "object",
16839
+ "properties": {
16840
+ "version": {
16841
+ "type": "number",
16842
+ "const": 1
16843
+ },
16844
+ "vocabulary": {
16845
+ "type": "string",
16846
+ "description": "Vocabulary version, such as v1."
16847
+ },
16848
+ "when": {
16849
+ "type": "object",
16850
+ "propertyNames": { "type": "string" },
16851
+ "additionalProperties": {},
16852
+ "description": "A condition {column, op, value?, min_confidence?} (see GET /email-rules/vocabulary) or {all: [...]}, {any: [...]}, {not: ...}."
16853
+ },
16854
+ "questions": {
16855
+ "type": "array",
16856
+ "items": { "type": "string" },
16857
+ "description": "Yes/no questions asked once the conditions match, over the email's text and attachment names, never attachment contents. A grant rule needs every one yes; a do_not_share rule matches on any yes."
16858
+ }
16859
+ },
16860
+ "required": [
16861
+ "version",
16862
+ "vocabulary",
16863
+ "when",
16864
+ "questions"
16865
+ ]
16866
+ },
16867
+ "explanation": { "type": "string" },
16868
+ "assumptions": {
16869
+ "type": "array",
16870
+ "items": { "type": "string" }
16871
+ },
16872
+ "warnings": {
16873
+ "type": "array",
16874
+ "items": { "type": "string" },
16875
+ "description": "As the member who asked sent them, normally from their compile, then every compiler note on the rule's tree and words they lack. The compiler's note that the rule matches nearly everything, in its own wording, counted that member's recent mail: anyone else reads it naming them."
16876
+ },
16877
+ "server_explanation": {
16878
+ "description": "What the rule as asked actually does: Primitive's own reading of the request's tree, never the words of the member who asked or of a model. Null when the tree no longer reads as one.",
16879
+ "type": ["string", "null"]
16880
+ },
16881
+ "server_notes": {
16882
+ "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes and that counts the asker quotes came from their own mail. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
16883
+ "type": "array",
16884
+ "items": { "type": "string" }
16885
+ },
16886
+ "compiled_by": { "type": "string" },
16887
+ "vocabulary": { "type": "string" },
16888
+ "proposed_via": {
16889
+ "type": "string",
16890
+ "enum": ["session", "oauth"],
16891
+ "description": "session: the proposer's own session; oauth: an OAuth or CLI token acting for them."
16892
+ },
16893
+ "created_at": {
16894
+ "type": "string",
16895
+ "format": "date-time"
16896
+ },
16897
+ "decided_at": {
16898
+ "type": ["string", "null"],
16899
+ "format": "date-time"
16900
+ },
16901
+ "decided_by_user_id": {
16902
+ "type": ["string", "null"],
16903
+ "format": "uuid"
16904
+ },
16905
+ "proposer": {
16906
+ "type": "object",
16907
+ "properties": {
16908
+ "user_id": {
16909
+ "type": "string",
16910
+ "format": "uuid"
16911
+ },
16912
+ "name": { "type": ["string", "null"] },
16913
+ "email": {
16914
+ "description": "Sign-in email; null unless you can list member emails, this is you, or they asked you.",
16915
+ "type": ["string", "null"]
16916
+ },
16917
+ "active": {
16918
+ "type": "boolean",
16919
+ "description": "Still a member under the membership recorded (a request or share with someone who left no longer works)."
16920
+ }
16921
+ },
16922
+ "required": [
16923
+ "user_id",
16924
+ "name",
16925
+ "email",
16926
+ "active"
16927
+ ]
16928
+ },
16929
+ "target": {
16930
+ "type": "object",
16931
+ "properties": {
16932
+ "user_id": {
16933
+ "type": ["string", "null"],
16934
+ "format": "uuid",
16935
+ "description": "Null unless you can list members or this is you."
16936
+ },
16937
+ "name": {
16938
+ "description": "Null unless you can list members or this is you.",
16939
+ "type": ["string", "null"]
16940
+ },
16941
+ "email": {
16942
+ "description": "Sign-in email; null unless you can list member emails or this is you.",
16943
+ "type": ["string", "null"]
16944
+ },
16945
+ "active": {
16946
+ "type": "boolean",
16947
+ "description": "Still a member under the membership recorded (a request or share with someone who left no longer works)."
16948
+ }
16949
+ },
16950
+ "required": [
16951
+ "user_id",
16952
+ "name",
16953
+ "email",
16954
+ "active"
16955
+ ]
16956
+ },
16957
+ "target_address_typed": {
16958
+ "description": "The address the proposer typed to name the target; null for anyone else, and when named by user id.",
16959
+ "type": ["string", "null"]
16960
+ },
16961
+ "is_proposer": { "type": "boolean" },
16962
+ "is_target": { "type": "boolean" },
16963
+ "share_id": {
16964
+ "type": ["string", "null"],
16965
+ "format": "uuid",
16966
+ "description": "The share accepting created, while it exists."
16967
+ },
16968
+ "message": {
16969
+ "description": "What the member asking wrote about why; null when they wrote nothing.",
16970
+ "type": ["string", "null"]
16971
+ },
16972
+ "decline_reason": {
16973
+ "description": "Why the member asked declined it; null unless they gave a reason when declining.",
16974
+ "type": ["string", "null"]
16975
+ },
16976
+ "edited_on_accept": {
16977
+ "description": "Once accepted: whether the rule was changed first, as on the share. Null until then, or when unreadable.",
16978
+ "type": ["boolean", "null"]
16979
+ },
16980
+ "notice": {
16981
+ "description": "For the member asked, while pending: who asked (as proposer names them), what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results and rule_deliveries). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
16982
+ "type": ["string", "null"]
16983
+ }
16984
+ },
16985
+ "required": [
16986
+ "id",
16987
+ "status",
16988
+ "name",
16989
+ "english",
16990
+ "tree",
16991
+ "explanation",
16992
+ "assumptions",
16993
+ "warnings",
16994
+ "compiled_by",
16995
+ "vocabulary",
16996
+ "proposed_via",
16997
+ "created_at",
16998
+ "decided_at",
16999
+ "decided_by_user_id",
17000
+ "proposer",
17001
+ "target",
17002
+ "target_address_typed",
17003
+ "is_proposer",
17004
+ "is_target",
17005
+ "share_id"
17006
+ ]
16625
17007
  }
16626
17008
  },
16627
17009
  "required": [
16628
- "request",
16629
17010
  "rule",
16630
- "share"
17011
+ "share",
17012
+ "request"
16631
17013
  ]
16632
17014
  },
16633
17015
  "sdkName": "acceptEmailRuleRequest",
@@ -16927,6 +17309,43 @@ const operationManifest = [
16927
17309
  },
16928
17310
  "required": ["evaluation_scope", "scope_selection"]
16929
17311
  },
17312
+ "scope_warnings": {
17313
+ "description": "Names in the scope_selection sent that match nothing this organization receives mail at (a typo, or an inbox not yet in use), as a test or write would warn of them. Present only when there are some; writes ignore it.",
17314
+ "maxItems": 150,
17315
+ "type": "array",
17316
+ "items": {
17317
+ "type": "object",
17318
+ "properties": {
17319
+ "name": {
17320
+ "type": "string",
17321
+ "maxLength": 320
17322
+ },
17323
+ "kind": {
17324
+ "type": "string",
17325
+ "enum": ["address", "domain"]
17326
+ },
17327
+ "reason": {
17328
+ "type": "string",
17329
+ "enum": [
17330
+ "unknown_domain",
17331
+ "inactive_domain",
17332
+ "unknown_address"
17333
+ ],
17334
+ "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
17335
+ },
17336
+ "message": {
17337
+ "type": "string",
17338
+ "maxLength": 1e3
17339
+ }
17340
+ },
17341
+ "required": [
17342
+ "name",
17343
+ "kind",
17344
+ "reason",
17345
+ "message"
17346
+ ]
17347
+ }
17348
+ },
16930
17349
  "sql": {
16931
17350
  "description": "Present only when include_sql was true.",
16932
17351
  "type": "object",
@@ -17318,6 +17737,43 @@ const operationManifest = [
17318
17737
  }
17319
17738
  },
17320
17739
  "required": ["evaluation_scope", "scope_selection"]
17740
+ },
17741
+ "scope_warnings": {
17742
+ "description": "Ignored (the compile answer's scope_warnings).",
17743
+ "maxItems": 150,
17744
+ "type": "array",
17745
+ "items": {
17746
+ "type": "object",
17747
+ "properties": {
17748
+ "name": {
17749
+ "type": "string",
17750
+ "maxLength": 320
17751
+ },
17752
+ "kind": {
17753
+ "type": "string",
17754
+ "enum": ["address", "domain"]
17755
+ },
17756
+ "reason": {
17757
+ "type": "string",
17758
+ "enum": [
17759
+ "unknown_domain",
17760
+ "inactive_domain",
17761
+ "unknown_address"
17762
+ ],
17763
+ "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
17764
+ },
17765
+ "message": {
17766
+ "type": "string",
17767
+ "maxLength": 1e3
17768
+ }
17769
+ },
17770
+ "required": [
17771
+ "name",
17772
+ "kind",
17773
+ "reason",
17774
+ "message"
17775
+ ]
17776
+ }
17321
17777
  }
17322
17778
  },
17323
17779
  "required": [
@@ -17524,11 +17980,15 @@ const operationManifest = [
17524
17980
  },
17525
17981
  "scope_warnings": {
17526
17982
  "description": "Names in scope_selection that match nothing this organization receives mail at (a typo, or an inbox not yet in use). Present only when there are some.",
17983
+ "maxItems": 150,
17527
17984
  "type": "array",
17528
17985
  "items": {
17529
17986
  "type": "object",
17530
17987
  "properties": {
17531
- "name": { "type": "string" },
17988
+ "name": {
17989
+ "type": "string",
17990
+ "maxLength": 320
17991
+ },
17532
17992
  "kind": {
17533
17993
  "type": "string",
17534
17994
  "enum": ["address", "domain"]
@@ -17542,7 +18002,10 @@ const operationManifest = [
17542
18002
  ],
17543
18003
  "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
17544
18004
  },
17545
- "message": { "type": "string" }
18005
+ "message": {
18006
+ "type": "string",
18007
+ "maxLength": 1e3
18008
+ }
17546
18009
  },
17547
18010
  "required": [
17548
18011
  "name",
@@ -17732,13 +18195,43 @@ const operationManifest = [
17732
18195
  }
17733
18196
  },
17734
18197
  "undecided_samples": {
17735
- "description": "Made-up emails not decided, by index. Only a write sent with if_expectations_pass that saves a version or activates the rule judges them.",
18198
+ "description": "Made-up emails not decided, by index. Only a write that saves a version or activates the rule, sent with if_expectations_pass or judged by default, judges them.",
17736
18199
  "type": "array",
17737
18200
  "items": {
17738
18201
  "type": "integer",
17739
18202
  "minimum": 0
17740
18203
  }
17741
18204
  },
18205
+ "failed_sample_details": {
18206
+ "description": "failed_samples with each one's label, from a write that judged them before saving (if_expectations_pass, or by default).",
18207
+ "type": "array",
18208
+ "items": {
18209
+ "type": "object",
18210
+ "properties": {
18211
+ "index": {
18212
+ "type": "integer",
18213
+ "minimum": 0
18214
+ },
18215
+ "label": { "type": ["string", "null"] }
18216
+ },
18217
+ "required": ["index", "label"]
18218
+ }
18219
+ },
18220
+ "undecided_sample_details": {
18221
+ "description": "undecided_samples with each one's label, as failed_sample_details.",
18222
+ "type": "array",
18223
+ "items": {
18224
+ "type": "object",
18225
+ "properties": {
18226
+ "index": {
18227
+ "type": "integer",
18228
+ "minimum": 0
18229
+ },
18230
+ "label": { "type": ["string", "null"] }
18231
+ },
18232
+ "required": ["index", "label"]
18233
+ }
18234
+ },
17742
18235
  "note": {
17743
18236
  "description": "On an update that saved a version that did not pass, or a do_not_share rule created active: that it was saved anyway, is current, and whether it is live.",
17744
18237
  "type": "string"
@@ -17764,7 +18257,7 @@ const operationManifest = [
17764
18257
  "required": ["version", "note"]
17765
18258
  },
17766
18259
  "affects": {
17767
- "description": "After an update that saved a version: API keys listing the rule, the webhooks they own, and shares this write ended. The rule keeps its state. Absent if not read.",
18260
+ "description": "After an update that saved a version, or turned a grant rule active: API keys listing the rule and the webhooks they own, which read and receive what a grant rule grants from now on. shares_ended is always 0: a new version keeps the rule's share (share_notice says so). Saving a version does not by itself change the rule's state. Absent after any other write, and if not read.",
17768
18261
  "type": "object",
17769
18262
  "properties": {
17770
18263
  "keys": {
@@ -17787,11 +18280,11 @@ const operationManifest = [
17787
18280
  ]
17788
18281
  },
17789
18282
  "notice": {
17790
- "description": "After a write that saved a version of an active rule keys or webhooks read without checking it first: what it changes, and how to have the next one checked.",
18283
+ "description": "After a write that saved a version of an active rule keys, webhooks or a share read without checking it first: what it changes, and how to have the next one checked.",
17791
18284
  "type": "string"
17792
18285
  },
17793
18286
  "share_notice": {
17794
- "description": "After a write that ended the rule's share: that it did, given even when affects is not, with whom it was with and the version they accepted when those can be read.",
18287
+ "description": "After a write that saved a version of a rule with a live share: that the share goes on under it, given even when affects is not, with whom it is and the version they accepted when those can be read.",
17795
18288
  "type": "string"
17796
18289
  }
17797
18290
  },
@@ -18003,6 +18496,43 @@ const operationManifest = [
18003
18496
  },
18004
18497
  "required": ["evaluation_scope", "scope_selection"]
18005
18498
  },
18499
+ "scope_warnings": {
18500
+ "description": "Ignored (the compile answer's scope_warnings).",
18501
+ "maxItems": 150,
18502
+ "type": "array",
18503
+ "items": {
18504
+ "type": "object",
18505
+ "properties": {
18506
+ "name": {
18507
+ "type": "string",
18508
+ "maxLength": 320
18509
+ },
18510
+ "kind": {
18511
+ "type": "string",
18512
+ "enum": ["address", "domain"]
18513
+ },
18514
+ "reason": {
18515
+ "type": "string",
18516
+ "enum": [
18517
+ "unknown_domain",
18518
+ "inactive_domain",
18519
+ "unknown_address"
18520
+ ],
18521
+ "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
18522
+ },
18523
+ "message": {
18524
+ "type": "string",
18525
+ "maxLength": 1e3
18526
+ }
18527
+ },
18528
+ "required": [
18529
+ "name",
18530
+ "kind",
18531
+ "reason",
18532
+ "message"
18533
+ ]
18534
+ }
18535
+ },
18006
18536
  "kind": {
18007
18537
  "description": "Only grant.",
18008
18538
  "type": "string",
@@ -18079,7 +18609,7 @@ const operationManifest = [
18079
18609
  "type": ["string", "null"]
18080
18610
  },
18081
18611
  "server_notes": {
18082
- "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
18612
+ "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes and that counts the asker quotes came from their own mail. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
18083
18613
  "type": "array",
18084
18614
  "items": { "type": "string" }
18085
18615
  },
@@ -18178,7 +18708,7 @@ const operationManifest = [
18178
18708
  "type": ["boolean", "null"]
18179
18709
  },
18180
18710
  "notice": {
18181
- "description": "For the member asked, while pending: what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
18711
+ "description": "For the member asked, while pending: who asked (as proposer names them), what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results and rule_deliveries). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
18182
18712
  "type": ["string", "null"]
18183
18713
  },
18184
18714
  "target_can_accept": {
@@ -18322,7 +18852,7 @@ const operationManifest = [
18322
18852
  "type": ["string", "null"]
18323
18853
  },
18324
18854
  "server_notes": {
18325
- "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
18855
+ "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes and that counts the asker quotes came from their own mail. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
18326
18856
  "type": "array",
18327
18857
  "items": { "type": "string" }
18328
18858
  },
@@ -18421,7 +18951,7 @@ const operationManifest = [
18421
18951
  "type": ["boolean", "null"]
18422
18952
  },
18423
18953
  "notice": {
18424
- "description": "For the member asked, while pending: what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
18954
+ "description": "For the member asked, while pending: who asked (as proposer names them), what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results and rule_deliveries). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
18425
18955
  "type": ["string", "null"]
18426
18956
  }
18427
18957
  },
@@ -18856,7 +19386,15 @@ const operationManifest = [
18856
19386
  "properties": {
18857
19387
  "question": { "type": "string" },
18858
19388
  "answer": { "type": ["boolean", "null"] },
18859
- "probability": { "type": ["number", "null"] },
19389
+ "confidence": {
19390
+ "description": "How sure the answer is, from 0 to 1: the chance of the answer given, as webhook payloads carry it. Null when unanswered.",
19391
+ "type": ["number", "null"]
19392
+ },
19393
+ "probability": {
19394
+ "deprecated": true,
19395
+ "description": "Deprecated: read confidence. The chance the answer is yes.",
19396
+ "type": ["number", "null"]
19397
+ },
18860
19398
  "error_class": { "type": "string" }
18861
19399
  },
18862
19400
  "required": [
@@ -19384,7 +19922,7 @@ const operationManifest = [
19384
19922
  "type": ["string", "null"]
19385
19923
  },
19386
19924
  "server_notes": {
19387
- "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
19925
+ "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes and that counts the asker quotes came from their own mail. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
19388
19926
  "type": "array",
19389
19927
  "items": { "type": "string" }
19390
19928
  },
@@ -19483,7 +20021,7 @@ const operationManifest = [
19483
20021
  "type": ["boolean", "null"]
19484
20022
  },
19485
20023
  "notice": {
19486
- "description": "For the member asked, while pending: what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
20024
+ "description": "For the member asked, while pending: who asked (as proposer names them), what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results and rule_deliveries). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
19487
20025
  "type": ["string", "null"]
19488
20026
  }
19489
20027
  },
@@ -19601,11 +20139,15 @@ const operationManifest = [
19601
20139
  },
19602
20140
  "scope_warnings": {
19603
20141
  "description": "Names in scope_selection that match nothing this organization receives mail at (a typo, or an inbox not yet in use). Present only when there are some.",
20142
+ "maxItems": 150,
19604
20143
  "type": "array",
19605
20144
  "items": {
19606
20145
  "type": "object",
19607
20146
  "properties": {
19608
- "name": { "type": "string" },
20147
+ "name": {
20148
+ "type": "string",
20149
+ "maxLength": 320
20150
+ },
19609
20151
  "kind": {
19610
20152
  "type": "string",
19611
20153
  "enum": ["address", "domain"]
@@ -19619,7 +20161,10 @@ const operationManifest = [
19619
20161
  ],
19620
20162
  "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
19621
20163
  },
19622
- "message": { "type": "string" }
20164
+ "message": {
20165
+ "type": "string",
20166
+ "maxLength": 1e3
20167
+ }
19623
20168
  },
19624
20169
  "required": [
19625
20170
  "name",
@@ -19698,11 +20243,11 @@ const operationManifest = [
19698
20243
  "rule_deleted",
19699
20244
  null
19700
20245
  ],
19701
- "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
20246
+ "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved, on a share that ended before new versions kept shares) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
19702
20247
  },
19703
20248
  "accepted_rule_version": {
19704
20249
  "type": "integer",
19705
- "description": "The version of the rule that was accepted. A new version of the rule ends the share."
20250
+ "description": "The version of the rule that was accepted. A later version keeps the share: what each version matches is shared from when it is saved."
19706
20251
  },
19707
20252
  "edited_on_accept": {
19708
20253
  "type": "boolean",
@@ -19716,6 +20261,44 @@ const operationManifest = [
19716
20261
  "description": "True when the rule is active and the share live but new email is not being shared now (what was shared stays visible); false when new email is shared. Null when it does not apply (share not live, rule not active, or you are not on the share) or could not be read.",
19717
20262
  "type": ["boolean", "null"]
19718
20263
  },
20264
+ "activity": {
20265
+ "description": "For the member it is shared with, on the dashboard or the Primitive CLI, while it is live and their access reads content: whether it is working, so a quiet mailbox can be told from a stopped share. Null otherwise.",
20266
+ "anyOf": [{
20267
+ "type": "object",
20268
+ "properties": {
20269
+ "rule_active": {
20270
+ "type": "boolean",
20271
+ "description": "Whether the rule is active now: only an active rule shares."
20272
+ },
20273
+ "last_decided_at": {
20274
+ "type": ["string", "null"],
20275
+ "format": "date-time",
20276
+ "description": "The start of the hour in which the rule last decided on any email in the sharing member's mailboxes since the share began, counting only hours that have ended and the hour of the newest email shared; null if none, or not read."
20277
+ },
20278
+ "shared_emails": {
20279
+ "type": ["integer", "null"],
20280
+ "minimum": 0,
20281
+ "description": "Emails this share has shared, counted up to 10,000; null when these could not be read."
20282
+ },
20283
+ "shared_emails_more": {
20284
+ "description": "Present when it has shared more than 10,000.",
20285
+ "type": "boolean",
20286
+ "const": true
20287
+ },
20288
+ "last_shared_at": {
20289
+ "type": ["string", "null"],
20290
+ "format": "date-time",
20291
+ "description": "When it last shared one; null if it has not, or not read."
20292
+ }
20293
+ },
20294
+ "required": [
20295
+ "rule_active",
20296
+ "last_decided_at",
20297
+ "shared_emails",
20298
+ "last_shared_at"
20299
+ ]
20300
+ }, { "type": "null" }]
20301
+ },
19719
20302
  "is_granter": {
19720
20303
  "type": "boolean",
19721
20304
  "description": "Whether you are the member sharing their mail."
@@ -19805,7 +20388,7 @@ const operationManifest = [
19805
20388
  "rule_id": {
19806
20389
  "type": ["string", "null"],
19807
20390
  "format": "uuid",
19808
- "description": "The rule itself. Only for the member sharing their mail; null for anyone else."
20391
+ "description": "The rule itself. Only for the member sharing their mail; null for anyone else. The member it is shared with lists this share's id in a key's grant.rules instead (from the dashboard), and their own webhooks receive what it shares."
19809
20392
  }
19810
20393
  },
19811
20394
  "required": [
@@ -20085,7 +20668,7 @@ const operationManifest = [
20085
20668
  "question_answers": {
20086
20669
  "type": "array",
20087
20670
  "items": {},
20088
- "description": "The answers to the rule's own questions, when they were asked."
20671
+ "description": "The answers to the rule's own questions, when they were asked: each with question, answer, confidence, the deprecated probability and, when unanswered, error_class, as a test gives them."
20089
20672
  },
20090
20673
  "detail_withheld": {
20091
20674
  "description": "Present, as true, on a decision about an email whose content cannot be read (withheld, failed to parse, discarded, or still awaiting sender authentication): matched still says what the rule decided, but how it got there was read from that content, so parts and question_answers are empty and near_miss is false. Discarding an email's content normally removes its decisions. Absent otherwise.",
@@ -20283,7 +20866,7 @@ const operationManifest = [
20283
20866
  "type": ["string", "null"]
20284
20867
  },
20285
20868
  "server_notes": {
20286
- "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
20869
+ "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes and that counts the asker quotes came from their own mail. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
20287
20870
  "type": "array",
20288
20871
  "items": { "type": "string" }
20289
20872
  },
@@ -20382,7 +20965,7 @@ const operationManifest = [
20382
20965
  "type": ["boolean", "null"]
20383
20966
  },
20384
20967
  "notice": {
20385
- "description": "For the member asked, while pending: what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
20968
+ "description": "For the member asked, while pending: who asked (as proposer names them), what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results and rule_deliveries). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
20386
20969
  "type": ["string", "null"]
20387
20970
  }
20388
20971
  },
@@ -20419,7 +21002,7 @@ const operationManifest = [
20419
21002
  "binaryResponse": false,
20420
21003
  "bodyRequired": false,
20421
21004
  "command": "list-email-rule-results",
20422
- "description": "What each rule you can see decided about this email (matched, not matched, or not run), in the words of the deciding version. A do_not_share rule that matched it blocks sharing while active; earlier shares stay. Only a caller who can read the email gets an answer. classification is every fact the classifier read, as rule conditions read it. At most 50 rules are listed, results first; not_listed counts the rest. Another member's rule that decided on your own mail is listed read_only (dashboard and CLI only), with who receives what it shares (receivers) while it covers you; hidden counts deciding rules you cannot see. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token).",
21005
+ "description": "What each rule you can see decided about this email (matched, not matched, or not run), in the words of the deciding version. A do_not_share rule that matched it blocks sharing while active; earlier shares stay. Only a caller who can read the email gets an answer. classification is every fact the classifier read, as rule conditions read it. At most 50 rules are listed, results first; not_listed counts the rest. Another member's rule that decided on your own mail is listed read_only (dashboard and CLI only), with who receives what it shares (receivers) while it covers you; hidden counts deciding rules you cannot see. Whether a rule delivered the email by webhook is not in the rule results: on your own mail, rule_deliveries on GET /v1/emails/{id} (primitive emails get <email-id> --json) counts each rule's webhook deliveries; on another member's mail, GET /v1/webhooks/deliveries?email_id=<email-id> (primitive webhook-deliveries list --email-id <email-id>, with webhooks:read) lists them. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token).",
20423
21006
  "hasJsonBody": false,
20424
21007
  "method": "GET",
20425
21008
  "operationId": "listEmailRuleResults",
@@ -20535,7 +21118,15 @@ const operationManifest = [
20535
21118
  "properties": {
20536
21119
  "question": { "type": "string" },
20537
21120
  "answer": { "type": ["boolean", "null"] },
20538
- "probability": { "type": ["number", "null"] },
21121
+ "confidence": {
21122
+ "description": "How sure the answer is, from 0 to 1: the chance of the answer given, as webhook payloads carry it. Null when unanswered.",
21123
+ "type": ["number", "null"]
21124
+ },
21125
+ "probability": {
21126
+ "deprecated": true,
21127
+ "description": "Deprecated: read confidence. The chance the answer is yes.",
21128
+ "type": ["number", "null"]
21129
+ },
20539
21130
  "error_class": { "type": "string" }
20540
21131
  },
20541
21132
  "required": [
@@ -20720,7 +21311,7 @@ const operationManifest = [
20720
21311
  "exclusiveMinimum": 0
20721
21312
  },
20722
21313
  "reads_in_full": {
20723
- "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches.",
21314
+ "description": "On a rule over your mail: how many of these keys also list one of your own mailboxes, or its domain, so they read your mail there beyond what this rule matches. It counts what they can read, not whether any has read an email.",
20724
21315
  "type": "integer",
20725
21316
  "minimum": 0
20726
21317
  },
@@ -21425,11 +22016,11 @@ const operationManifest = [
21425
22016
  "rule_deleted",
21426
22017
  null
21427
22018
  ],
21428
- "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
22019
+ "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved, on a share that ended before new versions kept shares) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
21429
22020
  },
21430
22021
  "accepted_rule_version": {
21431
22022
  "type": "integer",
21432
- "description": "The version of the rule that was accepted. A new version of the rule ends the share."
22023
+ "description": "The version of the rule that was accepted. A later version keeps the share: what each version matches is shared from when it is saved."
21433
22024
  },
21434
22025
  "edited_on_accept": {
21435
22026
  "type": "boolean",
@@ -21443,6 +22034,44 @@ const operationManifest = [
21443
22034
  "description": "True when the rule is active and the share live but new email is not being shared now (what was shared stays visible); false when new email is shared. Null when it does not apply (share not live, rule not active, or you are not on the share) or could not be read.",
21444
22035
  "type": ["boolean", "null"]
21445
22036
  },
22037
+ "activity": {
22038
+ "description": "For the member it is shared with, on the dashboard or the Primitive CLI, while it is live and their access reads content: whether it is working, so a quiet mailbox can be told from a stopped share. Null otherwise.",
22039
+ "anyOf": [{
22040
+ "type": "object",
22041
+ "properties": {
22042
+ "rule_active": {
22043
+ "type": "boolean",
22044
+ "description": "Whether the rule is active now: only an active rule shares."
22045
+ },
22046
+ "last_decided_at": {
22047
+ "type": ["string", "null"],
22048
+ "format": "date-time",
22049
+ "description": "The start of the hour in which the rule last decided on any email in the sharing member's mailboxes since the share began, counting only hours that have ended and the hour of the newest email shared; null if none, or not read."
22050
+ },
22051
+ "shared_emails": {
22052
+ "type": ["integer", "null"],
22053
+ "minimum": 0,
22054
+ "description": "Emails this share has shared, counted up to 10,000; null when these could not be read."
22055
+ },
22056
+ "shared_emails_more": {
22057
+ "description": "Present when it has shared more than 10,000.",
22058
+ "type": "boolean",
22059
+ "const": true
22060
+ },
22061
+ "last_shared_at": {
22062
+ "type": ["string", "null"],
22063
+ "format": "date-time",
22064
+ "description": "When it last shared one; null if it has not, or not read."
22065
+ }
22066
+ },
22067
+ "required": [
22068
+ "rule_active",
22069
+ "last_decided_at",
22070
+ "shared_emails",
22071
+ "last_shared_at"
22072
+ ]
22073
+ }, { "type": "null" }]
22074
+ },
21446
22075
  "is_granter": {
21447
22076
  "type": "boolean",
21448
22077
  "description": "Whether you are the member sharing their mail."
@@ -21532,7 +22161,7 @@ const operationManifest = [
21532
22161
  "rule_id": {
21533
22162
  "type": ["string", "null"],
21534
22163
  "format": "uuid",
21535
- "description": "The rule itself. Only for the member sharing their mail; null for anyone else."
22164
+ "description": "The rule itself. Only for the member sharing their mail; null for anyone else. The member it is shared with lists this share's id in a key's grant.rules instead (from the dashboard), and their own webhooks receive what it shares."
21536
22165
  }
21537
22166
  },
21538
22167
  "required": [
@@ -21940,11 +22569,11 @@ const operationManifest = [
21940
22569
  "rule_deleted",
21941
22570
  null
21942
22571
  ],
21943
- "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
22572
+ "description": "Why it ended, once it has: stopped_by_granter, removed_by_beneficiary, stopped_by_admin, rule_changed (a new version of the rule was saved, on a share that ended before new versions kept shares) or rule_deleted (the rule was deleted; the share keeps its record, and the rule is no longer shown). Null while it has not."
21944
22573
  },
21945
22574
  "accepted_rule_version": {
21946
22575
  "type": "integer",
21947
- "description": "The version of the rule that was accepted. A new version of the rule ends the share."
22576
+ "description": "The version of the rule that was accepted. A later version keeps the share: what each version matches is shared from when it is saved."
21948
22577
  },
21949
22578
  "edited_on_accept": {
21950
22579
  "type": "boolean",
@@ -21958,6 +22587,44 @@ const operationManifest = [
21958
22587
  "description": "True when the rule is active and the share live but new email is not being shared now (what was shared stays visible); false when new email is shared. Null when it does not apply (share not live, rule not active, or you are not on the share) or could not be read.",
21959
22588
  "type": ["boolean", "null"]
21960
22589
  },
22590
+ "activity": {
22591
+ "description": "For the member it is shared with, on the dashboard or the Primitive CLI, while it is live and their access reads content: whether it is working, so a quiet mailbox can be told from a stopped share. Null otherwise.",
22592
+ "anyOf": [{
22593
+ "type": "object",
22594
+ "properties": {
22595
+ "rule_active": {
22596
+ "type": "boolean",
22597
+ "description": "Whether the rule is active now: only an active rule shares."
22598
+ },
22599
+ "last_decided_at": {
22600
+ "type": ["string", "null"],
22601
+ "format": "date-time",
22602
+ "description": "The start of the hour in which the rule last decided on any email in the sharing member's mailboxes since the share began, counting only hours that have ended and the hour of the newest email shared; null if none, or not read."
22603
+ },
22604
+ "shared_emails": {
22605
+ "type": ["integer", "null"],
22606
+ "minimum": 0,
22607
+ "description": "Emails this share has shared, counted up to 10,000; null when these could not be read."
22608
+ },
22609
+ "shared_emails_more": {
22610
+ "description": "Present when it has shared more than 10,000.",
22611
+ "type": "boolean",
22612
+ "const": true
22613
+ },
22614
+ "last_shared_at": {
22615
+ "type": ["string", "null"],
22616
+ "format": "date-time",
22617
+ "description": "When it last shared one; null if it has not, or not read."
22618
+ }
22619
+ },
22620
+ "required": [
22621
+ "rule_active",
22622
+ "last_decided_at",
22623
+ "shared_emails",
22624
+ "last_shared_at"
22625
+ ]
22626
+ }, { "type": "null" }]
22627
+ },
21961
22628
  "is_granter": {
21962
22629
  "type": "boolean",
21963
22630
  "description": "Whether you are the member sharing their mail."
@@ -22047,7 +22714,7 @@ const operationManifest = [
22047
22714
  "rule_id": {
22048
22715
  "type": ["string", "null"],
22049
22716
  "format": "uuid",
22050
- "description": "The rule itself. Only for the member sharing their mail; null for anyone else."
22717
+ "description": "The rule itself. Only for the member sharing their mail; null for anyone else. The member it is shared with lists this share's id in a key's grant.rules instead (from the dashboard), and their own webhooks receive what it shares."
22051
22718
  }
22052
22719
  },
22053
22720
  "required": [
@@ -22543,6 +23210,11 @@ const operationManifest = [
22543
23210
  "type": "string"
22544
23211
  },
22545
23212
  "subject": { "type": ["string", "null"] },
23213
+ "attachment_names": {
23214
+ "description": "On matched and near_miss: the file names the email lists, in order, at most 10 (the names its questions are given; never what is in the files). Parts with no name are left out; absent when there are none.",
23215
+ "type": "array",
23216
+ "items": { "type": "string" }
23217
+ },
22546
23218
  "parts": {
22547
23219
  "description": "How each top-level part of the rule decided. Present for matched, near_miss and no_match.",
22548
23220
  "type": "array",
@@ -22607,7 +23279,15 @@ const operationManifest = [
22607
23279
  "properties": {
22608
23280
  "question": { "type": "string" },
22609
23281
  "answer": { "type": ["boolean", "null"] },
22610
- "probability": { "type": ["number", "null"] },
23282
+ "confidence": {
23283
+ "description": "How sure the answer is, from 0 to 1: the chance of the answer given, as webhook payloads carry it. Null when unanswered.",
23284
+ "type": ["number", "null"]
23285
+ },
23286
+ "probability": {
23287
+ "deprecated": true,
23288
+ "description": "Deprecated: read confidence. The chance the answer is yes.",
23289
+ "type": ["number", "null"]
23290
+ },
22611
23291
  "error_class": { "type": "string" }
22612
23292
  },
22613
23293
  "required": [
@@ -22742,11 +23422,15 @@ const operationManifest = [
22742
23422
  },
22743
23423
  "scope_warnings": {
22744
23424
  "description": "Names in scope_selection that match nothing this organization receives mail at (a typo, or an inbox not yet in use). Present only when there are some.",
23425
+ "maxItems": 150,
22745
23426
  "type": "array",
22746
23427
  "items": {
22747
23428
  "type": "object",
22748
23429
  "properties": {
22749
- "name": { "type": "string" },
23430
+ "name": {
23431
+ "type": "string",
23432
+ "maxLength": 320
23433
+ },
22750
23434
  "kind": {
22751
23435
  "type": "string",
22752
23436
  "enum": ["address", "domain"]
@@ -22760,7 +23444,10 @@ const operationManifest = [
22760
23444
  ],
22761
23445
  "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
22762
23446
  },
22763
- "message": { "type": "string" }
23447
+ "message": {
23448
+ "type": "string",
23449
+ "maxLength": 1e3
23450
+ }
22764
23451
  },
22765
23452
  "required": [
22766
23453
  "name",
@@ -22885,7 +23572,15 @@ const operationManifest = [
22885
23572
  "properties": {
22886
23573
  "question": { "type": "string" },
22887
23574
  "answer": { "type": ["boolean", "null"] },
22888
- "probability": { "type": ["number", "null"] },
23575
+ "confidence": {
23576
+ "description": "How sure the answer is, from 0 to 1: the chance of the answer given, as webhook payloads carry it. Null when unanswered.",
23577
+ "type": ["number", "null"]
23578
+ },
23579
+ "probability": {
23580
+ "deprecated": true,
23581
+ "description": "Deprecated: read confidence. The chance the answer is yes.",
23582
+ "type": ["number", "null"]
23583
+ },
22889
23584
  "error_class": { "type": "string" }
22890
23585
  },
22891
23586
  "required": [
@@ -23250,7 +23945,15 @@ const operationManifest = [
23250
23945
  "properties": {
23251
23946
  "question": { "type": "string" },
23252
23947
  "answer": { "type": ["boolean", "null"] },
23253
- "probability": { "type": ["number", "null"] },
23948
+ "confidence": {
23949
+ "description": "How sure the answer is, from 0 to 1: the chance of the answer given, as webhook payloads carry it. Null when unanswered.",
23950
+ "type": ["number", "null"]
23951
+ },
23952
+ "probability": {
23953
+ "deprecated": true,
23954
+ "description": "Deprecated: read confidence. The chance the answer is yes.",
23955
+ "type": ["number", "null"]
23956
+ },
23254
23957
  "error_class": { "type": "string" }
23255
23958
  },
23256
23959
  "required": [
@@ -23362,7 +24065,7 @@ const operationManifest = [
23362
24065
  "binaryResponse": false,
23363
24066
  "bodyRequired": true,
23364
24067
  "command": "update-email-rule",
23365
- "description": "Renames the rule, saves a new version (english and tree together; earlier versions stay) or restores one (restore_version), changes its state (draft is off; observe; active), its scope (evaluation_scope, with scope_selection when selected) or its saved expectations (judged in expectations_check). Anyone but its author who sees it may only set state draft, and while it is shared only if they manage members from the dashboard. A scope change saves a new version; a shared rule keeps its scope, and a kind never changes. A saved version takes effect at once. if_version refuses a write once a version was saved since you read it; if_revision, once anything changed. Without if_expectations_pass a version is saved even when its expectations fail, except on an active rule keys or webhooks read: that write is checked first unless if_expectations_pass is false. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token).",
24068
+ "description": "Renames the rule, saves a new version (english and tree together; earlier versions stay) or restores one (restore_version), changes its state (draft is off; observe; active), its scope (evaluation_scope, with scope_selection when selected) or its saved expectations (judged in expectations_check). Anyone but its author who sees it may only set state draft, and while it is shared only if they manage members from the dashboard. A scope change saves a new version; a shared rule keeps its scope, and a kind never changes. A saved version takes effect at once, on the rule's share too, which goes on under it. if_version refuses a write once a version was saved since you read it; if_revision, once anything changed. Without if_expectations_pass a version is saved even when its expectations fail, except on an active rule keys, webhooks or a share read: that write is checked first unless if_expectations_pass is false. Needs mail:read, the email rules feature, and a member's own full-access credential (no API key, agent key or narrowed token).",
23366
24069
  "hasJsonBody": true,
23367
24070
  "method": "PATCH",
23368
24071
  "operationId": "updateEmailRule",
@@ -23540,6 +24243,43 @@ const operationManifest = [
23540
24243
  },
23541
24244
  "required": ["evaluation_scope", "scope_selection"]
23542
24245
  },
24246
+ "scope_warnings": {
24247
+ "description": "Ignored (the compile answer's scope_warnings).",
24248
+ "maxItems": 150,
24249
+ "type": "array",
24250
+ "items": {
24251
+ "type": "object",
24252
+ "properties": {
24253
+ "name": {
24254
+ "type": "string",
24255
+ "maxLength": 320
24256
+ },
24257
+ "kind": {
24258
+ "type": "string",
24259
+ "enum": ["address", "domain"]
24260
+ },
24261
+ "reason": {
24262
+ "type": "string",
24263
+ "enum": [
24264
+ "unknown_domain",
24265
+ "inactive_domain",
24266
+ "unknown_address"
24267
+ ],
24268
+ "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
24269
+ },
24270
+ "message": {
24271
+ "type": "string",
24272
+ "maxLength": 1e3
24273
+ }
24274
+ },
24275
+ "required": [
24276
+ "name",
24277
+ "kind",
24278
+ "reason",
24279
+ "message"
24280
+ ]
24281
+ }
24282
+ },
23543
24283
  "kind": {
23544
24284
  "description": "Must be the rule's own (400 kind_mismatch).",
23545
24285
  "type": "string",
@@ -23847,7 +24587,7 @@ const operationManifest = [
23847
24587
  "maximum": 2147483647
23848
24588
  },
23849
24589
  "if_expectations_pass": {
23850
- "description": "true: judge the rule as this write leaves it (new tree, restored version, new scope, or the version it activates) against the expectations it leaves, as POST /email-rules/test would, before saving; it can take as long as a test. Failed: 409 expectations_failed; on emails the rule cannot read: 409 expectations_unreadable; undecided: 409 expectations_undecided (each with details.expectations_check); none to judge: 400 no_expectations. Refused writes save nothing; a pass saves unless the rule moved meanwhile (409 email_rule_conflict). Only writes that save a version or activate the rule are judged. Omitted: judged as with true when the write saves a version or changes the scope of an active rule that API keys or webhooks read and that has expectations. false: never judged first.",
24590
+ "description": "true: judge the rule as this write leaves it (new tree, restored version, new scope, or the version it activates) against the expectations it leaves, as POST /email-rules/test would, before saving; it can take as long as a test. Failed: 409 expectations_failed; on emails the rule cannot read: 409 expectations_unreadable; undecided: 409 expectations_undecided (each with details.expectations_check); none to judge: 400 no_expectations. Refused writes save nothing; a pass saves unless the rule moved meanwhile (409 email_rule_conflict). Only writes that save a version or activate the rule are judged. Omitted: judged as with true when the write saves a version or changes the scope of an active rule that API keys, webhooks or a share read and that has expectations. false: never judged first.",
23851
24591
  "type": "boolean"
23852
24592
  },
23853
24593
  "restore_version": {
@@ -24056,11 +24796,15 @@ const operationManifest = [
24056
24796
  },
24057
24797
  "scope_warnings": {
24058
24798
  "description": "Names in scope_selection that match nothing this organization receives mail at (a typo, or an inbox not yet in use). Present only when there are some.",
24799
+ "maxItems": 150,
24059
24800
  "type": "array",
24060
24801
  "items": {
24061
24802
  "type": "object",
24062
24803
  "properties": {
24063
- "name": { "type": "string" },
24804
+ "name": {
24805
+ "type": "string",
24806
+ "maxLength": 320
24807
+ },
24064
24808
  "kind": {
24065
24809
  "type": "string",
24066
24810
  "enum": ["address", "domain"]
@@ -24074,7 +24818,10 @@ const operationManifest = [
24074
24818
  ],
24075
24819
  "description": "unknown_domain: none of the organization's domains. inactive_domain: one of its domains, not active now, so no new mail arrives. unknown_address: no inbox known as someone's, and no mail has reached it yet."
24076
24820
  },
24077
- "message": { "type": "string" }
24821
+ "message": {
24822
+ "type": "string",
24823
+ "maxLength": 1e3
24824
+ }
24078
24825
  },
24079
24826
  "required": [
24080
24827
  "name",
@@ -24264,13 +25011,43 @@ const operationManifest = [
24264
25011
  }
24265
25012
  },
24266
25013
  "undecided_samples": {
24267
- "description": "Made-up emails not decided, by index. Only a write sent with if_expectations_pass that saves a version or activates the rule judges them.",
25014
+ "description": "Made-up emails not decided, by index. Only a write that saves a version or activates the rule, sent with if_expectations_pass or judged by default, judges them.",
24268
25015
  "type": "array",
24269
25016
  "items": {
24270
25017
  "type": "integer",
24271
25018
  "minimum": 0
24272
25019
  }
24273
25020
  },
25021
+ "failed_sample_details": {
25022
+ "description": "failed_samples with each one's label, from a write that judged them before saving (if_expectations_pass, or by default).",
25023
+ "type": "array",
25024
+ "items": {
25025
+ "type": "object",
25026
+ "properties": {
25027
+ "index": {
25028
+ "type": "integer",
25029
+ "minimum": 0
25030
+ },
25031
+ "label": { "type": ["string", "null"] }
25032
+ },
25033
+ "required": ["index", "label"]
25034
+ }
25035
+ },
25036
+ "undecided_sample_details": {
25037
+ "description": "undecided_samples with each one's label, as failed_sample_details.",
25038
+ "type": "array",
25039
+ "items": {
25040
+ "type": "object",
25041
+ "properties": {
25042
+ "index": {
25043
+ "type": "integer",
25044
+ "minimum": 0
25045
+ },
25046
+ "label": { "type": ["string", "null"] }
25047
+ },
25048
+ "required": ["index", "label"]
25049
+ }
25050
+ },
24274
25051
  "note": {
24275
25052
  "description": "On an update that saved a version that did not pass, or a do_not_share rule created active: that it was saved anyway, is current, and whether it is live.",
24276
25053
  "type": "string"
@@ -24296,7 +25073,7 @@ const operationManifest = [
24296
25073
  "required": ["version", "note"]
24297
25074
  },
24298
25075
  "affects": {
24299
- "description": "After an update that saved a version: API keys listing the rule, the webhooks they own, and shares this write ended. The rule keeps its state. Absent if not read.",
25076
+ "description": "After an update that saved a version, or turned a grant rule active: API keys listing the rule and the webhooks they own, which read and receive what a grant rule grants from now on. shares_ended is always 0: a new version keeps the rule's share (share_notice says so). Saving a version does not by itself change the rule's state. Absent after any other write, and if not read.",
24300
25077
  "type": "object",
24301
25078
  "properties": {
24302
25079
  "keys": {
@@ -24319,11 +25096,11 @@ const operationManifest = [
24319
25096
  ]
24320
25097
  },
24321
25098
  "notice": {
24322
- "description": "After a write that saved a version of an active rule keys or webhooks read without checking it first: what it changes, and how to have the next one checked.",
25099
+ "description": "After a write that saved a version of an active rule keys, webhooks or a share read without checking it first: what it changes, and how to have the next one checked.",
24323
25100
  "type": "string"
24324
25101
  },
24325
25102
  "share_notice": {
24326
- "description": "After a write that ended the rule's share: that it did, given even when affects is not, with whom it was with and the version they accepted when those can be read.",
25103
+ "description": "After a write that saved a version of a rule with a live share: that the share goes on under it, given even when affects is not, with whom it is and the version they accepted when those can be read.",
24327
25104
  "type": "string"
24328
25105
  }
24329
25106
  },
@@ -24434,7 +25211,7 @@ const operationManifest = [
24434
25211
  "type": ["string", "null"]
24435
25212
  },
24436
25213
  "server_notes": {
24437
- "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
25214
+ "description": "Primitive's own notes on the rule as asked, worked out from its tree and description each time the request is read, and to the member asked while pending, how to test it on look-alikes and that counts the asker quotes came from their own mail. Unlike warnings, never written by the member who asked, though a note can quote their words or tree values.",
24438
25215
  "type": "array",
24439
25216
  "items": { "type": "string" }
24440
25217
  },
@@ -24533,7 +25310,7 @@ const operationManifest = [
24533
25310
  "type": ["boolean", "null"]
24534
25311
  },
24535
25312
  "notice": {
24536
- "description": "For the member asked, while pending: what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
25313
+ "description": "For the member asked, while pending: who asked (as proposer names them), what the rule actually does (server_explanation), Primitive's warnings, what accepting would share, then where to see what becomes of one email (rule-results and rule_deliveries). For the member who asked, once accepted with changes: that the request is not what is shared. Else null.",
24537
25314
  "type": ["string", "null"]
24538
25315
  }
24539
25316
  },
@@ -25253,25 +26030,25 @@ const operationManifest = [
25253
26030
  },
25254
26031
  "webhook_attempt_count": {
25255
26032
  "type": "integer",
25256
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. Its attempts."
26033
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. Its attempts."
25257
26034
  },
25258
26035
  "webhook_last_attempt_at": {
25259
26036
  "type": ["string", "null"],
25260
26037
  "format": "date-time",
25261
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. Its last attempt."
26038
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. Its last attempt."
25262
26039
  },
25263
26040
  "webhook_last_status_code": {
25264
26041
  "type": ["integer", "null"],
25265
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. What it last answered."
26042
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. What it last answered."
25266
26043
  },
25267
26044
  "webhook_last_error": {
25268
26045
  "type": ["string", "null"],
25269
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. Its last error."
26046
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. Its last error."
25270
26047
  },
25271
26048
  "webhook_fired_at": {
25272
26049
  "type": ["string", "null"],
25273
26050
  "format": "date-time",
25274
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. When it was delivered."
26051
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. When it was delivered."
25275
26052
  },
25276
26053
  "smtp_helo": { "type": ["string", "null"] },
25277
26054
  "smtp_mail_from": {
@@ -25798,7 +26575,7 @@ const operationManifest = [
25798
26575
  },
25799
26576
  "shared_through": {
25800
26577
  "type": ["object", "null"],
25801
- "description": "The rule share a reader has this email through, when that is their only way to it. Null for everyone else.",
26578
+ "description": "Only for a reader who has this email through a colleague's share of their mail, when that share is their only way to it: the share and who gave it. Null for everyone else, including on your own mail when a rule or share of yours gave it to someone: rule_deliveries counts the webhooks rules delivered it to, and GET /v1/email-rule-shares/{id}/emails lists what a share you gave has given.",
25802
26579
  "required": [
25803
26580
  "share_id",
25804
26581
  "rule_name",
@@ -25827,7 +26604,7 @@ const operationManifest = [
25827
26604
  },
25828
26605
  "rule_deliveries": {
25829
26606
  "type": ["object", "null"],
25830
- "description": "Where Email Rules delivered this email by webhook, for the owner of the mailbox it is at, on their own dashboard session or the Primitive CLI. Null for everyone else, and when it could not be read in time. A key reading it through a rule is not a delivery.",
26607
+ "description": "Where Email Rules delivered this email by webhook, for the owner of the mailbox it is at, on their own dashboard session or the Primitive CLI. Null for everyone else, including on another member's mail even for an organization owner or admin (GET /v1/webhooks/deliveries?email_id=<email-id> lists its deliveries, a rule's included), and when it could not be read in time. A key reading it through a rule is not a delivery.",
25831
26608
  "required": [
25832
26609
  "rules",
25833
26610
  "hidden",
@@ -26797,7 +27574,7 @@ const operationManifest = [
26797
27574
  },
26798
27575
  "webhook_attempt_count": {
26799
27576
  "type": "integer",
26800
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. Its attempts."
27577
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. Its attempts."
26801
27578
  },
26802
27579
  "thread_id": {
26803
27580
  "type": ["string", "null"],
@@ -27535,7 +28312,7 @@ const operationManifest = [
27535
28312
  },
27536
28313
  "webhook_attempt_count": {
27537
28314
  "type": "integer",
27538
- "description": "The email's own routed delivery only (where routing sent it); a rule's deliveries never change this, and are in `rule_deliveries` on GET /emails/{id} for the mailbox's owner. Its attempts."
28315
+ "description": "Only this email's routed delivery (the webhook or Function routing sent it to), never a rule's. On mail routing sent nowhere it stays pending, 0 or null unless the email is sent later (POST /emails/{id}/replay), and says nothing about rule deliveries: those are in `rule_deliveries` on GET /emails/{id}, for the mailbox's owner. Its attempts."
27539
28316
  },
27540
28317
  "thread_id": {
27541
28318
  "type": ["string", "null"],
@@ -41060,6 +41837,7 @@ const operationManifest = [
41060
41837
  "items": { "type": "string" }
41061
41838
  },
41062
41839
  "rules": {
41840
+ "description": "Email rule ids: the key also reads the emails these rules granted. An address listed beside them is read in full, so rules beside a domain, a retired address or the address of a member other than the key's holder (its creator, or whoever it was transferred to) are refused (400 validation_error, details.reason rules_beside_domain or rules_beside_personal_mailbox). A rule shared with you goes here by its share's id, from your dashboard session only.",
41063
41841
  "maxItems": 20,
41064
41842
  "type": "array",
41065
41843
  "items": { "type": "string" }
@@ -52362,7 +53140,7 @@ const operationManifest = [
52362
53140
  "attempt_count": { "type": "integer" },
52363
53141
  "duration_ms": { "type": ["integer", "null"] },
52364
53142
  "last_error": {
52365
- "description": "Why the last attempt failed, or null. A webhook's answer is quoted after its status (HTTP 404: ...) only for a caller who can read the webhook (GET /endpoints/{id}; a deleted webhook only for a caller who reads every webhook); anyone else gets the status and a note. Text the platform writes (a redirect not followed, a network error) is shown to everyone.",
53143
+ "description": "Why the last attempt failed, or null. A webhook's answer follows its status (HTTP 404: ...) as plain text, at most 300 characters (response_body has more); older attempts can quote more. It is quoted only for a caller who can read the webhook (GET /endpoints/{id}; a deleted webhook only for a caller who reads every webhook); anyone else gets the status and a note. Text the platform writes (a redirect not followed, a network error) is shown to everyone.",
52366
53144
  "type": ["string", "null"]
52367
53145
  },
52368
53146
  "last_error_code": {
@@ -52615,7 +53393,7 @@ const operationManifest = [
52615
53393
  "duration_ms": { "type": ["integer", "null"] },
52616
53394
  "last_error": {
52617
53395
  "type": ["string", "null"],
52618
- "description": "Why the last attempt failed, or null. A webhook's answer is quoted after its status (HTTP 404: ...) only for a caller who can read the webhook (GET /endpoints/{id}; a deleted webhook only for a caller who reads every webhook); anyone else gets the status and a note. Text the platform writes (a redirect not followed, a network error) is shown to everyone."
53396
+ "description": "Why the last attempt failed, or null. A webhook's answer follows its status (HTTP 404: ...) as plain text, at most 300 characters (response_body has more); older attempts can quote more. It is quoted only for a caller who can read the webhook (GET /endpoints/{id}; a deleted webhook only for a caller who reads every webhook); anyone else gets the status and a note. Text the platform writes (a redirect not followed, a network error) is shown to everyone."
52619
53397
  },
52620
53398
  "created_at": {
52621
53399
  "type": "string",
@@ -54134,8 +54912,8 @@ function shownKey(key) {
54134
54912
  function unknownFieldsNote(source, sent, all) {
54135
54913
  const carriers = /* @__PURE__ */ new Map();
54136
54914
  for (const sample of sent) {
54137
- const number = all.indexOf(sample) + 1;
54138
- for (const field of UNKNOWN_FIELDS.get(sample) ?? []) carriers.set(field, [...carriers.get(field) ?? [], number]);
54915
+ const index = all.indexOf(sample);
54916
+ for (const field of UNKNOWN_FIELDS.get(sample) ?? []) carriers.set(field, [...carriers.get(field) ?? [], `${index + 1} (index ${index})`]);
54139
54917
  }
54140
54918
  if (carriers.size === 0) return null;
54141
54919
  return `${source} has fields this CLI does not know, which it does not refuse but leaves for the API to judge (if the API refuses one, take it out): ${[...carriers].map(([field, numbers]) => `${field} (sample${numbers.length === 1 ? "" : "s"} ${numbers.join(", ")})`).join(", ")}.`;
@@ -54191,14 +54969,14 @@ function samplesFromJson(value, source) {
54191
54969
  const samples = lookAlikeSamples(data);
54192
54970
  if (samples.length === 0) throw usageError$2(`${source} is a generate-look-alikes answer with no look-alikes in it.`);
54193
54971
  samples.forEach((sample, index) => {
54194
- const unknown = checkSampleEmail(sample.email, `${source}, look-alike ${index + 1}`);
54972
+ const unknown = checkSampleEmail(sample.email, `${source}, look-alike ${index + 1} (index ${index})`);
54195
54973
  if (unknown.length > 0) UNKNOWN_FIELDS.set(sample, unknown);
54196
54974
  });
54197
54975
  return samples;
54198
54976
  }
54199
54977
  if (!Array.isArray(data)) throw usageError$2(`${source} must hold a JSON array of samples, such as [{"expected": "no_match", "label": "a personal bill", "email": {...}}], or a generate-look-alikes answer.`);
54200
54978
  return data.map((item, index) => {
54201
- const at = `${source}, sample ${index + 1}`;
54979
+ const at = `${source}, sample ${index + 1} (index ${index})`;
54202
54980
  if (!isRecord$1(item)) throw usageError$2(`${at} is not an object.`);
54203
54981
  const unknown = Object.keys(item).filter((key) => !SAMPLE_KEYS.has(key));
54204
54982
  if (item.expected !== "match" && item.expected !== "no_match") throw usageError$2(`${at}: expected must be "match" or "no_match".`);
@@ -54611,6 +55389,47 @@ function expectBodyFields(flags) {
54611
55389
  value: expect
54612
55390
  }];
54613
55391
  }
55392
+ /** test-email-rule's flag that tests the emails an earlier answer tested. */
55393
+ const SAME_EMAILS_FLAG = "same-emails-as";
55394
+ const EMAIL_IDS_MAX = 200;
55395
+ /**
55396
+ * `email_ids` for test-email-rule, from --same-emails-as: every email an
55397
+ * earlier test's answer, saved as it printed it, tested (its results'
55398
+ * email_id), so a second tree is tested over the same mail rather than over
55399
+ * whatever is newest by then.
55400
+ */
55401
+ function sameEmailsBodyFields(flags) {
55402
+ const file = flags[SAME_EMAILS_FLAG];
55403
+ if (typeof file !== "string") return [];
55404
+ const saved = readJsonFileFlag(file, `--${SAME_EMAILS_FLAG}`);
55405
+ SAVED_ANSWERS.set(flags, saved);
55406
+ const answer = isRecord(saved) && isRecord(saved.data) ? saved.data : saved;
55407
+ const results = isRecord(answer) && Array.isArray(answer.results) ? answer.results : null;
55408
+ if (!results) throw usageError(`--${SAME_EMAILS_FLAG} ${file} is not a saved test-email-rule answer: it has no results. Save one with test-email-rule --json > answer.json.`);
55409
+ const ids = [...new Set(results.flatMap((result) => isRecord(result) && typeof result.email_id === "string" && isEmailId(result.email_id) ? [result.email_id.toLowerCase()] : []))];
55410
+ if (ids.length === 0) throw usageError(`--${SAME_EMAILS_FLAG} ${file} names no emails.`);
55411
+ if (ids.length > EMAIL_IDS_MAX) throw usageError(`--${SAME_EMAILS_FLAG} ${file} names ${ids.length} emails; a test takes at most ${EMAIL_IDS_MAX}.`);
55412
+ return [{
55413
+ flag: `--${SAME_EMAILS_FLAG}`,
55414
+ property: "email_ids",
55415
+ value: ids
55416
+ }];
55417
+ }
55418
+ /**
55419
+ * The emails --same-emails-as names with the expected ones this test sends
55420
+ * (from the expect flags, or the body's own expect) are at most
55421
+ * EMAIL_IDS_MAX, as the API takes them: refused here, naming the flag,
55422
+ * rather than by the API as email_ids the caller never typed. A saved rule's
55423
+ * own expectations are not known here; the API counts those.
55424
+ */
55425
+ function checkSameEmailsWithExpected(same, expect, base) {
55426
+ const ids = same[0]?.value;
55427
+ if (!Array.isArray(ids)) return;
55428
+ const sent = expect[0]?.value ?? (isRecord(base) ? base.expect : void 0);
55429
+ const expected = isRecord(sent) ? [sent.match, sent.no_match].flatMap((list) => Array.isArray(list) ? list.filter((id) => typeof id === "string") : []) : [];
55430
+ const all = /* @__PURE__ */ new Set([...ids, ...expected.map((id) => id.toLowerCase())]);
55431
+ if (all.size > EMAIL_IDS_MAX) throw usageError(`--${SAME_EMAILS_FLAG} names ${ids.length} emails and the expectations sent name others: ${all.size} in all, and a test takes at most ${EMAIL_IDS_MAX}.`);
55432
+ }
54614
55433
  /**
54615
55434
  * `expectations` for create-email-rule and update-email-rule, from
54616
55435
  * --expectations-file. A file holding `null` removes the saved expectations,
@@ -54664,6 +55483,20 @@ function scopeWarningLine(warning) {
54664
55483
  function scopeWarningLines(warnings) {
54665
55484
  return Array.isArray(warnings) ? warnings.filter(isRecord).map(scopeWarningLine) : [];
54666
55485
  }
55486
+ const unitInterval = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
55487
+ /**
55488
+ * How sure an answer is, from 0 to 1: the answer's `confidence`, the number
55489
+ * a webhook payload carries for it, when the answer has one; otherwise the
55490
+ * chance of the answer given, worked out from `probability`, the chance of
55491
+ * yes. Null for an unanswered question.
55492
+ */
55493
+ function answerConfidence(answer) {
55494
+ if (typeof answer.answer !== "boolean") return null;
55495
+ if (unitInterval(answer.confidence)) return answer.confidence;
55496
+ const p = answer.probability;
55497
+ if (!unitInterval(p)) return null;
55498
+ return answer.answer ? p : 1 - p;
55499
+ }
54667
55500
  const UNCLASSIFIED_REASONS = {
54668
55501
  pending: {
54669
55502
  why: "not classified yet",
@@ -54720,9 +55553,10 @@ function undecidedNote(reason) {
54720
55553
  }
54721
55554
  function answerText(answer) {
54722
55555
  const verdict = answer.answer === true ? "yes" : answer.answer === false ? "no" : "unanswered";
54723
- const probability = typeof answer.probability === "number" ? ` at ${confidence(answer.probability)}` : "";
55556
+ const sure = answerConfidence(answer);
55557
+ const at = sure === null ? "" : ` at ${confidence(sure)}`;
54724
55558
  const error = answer.error_class ? ` (${answer.error_class})` : "";
54725
- return `"${answer.question}" ${verdict}${probability}${error}`;
55559
+ return `"${answer.question}" ${verdict}${at}${error}`;
54726
55560
  }
54727
55561
  function conditionLines(summary) {
54728
55562
  const conditions = Array.isArray(summary?.conditions) ? summary.conditions : [];
@@ -54759,7 +55593,8 @@ function sampleNamer(request) {
54759
55593
  const fromFile = sent && typeof request?.flags?.["expect-samples-file"] === "string";
54760
55594
  return ({ index, label }) => {
54761
55595
  const n = fromFile ? sentSampleNumber(index, request?.flags) : index + 1;
54762
- const name = sent ? `sample ${n}` : `saved sample ${n}`;
55596
+ if (!sent) return `saved sample ${n} (index ${index}${label ? `, "${label}"` : ""})`;
55597
+ const name = `sample ${n}`;
54763
55598
  return label ? `${name} ("${label}")` : name;
54764
55599
  };
54765
55600
  }
@@ -54846,7 +55681,55 @@ function notMatchedLine(result) {
54846
55681
  const source = result.question_answers_source ? ` (${result.question_answers_source})` : "";
54847
55682
  lines.push(` questions${source}: ${answers.map(answerText).join("; ")}`);
54848
55683
  }
54849
- return lines;
55684
+ return [...lines, ...attachmentsLine(result)];
55685
+ }
55686
+ /** Marks that reorder text on screen, so "inv\u202egpj.exe" could show as "invexe.jpg". */
55687
+ const BIDI_CONTROLS = /[\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;
55688
+ /** The longest a sender's subject or file name is shown in a report line. */
55689
+ const SHOWN_TEXT_MAX = 100;
55690
+ /** Text from outside the CLI on one report line: no terminal control sequences or reordering marks, and uncut. */
55691
+ function shownLine(value) {
55692
+ if (typeof value !== "string") return "";
55693
+ return sanitizeForTerminal(value).replace(BIDI_CONTROLS, "").replaceAll(/\s+/g, " ").trim();
55694
+ }
55695
+ /**
55696
+ * Text a sender wrote (a subject, an address, a file name), as a report
55697
+ * line shows it: shownLine, cut at SHOWN_TEXT_MAX.
55698
+ */
55699
+ function shownText(value) {
55700
+ const line = shownLine(value);
55701
+ return line.length > SHOWN_TEXT_MAX ? `${line.slice(0, 97)}...` : line;
55702
+ }
55703
+ /**
55704
+ * The file names a matched or near-miss result lists (attachment_names), on
55705
+ * one line under it: the names its questions are given, shown as shownText
55706
+ * shows a sender's text.
55707
+ */
55708
+ function attachmentsLine(result) {
55709
+ const names = result.attachment_names;
55710
+ if (!Array.isArray(names)) return [];
55711
+ const shown = names.map(shownText).filter(Boolean);
55712
+ return shown.length > 0 ? [` attachments: ${shown.join(", ")}`] : [];
55713
+ }
55714
+ /**
55715
+ * The matched emails, each with who sent it, its subject and its attachments'
55716
+ * file names, so a match can be judged without opening it; cut as the not
55717
+ * matched list is.
55718
+ */
55719
+ function matchedLines(results, expectations) {
55720
+ const flagged = new Set((expectations?.results ?? []).filter((result) => result.status !== "passed").map((result) => result.email_id));
55721
+ const matched = results.filter((result) => result.outcome === "matched").map((result, position) => ({
55722
+ result,
55723
+ position
55724
+ })).sort((a, b) => Number(flagged.has(b.result.email_id)) - Number(flagged.has(a.result.email_id)) || a.position - b.position).map(({ result }) => result);
55725
+ if (matched.length === 0) return [];
55726
+ const shown = matched.slice(0, 25);
55727
+ return [shown.length < matched.length ? `Matched (${shown.length} of ${matched.length} shown; the JSON has every result):` : `Matched (${matched.length}):`, ...shown.flatMap((result) => {
55728
+ const from = shownText(result.from_address);
55729
+ const subject = shownText(result.subject);
55730
+ const about = [from, subject ? `"${subject}"` : ""].filter(Boolean);
55731
+ return [` ${result.email_id}${about.length > 0 ? ` ${about.join(" ")}` : ""}`, ...attachmentsLine(result)];
55732
+ })];
54850
55733
  }
54851
55734
  function notMatchedLines(results, expectations) {
54852
55735
  const flagged = new Set((expectations?.results ?? []).filter((result) => result.status !== "passed").map((result) => result.email_id));
@@ -54915,6 +55798,266 @@ function expectationsOutcome(expectations, testResults = [], name = sampleNamer(
54915
55798
  };
54916
55799
  return {};
54917
55800
  }
55801
+ /** A time an answer gives, to the minute, in UTC. */
55802
+ function minuteUtc(value) {
55803
+ const at = new Date(value);
55804
+ return Number.isNaN(at.getTime()) ? shownLine(value) : `${at.toISOString().slice(0, 16).replace("T", " ")} UTC`;
55805
+ }
55806
+ /**
55807
+ * The first line of a test report: which mail was tested. A test of recent
55808
+ * mail covers the newest emails, so a later one covers what has arrived since,
55809
+ * and two counts compare only over the same emails.
55810
+ */
55811
+ function windowLine(data, tested) {
55812
+ const window = isRecord(data.window) ? data.window : void 0;
55813
+ const oldest = typeof window?.oldest_at === "string" ? window.oldest_at : void 0;
55814
+ const newest = typeof window?.newest_at === "string" ? window.newest_at : void 0;
55815
+ if (!window || !oldest || !newest) return [];
55816
+ const span = `Tested ${plural$1(tested, "email", "emails")} received ${minuteUtc(oldest)} to ${minuteUtc(newest)}.`;
55817
+ return window.mode === "recent" ? [`${span} A later test of recent mail covers what has arrived since: to compare two trees, test the second with --${SAME_EMAILS_FLAG} <this answer, saved with --json>.`] : [span];
55818
+ }
55819
+ /** How many of the emails still matched the comparison names. */
55820
+ const STILL_MATCHED_NAMED = 5;
55821
+ /** Outcomes decided on a rule's conditions: only these carry parts. */
55822
+ const DECIDED = /* @__PURE__ */ new Set([
55823
+ "matched",
55824
+ "near_miss",
55825
+ "no_match"
55826
+ ]);
55827
+ /** Every outcome a test answer gives, in the order the comparison shows them; any other reads as unknown. */
55828
+ const OUTCOMES = [
55829
+ "matched",
55830
+ "near_miss",
55831
+ "no_match",
55832
+ "unclassified",
55833
+ "skipped",
55834
+ "not_found",
55835
+ "unknown"
55836
+ ];
55837
+ /** The answer a saved file holds, as --json printed it or with --envelope. */
55838
+ function savedAnswer(saved) {
55839
+ const answer = isRecord(saved) && isRecord(saved.data) ? saved.data : saved;
55840
+ return isRecord(answer) ? answer : null;
55841
+ }
55842
+ /** An answer's results by email id, in lower case. Null when it holds none. */
55843
+ function resultsById(answer) {
55844
+ if (!answer || !Array.isArray(answer.results)) return null;
55845
+ const byId = /* @__PURE__ */ new Map();
55846
+ for (const result of answer.results) if (isRecord(result) && typeof result.email_id === "string") byId.set(result.email_id.toLowerCase(), result);
55847
+ return byId;
55848
+ }
55849
+ /** An outcome as the comparison names it: one a test gives, or unknown. */
55850
+ function outcomeOf(result) {
55851
+ const outcome = result?.outcome;
55852
+ return typeof outcome === "string" && OUTCOMES.includes(outcome) ? outcome : "unknown";
55853
+ }
55854
+ /** Which conditions held on an email, by parts index. */
55855
+ function heldParts(result) {
55856
+ const parts = Array.isArray(result?.parts) ? result.parts : [];
55857
+ return new Map(parts.flatMap((part) => isRecord(part) && typeof part.index === "number" ? [[part.index, part.matched === true]] : []));
55858
+ }
55859
+ /**
55860
+ * Decided on its conditions, with the parts that say how, and no fact the rule
55861
+ * reads left out: what the summary's own counts cover.
55862
+ */
55863
+ function decidedOnConditions(result) {
55864
+ const missing = result?.missing_facts;
55865
+ return DECIDED.has(outcomeOf(result)) && Array.isArray(result?.parts) && result.parts.length > 0 && !(Array.isArray(missing) && missing.length > 0);
55866
+ }
55867
+ /** A tree's top-level conditions, by index, with their text: from the summary, or the parts the results name. */
55868
+ function conditionsOf(answer, results) {
55869
+ const texts = /* @__PURE__ */ new Map();
55870
+ const summary = answer?.summary;
55871
+ if (isRecord(summary) && Array.isArray(summary.conditions)) {
55872
+ for (const c of summary.conditions) if (isRecord(c) && typeof c.index === "number") texts.set(c.index, typeof c.text === "string" ? c.text : "");
55873
+ }
55874
+ for (const result of results) for (const index of heldParts(result).keys()) if (!texts.has(index)) texts.set(index, "");
55875
+ return [...texts.entries()].sort(([a], [b]) => a - b).map(([index, text]) => ({
55876
+ index,
55877
+ text: text || `condition ${index}`
55878
+ }));
55879
+ }
55880
+ /**
55881
+ * The comparison of `now` with `earlier`, the answer --same-emails-as named
55882
+ * (saved at `against`). Null when the saved answer holds no results.
55883
+ */
55884
+ function compareSameEmails(earlier, now, against) {
55885
+ const earlierAnswer = savedAnswer(earlier);
55886
+ const nowAnswer = savedAnswer(now);
55887
+ const before = resultsById(earlierAnswer);
55888
+ const after = resultsById(nowAnswer);
55889
+ if (!before || !after) return null;
55890
+ const both = [...after.keys()].filter((id) => before.has(id));
55891
+ const tally = (byId) => {
55892
+ const counts = /* @__PURE__ */ new Map();
55893
+ for (const id of both) {
55894
+ const outcome = outcomeOf(byId.get(id));
55895
+ counts.set(outcome, (counts.get(outcome) ?? 0) + 1);
55896
+ }
55897
+ return Object.fromEntries(counts);
55898
+ };
55899
+ const decided = both.filter((id) => decidedOnConditions(before.get(id)) && decidedOnConditions(after.get(id)));
55900
+ const heldBefore = new Map(decided.map((id) => [id, heldParts(before.get(id))]));
55901
+ const heldAfter = new Map(decided.map((id) => [id, heldParts(after.get(id))]));
55902
+ const heldOn = (held, index) => decided.filter((id) => held.get(id)?.get(index) === true).length;
55903
+ const earlierConditions = conditionsOf(earlierAnswer, before.values()).map((c) => ({
55904
+ ...c,
55905
+ held: heldOn(heldBefore, c.index)
55906
+ }));
55907
+ const nowConditions = conditionsOf(nowAnswer, after.values()).map((c) => ({
55908
+ ...c,
55909
+ held: heldOn(heldAfter, c.index)
55910
+ }));
55911
+ const pairs = [];
55912
+ const leftNow = [...nowConditions];
55913
+ const leftEarlier = [];
55914
+ for (const condition of earlierConditions) {
55915
+ const same = leftNow.findIndex((c) => c.text === condition.text);
55916
+ const match = same >= 0 ? leftNow.splice(same, 1)[0] : void 0;
55917
+ if (match) pairs.push({
55918
+ earlier: condition,
55919
+ now: match
55920
+ });
55921
+ else leftEarlier.push(condition);
55922
+ }
55923
+ if (leftEarlier.length === leftNow.length) {
55924
+ leftEarlier.forEach((condition, i) => {
55925
+ const match = leftNow[i];
55926
+ if (match) pairs.push({
55927
+ earlier: condition,
55928
+ now: match
55929
+ });
55930
+ });
55931
+ leftEarlier.length = 0;
55932
+ leftNow.length = 0;
55933
+ }
55934
+ const moved = (e, n) => {
55935
+ let lost = 0;
55936
+ let gained = 0;
55937
+ for (const id of decided) {
55938
+ const was = heldBefore.get(id)?.get(e.index) === true;
55939
+ const is = heldAfter.get(id)?.get(n.index) === true;
55940
+ if (was && !is) lost += 1;
55941
+ if (!was && is) gained += 1;
55942
+ }
55943
+ return {
55944
+ lost,
55945
+ gained
55946
+ };
55947
+ };
55948
+ const conditions = [
55949
+ ...pairs.sort((a, b) => a.earlier.index - b.earlier.index).map((pair) => ({
55950
+ ...pair,
55951
+ ...moved(pair.earlier, pair.now)
55952
+ })),
55953
+ ...leftEarlier.map((e) => ({
55954
+ earlier: e,
55955
+ now: null,
55956
+ lost: null,
55957
+ gained: null
55958
+ })),
55959
+ ...leftNow.map((n) => ({
55960
+ earlier: null,
55961
+ now: n,
55962
+ lost: null,
55963
+ gained: null
55964
+ }))
55965
+ ];
55966
+ const subjectOf = (result) => typeof result?.subject === "string" ? result.subject : null;
55967
+ const changed = both.filter((id) => outcomeOf(before.get(id)) !== outcomeOf(after.get(id))).map((id) => ({
55968
+ email_id: id,
55969
+ subject: subjectOf(after.get(id)) ?? subjectOf(before.get(id)),
55970
+ earlier: outcomeOf(before.get(id)),
55971
+ now: outcomeOf(after.get(id))
55972
+ }));
55973
+ const still = both.filter((id) => outcomeOf(before.get(id)) === "matched" && outcomeOf(after.get(id)) === "matched");
55974
+ return {
55975
+ against,
55976
+ emails: both.length,
55977
+ only_earlier: [...before.keys()].filter((id) => !after.has(id)).length,
55978
+ only_now: [...after.keys()].filter((id) => !before.has(id)).length,
55979
+ decided: decided.length,
55980
+ unchanged: both.length > 0 && changed.length === 0 && (conditions.length === 0 || decided.length > 0 && conditions.every((c) => c.lost === 0 && c.gained === 0)),
55981
+ tree_changed: conditions.some((c) => !c.earlier || !c.now || c.earlier.text !== c.now.text),
55982
+ outcomes: {
55983
+ earlier: tally(before),
55984
+ now: tally(after)
55985
+ },
55986
+ conditions,
55987
+ changed,
55988
+ still_matched: {
55989
+ count: still.length,
55990
+ emails: still.slice(0, STILL_MATCHED_NAMED).map((id) => ({
55991
+ email_id: id,
55992
+ subject: subjectOf(after.get(id))
55993
+ }))
55994
+ }
55995
+ };
55996
+ }
55997
+ /** A subject as the comparison quotes it, or that it has none. */
55998
+ function quotedSubject(subject) {
55999
+ const shown = shownText(subject);
56000
+ return shown ? `"${shown}"` : "(no subject)";
56001
+ }
56002
+ /** One condition of a comparison as a report line. */
56003
+ function comparedConditionLine(x) {
56004
+ if (x.earlier && x.now) {
56005
+ const at = x.earlier.index === x.now.index ? `${x.now.index}` : `${x.earlier.index} -> ${x.now.index}`;
56006
+ const text = x.earlier.text === x.now.text ? shownLine(x.now.text) : `earlier "${shownLine(x.earlier.text)}", now "${shownLine(x.now.text)}"`;
56007
+ const moved = x.lost === 0 && x.gained === 0 ? "the same emails" : `lost ${x.lost}, gained ${x.gained}`;
56008
+ return ` ${at}. ${text}: ${x.earlier.held} -> ${x.now.held} (${moved})`;
56009
+ }
56010
+ if (x.earlier) return ` removed, earlier ${x.earlier.index}. ${shownLine(x.earlier.text)}: held on ${x.earlier.held}`;
56011
+ return ` added, now ${x.now?.index}. ${shownLine(x.now?.text)}: holds on ${x.now?.held}`;
56012
+ }
56013
+ /** The comparison as report lines, after the rest of the report. */
56014
+ function comparisonLines(c) {
56015
+ const left = [c.only_earlier > 0 ? `${c.only_earlier} only in the earlier answer` : "", c.only_now > 0 ? `${c.only_now} only in this one` : ""].filter(Boolean);
56016
+ const lines = [`Compared with ${shownLine(c.against)}, over the ${plural$1(c.emails, "email", "emails")} both tested${left.length > 0 ? ` (left out: ${left.join(", ")})` : ""}:`];
56017
+ if (c.emails === 0) return [...lines, " None to compare."];
56018
+ lines.push(c.unchanged ? c.tree_changed ? " Nothing changed on these emails: the tree changed, but every email has the same outcome and each condition holds on the same emails as before." : c.conditions.length === 0 ? " Nothing changed: every email has the same outcome." : " Nothing changed: every email has the same outcome, and each condition holds on the same emails as before." : c.changed.length === 0 ? " No email changed outcome." : ` ${plural$1(c.changed.length, "email changed outcome", "emails changed outcome")}.`);
56019
+ const outcomes = OUTCOMES.filter((o) => (c.outcomes.earlier[o] ?? 0) + (c.outcomes.now[o] ?? 0) > 0).map((o) => `${o} ${c.outcomes.earlier[o] ?? 0} -> ${c.outcomes.now[o] ?? 0}`);
56020
+ lines.push(` Outcomes, earlier -> now: ${outcomes.join(", ")}.`);
56021
+ if (c.conditions.length > 0 && c.decided === 0) lines.push(" Conditions: no email was decided on its conditions in both answers, so they are not compared.");
56022
+ else if (c.conditions.length > 0) lines.push(` Conditions, how many of the ${plural$1(c.decided, "email", "emails")} decided in both each held on, earlier -> now:`, ...c.conditions.map(comparedConditionLine));
56023
+ if (c.changed.length > 0) {
56024
+ const shown = c.changed.slice(0, 25);
56025
+ lines.push(shown.length < c.changed.length ? ` Changed outcome (${shown.length} of ${c.changed.length} shown; with --json, comparison.changed has every one):` : ` Changed outcome (${c.changed.length}):`, ...shown.map((x) => ` ${x.email_id} ${quotedSubject(x.subject)}: ${x.earlier} -> ${x.now}`));
56026
+ }
56027
+ const named = c.still_matched.emails.map((x) => quotedSubject(x.subject));
56028
+ const more = c.still_matched.count - named.length;
56029
+ lines.push(c.still_matched.count === 0 ? " Matched before and still matched: none." : ` Matched before and still matched: ${c.still_matched.count}, such as ${named.join(", ")}${more > 0 ? `, and ${more} more` : ""}.`);
56030
+ return lines;
56031
+ }
56032
+ /**
56033
+ * The earlier answers --same-emails-as read, by the parsed flags they came
56034
+ * with: the file is read once, so one that can be read only once (a pipe, a
56035
+ * process substitution) is compared too, and one rewritten meanwhile is
56036
+ * compared as it was sent.
56037
+ */
56038
+ const SAVED_ANSWERS = /* @__PURE__ */ new WeakMap();
56039
+ /** The comparison --same-emails-as asks for; when there can be none, a line and an error saying why. */
56040
+ function sameEmailsComparison(data, flags) {
56041
+ const file = flags?.[SAME_EMAILS_FLAG];
56042
+ if (typeof file !== "string") return { lines: [] };
56043
+ const failed = (why) => ({
56044
+ json: { comparison: {
56045
+ against: file,
56046
+ error: why
56047
+ } },
56048
+ lines: [`Not compared with ${shownLine(file)}: ${shownLine(why)}`]
56049
+ });
56050
+ try {
56051
+ const comparison = compareSameEmails(flags && SAVED_ANSWERS.has(flags) ? SAVED_ANSWERS.get(flags) : readJsonFileFlag(file, `--${SAME_EMAILS_FLAG}`), data, file);
56052
+ if (!comparison) return failed("it holds no results.");
56053
+ return {
56054
+ json: { comparison },
56055
+ lines: comparisonLines(comparison)
56056
+ };
56057
+ } catch (error) {
56058
+ return failed(error instanceof Error ? error.message : String(error));
56059
+ }
56060
+ }
54918
56061
  /** The stderr report and exit code of a test-email-rule answer. */
54919
56062
  function testEmailRuleReport(data, request) {
54920
56063
  if (!isRecord(data)) return { lines: [] };
@@ -54922,15 +56065,21 @@ function testEmailRuleReport(data, request) {
54922
56065
  const result = data;
54923
56066
  const results = Array.isArray(result.results) ? result.results : [];
54924
56067
  const summary = isRecord(result.summary) ? result.summary : void 0;
56068
+ const counts = isRecord(data.counts) ? data.counts : void 0;
56069
+ const lines = [
56070
+ ...windowLine(data, (typeof counts?.emails === "number" ? counts.emails : results.length) - (typeof counts?.not_found === "number" ? counts.not_found : 0)),
56071
+ ...(Array.isArray(summary?.warnings) ? summary.warnings : []).map((warning) => `Warning: ${warning}`),
56072
+ ...scopeWarningLines(result.scope_warnings),
56073
+ ...conditionLines(summary),
56074
+ ...questionLines(summary, results),
56075
+ ...expectationsLines(result.expectations, results, name),
56076
+ ...matchedLines(results, result.expectations),
56077
+ ...notMatchedLines(results, result.expectations)
56078
+ ];
56079
+ const compared = sameEmailsComparison(data, request?.flags);
54925
56080
  return {
54926
- lines: [
54927
- ...(Array.isArray(summary?.warnings) ? summary.warnings : []).map((warning) => `Warning: ${warning}`),
54928
- ...scopeWarningLines(result.scope_warnings),
54929
- ...conditionLines(summary),
54930
- ...questionLines(summary, results),
54931
- ...expectationsLines(result.expectations, results, name),
54932
- ...notMatchedLines(results, result.expectations)
54933
- ],
56081
+ lines: [...lines, ...compared.lines],
56082
+ ...compared.json ? { json: compared.json } : {},
54934
56083
  ...expectationsOutcome(result.expectations, results, name)
54935
56084
  };
54936
56085
  }
@@ -54939,28 +56088,50 @@ function indexList(value) {
54939
56088
  return Array.isArray(value) ? value.filter((n) => typeof n === "number") : [];
54940
56089
  }
54941
56090
  /**
56091
+ * The labels a write's check gives the made-up emails it names, by index
56092
+ * (failed_sample_details and undecided_sample_details), from a server that
56093
+ * sends them.
56094
+ */
56095
+ function sampleDetailLabels(check) {
56096
+ const labels = /* @__PURE__ */ new Map();
56097
+ if (!isRecord(check)) return labels;
56098
+ for (const key of ["failed_sample_details", "undecided_sample_details"]) {
56099
+ const details = check[key];
56100
+ if (!Array.isArray(details)) continue;
56101
+ for (const detail of details) if (isRecord(detail) && typeof detail.index === "number" && Number.isInteger(detail.index) && detail.index >= 0) labels.set(detail.index, typeof detail.label === "string" ? detail.label : null);
56102
+ }
56103
+ return labels;
56104
+ }
56105
+ /**
54942
56106
  * How a rule write names a made-up email its check gives by index, from 0 in
54943
56107
  * the set judged: those this write sends in place of the rule's
54944
56108
  * (expectation_samples), or the rule's saved ones oldest first and then
54945
56109
  * those it adds (add_expectation_samples). One this write sent is "sample
54946
56110
  * N", its number in the samples file --pick took it from (or its place in
54947
- * what was sent); any other is "saved sample N", its place among the rule's.
54948
- * With its label when known. `saved` is the answer's expectation_samples,
54949
- * every one the rule keeps after the write, when it has them.
56111
+ * what was sent); any other is "saved sample N (index i)", its place among
56112
+ * the rule's and the index the API names it by. With its label when known,
56113
+ * from the samples or from `labels` (sampleDetailLabels). `saved` is the
56114
+ * answer's expectation_samples, every one the rule keeps after the write,
56115
+ * when it has them.
54950
56116
  */
54951
- function writtenSampleNamer(body, flags, saved) {
56117
+ function writtenSampleNamer(body, flags, saved, labels = /* @__PURE__ */ new Map()) {
54952
56118
  const sent = isRecord(body) && Array.isArray(body.expectation_samples) ? body.expectation_samples : null;
54953
56119
  const added = isRecord(body) && Array.isArray(body.add_expectation_samples) ? body.add_expectation_samples : null;
54954
56120
  const kept = Array.isArray(saved) ? saved : null;
54955
56121
  const labelled = (name, sample) => isRecord(sample) && typeof sample.label === "string" && sample.label ? `${name} ("${sample.label}")` : name;
56122
+ const indexed = (name, index) => {
56123
+ const sample = kept?.[index];
56124
+ const label = isRecord(sample) && typeof sample.label === "string" && sample.label ? sample.label : labels.get(index);
56125
+ return `${name} (index ${index}${label ? `, "${label}"` : ""})`;
56126
+ };
54956
56127
  return (index) => {
54957
56128
  if (sent) return labelled(`sample ${sentSampleNumber(index, flags)}`, sent[index]);
54958
56129
  if (added) {
54959
56130
  const start = kept ? kept.length - added.length : null;
54960
- if (start === null) return `made-up email ${index + 1}`;
56131
+ if (start === null) return indexed(`made-up email ${index + 1}`, index);
54961
56132
  if (index >= start) return labelled(`sample ${sentSampleNumber(index - start, flags)}`, added[index - start]);
54962
56133
  }
54963
- return labelled(`saved sample ${index + 1}`, kept?.[index]);
56134
+ return indexed(`saved sample ${index + 1}`, index);
54964
56135
  };
54965
56136
  }
54966
56137
  function expectationsCheckLine(check, ruleId, name = (index) => `saved sample ${index + 1}`) {
@@ -55051,18 +56222,24 @@ function restoredLine(restored, currentVersion) {
55051
56222
  return `Saved version ${restored.version} again ${as}.${note}`;
55052
56223
  }
55053
56224
  /**
55054
- * Who an update that saved a version reaches, as its answer counts them: the
55055
- * keys listing the rule, the webhooks those keys own, and the shares the
55056
- * write ended.
56225
+ * Who an update that saved a version, or turned a grant rule active, reaches,
56226
+ * as its answer counts them: the keys listing the rule and the webhooks those
56227
+ * keys own, and the shares the write ended when it ended any. A new version
56228
+ * keeps a rule's share, so the API counts none; the answer's `share_notice`
56229
+ * says the share goes on.
55057
56230
  */
55058
- function affectsLine(affects) {
56231
+ function affectsLine(affects, write = {}) {
55059
56232
  if (!isRecord(affects)) return void 0;
55060
56233
  const count = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
55061
56234
  const keys = count(affects.keys);
55062
56235
  const endpoints = count(affects.endpoints);
55063
- const shares = count(affects.shares_ended);
55064
- if (keys === void 0 || endpoints === void 0 || shares === void 0) return void 0;
55065
- return `This version reaches ${plural$1(keys, "API key", "API keys")} listing the rule and ${plural$1(endpoints, "webhook", "webhooks")} those keys own; it ended ${plural$1(shares, "share", "shares")}. The rule keeps its state.`;
56236
+ const shares = count(affects.shares_ended) ?? 0;
56237
+ const reach = `${plural$1(keys ?? 0, "API key", "API keys")} listing the rule and ${plural$1(endpoints ?? 0, "webhook", "webhooks")} those keys own`;
56238
+ if (write.activatedOnly && keys !== void 0 && endpoints !== void 0) return `Now active${write.scopeSent ? ", over the scope this write sent" : ""}: it reaches ${reach}.`;
56239
+ if (keys === void 0 || endpoints === void 0) return void 0;
56240
+ const ended = shares > 0 ? `; it ended ${plural$1(shares, "share", "shares")}` : "";
56241
+ if (write.stateSent !== void 0 && typeof write.state === "string") return `This version reaches ${reach}${ended}. The rule is now ${write.state}.`;
56242
+ return `This version reaches ${reach}${ended}. The rule keeps its state.`;
55066
56243
  }
55067
56244
  /** The rule's author, by name and email where the answer gives them. */
55068
56245
  function authorLine(author) {
@@ -55089,7 +56266,15 @@ function writtenEmailRuleReport(data, request) {
55089
56266
  }
55090
56267
  const restored = restoredLine(rule.restored_from, rule.current_version);
55091
56268
  if (restored) lines.push(restored);
55092
- const reach = affectsLine(rule.affects);
56269
+ const body = isRecord(request.body) ? request.body : {};
56270
+ const activatedOnly = body.state === "active" && body.tree === void 0 && body.restore_version === void 0;
56271
+ const scopeSent = body.evaluation_scope !== void 0;
56272
+ const reach = rule.kind === "do_not_share" && activatedOnly && !scopeSent ? void 0 : affectsLine(rule.affects, {
56273
+ activatedOnly,
56274
+ scopeSent,
56275
+ stateSent: body.state,
56276
+ state: rule.state
56277
+ });
55093
56278
  if (reach) lines.push(reach);
55094
56279
  for (const note of [
55095
56280
  rule.share_notice,
@@ -55100,7 +56285,7 @@ function writtenEmailRuleReport(data, request) {
55100
56285
  if (line) lines.push(line);
55101
56286
  }
55102
56287
  const sentExpectations = sentExpectationsIn(request.body);
55103
- const name = writtenSampleNamer(request.body, request.flags, rule.expectation_samples);
56288
+ const name = writtenSampleNamer(request.body, request.flags, rule.expectation_samples, sampleDetailLabels(rule.expectations_check));
55104
56289
  const checked = expectationsCheckLine(rule.expectations_check, ruleId, name);
55105
56290
  if (checked) lines.push(checked);
55106
56291
  else if (sentExpectations) lines.push(`Expectations were not checked on this write. Test them with \`primitive email-rules test-email-rule --rule-id ${ruleId}\`.`);
@@ -55197,14 +56382,17 @@ function readAgain(id) {
55197
56382
  /**
55198
56383
  * Who reads an active rule, from a refusal's details.read_by: the server
55199
56384
  * sends it when it checked the write against the rule's expectations because
55200
- * API keys or webhooks read the rule, whether or not the write asked.
56385
+ * API keys, webhooks or a share read the rule, whether or not the write asked.
55201
56386
  * Undefined without it.
55202
56387
  */
55203
56388
  function readByText(details) {
55204
56389
  const readBy = details.read_by;
55205
56390
  if (!isRecord(readBy)) return void 0;
55206
- const { keys, webhooks } = readBy;
55207
- return typeof keys === "number" && typeof webhooks === "number" ? `${plural$1(keys, "API key", "API keys")} and ${plural$1(webhooks, "webhook", "webhooks")} read what it grants` : "API keys or webhooks may read what it grants (they could not be counted in time)";
56391
+ const { keys, webhooks, shares } = readBy;
56392
+ if (typeof keys !== "number" || typeof webhooks !== "number" || shares === null) return "API keys, webhooks or a share may read what it grants (they could not be counted in time)";
56393
+ const shared = typeof shares === "number" && shares > 0 ? `it is shared with ${plural$1(shares, "member", "members")}` : void 0;
56394
+ if (keys + webhooks === 0 && shared) return shared;
56395
+ return `${plural$1(keys, "API key", "API keys")} and ${plural$1(webhooks, "webhook", "webhooks")} read what it grants${shared ? `, and ${shared}` : ""}`;
55208
56396
  }
55209
56397
  /** How to save a write the default check refused, without the check. */
55210
56398
  function saveUncheckedText(flags) {
@@ -55217,14 +56405,14 @@ function saveUncheckedText(flags) {
55217
56405
  * expectations_failed, expectations_undecided, expectations_unreadable and
55218
56406
  * no_expectations. The guard runs when the write sends if_expectations_pass,
55219
56407
  * and by default (details.read_by) when it changes what an active rule that
55220
- * API keys or webhooks read grants. Nothing was saved in any of them.
56408
+ * API keys, webhooks or a share read grants. Nothing was saved in any of them.
55221
56409
  */
55222
56410
  function updateEmailRuleErrorHint(code, payload, ruleId, body, flags) {
55223
56411
  const id = typeof ruleId === "string" && ruleId ? ruleId : "<rule-id>";
55224
56412
  const details = errorDetails(payload);
55225
56413
  const guarded = isRecord(body) && body.if_expectations_pass === true;
55226
56414
  const readBy = readByText(details);
55227
- const judged = readBy ? "was judged against its expectations before saving, as a write that changes what an active rule grants is by default while API keys or webhooks read it, and nothing was saved" : "was judged against its expectations before saving (if_expectations_pass), and nothing was saved";
56415
+ const judged = readBy ? "was judged against its expectations before saving, as a write that changes what an active rule grants is by default while API keys, webhooks or a share read it, and nothing was saved" : "was judged against its expectations before saving (if_expectations_pass), and nothing was saved";
55228
56416
  const unchecked = readBy ? ` The rule is active and ${readBy}; to save the write without the check, ${saveUncheckedText(flags)}.` : "";
55229
56417
  if (code === "email_rule_conflict") switch (details.reason) {
55230
56418
  case "version_moved": return versionMovedHint(payload, ruleId);
@@ -55234,14 +56422,14 @@ function updateEmailRuleErrorHint(code, payload, ruleId, body, flags) {
55234
56422
  }
55235
56423
  case "expectations_moved": return `Hint: the rule's saved expectations changed while this write was checked against them, so nothing was saved. ${readAgain(id)}.`;
55236
56424
  case "rule_changed": return guarded ? `Hint: the rule changed after this write was judged against its expectations and before it was saved, so saving it would have gone unchecked; nothing was saved. ${readAgain(id)}.` : `Hint: the rule changed while this write was being saved, so nothing was saved. ${readAgain(id)}.`;
55237
- case "readers_changed": return "Hint: API keys or webhooks started reading this rule while this write was being saved, and saving it would have changed what they receive without checking it against the rule's expectations, so nothing was saved. Send the write again: it is then checked first.";
56425
+ case "readers_changed": return "Hint: API keys, webhooks or a share started reading this rule while this write was being saved, and saving it would have changed what they receive without checking it against the rule's expectations, so nothing was saved. Send the write again: it is then checked first.";
55238
56426
  default: return;
55239
56427
  }
55240
56428
  if (code === "expectations_failed" || code === "expectations_undecided") {
55241
56429
  const check = isRecord(details.expectations_check) ? details.expectations_check : {};
55242
56430
  const failed = Array.isArray(check.failed) ? check.failed : [];
55243
56431
  const undecided = Array.isArray(check.undecided) ? check.undecided : [];
55244
- const name = writtenSampleNamer(body, flags);
56432
+ const name = writtenSampleNamer(body, flags, void 0, sampleDetailLabels(check));
55245
56433
  const failedAll = [...failed, ...indexList(check.failed_samples).map(name)];
55246
56434
  const undecidedSamples = indexList(check.undecided_samples);
55247
56435
  const undecidedAll = [...undecided, ...undecidedSamples.map(name)];
@@ -55345,7 +56533,7 @@ const BREADTH_SCOPE = {
55345
56533
  /** The stderr report of compile-email-rule: how many recent emails it holds for. */
55346
56534
  function compileEmailRuleReport(data, request) {
55347
56535
  if (!isRecord(data)) return { lines: [] };
55348
- const lines = (Array.isArray(data.warnings) ? data.warnings : []).filter((warning) => typeof warning === "string" && warning.trim() !== "").map((warning) => `Warning: ${warning.trim()}`);
56536
+ const lines = [...scopeWarningLines(data.scope_warnings), ...(Array.isArray(data.warnings) ? data.warnings : []).filter((warning) => typeof warning === "string" && warning.trim() !== "").map((warning) => `Warning: ${warning.trim()}`)];
55349
56537
  const breadth = data.breadth;
55350
56538
  const sent = isRecord(request?.body) && typeof request.body.evaluation_scope === "string" ? request.body.evaluation_scope : void 0;
55351
56539
  const counted = isRecord(data.breadth_scope) && typeof data.breadth_scope.evaluation_scope === "string" ? data.breadth_scope.evaluation_scope : sent;
@@ -55381,11 +56569,11 @@ function listEmailRulesReport(data) {
55381
56569
  return { lines };
55382
56570
  }
55383
56571
  /** create-email-rule's --fail-on-expectations: the exit code follows the check made after saving. */
55384
- const FAIL_ON_EXPECTATIONS_HELP = "Exit 1 when an expectation in the answer's expectations_check failed, and 3 when none failed but one is undecided or the expectations this write sent were not checked (test the rule to decide). A create does not judge made-up emails, so with some it exits 3. Without it the command exits 0 whatever the check says.";
56572
+ const FAIL_ON_EXPECTATIONS_HELP = "Exit 1 when an expectation in the answer's expectations_check failed, and 3 when none failed but one is undecided or the expectations this write sent were not checked (test the rule to decide). A create does not judge made-up emails, so with some it exits 3. It judges emails by id on their stored classification without asking the rule's questions, so on a new rule with questions an email whose conditions hold stays undecided (exit 3) until `test-email-rule --rule-id` asks them. Without it the command exits 0 whatever the check says.";
55385
56573
  /** update-email-rule's --fail-on-expectations: the server refuses the write. */
55386
- const UPDATE_FAIL_ON_EXPECTATIONS_HELP = "Refuse the write unless the rule, as this write would leave it, passes its expectations. It sends if_expectations_pass (over any in --body-file or --raw-body), so the server judges a new version, a restored one, a new scope or turning the rule active before saving, on its emails by id and its made-up emails, and saves nothing when one failed (exit 1), one names an email the rule cannot read (exit 1, since sending again never decides it), one is undecided (exit 3, or 1 when the rule cannot run as its author or a made-up email is undecided for no reason the answer gives) or the rule has none (exit 1). It can take as long as a test of the rule; the command waits for it. Judging needs a credential that reads the mail's content. A write the server does not judge (one changing only expectations, say) is saved, and the exit code then follows the answer's expectations_check, as on create. Without it, the server still judges, and refuses the same way, a write that saves a version or changes the scope of an active rule that API keys or webhooks read and that has expectations (the refusal's details.read_by counts them), unless --no-if-expectations-pass is sent. With --json, a refused write's document holds the API's error alone; a saved write's holds the rule.";
56574
+ const UPDATE_FAIL_ON_EXPECTATIONS_HELP = "Refuse the write unless the rule, as this write would leave it, passes its expectations. It sends if_expectations_pass (over any in --body-file or --raw-body), so the server judges a new version, a restored one, a new scope or turning the rule active before saving, on its emails by id and its made-up emails, and saves nothing when one failed (exit 1), one names an email the rule cannot read (exit 1, since sending again never decides it), one is undecided (exit 3, or 1 when the rule cannot run as its author or a made-up email is undecided for no reason the answer gives) or the rule has none (exit 1). It can take as long as a test of the rule; the command waits for it. Judging needs a credential that reads the mail's content. A write the server does not judge (one changing only expectations, say) is saved, and the exit code then follows the answer's expectations_check, as on create. Without it, the server still judges, and refuses the same way, a write that saves a version or changes the scope of an active rule that API keys, webhooks or a share read and that has expectations (the refusal's details.read_by counts them), unless --no-if-expectations-pass is sent. With --json, a refused write's document holds the API's error alone; a saved write's holds the rule.";
55387
56575
  /** When update-email-rule judges the made-up emails a samples flag sets. */
55388
- const UPDATE_JUDGES_SAMPLES = `The write judges them before saving with --${FAIL_ON_EXPECTATIONS_FLAG}, when it saves a version or turns the rule active, and without it when it saves a version or changes the scope of an active rule that API keys or webhooks read, unless --no-if-expectations-pass is sent.`;
56576
+ const UPDATE_JUDGES_SAMPLES = `The write judges them before saving with --${FAIL_ON_EXPECTATIONS_FLAG}, when it saves a version or turns the rule active, and without it when it saves a version or changes the scope of an active rule that API keys, webhooks or a share read, unless --no-if-expectations-pass is sent.`;
55389
56577
  /** What a samples file flag reads. */
55390
56578
  const SAMPLES_FILE_SHAPE = "A JSON file of made-up emails the rule must match or not: an array such as [{\"expected\": \"no_match\", \"label\": \"a personal bill\", \"email\": {...}}], with email as test-email-rule-on-sample takes it (text up to 4,000 characters, at most 10 each of to, cc, attachment_types and attachment_names), like the one generate-look-alikes --samples-file writes, or a generate-look-alikes answer saved as it printed it.";
55391
56579
  const EXPECTATION_FLAG_NOTE = "Replaces any expect in --body-file or --raw-body. The answer reports them in expectations (passed, counts, results) and the exit code follows it; see --help-full.";
@@ -55411,6 +56599,52 @@ function endEmailRuleShareReport(data) {
55411
56599
  const note = isRecord(data) && typeof data.note === "string" ? data.note.trim() : "";
55412
56600
  return { lines: note ? [note] : [] };
55413
56601
  }
56602
+ /**
56603
+ * Whether a share made with you is working, from its `activity`, as one line:
56604
+ * the last hour that has ended (or in which an email was shared with you) in
56605
+ * which its rule looked at an email in the sharing member's mailboxes, how
56606
+ * many emails it has shared and when it last did, and whether the rule is
56607
+ * active. Nothing for a share without it: one you are not the person it is
56608
+ * shared with, one not live, or a server that predates the field.
56609
+ */
56610
+ function shareActivityLines(share) {
56611
+ if (!isRecord(share) || !isRecord(share.activity)) return [];
56612
+ const activity = share.activity;
56613
+ const id = typeof share.id === "string" ? share.id : "<share-id>";
56614
+ const rule = isRecord(share.rule) && typeof share.rule.name === "string" ? shownLine(share.rule.name) : "";
56615
+ const granter = isRecord(share.granter) ? share.granter : {};
56616
+ const person = shownLine(granter.name) || shownLine(granter.email) || "the member sharing";
56617
+ const head = `Share ${id}${rule ? ` (${rule})` : ""}:`;
56618
+ const count = activity.shared_emails;
56619
+ const sharedAt = typeof activity.last_shared_at === "string" ? activity.last_shared_at : null;
56620
+ const unread = `${head} whether it is working could not be read just now; try again.`;
56621
+ if (typeof count !== "number") return [unread];
56622
+ if (typeof activity.last_decided_at !== "string" && (count > 0 || sharedAt)) return [unread];
56623
+ if (count > 0 !== (sharedAt !== null)) return [unread];
56624
+ const decided = typeof activity.last_decided_at === "string" ? `its rule last looked at an email in ${person}'s mailboxes in the hour starting ${minuteUtc(activity.last_decided_at)}` : `its rule has not looked at an email in ${person}'s mailboxes in any hour that has ended since it was shared with you`;
56625
+ const more = activity.shared_emails_more === true;
56626
+ const many = `${more ? "more than " : ""}${count.toLocaleString("en-US")}`;
56627
+ return [`${head} ${decided}; ${count === 0 ? "nothing has been shared with you yet" : `it has shared ${many} ${count === 1 && !more ? "email" : "emails"} with you${sharedAt ? `, the last at ${minuteUtc(sharedAt)}` : ""}`}.${activity.rule_active === false ? " The rule is not active, so nothing new is shared until it is." : share.delivery_paused === true ? " New email is not being shared with you right now; what was shared stays visible." : ""}`];
56628
+ }
56629
+ /**
56630
+ * accept-email-rule-request without --json: the answer's notice, then the
56631
+ * rule as it was agreed, since the answer's request block holds the rule as
56632
+ * it was asked and reads like what was accepted.
56633
+ */
56634
+ function acceptEmailRuleRequestReport(data) {
56635
+ if (!isRecord(data)) return { lines: [] };
56636
+ const notice = typeof data.notice === "string" ? data.notice.split(/\n\s*\n/).map((part) => part.trim()).filter(Boolean) : [];
56637
+ const rule = isRecord(data.rule) ? data.rule : void 0;
56638
+ const current = rule && isRecord(rule.current) ? rule.current : void 0;
56639
+ const lines = [...notice];
56640
+ if (rule && typeof rule.name === "string" && typeof rule.id === "string") {
56641
+ const version = typeof current?.version === "number" ? `, version ${current.version}` : "";
56642
+ const state = typeof rule.state === "string" ? `, ${rule.state}` : "";
56643
+ const agreed = typeof current?.english === "string" ? ` What you agreed to: ${current.english}` : "";
56644
+ lines.push(`Accepted as ${rule.name} (${rule.id})${version}${state}.${agreed}`);
56645
+ }
56646
+ return { lines };
56647
+ }
55414
56648
  const EMAIL_RULE_OPERATION_EXTENSIONS = {
55415
56649
  testEmailRule: {
55416
56650
  flags: {
@@ -55430,9 +56664,19 @@ const EMAIL_RULE_OPERATION_EXTENSIONS = {
55430
56664
  }),
55431
56665
  [EXPECT_SAMPLES_FILE_FLAG]: Flags.string({ description: `${SAMPLES_FILE_SHAPE} Sets expect.samples (at most 20), beside any emails by id; the answer judges each in expectations.samples (index from 0 over those sent), and the report names each by its number in the file. Like any expect, it replaces a saved rule's own expectations and samples for this test. ${EXPECTATION_FLAG_NOTE}` }),
55432
56666
  [PICK_FLAG]: Flags.string({ description: pickFlagHelp([EXPECT_SAMPLES_FILE_FLAG]) }),
56667
+ [SAME_EMAILS_FLAG]: Flags.string({ description: `Test the same emails as an earlier test: a file holding what test-email-rule --json printed. Sets email_ids to its results' email_id, over any in --body-file or --raw-body, so two trees are compared over the same mail; a test of recent mail covers the newest emails, which move on as mail arrives. At most ${EMAIL_IDS_MAX} emails, counting the expected ones a test adds (a saved rule's own, with --rule-id). The report then ends with what changed against that answer, over the emails both tested: the emails whose outcome changed; each top-level condition's count, earlier and now, of the emails both decided on their conditions that it held on, with how many it lost and gained (conditions pair by their text, then in order; one left over shows as added or removed); and the emails matched before and still matched. It says so when nothing changed. With --json, the document gains a comparison key beside the answer's own, which the CLI works out from the two answers; when it cannot compare them, comparison holds only against and error.` }),
55433
56668
  ...scopeSelectionFlags()
55434
56669
  },
55435
- bodyFields: (flags, base) => [...expectBodyFields(flags), ...scopeSelectionBodyFields(flags, base)],
56670
+ bodyFields: (flags, base) => {
56671
+ const expect = expectBodyFields(flags);
56672
+ const same = sameEmailsBodyFields(flags);
56673
+ checkSameEmailsWithExpected(same, expect, base);
56674
+ return [
56675
+ ...expect,
56676
+ ...same,
56677
+ ...scopeSelectionBodyFields(flags, base)
56678
+ ];
56679
+ },
55436
56680
  bodyProperties: ["expect", "scope_selection"],
55437
56681
  fallbackExitCode: (data) => {
55438
56682
  const expectations = data?.expectations;
@@ -55513,7 +56757,8 @@ const EMAIL_RULE_OPERATION_EXTENSIONS = {
55513
56757
  [PICK_FLAG]: Flags.string({ description: pickFlagHelp([SAMPLES_FILE_FLAG]) })
55514
56758
  },
55515
56759
  bodyFields: samplesBodyFields(false),
55516
- bodyProperties: ["expectation_samples"]
56760
+ bodyProperties: ["expectation_samples"],
56761
+ report: acceptEmailRuleRequestReport
55517
56762
  },
55518
56763
  compileEmailRule: {
55519
56764
  flags: scopeSelectionFlags(),
@@ -55525,6 +56770,14 @@ const EMAIL_RULE_OPERATION_EXTENSIONS = {
55525
56770
  flags: {},
55526
56771
  report: endEmailRuleShareReport
55527
56772
  },
56773
+ getEmailRuleShare: {
56774
+ flags: {},
56775
+ report: (data) => ({ lines: shareActivityLines(data) })
56776
+ },
56777
+ listEmailRuleShares: {
56778
+ flags: {},
56779
+ report: (data) => ({ lines: (Array.isArray(data) ? data : []).flatMap(shareActivityLines) })
56780
+ },
55528
56781
  getEmailRule: {
55529
56782
  flags: {},
55530
56783
  report: getEmailRuleReport
@@ -55793,7 +57046,7 @@ function unknownEventTypes(eventTypes) {
55793
57046
  function unknownEventTypesWarning(unknown) {
55794
57047
  return `Warning: ${unknown.join(", ")} ${unknown.length === 1 ? "is" : "are"} not an event type this CLI knows. Subscriptions match exact names, so a misspelled name receives nothing. Continuing; newer event types may not be known to this CLI yet.\n`;
55795
57048
  }
55796
- function isPlainObject$1(value) {
57049
+ function isPlainObject(value) {
55797
57050
  return value !== null && typeof value === "object" && !Array.isArray(value);
55798
57051
  }
55799
57052
  /**
@@ -55806,16 +57059,16 @@ async function currentEndpointRules(endpointId, listEndpoints) {
55806
57059
  if (response.error) throw new EventTypesFlagError("Could not read the endpoint's current rules to keep them. Retry, or pass the full rules with --raw-body.");
55807
57060
  const row = (response.data?.data ?? []).find((endpoint) => endpoint.id === endpointId);
55808
57061
  if (!row) throw new EventTypesFlagError(`No endpoint ${endpointId} is visible to this credential, so its rules cannot be updated.`);
55809
- return isPlainObject$1(row.rules) ? row.rules : {};
57062
+ return isPlainObject(row.rules) ? row.rules : {};
55810
57063
  }
55811
57064
  /**
55812
57065
  * Put `eventTypes` in the request body's `rules.event_types`, on top of
55813
57066
  * `baseRules` (rules the caller passed in the body win over `baseRules`).
55814
57067
  */
55815
57068
  function withEventTypes(body, eventTypes, baseRules = {}) {
55816
- if (body !== void 0 && !isPlainObject$1(body)) throw new EventTypesFlagError("--raw-body must be a JSON object when also passing --event-types.");
57069
+ if (body !== void 0 && !isPlainObject(body)) throw new EventTypesFlagError("--raw-body must be a JSON object when also passing --event-types.");
55817
57070
  const current = body ?? {};
55818
- if (current.rules !== void 0 && !isPlainObject$1(current.rules)) throw new EventTypesFlagError("rules in --raw-body must be a JSON object when also passing --event-types.");
57071
+ if (current.rules !== void 0 && !isPlainObject(current.rules)) throw new EventTypesFlagError("rules in --raw-body must be a JSON object when also passing --event-types.");
55819
57072
  const explicitRules = current.rules ?? {};
55820
57073
  return {
55821
57074
  ...current,
@@ -55828,115 +57081,7 @@ function withEventTypes(body, eventTypes, baseRules = {}) {
55828
57081
  }
55829
57082
  /** True when the caller already passed `rules` in the request body. */
55830
57083
  function bodyHasRules(body) {
55831
- return isPlainObject$1(body) && body.rules !== void 0;
55832
- }
55833
- // src/oclif/endpoint-url-shown.ts
55834
- /** The commands whose answers carry endpoints, by operation sdkName. */
55835
- const ENDPOINT_URL_OPERATIONS = /* @__PURE__ */ new Set([
55836
- "getEndpoint",
55837
- "listEndpoints",
55838
- "createEndpoint",
55839
- "updateEndpoint"
55840
- ]);
55841
- /** The commands that send a URL, whose value is checked for the placeholder. */
55842
- const ENDPOINT_URL_WRITE_OPERATIONS = /* @__PURE__ */ new Set(["createEndpoint", "updateEndpoint"]);
55843
- /** What a hidden query string is replaced with. */
55844
- const HIDDEN_QUERY = "?... (query hidden)";
55845
- const SHOW_URL_FLAG_DESCRIPTION = "Print each webhook URL in full, its query string included. Without it the query string is shown as ?... (query hidden), with url_query_hidden: true on the endpoint, because it can carry a secret such as a deployment protection bypass token.";
55846
- /**
55847
- * Said when an answer had a URL shortened: on stderr without --json, and in
55848
- * the document's summary with --json --envelope.
55849
- */
55850
- const HIDDEN_QUERY_NOTE = "A webhook URL's query string is hidden, as it can carry a secret. Pass --show-url to print it in full.";
55851
- /**
55852
- * The URL with its query string, and anything after it, replaced by
55853
- * HIDDEN_QUERY; null when it has no query string. A `?` after a `#` is part
55854
- * of the fragment, not a query.
55855
- */
55856
- function urlWithQueryHidden(url) {
55857
- const query = url.indexOf("?");
55858
- if (query < 0) return null;
55859
- const fragment = url.indexOf("#");
55860
- if (fragment >= 0 && fragment < query) return null;
55861
- return `${url.slice(0, query)}${HIDDEN_QUERY}`;
55862
- }
55863
- function hideOne(endpoint) {
55864
- if (endpoint === null || typeof endpoint !== "object" || Array.isArray(endpoint)) return {
55865
- value: endpoint,
55866
- hidden: false
55867
- };
55868
- const url = endpoint.url;
55869
- const shown = typeof url === "string" ? urlWithQueryHidden(url) : null;
55870
- if (shown === null) return {
55871
- value: endpoint,
55872
- hidden: false
55873
- };
55874
- return {
55875
- value: {
55876
- ...endpoint,
55877
- url: shown,
55878
- url_query_hidden: true
55879
- },
55880
- hidden: true
55881
- };
55882
- }
55883
- /**
55884
- * An answer's data (one endpoint, or a list of them) with each URL's query
55885
- * string hidden, and whether any was.
55886
- */
55887
- function endpointsWithQueryHidden(data) {
55888
- if (!Array.isArray(data)) {
55889
- const one = hideOne(data);
55890
- return {
55891
- data: one.value,
55892
- hidden: one.hidden
55893
- };
55894
- }
55895
- let hidden = false;
55896
- return {
55897
- data: data.map((row) => {
55898
- const one = hideOne(row);
55899
- hidden ||= one.hidden;
55900
- return one.value;
55901
- }),
55902
- hidden
55903
- };
55904
- }
55905
- function isPlainObject(value) {
55906
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
55907
- const prototype = Object.getPrototypeOf(value);
55908
- return prototype === Object.prototype || prototype === null;
55909
- }
55910
- /** How deep errorWithQueryHidden looks into an error payload. */
55911
- const ERROR_DEPTH = 8;
55912
- /**
55913
- * An error answer with the query string hidden in every `url` it names, such
55914
- * as `details.holder.url` on a 409 for a slot another endpoint holds.
55915
- * Anything that is not a plain object or a list is left as it is.
55916
- */
55917
- function errorWithQueryHidden(payload, depth = 0) {
55918
- if (depth > ERROR_DEPTH) return payload;
55919
- if (Array.isArray(payload)) return payload.map((entry) => errorWithQueryHidden(entry, depth + 1));
55920
- if (!isPlainObject(payload)) return payload;
55921
- const out = {};
55922
- for (const [key, value] of Object.entries(payload)) out[key] = errorWithQueryHidden(value, depth + 1);
55923
- return hideOne(out).value;
55924
- }
55925
- /**
55926
- * A query string as a partial copy of HIDDEN_QUERY leaves it: a terminal's
55927
- * word selection stops at its first space, after `?...`.
55928
- */
55929
- const HIDDEN_QUERY_START = "?...";
55930
- /**
55931
- * The refusal for a request body whose url is a URL as these commands print
55932
- * it with the query hidden, whole or cut at its first space, so a printed URL
55933
- * is never written back in place of the real one; null for any other body.
55934
- */
55935
- function hiddenQueryUrlRefusal(body) {
55936
- if (body === null || typeof body !== "object" || Array.isArray(body)) return null;
55937
- const url = body.url;
55938
- if (typeof url !== "string" || !url.includes(HIDDEN_QUERY_START)) return null;
55939
- return `The url carries ${HIDDEN_QUERY_START}, the start of ${HIDDEN_QUERY}, which is how the endpoint commands print a URL with its query string hidden, not the URL itself. Pass the full URL; \`primitive endpoints get <id> --show-url\` prints a webhook's URL in full.`;
57084
+ return isPlainObject(body) && body.rules !== void 0;
55940
57085
  }
55941
57086
  // src/oclif/endpoints-test-redirect.ts
55942
57087
  async function detectFunctionEndpoint(endpointId, listEndpoints) {
@@ -56554,8 +57699,30 @@ function formatScheduledSummary(noun, sent, idempotencyKey) {
56554
57699
  const byKey = idempotencyKey ? ` or \`primitive sent cancel --idempotency-key ${shellQuote(idempotencyKey)}\`` : "";
56555
57700
  return `${noun} ${verb}${when} (id ${sent.id}). Nothing has gone out yet. Do not resend. To cancel it before then, run \`primitive sent cancel --id ${sent.id}\`${byKey}.`;
56556
57701
  }
56557
- function formatSendFailureSummary(noun, outcome, httpStatus) {
56558
- if (outcome === "not_sent") return `${noun} not sent: ${httpStatus === void 0 ? "the request failed before sending" : `the API rejected the request (HTTP ${httpStatus})`}. Nothing went out; fix the problem before retrying.`;
57702
+ /**
57703
+ * The API's own words for a refusal (`message` on its error), on one line and
57704
+ * ending in a full stop, or undefined when it gave none.
57705
+ */
57706
+ function sendErrorMessage(payload) {
57707
+ const message = payload !== null && typeof payload === "object" ? payload.message : void 0;
57708
+ if (typeof message !== "string") return void 0;
57709
+ const line = sanitizeForTerminal(message).replaceAll(/\s+/g, " ").trim();
57710
+ if (!line) return void 0;
57711
+ const cut = line.length > SEND_ERROR_MESSAGE_MAX ? `${line.slice(0, SEND_ERROR_MESSAGE_MAX - 3).trimEnd()}...` : line;
57712
+ return /[.!?]["')\]]*$/.test(cut) ? cut : `${cut}.`;
57713
+ }
57714
+ /** The longest API message the failure line repeats; the error itself follows in full. */
57715
+ const SEND_ERROR_MESSAGE_MAX = 300;
57716
+ /**
57717
+ * The one line that says a send failed. A refusal leads with what the API
57718
+ * said was wrong (`message`, from sendErrorMessage), so the first line read
57719
+ * names the problem rather than only its status.
57720
+ */
57721
+ function formatSendFailureSummary(noun, outcome, httpStatus, message) {
57722
+ if (outcome === "not_sent") {
57723
+ if (message) return `${noun} not sent${httpStatus === void 0 ? "" : ` (HTTP ${httpStatus})`}: ${message} Nothing went out; fix the problem before retrying.`;
57724
+ return `${noun} not sent: ${httpStatus === void 0 ? "the request failed before sending" : `the API rejected the request (HTTP ${httpStatus})`}. Nothing went out; fix the problem before retrying.`;
57725
+ }
56559
57726
  return `${noun} send outcome uncertain (${httpStatus === void 0 ? "no response from the API" : `HTTP ${httpStatus}`}): it may or may not have gone out. Do not resend blindly; check sent history first.`;
56560
57727
  }
56561
57728
  function priorRepliesThatWentOut(replies, options = {}) {
@@ -56825,11 +57992,11 @@ function reportSendCommandResult(params) {
56825
57992
  let errorPayload = null;
56826
57993
  if (params.result.error) {
56827
57994
  errorPayload = extractErrorPayload(params.result.error);
56828
- params.onApiError(errorPayload);
56829
57995
  const failure = classifySendError(httpStatus, errorPayload);
56830
57996
  outcome = failure;
56831
- outcomeMessage = failure === "already_sent" ? formatDeletedEarlierSendNotice() : formatSendFailureSummary(params.noun, failure, httpStatus);
57997
+ outcomeMessage = failure === "already_sent" ? formatDeletedEarlierSendNotice() : formatSendFailureSummary(params.noun, failure, httpStatus, sendErrorMessage(errorPayload));
56832
57998
  if (!params.json) params.writeStderr(`${outcomeMessage}\n`);
57999
+ params.onApiError(errorPayload);
56833
58000
  } else {
56834
58001
  sent = params.result.data?.data ?? null;
56835
58002
  if (sent === null) {
@@ -56893,7 +58060,7 @@ function buildThrownSendFailureEnvelope(params) {
56893
58060
  return {
56894
58061
  outcome,
56895
58062
  exit_code: params.requestStarted ? sendOutcomeExitCode("uncertain") : thrownErrorExitCode(params.error),
56896
- outcome_message: formatSendFailureSummary(params.noun, outcome, void 0),
58063
+ outcome_message: formatSendFailureSummary(params.noun, outcome, void 0, params.requestStarted ? void 0 : sendErrorMessage(thrownErrorBody(params.error))),
56897
58064
  ...sendIdentityFields({
56898
58065
  idempotencyKey: params.idempotencyKey,
56899
58066
  sent: null
@@ -57793,7 +58960,7 @@ function savedConnectedProfiles(configDir, exclude) {
57793
58960
  */
57794
58961
  async function otherProfiles(configDir, session, current) {
57795
58962
  if (session) try {
57796
- const { connectedProfilesForSession } = await import("./machine-session-DyGP7wDs.js").then((n) => n.s);
58963
+ const { connectedProfilesForSession } = await import("./machine-session-CSqj4DmF.js").then((n) => n.s);
57797
58964
  return {
57798
58965
  inSession: true,
57799
58966
  profiles: connectedProfilesForSession(configDir, session, current)
@@ -58299,10 +59466,19 @@ const API_ERROR_CODES = {
58299
59466
  forbidden: "forbidden",
58300
59467
  grantForbidden: "grant_forbidden",
58301
59468
  invalidDeviceCode: "invalid_device_code",
59469
+ keyRevoked: "key_revoked",
58302
59470
  notFound: "not_found",
58303
59471
  slowDown: "slow_down",
58304
59472
  unauthorized: "unauthorized"
58305
59473
  };
59474
+ /**
59475
+ * Whether an error code says the credential itself is not accepted: unknown
59476
+ * or invalid (`unauthorized`), or a full API key that was revoked
59477
+ * (`key_revoked`, which carries its own message and gets no sign-in hint).
59478
+ */
59479
+ function refusesCredential(code) {
59480
+ return code === API_ERROR_CODES.unauthorized || code === API_ERROR_CODES.keyRevoked;
59481
+ }
58306
59482
  function flagName(parameterName) {
58307
59483
  return parameterName.replace(/_/g, "-");
58308
59484
  }
@@ -58500,7 +59676,8 @@ function extractBodyFields(schema) {
58500
59676
  kind,
58501
59677
  ...enumValues && enumValues.length > 0 ? { enumValues } : {},
58502
59678
  ...typeof propSchema.maximum === "number" ? { maximum: propSchema.maximum } : {},
58503
- ...typeof propSchema.minimum === "number" ? { minimum: propSchema.minimum } : {}
59679
+ ...typeof propSchema.minimum === "number" ? { minimum: propSchema.minimum } : {},
59680
+ ...typeof propSchema.maxLength === "number" && propSchema.pattern === void 0 && propSchema.format === void 0 ? { maxLength: propSchema.maxLength } : {}
58504
59681
  });
58505
59682
  }
58506
59683
  return fields.sort((a, b) => {
@@ -58804,8 +59981,24 @@ function bodyFieldFlag(field, aliases) {
58804
59981
  ...common,
58805
59982
  options: field.enumValues
58806
59983
  });
58807
- return Flags.string(common);
59984
+ return Flags.string({
59985
+ ...common,
59986
+ description: withLengthLimit(field.description, field.maxLength) || field.name
59987
+ });
58808
59988
  }
59989
+ /**
59990
+ * A text flag's help with the most characters it takes, when the schema has
59991
+ * a limit its description does not already give so a long
59992
+ * message is cut to fit before it is written rather than refused after.
59993
+ */
59994
+ function withLengthLimit(description, max) {
59995
+ if (max === void 0 || SAYS_A_LIMIT.test(description)) return description;
59996
+ if (new RegExp(`\\b${max}\\b`).test(description)) return description;
59997
+ const limit = `At most ${max} characters.`;
59998
+ return description.trim() ? `${sentence(description)} ${limit}` : limit;
59999
+ }
60000
+ /** A description that already states a size limit of its own, in any unit. */
60001
+ const SAYS_A_LIMIT = /\b(?:up to|at most|no more than)\b|\b[KMG]i?B\b|\bbytes?\b/i;
58809
60002
  function buildFlags(operation) {
58810
60003
  const flags = {
58811
60004
  "api-key": Flags.string({
@@ -58838,7 +60031,7 @@ function buildFlags(operation) {
58838
60031
  const bodyFieldFlagToProperty = /* @__PURE__ */ new Map();
58839
60032
  if (operation.hasJsonBody) {
58840
60033
  flags["raw-body"] = Flags.string({ description: "Full request body as raw JSON. Escape hatch for nested or complex fields (e.g. arrays); prefer per-field flags (e.g. --to, --from, --body-text) when available." });
58841
- flags["body-file"] = Flags.string({ description: "Path to a JSON file used as the request body. Same role as --raw-body for callers passing a saved payload." });
60034
+ flags["body-file"] = Flags.string({ description: `Path to a JSON file used as the request body. Same role as --raw-body for callers passing a saved payload.${BODY_FILE_HELP[operation.sdkName] ? ` ${BODY_FILE_HELP[operation.sdkName]}` : ""}` });
58842
60035
  const bodyFields = extractBodyFields(operation.requestSchema);
58843
60036
  const aliasesForOperation = OPERATION_FLAG_ALIASES[operation.sdkName];
58844
60037
  for (const field of bodyFields) {
@@ -58884,10 +60077,6 @@ function buildFlags(operation) {
58884
60077
  multiple: true
58885
60078
  });
58886
60079
  if (operation.binaryResponse) flags.output = Flags.string({ description: "Write binary response bytes to a file" });
58887
- if (ENDPOINT_URL_OPERATIONS.has(operation.sdkName)) {
58888
- if (flags["show-url"] !== void 0) throw new Error(`${operation.sdkName}: --show-url is both a generated flag and the CLI's own`);
58889
- flags["show-url"] = Flags.boolean({ description: SHOW_URL_FLAG_DESCRIPTION });
58890
- }
58891
60080
  if (ATTACHMENT_WAIT_OPERATIONS.has(operation.sdkName)) flags.wait = Flags.boolean({
58892
60081
  allowNo: true,
58893
60082
  default: true,
@@ -58983,13 +60172,41 @@ const OPERATION_HINTS = {
58983
60172
  getMemory: "Tip: prefer `primitive memories get <key> [--function <function-id>]` for the common read path.",
58984
60173
  deleteMemory: "Tip: prefer `primitive memories delete <key> [--function <function-id>]` for the common delete path.",
58985
60174
  searchMemories: "Tip: prefer `primitive memories search [prefix] [--metadata-only] [--function <function-id>]` for the common search path.",
58986
- createEmailRuleObjection: "Tip: say in --message (up to 500 characters) what you want. It can ask for less than turning the rule off: ask the author to narrow the rule, or to explain where its matches go (its receivers). The author accepts, which turns the rule off, or declines, optionally giving a reason, which you see in `primitive email-rule-oversight get-email-rule-objection <objection-id>`. You can withdraw it with `primitive email-rule-oversight withdraw-email-rule-objection <objection-id>`. Objecting does not change the rule.",
58987
- declineEmailRuleObjection: "Tip: the member who objected sees --reason (up to 500 characters). When the objection asked you to narrow the rule or explain a receiver, the reason can answer that: say what you changed, or what the receiver is for.",
60175
+ listEmails: "Tip: for a one-line-per-email table, `primitive emails latest --limit 100`.",
60176
+ createEmailRuleObjection: "Tip: say in --message (up to 500 characters) what you want. It can ask for less than turning the rule off: ask the author to narrow the rule, or to explain where its matches go (its receivers). The author accepts, which turns the rule off; declines, optionally giving a reason; or answers amended once they have saved a new version of the rule, optionally with a note. You see the answer in `primitive email-rule-oversight get-email-rule-objection <objection-id>`. You can withdraw it with `primitive email-rule-oversight withdraw-email-rule-objection <objection-id>`. Objecting does not change the rule.",
60177
+ declineEmailRuleObjection: "Tip: the member who objected sees --reason (up to 500 characters). When the objection asked you to explain a receiver, the reason can say what the receiver is for. If you changed the rule instead of turning it off, do not decline: save the new version with `primitive email-rules update-email-rule`, then answer with `primitive email-rule-oversight amend-email-rule-objection <objection-id>`.",
60178
+ amendEmailRuleObjection: "Tip: save the new version first with `primitive email-rules update-email-rule`; until the rule's version is newer than when the objection was made, this answers 409 no_new_version. The member who objected sees --note (up to 500 characters) and both version numbers.",
58988
60179
  listEndpoints: "Tip: without --json, a table on stderr after the JSON shows each endpoint's ENABLED and DELIVERING. DELIVERING is read from delivery.delivering, whether a webhook is being sent mail at all, not from enabled: an endpoint can be enabled and still not be delivering (its owner's key revoked, say), shown as no with the reason codes in parentheses. A webhook whose delivery could not be checked shows unknown, and a Function or pull endpoint shows -.",
58989
60180
  startAgentSignup: "Tip: pass --terms-accepted. Capture the signup_token from the response and feed it to `primitive agent verify-agent-signup --signup-token <token> --verification-code <6-digit-code>` (the verify flag accepts --code as an alias). The high-level `primitive signup <email>` command walks an interactive user through both steps with friendlier prompts.",
58990
60181
  testEmailRule: "Tip: --expect-match and --expect-no-match (or --expect-file) set expect, the emails the rule must match and must not. When no expect is sent, by these flags or in the body, a saved rule's saved expectations are judged instead. Either way, the answer reports the expectations it judged in expectations: passed, counts and per-email results. (create-email-rule and update-email-rule instead judge the rule's saved expectations on the version they save, in expectations_check: passed, decided, failed and undecided.) The exit code follows that report: 1 when one failed; 1 when one is undecided and testing again will not decide it (its email cannot be found or read, cannot be classified, or cannot be tested: skipped); 3 when the only undecided ones can be decided later (not classified yet, or a question unanswered), so test again later. Exit 1 also means the request failed. With --json, error.code tells these apart: expectations_failed, expectations_unresolvable, expectations_undecided (exit 3), or the API's own code. Without --json a readable report follows the JSON on stderr: warnings, how each condition held, the expectations, and the values each email that did not match was compared on.",
58991
60182
  verifyAgentSignup: "Tip: pass --verification-code <code> (or --code; both work). The response carries OAuth tokens but not your assigned inbox domain; run `primitive domains list` (or `primitive whoami`) after success to see the managed *.primitive.email address that routes to this account."
58992
60183
  };
60184
+ /**
60185
+ * A top-level text field of `body` longer than the spec's maxLength for it,
60186
+ * said as a refusal, or undefined. Counted after trimming the ends, by code
60187
+ * point, which is never more than the API counts, so nothing the API would
60188
+ * take is refused here; a message over the limit is refused before it is
60189
+ * sent rather than by the API after typing it.
60190
+ */
60191
+ function overLongBodyField(schema, body) {
60192
+ if (body === null || typeof body !== "object" || Array.isArray(body)) return void 0;
60193
+ const properties = schema?.properties;
60194
+ if (!properties) return void 0;
60195
+ for (const [field, value] of Object.entries(body)) {
60196
+ const max = properties[field]?.maxLength;
60197
+ if (typeof value !== "string" || typeof max !== "number") continue;
60198
+ const length = Array.from(value.trim()).length;
60199
+ if (length > max) return `${field} is ${length} characters; the API takes at most ${max}. Nothing was sent.`;
60200
+ }
60201
+ }
60202
+ /** What a write that takes a compile answer reads from --body-file, said beside the generic help. */
60203
+ const COMPILE_ANSWER = "the answer `compile-email-rule --json` printed (without --include-sql), unchanged: save it to a file";
60204
+ const BODY_FILE_HELP = {
60205
+ createEmailRule: `For this command, ${COMPILE_ANSWER}, and add --english with the description you compiled, and --name. The answer carries no scope: pass --evaluation-scope again if you compiled with one.`,
60206
+ updateEmailRule: `For a new version, ${COMPILE_ANSWER}, and add --english with the description you compiled (required with a new tree); --name only to rename it.`,
60207
+ createEmailRuleRequest: `For this command, ${COMPILE_ANSWER}, and add --english with the description you compiled, --name and --target-email.`,
60208
+ acceptEmailRuleRequest: `To change the rule as you accept it, ${COMPILE_ANSWER}, and add --english with the description you compiled.`
60209
+ };
58993
60210
  const OPERATION_FLAG_ALIASES = { verifyAgentSignup: { verification_code: ["code"] } };
58994
60211
  const OPERATION_EXTRA_BODY_FLAGS = { addDomain: { "mail-relay": {
58995
60212
  property: "mail_relay",
@@ -59075,13 +60292,6 @@ function createOperationCommand(operation) {
59075
60292
  "verifyAgentSignup",
59076
60293
  "resendAgentSignupVerification"
59077
60294
  ].includes(operation.operationId)) requireDefaultLoginProfile();
59078
- const prereadBody = ENDPOINT_URL_WRITE_OPERATIONS.has(operation.sdkName) && operation.hasJsonBody ? { value: readJsonBody(parsedFlags) } : void 0;
59079
- if (prereadBody) {
59080
- const urlFlag = [...bodyFieldFlagToProperty].find(([, property]) => property === "url")?.[0];
59081
- const flagUrl = urlFlag ? parsedFlags[urlFlag] : void 0;
59082
- const refusal = hiddenQueryUrlRefusal(typeof flagUrl === "string" ? { url: flagUrl } : prereadBody.value);
59083
- if (refusal) throw new Errors.CLIError(refusal, { exit: 2 });
59084
- }
59085
60295
  await runWithTiming(parsedFlags.time === true, async () => {
59086
60296
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
59087
60297
  apiKey: typeof parsedFlags["api-key"] === "string" ? parsedFlags["api-key"] : void 0,
@@ -59090,7 +60300,7 @@ function createOperationCommand(operation) {
59090
60300
  });
59091
60301
  let body;
59092
60302
  if (operation.hasJsonBody) {
59093
- const explicit = prereadBody ? prereadBody.value : readJsonBody(parsedFlags);
60303
+ const explicit = readJsonBody(parsedFlags);
59094
60304
  const overrides = collectBodyFieldFlags(parsedFlags, bodyFieldFlagToProperty);
59095
60305
  const extensionFlagFor = /* @__PURE__ */ new Map();
59096
60306
  for (const field of extension?.bodyFields?.(parsedFlags, explicit) ?? []) {
@@ -59110,10 +60320,6 @@ function createOperationCommand(operation) {
59110
60320
  }
59111
60321
  } else body = explicit;
59112
60322
  }
59113
- if (ENDPOINT_URL_WRITE_OPERATIONS.has(operation.sdkName)) {
59114
- const refusal = hiddenQueryUrlRefusal(body);
59115
- if (refusal) throw new Errors.CLIError(refusal, { exit: 2 });
59116
- }
59117
60323
  if (EVENT_TYPES_FLAG_OPERATIONS.has(operation.sdkName) && Array.isArray(parsedFlags["event-types"])) body = await applyEventTypesFlag({
59118
60324
  body,
59119
60325
  values: parsedFlags["event-types"],
@@ -59125,6 +60331,8 @@ function createOperationCommand(operation) {
59125
60331
  quiet: parsedFlags.json === true
59126
60332
  });
59127
60333
  if (operation.bodyRequired && body === void 0) throw new Errors.CLIError(`Operation ${operation.operationId} requires a body. Pass each field as a --flag (see --help) or supply JSON via --raw-body / --body-file.`);
60334
+ const tooLong = overLongBodyField(operation.requestSchema, body);
60335
+ if (tooLong) throw new Errors.CLIError(tooLong, { exit: 2 });
59128
60336
  const operationFn = sdk_gen_exports[operation.sdkName];
59129
60337
  const query = collectValues(operation.queryParams, parsedFlags, operation.sdkName);
59130
60338
  const replyStateSurface = replyStateSurfaceForOperation(operation.sdkName, query);
@@ -59233,7 +60441,7 @@ function createOperationCommand(operation) {
59233
60441
  if (result.error) {
59234
60442
  const errorPayload = extractErrorPayload(result.error);
59235
60443
  const operationErrorHint = OPERATION_ERROR_HINTS[operation.sdkName]?.(extractErrorCode(errorPayload), body, errorPayload, collectValues(operation.pathParams, parsedFlags, operation.sdkName), parsedFlags);
59236
- writeErrorWithHints(ENDPOINT_URL_OPERATIONS.has(operation.sdkName) && parsedFlags["show-url"] !== true ? errorWithQueryHidden(errorPayload) : errorPayload, result.response, { codeHint: !(operationErrorHint && OPERATION_ERROR_HINTS_REPLACING_CODE_HINT.has(operation.sdkName)) });
60444
+ writeErrorWithHints(errorPayload, result.response, { codeHint: !(operationErrorHint && OPERATION_ERROR_HINTS_REPLACING_CODE_HINT.has(operation.sdkName)) });
59237
60445
  if (operationErrorHint) process.stderr.write(`${operationErrorHint}\n`);
59238
60446
  if (stepUpUrl) process.stderr.write(approveThenRerunHint(stepUpUrl));
59239
60447
  if (replyStateSurface && isAwaitingRejectedError(errorPayload)) process.stderr.write(`${awaitingRejectedError(replyStateSurface).message}\n`);
@@ -59381,26 +60589,19 @@ function createOperationCommand(operation) {
59381
60589
  }
59382
60590
  };
59383
60591
  }
59384
- let shownEnvelope = envelope;
59385
- let queryHidden = false;
59386
- if (ENDPOINT_URL_OPERATIONS.has(operation.sdkName) && parsedFlags["show-url"] !== true && envelope) {
59387
- const shown = endpointsWithQueryHidden(envelope.data);
59388
- if (shown.hidden) {
59389
- shownEnvelope = {
59390
- ...envelope,
59391
- data: shown.data
59392
- };
59393
- queryHidden = true;
59394
- if (jsonOutput && withEnvelope) summary.push(HIDDEN_QUERY_NOTE);
59395
- }
59396
- }
59397
- let printed = jsonOutput && withEnvelope ? operationJsonDocument(shownEnvelope, summary) : operationOutputPayload(shownEnvelope, withEnvelope);
60592
+ let printed = jsonOutput && withEnvelope ? operationJsonDocument(envelope, summary) : operationOutputPayload(envelope, withEnvelope);
59398
60593
  if (jsonOutput && report?.exitCode && report.error && printed !== null && typeof printed === "object" && !Array.isArray(printed)) printed = {
59399
60594
  ...printed,
59400
60595
  error: report.error
59401
60596
  };
60597
+ if (jsonOutput && report?.json && printed !== null && typeof printed === "object" && !Array.isArray(printed)) {
60598
+ const answer = printed;
60599
+ printed = {
60600
+ ...answer,
60601
+ ...Object.fromEntries(Object.entries(report.json).filter(([key]) => !Object.hasOwn(answer, key)))
60602
+ };
60603
+ }
59402
60604
  this.log(JSON.stringify(printed, null, 2));
59403
- if (queryHidden && !jsonOutput) process.stderr.write(`${HIDDEN_QUERY_NOTE}\n`);
59404
60605
  if (reportError !== void 0) process.stderr.write(`Warning: ${operation.sdkName} succeeded but its report could not be built (${reportError}). The JSON above is the full answer; read it rather than the exit code.\n`);
59405
60606
  if (report && !jsonOutput) for (const line of report.lines) process.stderr.write(`${line}\n`);
59406
60607
  if (reportError !== void 0 && report?.exitCode && !jsonOutput) process.stderr.write(`The answer's expectations were not all shown to pass, so the command exits ${report.exitCode}.\n`);
@@ -59434,4 +60635,4 @@ function emptyDeliveriesHint(sdkName, query) {
59434
60635
  function canonicalizeCliReferences(description) {
59435
60636
  return description.replaceAll("`primitive emails:latest`", "`primitive emails latest`").replaceAll("`primitive describe emails:get-email | jq '.responseSchema.properties'`", "`primitive describe emails:get | jq '.responseSchema.properties'`");
59436
60637
  }
59437
- export { interactionNextActions as $, ConnectedAgentKeyRequiredError as $t, openBrowser as A, DEFAULT_ENROLL_NAME as At, serverRelationship as B, runtimeSessionVariableList as Bt, approveThenRerunHint as C, sendIdentityFields as Ct, canOfferCopyHotkey as D, serializeErrorPayload as Dt, withApproval as E, sentHistoryWindowStart as Et, formatMailWakeLine as F, identitySuggestions as Ft, claimPendingMail as G, readCallerMailFor as Gt, wakeReadCommand as H, withFlagSuggestion as Ht, latestOwnOutbound as I, loadSkillLine as It, pendingMailPath as J, isEmailId as Jt, clearConsumedPendingMail as K, classificationFactLines as Kt, readThreadContext as L, currentMailSessionKey as Lt, bareAddress$1 as M, connectNextSteps as Mt, describeWake as N, defaultConnectionName as Nt, formatBrowserLoginInstructions as O, successfulSendOutcome as Ot, displayAddress as P, generatedAgentName as Pt, interactionHumanLine as Q, withAttachmentWait as Qt, sentInThread as R, detectAgentRuntime as Rt, STEP_UP_TOKEN_FLAG_DESCRIPTION as S, reportSendCommandResult as St, terminalApprovalIo as T, sendWaitClampNotice as Tt, wakeRecipientField as U, emptyEmailListHint as Ut, skillFirstLine as V, formatAlreadySentNotice as Vt, wakeRelationship as W, mailReach as Wt, recordPendingMail as X, ATTACHMENT_WAIT_FLAG_DESCRIPTION as Xt, readPendingMail as Y, noFactsMessage as Yt, removePendingMail as Z, ATTACHMENT_WAIT_MAX_MS as Zt, surfaceUnauthorizedHint as _, sanitizeForTerminal as _n, formatPriorRepliesCheckSkipped as _t, createOperationCommand as a, resolveCliApiRequestConfig as an, MAX_SEND_WAIT_TIMEOUT_MS as at, BROWSER_FLAG_DESCRIPTION as b, formatSendRecordFailureSummary as bt, formatErrorPayload as c, RESTRICTED_ROLE_NOTE as cn, assertValidIdempotencyKey as ct, isGrantRefusal as d, isBuiltInRoleKey as dn, checkPriorReplies as dt, SAVED_CLI_OAUTH_SESSION_EXPIRED_MESSAGE as en, readEmailInteraction as et, networkErrorHint as f, revokeUserLogin as fn, classifySendError as ft, runWithTiming as g, routeWarningLines as gn, formatDeletedEarlierSendNotice as gt, refusalDetails as h, switchCurrentOrg as hn, followUpCommandPrefix as ht, TIME_FLAG_DESCRIPTION as i, refuseOrgSelectionForProfile as in, IDEMPOTENCY_KEY_FLAG_DESCRIPTION as it, explainPendingMailNotFound as j, cliInvocation as jt, listenForCopyHotkey as k, thrownErrorExitCode as kt, hasControlCharacter as l, credentialsFromUserLogin as ln, buildFollowUpCommand as lt, readTextFileFlag as m, roleKeyText as mn, excludeSignalReplies as mt, API_ERROR_CODES as n, createCliApiClient as nn, replyInteractionWarning as nt, extractErrorCode as o, selectedOrgFromEnv as on, SEND_OUTCOME_HELP as ot, parameterFlagName as p, roleKeyLabel as pn, deriveSendIdempotencyKey as pt, clearReadPendingMail as q, classificationOf as qt, OPERATION_PATH_FLAGS as r, refreshStoredCliCredentials as rn, wakeInteractionSentence as rt, extractErrorPayload as s, CliOrgRefusedError as sn, apiResultHttpStatus as st, API_BASE_URL_FLAG_DESCRIPTION as t, createAuthenticatedCliApiClient as tn, replyExpectation as tt, headerFlagName as u, fetchCliOrgs as un, buildThrownSendFailureEnvelope as ut, takesStepUp as v, setKnownCommands as vn, formatPriorRepliesWarning as vt, promptLine as w, sendOutcomeExitCode as wt, STEP_UP_HEADER as x, priorRepliesThatWentOut as xt, writeErrorWithHints as y, operationManifest as yn, formatSendFailureSummary as yt, serverMuted as z, detectRuntimeSession as zt };
60638
+ export { interactionHumanLine as $, ATTACHMENT_WAIT_MAX_MS as $t, listenForCopyHotkey as A, successfulSendOutcome as At, serverMuted as B, detectAgentRuntime as Bt, STEP_UP_TOKEN_FLAG_DESCRIPTION as C, reportSendCommandResult as Ct, withApproval as D, sendWaitClampNotice as Dt, terminalApprovalIo as E, sendOutcomeExitCode as Et, displayAddress as F, defaultConnectionName as Ft, wakeRelationship as G, emptyEmailListHint as Gt, skillFirstLine as H, runtimeSessionVariableList as Ht, formatMailWakeLine as I, generatedAgentName as It, clearReadPendingMail as J, classificationFactLines as Jt, claimPendingMail as K, mailReach as Kt, latestOwnOutbound as L, identitySuggestions as Lt, explainPendingMailNotFound as M, DEFAULT_ENROLL_NAME as Mt, bareAddress$1 as N, cliInvocation as Nt, canOfferCopyHotkey as O, sentHistoryWindowStart as Ot, describeWake as P, connectNextSteps as Pt, removePendingMail as Q, ATTACHMENT_WAIT_FLAG_DESCRIPTION as Qt, readThreadContext as R, loadSkillLine as Rt, STEP_UP_HEADER as S, priorRepliesThatWentOut as St, promptLine as T, sendIdentityFields as Tt, wakeReadCommand as U, formatAlreadySentNotice as Ut, serverRelationship as V, detectRuntimeSession as Vt, wakeRecipientField as W, withFlagSuggestion as Wt, readPendingMail as X, isEmailId as Xt, pendingMailPath as Y, classificationOf as Yt, recordPendingMail as Z, noFactsMessage as Zt, runWithTiming as _, switchCurrentOrg as _n, formatDeletedEarlierSendNotice as _t, createOperationCommand as a, refreshStoredCliCredentials as an, IDEMPOTENCY_KEY_FLAG_DESCRIPTION as at, writeErrorWithHints as b, setKnownCommands as bn, formatSendFailureSummary as bt, formatErrorPayload as c, selectedOrgFromEnv as cn, apiResultHttpStatus as ct, isGrantRefusal as d, credentialsFromUserLogin as dn, buildThrownSendFailureEnvelope as dt, withAttachmentWait as en, interactionNextActions as et, networkErrorHint as f, fetchCliOrgs as fn, checkPriorReplies as ft, refusesCredential as g, roleKeyText as gn, followUpCommandPrefix as gt, refusalDetails as h, roleKeyLabel as hn, excludeSignalReplies as ht, TIME_FLAG_DESCRIPTION as i, createCliApiClient as in, wakeInteractionSentence as it, openBrowser as j, thrownErrorExitCode as jt, formatBrowserLoginInstructions as k, serializeErrorPayload as kt, hasControlCharacter as l, CliOrgRefusedError as ln, assertValidIdempotencyKey as lt, readTextFileFlag as m, revokeUserLogin as mn, deriveSendIdempotencyKey as mt, API_ERROR_CODES as n, SAVED_CLI_OAUTH_SESSION_EXPIRED_MESSAGE as nn, replyExpectation as nt, extractErrorCode as o, refuseOrgSelectionForProfile as on, MAX_SEND_WAIT_TIMEOUT_MS as ot, parameterFlagName as p, isBuiltInRoleKey as pn, classifySendError as pt, clearConsumedPendingMail as q, readCallerMailFor as qt, OPERATION_PATH_FLAGS as r, createAuthenticatedCliApiClient as rn, replyInteractionWarning as rt, extractErrorPayload as s, resolveCliApiRequestConfig as sn, SEND_OUTCOME_HELP as st, API_BASE_URL_FLAG_DESCRIPTION as t, ConnectedAgentKeyRequiredError as tn, readEmailInteraction as tt, headerFlagName as u, RESTRICTED_ROLE_NOTE as un, buildFollowUpCommand as ut, surfaceUnauthorizedHint as v, routeWarningLines as vn, formatPriorRepliesCheckSkipped as vt, approveThenRerunHint as w, sendErrorMessage as wt, BROWSER_FLAG_DESCRIPTION as x, operationManifest as xn, formatSendRecordFailureSummary as xt, takesStepUp as y, sanitizeForTerminal as yn, formatPriorRepliesWarning as yt, sentInThread as z, currentMailSessionKey as zt };