primcli 3.0.0-preview.21 → 3.0.0-preview.22

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,9 +1,9 @@
1
- import { $t as getThread, Bt as getEndpoint, C as parseRetryAfter, H as assertAwaitingFilterRows, J as isAwaitingRejectedError, U as awaitingRejectedError, V as ReplyStateUnsupportedError, Vn as sdk_gen_exports, W as ensureSearchReportsReplyState, X as replyStateSurfaceForOperation, Yt as getOwnGrant, at as expectedAutomatedVerdicts, et as AutomatedFilterUnsupportedError, it as ensureSearchReportsAutomated, nt as automatedRejectedError, pn as listEndpoints, rt as automatedSurfaceForOperation, st as isAutomatedRejectedError, tt as assertAutomatedVerdict, un as listDomains, zt as getEmail } from "./repeats-Dj_o6c-X-CraZzs4t.js";
2
- import { i as canonicalCommandId, n as canonicalBodyFlagName, r as canonicalCliText } from "./cli-command-names-BYbYdipl.js";
1
+ import { $t as getThread, Bt as getEndpoint, C as parseRetryAfter, H as assertAwaitingFilterRows, J as isAwaitingRejectedError, U as awaitingRejectedError, V as ReplyStateUnsupportedError, Vn as sdk_gen_exports, W as ensureSearchReportsReplyState, X as replyStateSurfaceForOperation, Yt as getOwnGrant, at as expectedAutomatedVerdicts, et as AutomatedFilterUnsupportedError, it as ensureSearchReportsAutomated, nt as automatedRejectedError, pn as listEndpoints, rt as automatedSurfaceForOperation, st as isAutomatedRejectedError, tt as assertAutomatedVerdict, un as listDomains, zt as getEmail } from "./repeats-Dj_o6c-X-x61TNLz-.js";
2
+ import { a as canonicalCommandId, i as canonicalCliText, r as canonicalBodyFlagName } from "./cli-command-names-DteMqL-H.js";
3
3
  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";
4
4
  import "./oclif/global-org-flag.js";
5
5
  import { a as assertRequiredBodyFields, i as operationHelpInputs } from "./help-inputs-NGARVZL_.js";
6
- import { a as thrownErrorBody } from "./json-output-xgN0ZLWP.js";
6
+ import { o as thrownErrorBody } from "./json-output-BMZrLH47.js";
7
7
  import { d as readMailJson, h as writeMailJson, m as withMailLock, p as syncMailDirectory, u as privateMailPermissions } from "./shared-mail-files-BAQSGxxz.js";
8
8
  import { a as writeRetryIdNotice, n as rememberRetryIds, r as retryIdFields, t as prepareRetryIds } from "./retry-ids-04ZPJCZY.js";
9
9
  import { Args, Command, Errors, Flags } from "@oclif/core";
@@ -9469,7 +9469,7 @@ const operationManifest = [
9469
9469
  "items": { "type": "string" }
9470
9470
  },
9471
9471
  "rules": {
9472
- "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.",
9472
+ "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; its rule's own id is refused (403 grant_forbidden, details.reason rule_shared_with_you, with the share in details.share_id) unless you could put the rule itself on a key.",
9473
9473
  "maxItems": 20,
9474
9474
  "type": "array",
9475
9475
  "items": { "type": "string" }
@@ -11342,7 +11342,7 @@ const operationManifest = [
11342
11342
  "items": { "type": "string" }
11343
11343
  },
11344
11344
  "rules": {
11345
- "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.",
11345
+ "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; its rule's own id is refused (403 grant_forbidden, details.reason rule_shared_with_you, with the share in details.share_id) unless you could put the rule itself on a key.",
11346
11346
  "maxItems": 20,
11347
11347
  "type": "array",
11348
11348
  "items": { "type": "string" }
@@ -14952,6 +14952,29 @@ const operationManifest = [
14952
14952
  "type": ["string", "null"],
14953
14953
  "format": "date-time",
14954
14954
  "description": "When the email arrived. Null, with from_address, subject and recipient, when you are not shown the email (it awaits sender authentication)."
14955
+ },
14956
+ "attachments": {
14957
+ "type": ["array", "null"],
14958
+ "items": {
14959
+ "type": "object",
14960
+ "properties": {
14961
+ "name": {
14962
+ "type": "string",
14963
+ "description": "The file name the email gives it, cut at 255 characters."
14964
+ },
14965
+ "description": {
14966
+ "description": "The one-line description read from the file where the organization has attachment reading on, as GET /v1/emails/{id} gives it; null when none was read, it could not be read, reading is off, or you cannot open the email yourself.",
14967
+ "type": ["string", "null"]
14968
+ }
14969
+ },
14970
+ "required": ["name", "description"]
14971
+ },
14972
+ "description": "The email's named attachments, in order, at most 10 (attachment_count counts them all). An empty list means the email has none. Null when you cannot read the email's content (withheld, awaiting sender authentication, not parsed yet, failed to parse, or discarded), or are not shown the email: then whether it has any is not known to you. A part with no file name is not listed or counted."
14973
+ },
14974
+ "attachment_count": {
14975
+ "type": ["integer", "null"],
14976
+ "minimum": 0,
14977
+ "description": "How many named attachments the email has in all, listed or not. Null exactly when attachments is."
14955
14978
  }
14956
14979
  },
14957
14980
  "required": [
@@ -14967,7 +14990,9 @@ const operationManifest = [
14967
14990
  "from_address",
14968
14991
  "subject",
14969
14992
  "recipient",
14970
- "received_at"
14993
+ "received_at",
14994
+ "attachments",
14995
+ "attachment_count"
14971
14996
  ]
14972
14997
  }
14973
14998
  },
@@ -16437,7 +16462,7 @@ const operationManifest = [
16437
16462
  "rule_id": {
16438
16463
  "type": ["string", "null"],
16439
16464
  "format": "uuid",
16440
- "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."
16465
+ "description": "The rule itself, given with rule: to the member sharing their mail, and while the share is live to anyone shown the rule, the member it is shared with included. Null otherwise, and for a deleted rule. It names the rule in webhook deliveries (email.analysis.understanding.rules[].id) and in GET /v1/emails/{id} shared_through; it opens none of the rule routes to someone who is not its author. The member it is shared with lists this share's id, not the rule's, in a key's grant.rules (from the dashboard), and their own webhooks receive what it shares."
16441
16466
  }
16442
16467
  },
16443
16468
  "required": [
@@ -17894,7 +17919,7 @@ const operationManifest = [
17894
17919
  },
17895
17920
  "accepted_english": {
17896
17921
  "default": null,
17897
- "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise, and from a core-api release that predates the field. (The accepted English can match english when only the tree changed.)",
17922
+ "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise. Older responses may omit this field. (The accepted English can match english when only the tree changed.)",
17898
17923
  "type": ["string", "null"]
17899
17924
  },
17900
17925
  "existing": {
@@ -18110,7 +18135,7 @@ const operationManifest = [
18110
18135
  },
18111
18136
  "accepted_english": {
18112
18137
  "default": null,
18113
- "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise, and from a core-api release that predates the field. (The accepted English can match english when only the tree changed.)",
18138
+ "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise. Older responses may omit this field. (The accepted English can match english when only the tree changed.)",
18114
18139
  "type": ["string", "null"]
18115
18140
  }
18116
18141
  },
@@ -19380,7 +19405,7 @@ const operationManifest = [
19380
19405
  },
19381
19406
  "accepted_english": {
19382
19407
  "default": null,
19383
- "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise, and from a core-api release that predates the field. (The accepted English can match english when only the tree changed.)",
19408
+ "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise. Older responses may omit this field. (The accepted English can match english when only the tree changed.)",
19384
19409
  "type": ["string", "null"]
19385
19410
  }
19386
19411
  },
@@ -19744,7 +19769,7 @@ const operationManifest = [
19744
19769
  "rule_id": {
19745
19770
  "type": ["string", "null"],
19746
19771
  "format": "uuid",
19747
- "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."
19772
+ "description": "The rule itself, given with rule: to the member sharing their mail, and while the share is live to anyone shown the rule, the member it is shared with included. Null otherwise, and for a deleted rule. It names the rule in webhook deliveries (email.analysis.understanding.rules[].id) and in GET /v1/emails/{id} shared_through; it opens none of the rule routes to someone who is not its author. The member it is shared with lists this share's id, not the rule's, in a key's grant.rules (from the dashboard), and their own webhooks receive what it shares."
19748
19773
  }
19749
19774
  },
19750
19775
  "required": [
@@ -20088,6 +20113,29 @@ const operationManifest = [
20088
20113
  "type": ["string", "null"],
20089
20114
  "format": "date-time",
20090
20115
  "description": "When the decided email arrived. Null, with from_address, subject and recipient, when you are not shown the email (it awaits sender authentication)."
20116
+ },
20117
+ "attachments": {
20118
+ "type": ["array", "null"],
20119
+ "items": {
20120
+ "type": "object",
20121
+ "properties": {
20122
+ "name": {
20123
+ "type": "string",
20124
+ "description": "The file name the email gives it, cut at 255 characters."
20125
+ },
20126
+ "description": {
20127
+ "description": "The one-line description read from the file where the organization has attachment reading on, as GET /v1/emails/{id} gives it; null when none was read, it could not be read, reading is off, or you cannot open the email yourself.",
20128
+ "type": ["string", "null"]
20129
+ }
20130
+ },
20131
+ "required": ["name", "description"]
20132
+ },
20133
+ "description": "The email's named attachments, in order, at most 10 (attachment_count counts them all). An empty list means the email has none. Null when you cannot read the email's content (withheld, awaiting sender authentication, not parsed yet, failed to parse, or discarded), or are not shown the email: then whether it has any is not known to you. A part with no file name is not listed or counted."
20134
+ },
20135
+ "attachment_count": {
20136
+ "type": ["integer", "null"],
20137
+ "minimum": 0,
20138
+ "description": "How many named attachments the email has in all, listed or not. Null exactly when attachments is."
20091
20139
  }
20092
20140
  },
20093
20141
  "required": [
@@ -20103,7 +20151,9 @@ const operationManifest = [
20103
20151
  "from_address",
20104
20152
  "subject",
20105
20153
  "recipient",
20106
- "received_at"
20154
+ "received_at",
20155
+ "attachments",
20156
+ "attachment_count"
20107
20157
  ]
20108
20158
  }
20109
20159
  },
@@ -20314,7 +20364,7 @@ const operationManifest = [
20314
20364
  },
20315
20365
  "accepted_english": {
20316
20366
  "default": null,
20317
- "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise, and from a core-api release that predates the field. (The accepted English can match english when only the tree changed.)",
20367
+ "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise. Older responses may omit this field. (The accepted English can match english when only the tree changed.)",
20318
20368
  "type": ["string", "null"]
20319
20369
  }
20320
20370
  },
@@ -20371,6 +20421,29 @@ const operationManifest = [
20371
20421
  "responseSchema": {
20372
20422
  "type": "object",
20373
20423
  "properties": {
20424
+ "attachments": {
20425
+ "type": ["array", "null"],
20426
+ "items": {
20427
+ "type": "object",
20428
+ "properties": {
20429
+ "name": {
20430
+ "type": "string",
20431
+ "description": "The file name the email gives it, cut at 255 characters."
20432
+ },
20433
+ "description": {
20434
+ "description": "The one-line description read from the file where the organization has attachment reading on, as GET /v1/emails/{id} gives it; null when none was read, it could not be read, reading is off, or you cannot open the email yourself.",
20435
+ "type": ["string", "null"]
20436
+ }
20437
+ },
20438
+ "required": ["name", "description"]
20439
+ },
20440
+ "description": "The email's named attachments, in order, at most 10 (attachment_count counts them all), each with its one-line description where one was read: the email every rule here decided on, so given once rather than on each rule. An empty list means it has none. Null when its content cannot be read (withheld, awaiting sender authentication, not parsed yet, failed to parse, or discarded): then whether it has any is not known to you."
20441
+ },
20442
+ "attachment_count": {
20443
+ "type": ["integer", "null"],
20444
+ "minimum": 0,
20445
+ "description": "How many named attachments the email has in all, listed or not. Null exactly when attachments is."
20446
+ },
20374
20447
  "rules": {
20375
20448
  "type": "array",
20376
20449
  "items": {
@@ -20733,6 +20806,8 @@ const operationManifest = [
20733
20806
  }
20734
20807
  },
20735
20808
  "required": [
20809
+ "attachments",
20810
+ "attachment_count",
20736
20811
  "rules",
20737
20812
  "hidden",
20738
20813
  "not_listed"
@@ -21413,7 +21488,7 @@ const operationManifest = [
21413
21488
  "rule_id": {
21414
21489
  "type": ["string", "null"],
21415
21490
  "format": "uuid",
21416
- "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."
21491
+ "description": "The rule itself, given with rule: to the member sharing their mail, and while the share is live to anyone shown the rule, the member it is shared with included. Null otherwise, and for a deleted rule. It names the rule in webhook deliveries (email.analysis.understanding.rules[].id) and in GET /v1/emails/{id} shared_through; it opens none of the rule routes to someone who is not its author. The member it is shared with lists this share's id, not the rule's, in a key's grant.rules (from the dashboard), and their own webhooks receive what it shares."
21417
21492
  }
21418
21493
  },
21419
21494
  "required": [
@@ -22135,7 +22210,7 @@ const operationManifest = [
22135
22210
  "rule_id": {
22136
22211
  "type": ["string", "null"],
22137
22212
  "format": "uuid",
22138
- "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."
22213
+ "description": "The rule itself, given with rule: to the member sharing their mail, and while the share is live to anyone shown the rule, the member it is shared with included. Null otherwise, and for a deleted rule. It names the rule in webhook deliveries (email.analysis.understanding.rules[].id) and in GET /v1/emails/{id} shared_through; it opens none of the rule routes to someone who is not its author. The member it is shared with lists this share's id, not the rule's, in a key's grant.rules (from the dashboard), and their own webhooks receive what it shares."
22139
22214
  }
22140
22215
  },
22141
22216
  "required": [
@@ -22654,15 +22729,28 @@ const operationManifest = [
22654
22729
  "type": "string"
22655
22730
  },
22656
22731
  "subject": { "type": ["string", "null"] },
22657
- "attachment_names": {
22658
- "description": "On matched and near_miss: the file names the email lists, in order, at most 10 (the names its questions are given). Parts with no name are left out; absent when there are none. attachment_descriptions says what each file is, where one was read.",
22659
- "type": "array",
22660
- "items": { "type": "string" }
22732
+ "attachments": {
22733
+ "type": ["array", "null"],
22734
+ "items": {
22735
+ "type": "object",
22736
+ "properties": {
22737
+ "name": {
22738
+ "type": "string",
22739
+ "description": "The file name the email gives it, cut at 255 characters."
22740
+ },
22741
+ "description": {
22742
+ "description": "The one-line description read from the file where the organization has attachment reading on, as GET /v1/emails/{id} gives it; null when none was read, it could not be read, reading is off, or you cannot open the email yourself.",
22743
+ "type": ["string", "null"]
22744
+ }
22745
+ },
22746
+ "required": ["name", "description"]
22747
+ },
22748
+ "description": "On matched, near_miss and no_match: the email's named attachments, in order, at most 10 (attachment_count counts them all), each with its one-line description where one was read and you can open the email yourself. An empty list means it has none; null means its content could not be read, so whether it has any is not known. Absent on other outcomes."
22661
22749
  },
22662
- "attachment_descriptions": {
22663
- "description": "Given exactly when attachment_names is, aligned with it by position: the one-line description read from each file where the organization has attachment reading on, else null (not read, could not be read, reading off, or an email you cannot open yourself).",
22664
- "type": "array",
22665
- "items": { "type": ["string", "null"] }
22750
+ "attachment_count": {
22751
+ "type": ["integer", "null"],
22752
+ "minimum": 0,
22753
+ "description": "Given exactly when attachments is: how many named attachments the email has in all."
22666
22754
  },
22667
22755
  "parts": {
22668
22756
  "description": "How each top-level part of the rule decided. Present for matched, near_miss and no_match.",
@@ -23213,13 +23301,38 @@ const operationManifest = [
23213
23301
  "received_at": {
23214
23302
  "type": ["string", "null"],
23215
23303
  "format": "date-time"
23304
+ },
23305
+ "attachments": {
23306
+ "type": ["array", "null"],
23307
+ "items": {
23308
+ "type": "object",
23309
+ "properties": {
23310
+ "name": {
23311
+ "type": "string",
23312
+ "description": "The file name the email gives it, cut at 255 characters."
23313
+ },
23314
+ "description": {
23315
+ "description": "The one-line description read from the file where the organization has attachment reading on, as GET /v1/emails/{id} gives it; null when none was read, it could not be read, reading is off, or you cannot open the email yourself.",
23316
+ "type": ["string", "null"]
23317
+ }
23318
+ },
23319
+ "required": ["name", "description"]
23320
+ },
23321
+ "description": "The email's named attachments, as its row in results gives them: in order, at most 10 (attachment_count counts them all), [] for none, null when its content could not be read."
23322
+ },
23323
+ "attachment_count": {
23324
+ "type": ["integer", "null"],
23325
+ "minimum": 0,
23326
+ "description": "How many named attachments the email has in all, listed or not. Null exactly when attachments is."
23216
23327
  }
23217
23328
  },
23218
23329
  "required": [
23219
23330
  "email_id",
23220
23331
  "subject",
23221
23332
  "from",
23222
- "received_at"
23333
+ "received_at",
23334
+ "attachments",
23335
+ "attachment_count"
23223
23336
  ]
23224
23337
  },
23225
23338
  "description": "Newest first, at most 50; count is the full number."
@@ -23248,13 +23361,38 @@ const operationManifest = [
23248
23361
  "received_at": {
23249
23362
  "type": ["string", "null"],
23250
23363
  "format": "date-time"
23364
+ },
23365
+ "attachments": {
23366
+ "type": ["array", "null"],
23367
+ "items": {
23368
+ "type": "object",
23369
+ "properties": {
23370
+ "name": {
23371
+ "type": "string",
23372
+ "description": "The file name the email gives it, cut at 255 characters."
23373
+ },
23374
+ "description": {
23375
+ "description": "The one-line description read from the file where the organization has attachment reading on, as GET /v1/emails/{id} gives it; null when none was read, it could not be read, reading is off, or you cannot open the email yourself.",
23376
+ "type": ["string", "null"]
23377
+ }
23378
+ },
23379
+ "required": ["name", "description"]
23380
+ },
23381
+ "description": "The email's named attachments, as its row in results gives them: in order, at most 10 (attachment_count counts them all), [] for none, null when its content could not be read."
23382
+ },
23383
+ "attachment_count": {
23384
+ "type": ["integer", "null"],
23385
+ "minimum": 0,
23386
+ "description": "How many named attachments the email has in all, listed or not. Null exactly when attachments is."
23251
23387
  }
23252
23388
  },
23253
23389
  "required": [
23254
23390
  "email_id",
23255
23391
  "subject",
23256
23392
  "from",
23257
- "received_at"
23393
+ "received_at",
23394
+ "attachments",
23395
+ "attachment_count"
23258
23396
  ]
23259
23397
  },
23260
23398
  "description": "Newest first, at most 50; count is the full number."
@@ -24859,7 +24997,7 @@ const operationManifest = [
24859
24997
  },
24860
24998
  "accepted_english": {
24861
24999
  "default": null,
24862
- "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise, and from a core-api release that predates the field. (The accepted English can match english when only the tree changed.)",
25000
+ "description": "When it was accepted with changes, for the member who asked and the member asked: the English that was accepted, beside english, which stays what was asked for. Null otherwise. Older responses may omit this field. (The accepted English can match english when only the tree changed.)",
24863
25001
  "type": ["string", "null"]
24864
25002
  }
24865
25003
  },
@@ -26168,6 +26306,7 @@ const operationManifest = [
26168
26306
  "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: GET /v1/email-rule-shares/{id}/emails lists what a share you gave has given.",
26169
26307
  "required": [
26170
26308
  "share_id",
26309
+ "rule_id",
26171
26310
  "rule_name",
26172
26311
  "sharer"
26173
26312
  ],
@@ -26177,6 +26316,11 @@ const operationManifest = [
26177
26316
  "format": "uuid",
26178
26317
  "description": "The share."
26179
26318
  },
26319
+ "rule_id": {
26320
+ "type": "string",
26321
+ "format": "uuid",
26322
+ "description": "The rule that was shared, as the share shows it to you while it is live. A key lists the share's id, not this one."
26323
+ },
26180
26324
  "rule_name": {
26181
26325
  "type": "string",
26182
26326
  "description": "The name of the rule that was shared."
@@ -41763,7 +41907,7 @@ const operationManifest = [
41763
41907
  "items": { "type": "string" }
41764
41908
  },
41765
41909
  "rules": {
41766
- "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.",
41910
+ "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; its rule's own id is refused (403 grant_forbidden, details.reason rule_shared_with_you, with the share in details.share_id) unless you could put the rule itself on a key.",
41767
41911
  "maxItems": 20,
41768
41912
  "type": "array",
41769
41913
  "items": { "type": "string" }
@@ -53966,11 +54110,16 @@ const operationManifest = [
53966
54110
  "type": "object",
53967
54111
  "properties": {
53968
54112
  "id": { "type": "string" },
53969
- "name": { "type": "string" }
54113
+ "name": { "type": "string" },
54114
+ "through_share": { "type": ["string", "null"] }
53970
54115
  },
53971
- "required": ["id", "name"]
54116
+ "required": [
54117
+ "id",
54118
+ "name",
54119
+ "through_share"
54120
+ ]
53972
54121
  },
53973
- "description": "The rules this attempt's payload named in email.analysis.understanding.rules, by id and name as sent, listing only rules you can read now; empty when it named none of those. Recorded for deliveries Primitive's API sends and for replays. Null where it was not recorded (other deliveries, records of no attempt, attempts before this field), for a caller that cannot read email rules or whose organization does not have them, below content depth, and once the message's content is discarded."
54122
+ "description": "The rules this attempt's payload named in email.analysis.understanding.rules, by id and name as sent, with through_share: the id of the share the receiver reached the rule through, or null when it lists the rule itself. Lists only rules you can read now, and a rule reached through a share while you can see that share and it has not ended; empty when it named none of those. Recorded for deliveries Primitive's API sends and for replays. Null where it was not recorded (other deliveries, records of no attempt, attempts before this field), for a caller that cannot read email rules or whose organization does not have them, below content depth, and once the message's content is discarded."
53974
54123
  },
53975
54124
  "created_at": { "type": "string" },
53976
54125
  "updated_at": { "type": "string" },
@@ -54253,13 +54402,21 @@ const operationManifest = [
54253
54402
  },
54254
54403
  "rules": {
54255
54404
  "type": ["array", "null"],
54256
- "description": "The rules this attempt's payload named in email.analysis.understanding.rules, by id and name as sent, listing only rules you can read now; empty when it named none of those. Recorded for deliveries Primitive's API sends and for replays. Null where it was not recorded (other deliveries, records of no attempt, attempts before this field), for a caller that cannot read email rules or whose organization does not have them, below content depth, and once the message's content is discarded.",
54405
+ "description": "The rules this attempt's payload named in email.analysis.understanding.rules, by id and name as sent, with through_share: the id of the share the receiver reached the rule through, or null when it lists the rule itself. Lists only rules you can read now, and a rule reached through a share while you can see that share and it has not ended; empty when it named none of those. Recorded for deliveries Primitive's API sends and for replays. Null where it was not recorded (other deliveries, records of no attempt, attempts before this field), for a caller that cannot read email rules or whose organization does not have them, below content depth, and once the message's content is discarded.",
54257
54406
  "items": {
54258
54407
  "type": "object",
54259
- "required": ["id", "name"],
54408
+ "required": [
54409
+ "id",
54410
+ "name",
54411
+ "through_share"
54412
+ ],
54260
54413
  "properties": {
54261
54414
  "id": { "type": "string" },
54262
- "name": { "type": "string" }
54415
+ "name": { "type": "string" },
54416
+ "through_share": {
54417
+ "type": ["string", "null"],
54418
+ "description": "The share the receiver reached the rule through; null when it lists the rule itself."
54419
+ }
54263
54420
  }
54264
54421
  }
54265
54422
  },
@@ -54513,7 +54670,7 @@ function terminalLine(line) {
54513
54670
  return sanitizeForTerminal(line).replace(BIDI_CONTROLS, "").replaceAll(/[\r\n\t]+/g, " ");
54514
54671
  }
54515
54672
  // src/oclif/answer-reports.ts
54516
- function isRecord$8(value) {
54673
+ function isRecord$10(value) {
54517
54674
  return value !== null && typeof value === "object" && !Array.isArray(value);
54518
54675
  }
54519
54676
  /** Text from an answer, made safe and one line for a report: no terminal controls. */
@@ -54522,10 +54679,10 @@ function oneLine(text) {
54522
54679
  }
54523
54680
  /** One line per warning a route write answers with (createRoute, updateRoute). */
54524
54681
  function routeWarningLines(data) {
54525
- const warnings = isRecord$8(data) ? data.warnings : void 0;
54682
+ const warnings = isRecord$10(data) ? data.warnings : void 0;
54526
54683
  if (!Array.isArray(warnings)) return [];
54527
54684
  return warnings.flatMap((warning) => {
54528
- if (!isRecord$8(warning)) return [];
54685
+ if (!isRecord$10(warning)) return [];
54529
54686
  const message = typeof warning.message === "string" ? oneLine(warning.message) : "";
54530
54687
  if (message) return [`Route warning: ${withCliCommands(message)}`];
54531
54688
  const code = typeof warning.code === "string" ? oneLine(warning.code) : "";
@@ -54553,11 +54710,11 @@ const DELIVERED_STATUSES = /* @__PURE__ */ new Set(["delivered", "header_confirm
54553
54710
  * and has no recorded answer says so.
54554
54711
  */
54555
54712
  function deliveryAttemptLines(data) {
54556
- const attempts = isRecord$8(data) ? data.attempts : void 0;
54713
+ const attempts = isRecord$10(data) ? data.attempts : void 0;
54557
54714
  if (!Array.isArray(attempts)) return [];
54558
54715
  const lines = [];
54559
54716
  for (const attempt of attempts) {
54560
- if (!isRecord$8(attempt)) continue;
54717
+ if (!isRecord$10(attempt)) continue;
54561
54718
  const text = (value) => typeof value === "string" && value ? oneLine(value) : "";
54562
54719
  const status = text(attempt.status);
54563
54720
  const parts = [
@@ -54583,9 +54740,9 @@ function deliveryAttemptLines(data) {
54583
54740
  */
54584
54741
  function deliveringCell(endpoint) {
54585
54742
  const delivery = endpoint.delivery;
54586
- if (isRecord$8(delivery) && typeof delivery.delivering === "boolean") {
54743
+ if (isRecord$10(delivery) && typeof delivery.delivering === "boolean") {
54587
54744
  if (delivery.delivering) return "yes";
54588
- const codes = Array.isArray(delivery.reasons) ? delivery.reasons.flatMap((reason) => isRecord$8(reason) && typeof reason.code === "string" && reason.code ? [oneLine(reason.code)] : []) : [];
54745
+ const codes = Array.isArray(delivery.reasons) ? delivery.reasons.flatMap((reason) => isRecord$10(reason) && typeof reason.code === "string" && reason.code ? [oneLine(reason.code)] : []) : [];
54589
54746
  return codes.length > 0 ? `no (${codes.join(", ")})` : "no";
54590
54747
  }
54591
54748
  return endpoint.kind === void 0 || endpoint.kind === "http" ? "unknown" : "-";
@@ -54596,7 +54753,7 @@ function deliveringCell(endpoint) {
54596
54753
  * (DELIVERING, from `delivery`), and its name. Nothing for an empty list.
54597
54754
  */
54598
54755
  function endpointDeliveryLines(data) {
54599
- const rows = Array.isArray(data) ? data.filter(isRecord$8) : [];
54756
+ const rows = Array.isArray(data) ? data.filter(isRecord$10) : [];
54600
54757
  if (rows.length === 0) return [];
54601
54758
  const text = (value) => typeof value === "string" && value ? oneLine(value) : "";
54602
54759
  const table = [[
@@ -54702,7 +54859,7 @@ var CliOrgRefusedError = class extends Errors.CLIError {
54702
54859
  this.orgId = params.orgId;
54703
54860
  }
54704
54861
  };
54705
- function isRecord$7(value) {
54862
+ function isRecord$9(value) {
54706
54863
  return value !== null && typeof value === "object" && !Array.isArray(value);
54707
54864
  }
54708
54865
  function apiOrigin(apiBaseUrl) {
@@ -54729,7 +54886,7 @@ function isUuid(value) {
54729
54886
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
54730
54887
  }
54731
54888
  function isOrgAccessToken(value) {
54732
- return isRecord$7(value) && typeof value.access_token === "string" && value.access_token.length > 0 && value.token_type === "Bearer" && typeof value.expires_in === "number" && value.expires_in > 0 && typeof value.org_id === "string" && (value.org_name === null || typeof value.org_name === "string") && typeof value.oauth_grant_id === "string";
54889
+ return isRecord$9(value) && typeof value.access_token === "string" && value.access_token.length > 0 && value.token_type === "Bearer" && typeof value.expires_in === "number" && value.expires_in > 0 && typeof value.org_id === "string" && (value.org_name === null || typeof value.org_name === "string") && typeof value.oauth_grant_id === "string";
54733
54890
  }
54734
54891
  function orgTokenFromResponse(token, now = Date.now) {
54735
54892
  return {
@@ -54776,7 +54933,7 @@ async function postTokenEndpoint(params) {
54776
54933
  throw new Errors.CLIError(`Could not reach the Primitive OAuth token endpoint: ${detail}`, { exit: 1 });
54777
54934
  }
54778
54935
  const payload = await response.json().catch(() => null);
54779
- if (response.ok && isRecord$7(payload)) return {
54936
+ if (response.ok && isRecord$9(payload)) return {
54780
54937
  ok: true,
54781
54938
  payload
54782
54939
  };
@@ -54784,7 +54941,7 @@ async function postTokenEndpoint(params) {
54784
54941
  ok: true,
54785
54942
  payload: {}
54786
54943
  };
54787
- const record = isRecord$7(payload) ? payload : {};
54944
+ const record = isRecord$9(payload) ? payload : {};
54788
54945
  return {
54789
54946
  ok: false,
54790
54947
  status: response.status,
@@ -54987,12 +55144,12 @@ async function fetchCliOrgs(params) {
54987
55144
  }
54988
55145
  const payload = await response.json().catch(() => null);
54989
55146
  if (!response.ok) {
54990
- const error = isRecord$7(payload) && isRecord$7(payload.error) ? payload.error : {};
55147
+ const error = isRecord$9(payload) && isRecord$9(payload.error) ? payload.error : {};
54991
55148
  if (response.status === 404 && error.code === "feature_disabled") throw new Errors.CLIError("This Primitive server does not support switching organizations for CLI logins.", { exit: 1 });
54992
55149
  throw new Errors.CLIError(`Could not list organizations${typeof error.message === "string" ? `: ${error.message}` : ` (HTTP ${response.status}).`}`, { exit: 1 });
54993
55150
  }
54994
- const data = isRecord$7(payload) ? payload.data : null;
54995
- if (!isRecord$7(data) || !Array.isArray(data.orgs)) throw new Errors.CLIError("Primitive API returned an unexpected organization list.", { exit: 1 });
55151
+ const data = isRecord$9(payload) ? payload.data : null;
55152
+ if (!isRecord$9(data) || !Array.isArray(data.orgs)) throw new Errors.CLIError("Primitive API returned an unexpected organization list.", { exit: 1 });
54996
55153
  return data;
54997
55154
  }
54998
55155
  /** How long a command waits for another CLI process to finish with the saved login. */
@@ -55654,10 +55811,61 @@ function withBooleanFlagValues(argv, flags) {
55654
55811
  }
55655
55812
  return out;
55656
55813
  }
55814
+ // src/oclif/bounded-pages.ts
55815
+ /** Read a bounded window, preserving the last page's metadata and errors. */
55816
+ async function fetchBoundedPages(options) {
55817
+ const { wanted, maximum, call } = options;
55818
+ const rows = [];
55819
+ const seen = /* @__PURE__ */ new Set([options.cursor]);
55820
+ let cursor = options.cursor;
55821
+ let merged = {};
55822
+ const budget = Math.ceil(wanted / maximum) + 20;
55823
+ for (let requests = 1;; requests += 1) {
55824
+ const result = await call(Math.min(maximum, wanted - rows.length), cursor);
55825
+ if (result.error) return { result };
55826
+ const envelope = result.data;
55827
+ rows.push(...Array.isArray(envelope?.data) ? envelope.data : []);
55828
+ const previousWarnings = merged.warnings;
55829
+ const previousMeta = { ...merged.meta };
55830
+ delete previousMeta.total;
55831
+ delete previousMeta.total_capped;
55832
+ delete previousMeta.total_unavailable;
55833
+ merged = {
55834
+ ...merged,
55835
+ ...envelope,
55836
+ meta: {
55837
+ ...previousMeta,
55838
+ ...envelope?.meta
55839
+ }
55840
+ };
55841
+ if (Array.isArray(previousWarnings) && Array.isArray(envelope?.warnings)) merged.warnings = [...previousWarnings, ...envelope.warnings];
55842
+ const next = envelope?.meta?.cursor ?? void 0;
55843
+ const repeated = Boolean(next) && seen.has(next);
55844
+ const bounded = Boolean(next) && rows.length < wanted && requests >= budget;
55845
+ if (!next || repeated || rows.length >= wanted || bounded) {
55846
+ const note = repeated ? `Stopped because the server repeated a cursor after ${requests} requests; more may remain. Continue with --cursor ${next}.` : bounded ? `Stopped after ${requests} requests with ${rows.length} of ${wanted}; more may remain. Continue with --cursor ${next}.` : void 0;
55847
+ return {
55848
+ result,
55849
+ envelope: {
55850
+ ...merged,
55851
+ data: rows,
55852
+ meta: {
55853
+ ...merged.meta,
55854
+ limit: wanted,
55855
+ cursor: next ?? null
55856
+ }
55857
+ },
55858
+ note
55859
+ };
55860
+ }
55861
+ seen.add(next);
55862
+ cursor = next;
55863
+ }
55864
+ }
55657
55865
  // src/oclif/rule-notes.ts
55658
55866
  /** The tags whose single-object answers get the notes printer. */
55659
55867
  const RULE_NOTES_TAGS = /* @__PURE__ */ new Set(["Email Rules", "Email Rule Oversight"]);
55660
- function isRecord$6(value) {
55868
+ function isRecord$8(value) {
55661
55869
  return value !== null && typeof value === "object" && !Array.isArray(value);
55662
55870
  }
55663
55871
  /** Server text as a report line shows it, or "" when there is none. */
@@ -55686,12 +55894,12 @@ function list(value) {
55686
55894
  * rule's, each once.
55687
55895
  */
55688
55896
  function ruleNotesLines(answer) {
55689
- if (!isRecord$6(answer)) return [];
55690
- const summary = isRecord$6(answer.summary) ? answer.summary : {};
55691
- const rule = isRecord$6(answer.rule) ? answer.rule : {};
55897
+ if (!isRecord$8(answer)) return [];
55898
+ const summary = isRecord$8(answer.summary) ? answer.summary : {};
55899
+ const rule = isRecord$8(answer.rule) ? answer.rule : {};
55692
55900
  const notes = (from) => NOTE_KEYS.map((key) => from[key]);
55693
55901
  const lines = [
55694
- ...list(answer.scope_warnings).filter(isRecord$6).map(scopeWarningLine),
55902
+ ...list(answer.scope_warnings).filter(isRecord$8).map(scopeWarningLine),
55695
55903
  ...[
55696
55904
  ...list(answer.warnings),
55697
55905
  answer.warning,
@@ -55713,7 +55921,7 @@ function errorDetail(error) {
55713
55921
  function usageError$3(message) {
55714
55922
  return new Errors.CLIError(message, { exit: 2 });
55715
55923
  }
55716
- function isRecord$5(value) {
55924
+ function isRecord$7(value) {
55717
55925
  return value !== null && typeof value === "object" && !Array.isArray(value);
55718
55926
  }
55719
55927
  /** A JSON file a flag names, parsed, or a usage error (exit 2) saying why not. */
@@ -55772,7 +55980,7 @@ function lookAlikeExpected(lookAlike) {
55772
55980
  * leaves it out of what a rule keeps.
55773
55981
  */
55774
55982
  function lookAlikeSample(lookAlike) {
55775
- if (!isRecord$5(lookAlike) || !isRecord$5(lookAlike.email)) return null;
55983
+ if (!isRecord$7(lookAlike) || !isRecord$7(lookAlike.email)) return null;
55776
55984
  const kind = typeof lookAlike.kind === "string" ? lookAlike.kind : "";
55777
55985
  const why = typeof lookAlike.why === "string" ? lookAlike.why.trim() : "";
55778
55986
  const both = kind && why ? `${kind}: ${why}` : kind || why;
@@ -55791,11 +55999,11 @@ function lookAlikeSample(lookAlike) {
55791
55999
  * samples file holds these, so a number means the same email in both.
55792
56000
  */
55793
56001
  function lookAlikeEntries(answer) {
55794
- const list = isRecord$5(answer) && Array.isArray(answer.look_alikes) ? answer.look_alikes : [];
56002
+ const list = isRecord$7(answer) && Array.isArray(answer.look_alikes) ? answer.look_alikes : [];
55795
56003
  const entries = [];
55796
56004
  for (const item of list) {
55797
56005
  const sample = lookAlikeSample(item);
55798
- if (sample && isRecord$5(item)) entries.push({
56006
+ if (sample && isRecord$7(item)) entries.push({
55799
56007
  lookAlike: item,
55800
56008
  sample
55801
56009
  });
@@ -55815,15 +56023,15 @@ function lookAlikeSamples(answer) {
55815
56023
  * refused, so it never empties a rule's.
55816
56024
  */
55817
56025
  function samplesFromJson(value, source) {
55818
- const data = isRecord$5(value) && isRecord$5(value.data) ? value.data : value;
55819
- if (isRecord$5(data) && Array.isArray(data.look_alikes)) {
56026
+ const data = isRecord$7(value) && isRecord$7(value.data) ? value.data : value;
56027
+ if (isRecord$7(data) && Array.isArray(data.look_alikes)) {
55820
56028
  const samples = lookAlikeSamples(data);
55821
56029
  if (samples.length === 0) throw usageError$3(`${source} is a generate-look-alikes answer with no look-alikes in it.`);
55822
56030
  return samples;
55823
56031
  }
55824
56032
  if (!Array.isArray(data)) throw usageError$3(`${source} must hold a JSON array of samples, such as [{"expected": "no_match", "label": "a personal bill", "email": {...}}], or a generate-look-alikes answer.`);
55825
56033
  return data.map((item, index) => {
55826
- if (!isRecord$5(item)) throw usageError$3(`${source}, sample ${index + 1} (index ${index}) is not an object.`);
56034
+ if (!isRecord$7(item)) throw usageError$3(`${source}, sample ${index + 1} (index ${index}) is not an object.`);
55827
56035
  const { id: _id, created_at: _createdAt, ...sample } = item;
55828
56036
  return sample;
55829
56037
  });
@@ -55916,11 +56124,11 @@ const CLOSE_CALL_NOTE = "a close call: decided by an answer below 0.75 confidenc
55916
56124
  * them left out: "By group: private 3 passed; near_miss 1 passed, 1 failed."
55917
56125
  */
55918
56126
  function groupCountsLines(byGroup) {
55919
- if (!isRecord$5(byGroup)) return [];
56127
+ if (!isRecord$7(byGroup)) return [];
55920
56128
  const parts = [];
55921
56129
  for (const group of SAMPLE_GROUPS) {
55922
56130
  const tally = byGroup[group];
55923
- if (!isRecord$5(tally)) continue;
56131
+ if (!isRecord$7(tally)) continue;
55924
56132
  const counted = [
55925
56133
  "passed",
55926
56134
  "failed",
@@ -55937,11 +56145,11 @@ function groupCountsLines(byGroup) {
55937
56145
  * match it, and what the rule decided; the counts; then the server's notes.
55938
56146
  */
55939
56147
  function lookAlikesReport(data) {
55940
- if (!isRecord$5(data)) return { lines: [] };
56148
+ if (!isRecord$7(data)) return { lines: [] };
55941
56149
  const lines = [];
55942
56150
  lookAlikeEntries(data).forEach(({ lookAlike }, index) => {
55943
56151
  const email = lookAlike.email;
55944
- const from = isRecord$5(email.from) ? shownText(email.from.address) : "";
56152
+ const from = isRecord$7(email.from) ? shownText(email.from.address) : "";
55945
56153
  const subject = shownText(email.subject);
55946
56154
  const status = shownLine(lookAlike.status) || "undecided";
55947
56155
  const kind = shownLine(lookAlike.kind) || "other";
@@ -55953,7 +56161,7 @@ function lookAlikesReport(data) {
55953
56161
  if (why) lines.push(` Why it should ${expected === "match" ? "" : "not "}match: ${why}`);
55954
56162
  lines.push(` ${outcome} (expected ${expected})${lookAlike.close_call === true ? `; ${CLOSE_CALL_NOTE}` : ""}`);
55955
56163
  });
55956
- const counts = isRecord$5(data.counts) ? data.counts : {};
56164
+ const counts = isRecord$7(data.counts) ? data.counts : {};
55957
56165
  const count = (key) => typeof counts[key] === "number" ? counts[key] : 0;
55958
56166
  const dropped = count("dropped");
55959
56167
  const closeCalls = count("close_calls");
@@ -56032,6 +56240,52 @@ function scopeSelectionBodyFields(flags, base) {
56032
56240
  });
56033
56241
  return fields;
56034
56242
  }
56243
+ function isRecord$6(value) {
56244
+ return value !== null && typeof value === "object" && !Array.isArray(value);
56245
+ }
56246
+ /**
56247
+ * Text a sender or a file reader wrote, on one line, in compatibility form (so a
56248
+ * fullwidth comma or parenthesis reads as the plain one), cut at `max` code
56249
+ * points.
56250
+ */
56251
+ function cut(value, max) {
56252
+ const chars = Array.from(shownLine(value).normalize("NFKC"));
56253
+ return chars.length > max ? `${chars.slice(0, max - 3).join("").trimEnd()}...` : chars.join("");
56254
+ }
56255
+ /**
56256
+ * A file name as the line shows it: in double quotes when it holds a comma, a
56257
+ * parenthesis or a quote, or starts with a plus, so a name cannot pass for more
56258
+ * files, a description or the count of the rest.
56259
+ */
56260
+ function fileName(value) {
56261
+ const name = cut(value, 40);
56262
+ if (name === "") return "(no name)";
56263
+ return /[,()"]|^\+/.test(name) ? `"${name.replaceAll("\"", "'")}"` : name;
56264
+ }
56265
+ /**
56266
+ * What a row's email carried, as one line without indentation: "2
56267
+ * attachments: rate-card.pdf (Contractor pay rates by role), logo.png",
56268
+ * "no attachments", or undefined when the row does not say (null or absent:
56269
+ * not known to the caller).
56270
+ */
56271
+ function attachmentsSummary(row) {
56272
+ if (!isRecord$6(row) || !Array.isArray(row.attachments)) return void 0;
56273
+ const listed = row.attachments.filter(isRecord$6);
56274
+ const count = typeof row.attachment_count === "number" && row.attachment_count >= listed.length ? row.attachment_count : listed.length;
56275
+ if (count === 0) return "no attachments";
56276
+ const shown = listed.slice(0, 3).map((file) => {
56277
+ const name = fileName(file.name);
56278
+ const description = cut(file.description, 60).replaceAll("(", "[").replaceAll(")", "]");
56279
+ return description ? `${name} (${description})` : name;
56280
+ });
56281
+ const more = count - shown.length;
56282
+ return `${count} ${count === 1 ? "attachment" : "attachments"}: ${[...shown, ...more > 0 ? [`+${more} more`] : []].join(", ")}`;
56283
+ }
56284
+ /** attachmentsSummary as lines under a row, indented by `indent`; none when it does not say. */
56285
+ function attachmentsLines(row, indent) {
56286
+ const summary = attachmentsSummary(row);
56287
+ return summary === void 0 ? [] : [`${indent}${summary}`];
56288
+ }
56035
56289
  // src/oclif/email-rule-authoring.ts
56036
56290
  const EMAIL_ID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
56037
56291
  /** Whether `id` has the shape of an email id (a UUID). */
@@ -56041,7 +56295,7 @@ function isEmailId(id) {
56041
56295
  function usageError$1(message) {
56042
56296
  return new Errors.CLIError(message, { exit: 2 });
56043
56297
  }
56044
- function isRecord$4(value) {
56298
+ function isRecord$5(value) {
56045
56299
  return value !== null && typeof value === "object" && !Array.isArray(value);
56046
56300
  }
56047
56301
  /** `count` and the word for it: "1 expectation", "2 expectations". */
@@ -56071,7 +56325,7 @@ function parseEmailIdList(values, flag) {
56071
56325
  * their own flag.
56072
56326
  */
56073
56327
  function checkExpectations(value, label) {
56074
- if (!isRecord$4(value)) throw usageError$1(`${label} must hold a JSON object such as {"match": ["<email-id>"], "no_match": ["<email-id>"]}.`);
56328
+ if (!isRecord$5(value)) throw usageError$1(`${label} must hold a JSON object such as {"match": ["<email-id>"], "no_match": ["<email-id>"]}.`);
56075
56329
  if ("samples" in value) throw usageError$1(`${label} takes emails by id only; give made-up emails with ${label.startsWith("--expectations-file") ? "--samples-file" : "--expect-samples-file"}.`);
56076
56330
  return value;
56077
56331
  }
@@ -56121,10 +56375,10 @@ function sameEmailsBodyFields(flags) {
56121
56375
  const file = flags[SAME_EMAILS_FLAG];
56122
56376
  if (typeof file !== "string") return [];
56123
56377
  const saved = readJsonFileFlag(file, `--${SAME_EMAILS_FLAG}`);
56124
- const answer = isRecord$4(saved) && isRecord$4(saved.data) ? saved.data : saved;
56125
- const results = isRecord$4(answer) && Array.isArray(answer.results) ? answer.results : null;
56378
+ const answer = isRecord$5(saved) && isRecord$5(saved.data) ? saved.data : saved;
56379
+ const results = isRecord$5(answer) && Array.isArray(answer.results) ? answer.results : null;
56126
56380
  if (!results) throw usageError$1(`--${SAME_EMAILS_FLAG} ${file} is not a saved test answer: it has no results. Save one with primitive email-rules test --json > answer.json.`);
56127
- const ids = [...new Set(results.flatMap((result) => isRecord$4(result) && typeof result.email_id === "string" && isEmailId(result.email_id) ? [result.email_id.toLowerCase()] : []))];
56381
+ const ids = [...new Set(results.flatMap((result) => isRecord$5(result) && typeof result.email_id === "string" && isEmailId(result.email_id) ? [result.email_id.toLowerCase()] : []))];
56128
56382
  if (ids.length === 0) throw usageError$1(`--${SAME_EMAILS_FLAG} ${file} names no emails.`);
56129
56383
  return [{
56130
56384
  flag: `--${SAME_EMAILS_FLAG}`,
@@ -56159,7 +56413,7 @@ function formatFactValue(fact) {
56159
56413
  const value = fact?.value;
56160
56414
  let text;
56161
56415
  if (Array.isArray(value)) {
56162
- const per = isRecord$4(fact?.value_confidences) ? fact.value_confidences : void 0;
56416
+ const per = isRecord$5(fact?.value_confidences) ? fact.value_confidences : void 0;
56163
56417
  text = `[${value.map((item) => {
56164
56418
  const name = String(item);
56165
56419
  const score = per?.[name];
@@ -56189,7 +56443,7 @@ function answerConfidence(answer) {
56189
56443
  * decide it. An entry that does not say it can is taken as one that cannot.
56190
56444
  */
56191
56445
  function undecidedOf(entry) {
56192
- const given = isRecord$4(entry) ? entry : {};
56446
+ const given = isRecord$5(entry) ? entry : {};
56193
56447
  return {
56194
56448
  reason: typeof given.reason === "string" ? given.reason : "undecided",
56195
56449
  retryable: given.retryable === true
@@ -56222,7 +56476,7 @@ function questionLines(summary, results) {
56222
56476
  }
56223
56477
  /** Whether an expectation entry is marked a close call. */
56224
56478
  function isCloseCall(entry) {
56225
- return isRecord$4(entry) && entry.close_call === true;
56479
+ return isRecord$5(entry) && entry.close_call === true;
56226
56480
  }
56227
56481
  function expectationLine(result) {
56228
56482
  const note = result.status === "undecided" ? undecidedNote(undecidedOf(result)) : isCloseCall(result) ? CLOSE_CALL_NOTE : void 0;
@@ -56230,13 +56484,13 @@ function expectationLine(result) {
56230
56484
  }
56231
56485
  /** The made-up emails a test's expectations judged, in order. */
56232
56486
  function sampleJudgments(expectations) {
56233
- return (isRecord$4(expectations) && Array.isArray(expectations.samples) ? expectations.samples : []).filter(isRecord$4).map((item, position) => ({
56487
+ return (isRecord$5(expectations) && Array.isArray(expectations.samples) ? expectations.samples : []).filter(isRecord$5).map((item, position) => ({
56234
56488
  index: typeof item.index === "number" ? item.index : position,
56235
56489
  label: typeof item.label === "string" ? item.label : null,
56236
56490
  expected: String(item.expected ?? ""),
56237
56491
  outcome: String(item.outcome ?? "not_decided"),
56238
56492
  status: String(item.status ?? "undecided"),
56239
- question_answers: Array.isArray(item.question_answers) ? item.question_answers.filter(isRecord$4) : [],
56493
+ question_answers: Array.isArray(item.question_answers) ? item.question_answers.filter(isRecord$5) : [],
56240
56494
  entry: item
56241
56495
  }));
56242
56496
  }
@@ -56286,10 +56540,10 @@ function expectationsLines(expectations, name = sampleNamer()) {
56286
56540
  * withheld.
56287
56541
  */
56288
56542
  function changesLines(changes, kind) {
56289
- if (!isRecord$4(changes)) return [];
56543
+ if (!isRecord$5(changes)) return [];
56290
56544
  const list = (value) => {
56291
- const given = isRecord$4(value) ? value : {};
56292
- const emails = Array.isArray(given.emails) ? given.emails.filter(isRecord$4) : [];
56545
+ const given = isRecord$5(value) ? value : {};
56546
+ const emails = Array.isArray(given.emails) ? given.emails.filter(isRecord$5) : [];
56293
56547
  return {
56294
56548
  count: typeof given.count === "number" ? given.count : emails.length,
56295
56549
  emails
@@ -56310,7 +56564,7 @@ function changesLines(changes, kind) {
56310
56564
  for (const [label, entry] of [[words[0], newly], [words[1], stops]]) {
56311
56565
  if (entry.emails.length === 0) continue;
56312
56566
  const shown = entry.emails.slice(0, 3);
56313
- lines.push(` ${label[0]?.toUpperCase()}${label.slice(1)}${entry.count > shown.length ? ` (${shown.length} of ${entry.count} shown; the JSON lists up to 50)` : ""}:`, ...shown.map(emailLine));
56567
+ lines.push(` ${label[0]?.toUpperCase()}${label.slice(1)}${entry.count > shown.length ? ` (${shown.length} of ${entry.count} shown; the JSON lists up to 50)` : ""}:`, ...shown.flatMap((email) => [emailLine(email), ...attachmentsLines(email, " ").map(terminalLine)]));
56314
56568
  }
56315
56569
  return lines;
56316
56570
  }
@@ -56342,20 +56596,16 @@ function notMatchedLine(result) {
56342
56596
  return [...lines, ...attachmentsLine(result)];
56343
56597
  }
56344
56598
  /**
56345
- * The file names a matched or near-miss result lists (attachment_names), on
56346
- * one line under it: the names its questions are given, shown as shownText
56347
- * shows a sender's text.
56599
+ * What a decided result's email carried (attachments), on one line under it,
56600
+ * as the decision listings show it (attachmentsSummary).
56348
56601
  */
56349
56602
  function attachmentsLine(result) {
56350
- const names = result.attachment_names;
56351
- if (!Array.isArray(names)) return [];
56352
- const shown = names.map(shownText).filter(Boolean);
56353
- return shown.length > 0 ? [` attachments: ${shown.join(", ")}`] : [];
56603
+ return attachmentsLines(result, " ").map(terminalLine);
56354
56604
  }
56355
56605
  /**
56356
- * The matched emails, each with who sent it, its subject and its attachments'
56357
- * file names, so a match can be judged without opening it; cut as the not
56358
- * matched list is.
56606
+ * The matched emails, each with who sent it, its subject and what it carried
56607
+ * (how many files, the first few names and descriptions), so a match can be
56608
+ * judged without opening it; cut as the not matched list is.
56359
56609
  */
56360
56610
  function matchedLines(results, expectations) {
56361
56611
  const flagged = new Set((expectations?.results ?? []).filter((result) => result.status !== "passed").map((result) => result.email_id));
@@ -56445,7 +56695,7 @@ function minuteUtc$1(value) {
56445
56695
  }
56446
56696
  /** The first line of a test report: which mail was tested. */
56447
56697
  function windowLine(data, tested) {
56448
- const window = isRecord$4(data.window) ? data.window : void 0;
56698
+ const window = isRecord$5(data.window) ? data.window : void 0;
56449
56699
  const oldest = typeof window?.oldest_at === "string" ? window.oldest_at : void 0;
56450
56700
  const newest = typeof window?.newest_at === "string" ? window.newest_at : void 0;
56451
56701
  if (!window || !oldest || !newest) return [];
@@ -56453,19 +56703,19 @@ function windowLine(data, tested) {
56453
56703
  }
56454
56704
  /** The stderr report and exit code of a test answer. */
56455
56705
  function testEmailRuleReport(data) {
56456
- if (!isRecord$4(data)) return { lines: [] };
56706
+ if (!isRecord$5(data)) return { lines: [] };
56457
56707
  const name = sampleNamer();
56458
56708
  const result = data;
56459
56709
  const results = Array.isArray(result.results) ? result.results : [];
56460
- const summary = isRecord$4(result.summary) ? result.summary : void 0;
56461
- const counts = isRecord$4(data.counts) ? data.counts : void 0;
56710
+ const summary = isRecord$5(result.summary) ? result.summary : void 0;
56711
+ const counts = isRecord$5(data.counts) ? data.counts : void 0;
56462
56712
  return {
56463
56713
  lines: [
56464
56714
  ...windowLine(data, (typeof counts?.emails === "number" ? counts.emails : results.length) - (typeof counts?.not_found === "number" ? counts.not_found : 0)),
56465
56715
  ...ruleNotesLines(data),
56466
56716
  ...conditionLines(summary),
56467
56717
  ...questionLines(summary, results),
56468
- ...changesLines(data.changes, isRecord$4(data.rule) ? data.rule.kind : void 0),
56718
+ ...changesLines(data.changes, isRecord$5(data.rule) ? data.rule.kind : void 0),
56469
56719
  ...expectationsLines(result.expectations, name),
56470
56720
  ...matchedLines(results, result.expectations),
56471
56721
  ...notMatchedLines(results, result.expectations)
@@ -56589,7 +56839,7 @@ const EMAIL_RULE_OPERATION_EXTENSIONS = {
56589
56839
  }
56590
56840
  };
56591
56841
  // src/oclif/email-rule-listings.ts
56592
- function isRecord$3(value) {
56842
+ function isRecord$4(value) {
56593
56843
  return value !== null && typeof value === "object" && !Array.isArray(value);
56594
56844
  }
56595
56845
  /** Rows as a table: every column padded to its widest cell but the last. */
@@ -56612,14 +56862,16 @@ function decisionOutcome(decision) {
56612
56862
  /**
56613
56863
  * A table of a rule's decisions (listEmailRuleDecisions and
56614
56864
  * listEmailRuleDecisionsOnMyMail): when each was decided, what it decided,
56615
- * the email, the mailbox it was received in, its sender and subject. An email
56616
- * you are not shown shows `-` for those. Nothing for an empty list.
56865
+ * the email, the mailbox it was received in, its sender and subject, and
56866
+ * under each row what the email carried (attachmentsSummary). An email you
56867
+ * are not shown shows `-` for those and no attachments line. Nothing for an
56868
+ * empty list.
56617
56869
  */
56618
56870
  function decisionLines(data) {
56619
- const rows = Array.isArray(data) ? data.filter(isRecord$3) : [];
56871
+ const rows = Array.isArray(data) ? data.filter(isRecord$4) : [];
56620
56872
  if (rows.length === 0) return [];
56621
56873
  const cell = (value) => shownText(value) || "-";
56622
- return tableLines([[
56874
+ const [header = "", ...table] = tableLines([[
56623
56875
  "DECIDED",
56624
56876
  "OUTCOME",
56625
56877
  "EMAIL",
@@ -56634,11 +56886,21 @@ function decisionLines(data) {
56634
56886
  cell(row.from_address),
56635
56887
  cell(row.subject)
56636
56888
  ])]);
56889
+ return [header, ...table.flatMap((line, i) => [line, ...attachmentsLines(rows[i], " ").map(terminalLine)])];
56890
+ }
56891
+ /**
56892
+ * The rule results on one email (listEmailRuleResults): what the email
56893
+ * carried, once for every rule listed, after any notes the answer carries.
56894
+ * Nothing when the answer says neither.
56895
+ */
56896
+ function ruleResultsLines(data) {
56897
+ const summary = attachmentsSummary(data);
56898
+ return [...ruleNotesLines(data), ...summary === void 0 ? [] : [terminalLine(`Email: ${summary}`)]];
56637
56899
  }
56638
56900
  /** At most this many scope addresses and domains are named in COVERS. */
56639
56901
  const COVERS_NAMED = 3;
56640
56902
  function ruleAuthor(rule) {
56641
- const author = isRecord$3(rule.author) ? rule.author : {};
56903
+ const author = isRecord$4(rule.author) ? rule.author : {};
56642
56904
  const name = shownText(author.name) || shownText(author.email) || shownLine(author.user_id).slice(0, 8) || "-";
56643
56905
  return rule.is_author === true ? `${name} (you)` : name;
56644
56906
  }
@@ -56648,7 +56910,7 @@ function ruleCovers(rule) {
56648
56910
  case "own_mailboxes": return "author's own mailboxes";
56649
56911
  case "author": return "all mail the author reads";
56650
56912
  case "selected": {
56651
- const selection = isRecord$3(rule.scope_selection) ? rule.scope_selection : {};
56913
+ const selection = isRecord$4(rule.scope_selection) ? rule.scope_selection : {};
56652
56914
  const names = [...(Array.isArray(selection.addresses) ? selection.addresses : []).map((address) => shownLine(address)), ...(Array.isArray(selection.domains) ? selection.domains : []).map((domain) => `@${shownLine(domain)}`)].filter((name) => name !== "" && name !== "@");
56653
56915
  if (names.length === 0) return "selected";
56654
56916
  const named = names.slice(0, COVERS_NAMED).join(", ");
@@ -56658,7 +56920,7 @@ function ruleCovers(rule) {
56658
56920
  }
56659
56921
  }
56660
56922
  function countSum(list) {
56661
- return Array.isArray(list) ? list.reduce((sum, entry) => sum + (isRecord$3(entry) && typeof entry.count === "number" ? entry.count : 0), 0) : 0;
56923
+ return Array.isArray(list) ? list.reduce((sum, entry) => sum + (isRecord$4(entry) && typeof entry.count === "number" ? entry.count : 0), 0) : 0;
56662
56924
  }
56663
56925
  /**
56664
56926
  * Who receives what a rule matches now, from receivers (the --all list
@@ -56666,7 +56928,7 @@ function countSum(list) {
56666
56928
  * `unknown` when it could not be read in time.
56667
56929
  */
56668
56930
  function ruleReceivers(rule) {
56669
- if (!isRecord$3(rule.receivers)) return "unknown";
56931
+ if (!isRecord$4(rule.receivers)) return "unknown";
56670
56932
  const keys = countSum(rule.receivers.keys);
56671
56933
  const webhooks = countSum(rule.receivers.webhooks);
56672
56934
  const shares = countSum(rule.receivers.shares);
@@ -56679,7 +56941,7 @@ function ruleReceivers(rule) {
56679
56941
  * with --all who receives what it matches. Nothing for an empty list.
56680
56942
  */
56681
56943
  function ruleListLines(data, all) {
56682
- const rows = Array.isArray(data) ? data.filter(isRecord$3) : [];
56944
+ const rows = Array.isArray(data) ? data.filter(isRecord$4) : [];
56683
56945
  if (rows.length === 0) return [];
56684
56946
  return tableLines([[
56685
56947
  "NAME",
@@ -56705,8 +56967,8 @@ function ruleListLines(data, all) {
56705
56967
  */
56706
56968
  function listEmailRulesErrorHint(code, payload, flags = {}) {
56707
56969
  if (code !== "grant_forbidden") return void 0;
56708
- const error = isRecord$3(payload) && isRecord$3(payload.error) ? payload.error : payload;
56709
- const details = isRecord$3(error) && isRecord$3(error.details) ? error.details : {};
56970
+ const error = isRecord$4(payload) && isRecord$4(payload.error) ? payload.error : payload;
56971
+ const details = isRecord$4(error) && isRecord$4(error.details) ? error.details : {};
56710
56972
  switch (details.reason) {
56711
56973
  case "owner_or_admin_only": return "Only owners and admins can list every rule. Run without --all to list the rules you can see.";
56712
56974
  case "person_credential": return "Listing every rule needs your own CLI login, not an API key or agent sign-in.";
@@ -56731,7 +56993,7 @@ const EMAIL_RULE_LISTING_EXTENSIONS = {
56731
56993
  const rows = Array.isArray(data) ? data : [];
56732
56994
  const lines = ruleListLines(data, flags.all === true);
56733
56995
  const limit = typeof flags.limit === "number" && flags.limit <= RULE_LIST_PAGE_MAX ? flags.limit : typeof flags.limit === "number" ? void 0 : RULE_LIST_DEFAULT_LIMIT;
56734
- const cursor = isRecord$3(meta) ? meta.cursor : void 0;
56996
+ const cursor = isRecord$4(meta) ? meta.cursor : void 0;
56735
56997
  if (typeof flags.mailbox === "string" && typeof cursor === "string" && cursor !== "" && limit !== void 0 && rows.length < limit) lines.push("Scanned part of the rules; run again with --cursor to continue.");
56736
56998
  return { lines };
56737
56999
  }
@@ -56743,6 +57005,91 @@ const EMAIL_RULE_LISTING_EXTENSIONS = {
56743
57005
  listEmailRuleDecisionsOnMyMail: {
56744
57006
  flags: {},
56745
57007
  report: (data) => ({ lines: decisionLines(data) })
57008
+ },
57009
+ listEmailRuleResults: {
57010
+ flags: {},
57011
+ report: (data) => ({ lines: ruleResultsLines(data) })
57012
+ }
57013
+ };
57014
+ // src/oclif/email-rule-shares.ts
57015
+ function isRecord$3(value) {
57016
+ return value !== null && typeof value === "object" && !Array.isArray(value);
57017
+ }
57018
+ /** A person on a share: their name, else their email, else `-`. */
57019
+ function person(value) {
57020
+ if (!isRecord$3(value)) return "-";
57021
+ return shownText(value.name) || shownText(value.email) || "-";
57022
+ }
57023
+ /** The rule's name: the live rule's, else the name the share recorded. */
57024
+ function ruleName(share) {
57025
+ return shownText((isRecord$3(share.rule) ? share.rule : null)?.name) || shownText(share.rule_name) || "-";
57026
+ }
57027
+ /** The rule's id, or `-` when the share does not show it to you. */
57028
+ function ruleId(share) {
57029
+ return shownLine(share.rule_id) || "-";
57030
+ }
57031
+ /** Live, or why not: ended (with its reason) or not live because someone left. */
57032
+ function shareState(share) {
57033
+ if (share.live === true) return "live";
57034
+ const reason = shownLine(share.end_reason);
57035
+ if (typeof share.ended_at === "string") return reason ? `ended (${reason})` : "ended";
57036
+ return "not live";
57037
+ }
57038
+ /** The other person on the share, from the caller's side of it. */
57039
+ function otherSide(share) {
57040
+ if (share.is_granter === true) return `to ${person(share.beneficiary)}`;
57041
+ if (share.is_beneficiary === true) return `from ${person(share.granter)}`;
57042
+ return `${person(share.granter)} to ${person(share.beneficiary)}`;
57043
+ }
57044
+ /**
57045
+ * A table of shares (listEmailRuleShares, listGivenEmailRuleShares): each
57046
+ * share's id, its rule's name and id (`-` where the share does not show the
57047
+ * id), who it is with and whether it is live. Nothing for an empty list.
57048
+ */
57049
+ function shareListLines(data) {
57050
+ const rows = Array.isArray(data) ? data.filter(isRecord$3) : [];
57051
+ if (rows.length === 0) return [];
57052
+ return [...tableLines([[
57053
+ "SHARE ID",
57054
+ "RULE",
57055
+ "RULE ID",
57056
+ "WITH",
57057
+ "STATE"
57058
+ ], ...rows.map((share) => [
57059
+ shownLine(share.id) || "-",
57060
+ ruleName(share),
57061
+ ruleId(share),
57062
+ otherSide(share),
57063
+ shareState(share)
57064
+ ])]), ...rows.some(showsReceivedRuleId) ? [KEY_NOTE] : []];
57065
+ }
57066
+ /** A share made with the caller that shows them its rule's id. */
57067
+ function showsReceivedRuleId(share) {
57068
+ return share.is_beneficiary === true && typeof share.rule_id === "string";
57069
+ }
57070
+ /** Said under a share made with the caller: which id goes where. */
57071
+ const KEY_NOTE = "RULE ID names the rule in your webhook deliveries (understanding.rules[].id, with through_share). A key reads a share by the SHARE ID, added from the dashboard's API keys page.";
57072
+ /** One share (getEmailRuleShare): the same facts as a list row, one per line. */
57073
+ function shareLines(data) {
57074
+ if (!isRecord$3(data)) return [];
57075
+ return [
57076
+ `Share ${shownLine(data.id) || "-"}: ${shareState(data)}, ${otherSide(data)}`,
57077
+ `Rule: ${ruleName(data)} (${typeof data.rule_id === "string" ? `id ${ruleId(data)}` : "id not shown to you"})`,
57078
+ ...showsReceivedRuleId(data) ? [KEY_NOTE] : []
57079
+ ];
57080
+ }
57081
+ const EMAIL_RULE_SHARE_EXTENSIONS = {
57082
+ listEmailRuleShares: {
57083
+ flags: {},
57084
+ report: (data) => ({ lines: shareListLines(data) })
57085
+ },
57086
+ listGivenEmailRuleShares: {
57087
+ flags: {},
57088
+ report: (data) => ({ lines: shareListLines(data) })
57089
+ },
57090
+ getEmailRuleShare: {
57091
+ flags: {},
57092
+ report: (data) => ({ lines: shareLines(data) })
56746
57093
  }
56747
57094
  };
56748
57095
  // src/oclif/empty-mail-hint.ts
@@ -57371,18 +57718,25 @@ const DOMAINS_TIMEOUT_MS = 5e3;
57371
57718
  /**
57372
57719
  * The verified domains this credential can read mail on, from GET /domains,
57373
57720
  * which lists only the domains a credential confined to some mailboxes
57374
- * reaches. Null when they cannot be read.
57721
+ * reaches, or why the server refused to list them for good. Neither when they
57722
+ * could not be read this time.
57375
57723
  */
57376
- async function readReadableDomains(client, timeoutMs = DOMAINS_TIMEOUT_MS) {
57724
+ async function readDomainsOrRefusal(client, timeoutMs = DOMAINS_TIMEOUT_MS) {
57377
57725
  try {
57378
57726
  const result = await listDomains({
57379
57727
  client,
57380
57728
  responseStyle: "fields",
57381
57729
  signal: AbortSignal.timeout(timeoutMs)
57382
57730
  });
57383
- if (result.error) return null;
57731
+ if (result.error) return {
57732
+ readable: null,
57733
+ refusal: refusalOf(result.error, result.response?.status)
57734
+ };
57384
57735
  const rows = result.data?.data;
57385
- if (!Array.isArray(rows)) return null;
57736
+ if (!Array.isArray(rows)) return {
57737
+ readable: null,
57738
+ refusal: null
57739
+ };
57386
57740
  let orgId = null;
57387
57741
  const domains = [];
57388
57742
  for (const row of rows) {
@@ -57396,13 +57750,37 @@ async function readReadableDomains(client, timeoutMs = DOMAINS_TIMEOUT_MS) {
57396
57750
  }
57397
57751
  domains.sort((a, b) => a.name.localeCompare(b.name));
57398
57752
  return {
57399
- orgId,
57400
- domains
57753
+ readable: {
57754
+ orgId,
57755
+ domains
57756
+ },
57757
+ refusal: null
57401
57758
  };
57402
57759
  } catch {
57403
- return null;
57760
+ return {
57761
+ readable: null,
57762
+ refusal: null
57763
+ };
57404
57764
  }
57405
57765
  }
57766
+ /** The most characters of the server's refusal shown. */
57767
+ const REFUSAL_MAX = 400;
57768
+ /**
57769
+ * A refusal asking again will not change, from an error answer: a 403 with a
57770
+ * code and message. Null for anything else, which may pass next time or has
57771
+ * its own hint (a 401), or that cannot be read.
57772
+ */
57773
+ function refusalOf(error, status) {
57774
+ if (status !== 403) return null;
57775
+ const body = error?.error;
57776
+ const code = typeof body?.code === "string" && /^[a-z0-9_]{1,80}$/.test(body.code) ? body.code : null;
57777
+ const shown = typeof body?.message === "string" ? shownLine(body.message).trim() : "";
57778
+ const message = shown.length > REFUSAL_MAX ? `${shown.slice(0, 397)}...` : shown;
57779
+ return code && message ? {
57780
+ code,
57781
+ message
57782
+ } : null;
57783
+ }
57406
57784
  function focusError(message, code, exit, details) {
57407
57785
  const error = new Errors.CLIError(message, {
57408
57786
  exit,
@@ -57516,7 +57894,10 @@ async function resolveFocus(params) {
57516
57894
  }
57517
57895
  };
57518
57896
  const profile = focusProfile(params.configDir, params.auth);
57519
- const readable = await (params.readDomains ?? readReadableDomains)(params.client);
57897
+ const { readable, refusal } = params.readDomains ? {
57898
+ readable: await params.readDomains(params.client),
57899
+ refusal: null
57900
+ } : await readDomainsOrRefusal(params.client);
57520
57901
  const orgId = readable?.orgId ?? params.auth.connectedAgent?.orgId ?? params.auth.credentials?.org_id ?? null;
57521
57902
  if (asked?.source === "env" && readable && readable.domains.length <= 1) return NO_FOCUS;
57522
57903
  if (asked && "all" in asked) return {
@@ -57530,6 +57911,10 @@ async function resolveFocus(params) {
57530
57911
  }
57531
57912
  };
57532
57913
  if (asked) {
57914
+ if (!readable && refusal) {
57915
+ const fromEnv = asked.source === "env" ? ` The names come from ${FOCUS_ENV}: unset it, or pass --all-domains.` : "";
57916
+ throw focusError(`Cannot look up ${joinNames(asked.names)}: ${refusal.message.replace(/\.?$/, ".")}${fromEnv}`, refusal.code, 1);
57917
+ }
57533
57918
  if (!readable) throw focusError(`Could not read this credential's domains to look up ${joinNames(asked.names)}; retry, or pass --all-domains.`, "focus_lookup_failed", 1);
57534
57919
  const domains = resolveDomainNames(asked.names, readable.domains, asked.source === "flag" ? "--domain" : FOCUS_ENV);
57535
57920
  return focusedOutcome(params.surface, domains, asked.source, readable);
@@ -59456,7 +59841,7 @@ function savedConnectedProfiles(configDir, exclude) {
59456
59841
  */
59457
59842
  async function otherProfiles(configDir, session, current) {
59458
59843
  if (session) try {
59459
- const { connectedProfilesForSession } = await import("./machine-session-cfgMKQ_U.js").then((n) => n.s);
59844
+ const { connectedProfilesForSession } = await import("./machine-session-DPLiLNot.js").then((n) => n.s);
59460
59845
  return {
59461
59846
  inSession: true,
59462
59847
  profiles: connectedProfilesForSession(configDir, session, current)
@@ -60622,6 +61007,7 @@ const OPERATION_EXTRA_BODY_FLAGS = { addDomain: { "mail-relay": {
60622
61007
  const OPERATION_EXTENSIONS = {
60623
61008
  ...EMAIL_RULE_OPERATION_EXTENSIONS,
60624
61009
  ...EMAIL_RULE_LISTING_EXTENSIONS,
61010
+ ...EMAIL_RULE_SHARE_EXTENSIONS,
60625
61011
  ...ENDPOINT_HEADER_EXTENSIONS,
60626
61012
  ...ANSWER_REPORT_EXTENSIONS
60627
61013
  };
@@ -60847,41 +61233,21 @@ function createOperationCommand(operation) {
60847
61233
  }
60848
61234
  let pagingNote;
60849
61235
  const callPaged = async () => {
60850
- const max = pageMaximum ?? wanted;
60851
- const rows = [];
60852
- let sentCursor = query.cursor;
60853
- let last = await callOperation(void 0, {
60854
- ...query,
60855
- limit: Math.min(max, wanted)
60856
- });
60857
- const budget = Math.ceil(wanted / max) + 20;
60858
- for (let requests = 1;; requests += 1) {
60859
- if (last.error) return last;
60860
- const envelope = last.data;
60861
- const page = Array.isArray(envelope?.data) ? envelope.data : [];
60862
- rows.push(...page);
60863
- const cursor = envelope?.meta?.cursor ?? void 0;
60864
- const exhausted = Boolean(cursor) && cursor !== sentCursor && rows.length < wanted && requests >= budget;
60865
- if (exhausted) pagingNote = `Stopped after ${requests} requests with ${rows.length} of ${wanted}; more may remain. Continue with --cursor ${cursor}.`;
60866
- if (!cursor || cursor === sentCursor || rows.length >= wanted || exhausted) return {
60867
- ...last,
60868
- data: {
60869
- ...envelope ?? {},
60870
- data: rows,
60871
- meta: {
60872
- ...envelope?.meta ?? {},
60873
- limit: wanted,
60874
- cursor: cursor ?? null
60875
- }
60876
- }
60877
- };
60878
- sentCursor = cursor;
60879
- last = await callOperation(void 0, {
61236
+ const page = await fetchBoundedPages({
61237
+ wanted,
61238
+ maximum: pageMaximum ?? wanted,
61239
+ cursor: typeof query.cursor === "string" ? query.cursor : void 0,
61240
+ call: (limit, cursor) => callOperation(void 0, {
60880
61241
  ...query,
60881
- cursor,
60882
- limit: Math.min(max, wanted - rows.length)
60883
- });
60884
- }
61242
+ limit,
61243
+ cursor
61244
+ })
61245
+ });
61246
+ pagingNote = page.note;
61247
+ return page.envelope ? {
61248
+ ...page.result,
61249
+ data: page.envelope
61250
+ } : page.result;
60885
61251
  };
60886
61252
  if (operation.sdkName === "setMemberRole") {
60887
61253
  const role = body && typeof body === "object" ? body.role : void 0;
@@ -60970,10 +61336,11 @@ function createOperationCommand(operation) {
60970
61336
  return;
60971
61337
  }
60972
61338
  const jsonOutput = parsedFlags.json === true;
61339
+ if (jsonOutput && operation.sdkName === "listEndpoints" && envelope) envelope.meta ??= {};
60973
61340
  writeFocusLine(focus, jsonOutput);
60974
61341
  const cursor = envelope?.meta?.cursor;
60975
61342
  if (cursor && !jsonOutput) process.stderr.write(`next cursor: ${cursor}\n`);
60976
- if (pagingNote && !jsonOutput) process.stderr.write(`${pagingNote}\n`);
61343
+ if (pagingNote) process.stderr.write(`${pagingNote}\n`);
60977
61344
  const summary = [];
60978
61345
  if (Array.isArray(envelope?.data) && envelope.data.length === 0 && (jsonOutput || !metaExplainsEmptyList(envelope?.meta))) {
60979
61346
  const tail = query.since !== void 0;
@@ -60987,7 +61354,7 @@ function createOperationCommand(operation) {
60987
61354
  if (hint && jsonOutput) summary.push(hint);
60988
61355
  else if (hint) process.stderr.write(`${hint}\n`);
60989
61356
  }
60990
- if (Array.isArray(envelope?.data) && envelope.data.length === 0 && focus.focused && query.since === void 0 && query.cursor === void 0) {
61357
+ if (Array.isArray(envelope?.data) && envelope.data.length === 0 && focus.focused && query.since === void 0 && query.cursor === void 0 && !envelope?.meta?.cursor) {
60991
61358
  const countParam = focusSpec?.countParam;
60992
61359
  const note = await focusEmptyHint(focus, async () => {
60993
61360
  const counted = await callOperation(void 0, {
@@ -61094,4 +61461,4 @@ function emptyDeliveriesHint(sdkName, query) {
61094
61461
  function canonicalizeCliReferences(description) {
61095
61462
  return canonicalCliText(description).replaceAll("`primitive emails:latest`", "`primitive emails latest`").replaceAll("`primitive describe emails:get-email | jq '.responseSchema.properties'`", "`primitive describe emails:get | jq '.responseSchema.properties'`");
61096
61463
  }
61097
- export { wakeInteractionSentence as $, queryScopesItself as $t, displayAddress as A, revokeUserLogin as An, defaultConnectionName as At, wakeRelationship as B, FOCUS_SERVER_SUPPORT as Bt, canOfferCopyHotkey as C, selectedOrgFromEnv as Cn, sentHistoryWindowStart as Ct, explainPendingMailNotFound as D, displayedRoleKey as Dn, DEFAULT_ENROLL_NAME as Dt, openBrowser as E, credentialsFromUserLogin as En, thrownErrorExitCode as Et, serverMuted as F, sanitizeForTerminal as Fn, detectAgentRuntime as Ft, readPendingMail as G, focusFlags as Gt, clearConsumedPendingMail as H, countFromMeta as Ht, serverRelationship as I, shownLine as In, detectRuntimeSession as It, interactionHumanLine as J, joinNames as Jt, recordPendingMail as K, focusForCorpus as Kt, skillFirstLine as L, setKnownCommands as Ln, runtimeSessionVariableList as Lt, latestOwnOutbound as M, roleKeyText as Mn, identitySuggestions as Mt, readThreadContext as N, switchCurrentOrg as Nn, loadSkillLine as Nt, bareAddress as O, fetchCliOrgs as On, cliInvocation as Ot, sentInThread as P, routeWarningLines as Pn, currentMailSessionKey as Pt, replyInteractionWarning as Q, oneDomainAtATimeError as Qt, wakeReadCommand as R, operationManifest as Rn, formatAlreadySentNotice as Rt, withApproval as S, resolveCliApiRequestConfig as Sn, sendWaitClampNotice as St, listenForCopyHotkey as T, RESTRICTED_ROLE_NOTE as Tn, successfulSendOutcome as Tt, clearReadPendingMail as U, focusEmptyHint as Ut, claimPendingMail as V, NO_FOCUS as Vt, pendingMailPath as W, focusFlagValues as Wt, readEmailInteraction as X, manyDomainsSupported as Xt, interactionNextActions as Y, loadSavedFocus as Yt, replyExpectation as Z, normalizeDomainNames as Zt, STEP_UP_HEADER as _, SAVED_CLI_OAUTH_SESSION_EXPIRED_MESSAGE as _n, priorRepliesThatWentOut as _t, extractErrorCode as a, withoutFocus as an, buildFollowUpCommand as at, promptLine as b, refreshStoredCliCredentials as bn, sendIdentityFields as bt, hasControlCharacter as c, emptyEmailListHint as cn, classifySendError as ct, readTextFileFlag as d, formatFact as dn, followUpCommandPrefix as dt, readReadableDomains as en, IDEMPOTENCY_KEY_FLAG_DESCRIPTION as et, refusesCredential as f, isEmailId as fn, formatDeletedEarlierSendNotice as ft, BROWSER_FLAG_DESCRIPTION as g, ConnectedAgentKeyRequiredError as gn, formatSendRecordFailureSummary as gt, writeErrorWithHints as h, withAttachmentWait as hn, formatSendFailureSummary as ht, createOperationCommand as i, withFocusMeta as in, assertValidIdempotencyKey as it, formatMailWakeLine as j, roleKeyLabel as jn, generatedAgentName as jt, describeWake as k, isBuiltInRoleKey as kn, connectNextSteps as kt, isGrantRefusal as l, mailReach as ln, deriveSendIdempotencyKey as lt, surfaceUnauthorizedHint as m, ATTACHMENT_WAIT_MAX_MS as mn, formatPriorRepliesWarning as mt, API_ERROR_CODES as n, resolveFocus as nn, SEND_OUTCOME_HELP as nt, extractErrorPayload as o, writeFocusLine as on, buildThrownSendFailureEnvelope as ot, runWithTiming as p, ATTACHMENT_WAIT_FLAG_DESCRIPTION as pn, formatPriorRepliesCheckSkipped as pt, removePendingMail as q, focusProfile as qt, TIME_FLAG_DESCRIPTION as r, saveFocus as rn, apiResultHttpStatus as rt, formatErrorPayload as s, withFlagSuggestion as sn, checkPriorReplies as st, API_BASE_URL_FLAG_DESCRIPTION as t, resolveDomainNames as tn, MAX_SEND_WAIT_TIMEOUT_MS as tt, networkErrorHint as u, readCallerMailFor as un, excludeSignalReplies as ut, STEP_UP_TOKEN_FLAG_DESCRIPTION as v, createAuthenticatedCliApiClient as vn, reportSendCommandResult as vt, formatBrowserLoginInstructions as w, CliOrgRefusedError as wn, serializeErrorPayload as wt, terminalApprovalIo as x, refuseOrgSelectionForProfile as xn, sendOutcomeExitCode as xt, approveThenRerunHint as y, createCliApiClient as yn, sendErrorMessage as yt, wakeRecipientField as z, FOCUS_ENV as zt };
61464
+ export { replyInteractionWarning as $, oneDomainAtATimeError as $t, describeWake as A, displayedRoleKey as An, connectNextSteps as At, wakeRecipientField as B, setKnownCommands as Bn, FOCUS_ENV as Bt, withApproval as C, refreshStoredCliCredentials as Cn, sendWaitClampNotice as Ct, openBrowser as D, CliOrgRefusedError as Dn, thrownErrorExitCode as Dt, listenForCopyHotkey as E, selectedOrgFromEnv as En, successfulSendOutcome as Et, sentInThread as F, roleKeyText as Fn, currentMailSessionKey as Ft, pendingMailPath as G, focusFlagValues as Gt, claimPendingMail as H, NO_FOCUS as Ht, serverMuted as I, switchCurrentOrg as In, detectAgentRuntime as It, removePendingMail as J, focusProfile as Jt, readPendingMail as K, focusFlags as Kt, serverRelationship as L, routeWarningLines as Ln, detectRuntimeSession as Lt, formatMailWakeLine as M, isBuiltInRoleKey as Mn, generatedAgentName as Mt, latestOwnOutbound as N, revokeUserLogin as Nn, identitySuggestions as Nt, explainPendingMailNotFound as O, RESTRICTED_ROLE_NOTE as On, DEFAULT_ENROLL_NAME as Ot, readThreadContext as P, roleKeyLabel as Pn, loadSkillLine as Pt, replyExpectation as Q, normalizeDomainNames as Qt, skillFirstLine as R, sanitizeForTerminal as Rn, runtimeSessionVariableList as Rt, terminalApprovalIo as S, createCliApiClient as Sn, sendOutcomeExitCode as St, formatBrowserLoginInstructions as T, resolveCliApiRequestConfig as Tn, serializeErrorPayload as Tt, clearConsumedPendingMail as U, countFromMeta as Ut, wakeRelationship as V, operationManifest as Vn, FOCUS_SERVER_SUPPORT as Vt, clearReadPendingMail as W, focusEmptyHint as Wt, interactionNextActions as X, loadSavedFocus as Xt, interactionHumanLine as Y, joinNames as Yt, readEmailInteraction as Z, manyDomainsSupported as Zt, BROWSER_FLAG_DESCRIPTION as _, ATTACHMENT_WAIT_MAX_MS as _n, formatSendRecordFailureSummary as _t, createOperationCommand as a, withFocusMeta as an, assertValidIdempotencyKey as at, approveThenRerunHint as b, SAVED_CLI_OAUTH_SESSION_EXPIRED_MESSAGE as bn, sendErrorMessage as bt, formatErrorPayload as c, withFlagSuggestion as cn, checkPriorReplies as ct, networkErrorHint as d, readCallerMailFor as dn, excludeSignalReplies as dt, queryScopesItself as en, wakeInteractionSentence as et, readTextFileFlag as f, formatFact as fn, followUpCommandPrefix as ft, writeErrorWithHints as g, ATTACHMENT_WAIT_FLAG_DESCRIPTION as gn, formatSendFailureSummary as gt, surfaceUnauthorizedHint as h, withBooleanFlagValues as hn, formatPriorRepliesWarning as ht, TIME_FLAG_DESCRIPTION as i, saveFocus as in, apiResultHttpStatus as it, displayAddress as j, fetchCliOrgs as jn, defaultConnectionName as jt, bareAddress as k, credentialsFromUserLogin as kn, cliInvocation as kt, hasControlCharacter as l, emptyEmailListHint as ln, classifySendError as lt, runWithTiming as m, fetchBoundedPages as mn, formatPriorRepliesCheckSkipped as mt, API_ERROR_CODES as n, resolveDomainNames as nn, MAX_SEND_WAIT_TIMEOUT_MS as nt, extractErrorCode as o, withoutFocus as on, buildFollowUpCommand as ot, refusesCredential as p, isEmailId as pn, formatDeletedEarlierSendNotice as pt, recordPendingMail as q, focusForCorpus as qt, PAGED_LIMIT_MAX as r, resolveFocus as rn, SEND_OUTCOME_HELP as rt, extractErrorPayload as s, writeFocusLine as sn, buildThrownSendFailureEnvelope as st, API_BASE_URL_FLAG_DESCRIPTION as t, readDomainsOrRefusal as tn, IDEMPOTENCY_KEY_FLAG_DESCRIPTION as tt, isGrantRefusal as u, mailReach as un, deriveSendIdempotencyKey as ut, STEP_UP_HEADER as v, withAttachmentWait as vn, priorRepliesThatWentOut as vt, canOfferCopyHotkey as w, refuseOrgSelectionForProfile as wn, sentHistoryWindowStart as wt, promptLine as x, createAuthenticatedCliApiClient as xn, sendIdentityFields as xt, STEP_UP_TOKEN_FLAG_DESCRIPTION as y, ConnectedAgentKeyRequiredError as yn, reportSendCommandResult as yt, wakeReadCommand as z, shownLine as zn, formatAlreadySentNotice as zt };