@primitivedotdev/cli 3.0.0-preview.21 → 3.0.0-preview.23

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";
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";
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
+ import { C as resolveCliAuth, I as agentProfilesDirectory, M as AGENT_PROFILE_ENV, P as agentProfileDirectory, Q as loadActiveAgentPass, S as normalizeApiBaseUrl, T as saveSignupCredentials, U as requireDefaultLoginProfile, b as detectPrimitiveKeyEnvMisname, ct as PrimitiveApiClient, f as validateCliHeaderName, h as cliAccessTokenExpiresAt, i as loadCliConfig, l as resolveConfigEnvironment, m as acquireCliCredentialsLock, ot as detectRuntimeSession, p as validateCliHeaderValue, v as deleteCliCredentials, w as saveCliCredentials, x as loadCliCredentials, z as loadConnectedAgentProfile } from "./cli-config-DUQEYQ42.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. */
@@ -55282,7 +55439,20 @@ function cliApiHeadersFromEnv(env = process.env) {
55282
55439
  return rawGenericHeaders ? parseHeadersJson(rawGenericHeaders) : void 0;
55283
55440
  }
55284
55441
  function resolveCliApiRequestConfig(params) {
55285
- if ((params.env ?? process.env)["PRIMITIVE_AGENT_PROFILE"]?.trim()) {
55442
+ const env = params.env ?? process.env;
55443
+ if (env["PRIMITIVE_AGENT_PROFILE"]?.trim() || env["PRIMITIVE_AGENT_PASS_PROFILE"]?.trim()) {
55444
+ const auth = resolveCliAuth(params);
55445
+ return {
55446
+ apiBaseUrl: auth.apiBaseUrl,
55447
+ resolvedApiBaseUrl: auth.apiBaseUrl,
55448
+ baseUrlOverridden: params.apiBaseUrl !== void 0,
55449
+ environmentName: null
55450
+ };
55451
+ }
55452
+ if (loadActiveAgentPass({
55453
+ configDir: params.configDir,
55454
+ env
55455
+ })) {
55286
55456
  const auth = resolveCliAuth(params);
55287
55457
  return {
55288
55458
  apiBaseUrl: auth.apiBaseUrl,
@@ -55503,7 +55673,7 @@ async function createAuthenticatedCliApiClient(params) {
55503
55673
  })
55504
55674
  } : { apiKey: auth.apiKey },
55505
55675
  apiBaseUrl: auth.apiBaseUrl,
55506
- headers: auth.connectedAgent ? void 0 : requestConfig.headers
55676
+ headers: auth.connectedAgent || auth.agentPass ? void 0 : requestConfig.headers
55507
55677
  }),
55508
55678
  auth,
55509
55679
  baseUrlOverridden: requestConfig.baseUrlOverridden,
@@ -55654,10 +55824,61 @@ function withBooleanFlagValues(argv, flags) {
55654
55824
  }
55655
55825
  return out;
55656
55826
  }
55827
+ // src/oclif/bounded-pages.ts
55828
+ /** Read a bounded window, preserving the last page's metadata and errors. */
55829
+ async function fetchBoundedPages(options) {
55830
+ const { wanted, maximum, call } = options;
55831
+ const rows = [];
55832
+ const seen = /* @__PURE__ */ new Set([options.cursor]);
55833
+ let cursor = options.cursor;
55834
+ let merged = {};
55835
+ const budget = Math.ceil(wanted / maximum) + 20;
55836
+ for (let requests = 1;; requests += 1) {
55837
+ const result = await call(Math.min(maximum, wanted - rows.length), cursor);
55838
+ if (result.error) return { result };
55839
+ const envelope = result.data;
55840
+ rows.push(...Array.isArray(envelope?.data) ? envelope.data : []);
55841
+ const previousWarnings = merged.warnings;
55842
+ const previousMeta = { ...merged.meta };
55843
+ delete previousMeta.total;
55844
+ delete previousMeta.total_capped;
55845
+ delete previousMeta.total_unavailable;
55846
+ merged = {
55847
+ ...merged,
55848
+ ...envelope,
55849
+ meta: {
55850
+ ...previousMeta,
55851
+ ...envelope?.meta
55852
+ }
55853
+ };
55854
+ if (Array.isArray(previousWarnings) && Array.isArray(envelope?.warnings)) merged.warnings = [...previousWarnings, ...envelope.warnings];
55855
+ const next = envelope?.meta?.cursor ?? void 0;
55856
+ const repeated = Boolean(next) && seen.has(next);
55857
+ const bounded = Boolean(next) && rows.length < wanted && requests >= budget;
55858
+ if (!next || repeated || rows.length >= wanted || bounded) {
55859
+ 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;
55860
+ return {
55861
+ result,
55862
+ envelope: {
55863
+ ...merged,
55864
+ data: rows,
55865
+ meta: {
55866
+ ...merged.meta,
55867
+ limit: wanted,
55868
+ cursor: next ?? null
55869
+ }
55870
+ },
55871
+ note
55872
+ };
55873
+ }
55874
+ seen.add(next);
55875
+ cursor = next;
55876
+ }
55877
+ }
55657
55878
  // src/oclif/rule-notes.ts
55658
55879
  /** The tags whose single-object answers get the notes printer. */
55659
55880
  const RULE_NOTES_TAGS = /* @__PURE__ */ new Set(["Email Rules", "Email Rule Oversight"]);
55660
- function isRecord$6(value) {
55881
+ function isRecord$8(value) {
55661
55882
  return value !== null && typeof value === "object" && !Array.isArray(value);
55662
55883
  }
55663
55884
  /** Server text as a report line shows it, or "" when there is none. */
@@ -55686,12 +55907,12 @@ function list(value) {
55686
55907
  * rule's, each once.
55687
55908
  */
55688
55909
  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 : {};
55910
+ if (!isRecord$8(answer)) return [];
55911
+ const summary = isRecord$8(answer.summary) ? answer.summary : {};
55912
+ const rule = isRecord$8(answer.rule) ? answer.rule : {};
55692
55913
  const notes = (from) => NOTE_KEYS.map((key) => from[key]);
55693
55914
  const lines = [
55694
- ...list(answer.scope_warnings).filter(isRecord$6).map(scopeWarningLine),
55915
+ ...list(answer.scope_warnings).filter(isRecord$8).map(scopeWarningLine),
55695
55916
  ...[
55696
55917
  ...list(answer.warnings),
55697
55918
  answer.warning,
@@ -55713,7 +55934,7 @@ function errorDetail(error) {
55713
55934
  function usageError$3(message) {
55714
55935
  return new Errors.CLIError(message, { exit: 2 });
55715
55936
  }
55716
- function isRecord$5(value) {
55937
+ function isRecord$7(value) {
55717
55938
  return value !== null && typeof value === "object" && !Array.isArray(value);
55718
55939
  }
55719
55940
  /** A JSON file a flag names, parsed, or a usage error (exit 2) saying why not. */
@@ -55772,7 +55993,7 @@ function lookAlikeExpected(lookAlike) {
55772
55993
  * leaves it out of what a rule keeps.
55773
55994
  */
55774
55995
  function lookAlikeSample(lookAlike) {
55775
- if (!isRecord$5(lookAlike) || !isRecord$5(lookAlike.email)) return null;
55996
+ if (!isRecord$7(lookAlike) || !isRecord$7(lookAlike.email)) return null;
55776
55997
  const kind = typeof lookAlike.kind === "string" ? lookAlike.kind : "";
55777
55998
  const why = typeof lookAlike.why === "string" ? lookAlike.why.trim() : "";
55778
55999
  const both = kind && why ? `${kind}: ${why}` : kind || why;
@@ -55791,11 +56012,11 @@ function lookAlikeSample(lookAlike) {
55791
56012
  * samples file holds these, so a number means the same email in both.
55792
56013
  */
55793
56014
  function lookAlikeEntries(answer) {
55794
- const list = isRecord$5(answer) && Array.isArray(answer.look_alikes) ? answer.look_alikes : [];
56015
+ const list = isRecord$7(answer) && Array.isArray(answer.look_alikes) ? answer.look_alikes : [];
55795
56016
  const entries = [];
55796
56017
  for (const item of list) {
55797
56018
  const sample = lookAlikeSample(item);
55798
- if (sample && isRecord$5(item)) entries.push({
56019
+ if (sample && isRecord$7(item)) entries.push({
55799
56020
  lookAlike: item,
55800
56021
  sample
55801
56022
  });
@@ -55815,15 +56036,15 @@ function lookAlikeSamples(answer) {
55815
56036
  * refused, so it never empties a rule's.
55816
56037
  */
55817
56038
  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)) {
56039
+ const data = isRecord$7(value) && isRecord$7(value.data) ? value.data : value;
56040
+ if (isRecord$7(data) && Array.isArray(data.look_alikes)) {
55820
56041
  const samples = lookAlikeSamples(data);
55821
56042
  if (samples.length === 0) throw usageError$3(`${source} is a generate-look-alikes answer with no look-alikes in it.`);
55822
56043
  return samples;
55823
56044
  }
55824
56045
  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
56046
  return data.map((item, index) => {
55826
- if (!isRecord$5(item)) throw usageError$3(`${source}, sample ${index + 1} (index ${index}) is not an object.`);
56047
+ if (!isRecord$7(item)) throw usageError$3(`${source}, sample ${index + 1} (index ${index}) is not an object.`);
55827
56048
  const { id: _id, created_at: _createdAt, ...sample } = item;
55828
56049
  return sample;
55829
56050
  });
@@ -55916,11 +56137,11 @@ const CLOSE_CALL_NOTE = "a close call: decided by an answer below 0.75 confidenc
55916
56137
  * them left out: "By group: private 3 passed; near_miss 1 passed, 1 failed."
55917
56138
  */
55918
56139
  function groupCountsLines(byGroup) {
55919
- if (!isRecord$5(byGroup)) return [];
56140
+ if (!isRecord$7(byGroup)) return [];
55920
56141
  const parts = [];
55921
56142
  for (const group of SAMPLE_GROUPS) {
55922
56143
  const tally = byGroup[group];
55923
- if (!isRecord$5(tally)) continue;
56144
+ if (!isRecord$7(tally)) continue;
55924
56145
  const counted = [
55925
56146
  "passed",
55926
56147
  "failed",
@@ -55937,11 +56158,11 @@ function groupCountsLines(byGroup) {
55937
56158
  * match it, and what the rule decided; the counts; then the server's notes.
55938
56159
  */
55939
56160
  function lookAlikesReport(data) {
55940
- if (!isRecord$5(data)) return { lines: [] };
56161
+ if (!isRecord$7(data)) return { lines: [] };
55941
56162
  const lines = [];
55942
56163
  lookAlikeEntries(data).forEach(({ lookAlike }, index) => {
55943
56164
  const email = lookAlike.email;
55944
- const from = isRecord$5(email.from) ? shownText(email.from.address) : "";
56165
+ const from = isRecord$7(email.from) ? shownText(email.from.address) : "";
55945
56166
  const subject = shownText(email.subject);
55946
56167
  const status = shownLine(lookAlike.status) || "undecided";
55947
56168
  const kind = shownLine(lookAlike.kind) || "other";
@@ -55953,7 +56174,7 @@ function lookAlikesReport(data) {
55953
56174
  if (why) lines.push(` Why it should ${expected === "match" ? "" : "not "}match: ${why}`);
55954
56175
  lines.push(` ${outcome} (expected ${expected})${lookAlike.close_call === true ? `; ${CLOSE_CALL_NOTE}` : ""}`);
55955
56176
  });
55956
- const counts = isRecord$5(data.counts) ? data.counts : {};
56177
+ const counts = isRecord$7(data.counts) ? data.counts : {};
55957
56178
  const count = (key) => typeof counts[key] === "number" ? counts[key] : 0;
55958
56179
  const dropped = count("dropped");
55959
56180
  const closeCalls = count("close_calls");
@@ -56032,6 +56253,52 @@ function scopeSelectionBodyFields(flags, base) {
56032
56253
  });
56033
56254
  return fields;
56034
56255
  }
56256
+ function isRecord$6(value) {
56257
+ return value !== null && typeof value === "object" && !Array.isArray(value);
56258
+ }
56259
+ /**
56260
+ * Text a sender or a file reader wrote, on one line, in compatibility form (so a
56261
+ * fullwidth comma or parenthesis reads as the plain one), cut at `max` code
56262
+ * points.
56263
+ */
56264
+ function cut(value, max) {
56265
+ const chars = Array.from(shownLine(value).normalize("NFKC"));
56266
+ return chars.length > max ? `${chars.slice(0, max - 3).join("").trimEnd()}...` : chars.join("");
56267
+ }
56268
+ /**
56269
+ * A file name as the line shows it: in double quotes when it holds a comma, a
56270
+ * parenthesis or a quote, or starts with a plus, so a name cannot pass for more
56271
+ * files, a description or the count of the rest.
56272
+ */
56273
+ function fileName(value) {
56274
+ const name = cut(value, 40);
56275
+ if (name === "") return "(no name)";
56276
+ return /[,()"]|^\+/.test(name) ? `"${name.replaceAll("\"", "'")}"` : name;
56277
+ }
56278
+ /**
56279
+ * What a row's email carried, as one line without indentation: "2
56280
+ * attachments: rate-card.pdf (Contractor pay rates by role), logo.png",
56281
+ * "no attachments", or undefined when the row does not say (null or absent:
56282
+ * not known to the caller).
56283
+ */
56284
+ function attachmentsSummary(row) {
56285
+ if (!isRecord$6(row) || !Array.isArray(row.attachments)) return void 0;
56286
+ const listed = row.attachments.filter(isRecord$6);
56287
+ const count = typeof row.attachment_count === "number" && row.attachment_count >= listed.length ? row.attachment_count : listed.length;
56288
+ if (count === 0) return "no attachments";
56289
+ const shown = listed.slice(0, 3).map((file) => {
56290
+ const name = fileName(file.name);
56291
+ const description = cut(file.description, 60).replaceAll("(", "[").replaceAll(")", "]");
56292
+ return description ? `${name} (${description})` : name;
56293
+ });
56294
+ const more = count - shown.length;
56295
+ return `${count} ${count === 1 ? "attachment" : "attachments"}: ${[...shown, ...more > 0 ? [`+${more} more`] : []].join(", ")}`;
56296
+ }
56297
+ /** attachmentsSummary as lines under a row, indented by `indent`; none when it does not say. */
56298
+ function attachmentsLines(row, indent) {
56299
+ const summary = attachmentsSummary(row);
56300
+ return summary === void 0 ? [] : [`${indent}${summary}`];
56301
+ }
56035
56302
  // src/oclif/email-rule-authoring.ts
56036
56303
  const EMAIL_ID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
56037
56304
  /** Whether `id` has the shape of an email id (a UUID). */
@@ -56041,7 +56308,7 @@ function isEmailId(id) {
56041
56308
  function usageError$1(message) {
56042
56309
  return new Errors.CLIError(message, { exit: 2 });
56043
56310
  }
56044
- function isRecord$4(value) {
56311
+ function isRecord$5(value) {
56045
56312
  return value !== null && typeof value === "object" && !Array.isArray(value);
56046
56313
  }
56047
56314
  /** `count` and the word for it: "1 expectation", "2 expectations". */
@@ -56071,7 +56338,7 @@ function parseEmailIdList(values, flag) {
56071
56338
  * their own flag.
56072
56339
  */
56073
56340
  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>"]}.`);
56341
+ if (!isRecord$5(value)) throw usageError$1(`${label} must hold a JSON object such as {"match": ["<email-id>"], "no_match": ["<email-id>"]}.`);
56075
56342
  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
56343
  return value;
56077
56344
  }
@@ -56121,10 +56388,10 @@ function sameEmailsBodyFields(flags) {
56121
56388
  const file = flags[SAME_EMAILS_FLAG];
56122
56389
  if (typeof file !== "string") return [];
56123
56390
  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;
56391
+ const answer = isRecord$5(saved) && isRecord$5(saved.data) ? saved.data : saved;
56392
+ const results = isRecord$5(answer) && Array.isArray(answer.results) ? answer.results : null;
56126
56393
  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()] : []))];
56394
+ const ids = [...new Set(results.flatMap((result) => isRecord$5(result) && typeof result.email_id === "string" && isEmailId(result.email_id) ? [result.email_id.toLowerCase()] : []))];
56128
56395
  if (ids.length === 0) throw usageError$1(`--${SAME_EMAILS_FLAG} ${file} names no emails.`);
56129
56396
  return [{
56130
56397
  flag: `--${SAME_EMAILS_FLAG}`,
@@ -56159,7 +56426,7 @@ function formatFactValue(fact) {
56159
56426
  const value = fact?.value;
56160
56427
  let text;
56161
56428
  if (Array.isArray(value)) {
56162
- const per = isRecord$4(fact?.value_confidences) ? fact.value_confidences : void 0;
56429
+ const per = isRecord$5(fact?.value_confidences) ? fact.value_confidences : void 0;
56163
56430
  text = `[${value.map((item) => {
56164
56431
  const name = String(item);
56165
56432
  const score = per?.[name];
@@ -56189,7 +56456,7 @@ function answerConfidence(answer) {
56189
56456
  * decide it. An entry that does not say it can is taken as one that cannot.
56190
56457
  */
56191
56458
  function undecidedOf(entry) {
56192
- const given = isRecord$4(entry) ? entry : {};
56459
+ const given = isRecord$5(entry) ? entry : {};
56193
56460
  return {
56194
56461
  reason: typeof given.reason === "string" ? given.reason : "undecided",
56195
56462
  retryable: given.retryable === true
@@ -56222,7 +56489,7 @@ function questionLines(summary, results) {
56222
56489
  }
56223
56490
  /** Whether an expectation entry is marked a close call. */
56224
56491
  function isCloseCall(entry) {
56225
- return isRecord$4(entry) && entry.close_call === true;
56492
+ return isRecord$5(entry) && entry.close_call === true;
56226
56493
  }
56227
56494
  function expectationLine(result) {
56228
56495
  const note = result.status === "undecided" ? undecidedNote(undecidedOf(result)) : isCloseCall(result) ? CLOSE_CALL_NOTE : void 0;
@@ -56230,13 +56497,13 @@ function expectationLine(result) {
56230
56497
  }
56231
56498
  /** The made-up emails a test's expectations judged, in order. */
56232
56499
  function sampleJudgments(expectations) {
56233
- return (isRecord$4(expectations) && Array.isArray(expectations.samples) ? expectations.samples : []).filter(isRecord$4).map((item, position) => ({
56500
+ return (isRecord$5(expectations) && Array.isArray(expectations.samples) ? expectations.samples : []).filter(isRecord$5).map((item, position) => ({
56234
56501
  index: typeof item.index === "number" ? item.index : position,
56235
56502
  label: typeof item.label === "string" ? item.label : null,
56236
56503
  expected: String(item.expected ?? ""),
56237
56504
  outcome: String(item.outcome ?? "not_decided"),
56238
56505
  status: String(item.status ?? "undecided"),
56239
- question_answers: Array.isArray(item.question_answers) ? item.question_answers.filter(isRecord$4) : [],
56506
+ question_answers: Array.isArray(item.question_answers) ? item.question_answers.filter(isRecord$5) : [],
56240
56507
  entry: item
56241
56508
  }));
56242
56509
  }
@@ -56286,10 +56553,10 @@ function expectationsLines(expectations, name = sampleNamer()) {
56286
56553
  * withheld.
56287
56554
  */
56288
56555
  function changesLines(changes, kind) {
56289
- if (!isRecord$4(changes)) return [];
56556
+ if (!isRecord$5(changes)) return [];
56290
56557
  const list = (value) => {
56291
- const given = isRecord$4(value) ? value : {};
56292
- const emails = Array.isArray(given.emails) ? given.emails.filter(isRecord$4) : [];
56558
+ const given = isRecord$5(value) ? value : {};
56559
+ const emails = Array.isArray(given.emails) ? given.emails.filter(isRecord$5) : [];
56293
56560
  return {
56294
56561
  count: typeof given.count === "number" ? given.count : emails.length,
56295
56562
  emails
@@ -56310,7 +56577,7 @@ function changesLines(changes, kind) {
56310
56577
  for (const [label, entry] of [[words[0], newly], [words[1], stops]]) {
56311
56578
  if (entry.emails.length === 0) continue;
56312
56579
  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));
56580
+ 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
56581
  }
56315
56582
  return lines;
56316
56583
  }
@@ -56342,20 +56609,16 @@ function notMatchedLine(result) {
56342
56609
  return [...lines, ...attachmentsLine(result)];
56343
56610
  }
56344
56611
  /**
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.
56612
+ * What a decided result's email carried (attachments), on one line under it,
56613
+ * as the decision listings show it (attachmentsSummary).
56348
56614
  */
56349
56615
  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(", ")}`] : [];
56616
+ return attachmentsLines(result, " ").map(terminalLine);
56354
56617
  }
56355
56618
  /**
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.
56619
+ * The matched emails, each with who sent it, its subject and what it carried
56620
+ * (how many files, the first few names and descriptions), so a match can be
56621
+ * judged without opening it; cut as the not matched list is.
56359
56622
  */
56360
56623
  function matchedLines(results, expectations) {
56361
56624
  const flagged = new Set((expectations?.results ?? []).filter((result) => result.status !== "passed").map((result) => result.email_id));
@@ -56445,7 +56708,7 @@ function minuteUtc$1(value) {
56445
56708
  }
56446
56709
  /** The first line of a test report: which mail was tested. */
56447
56710
  function windowLine(data, tested) {
56448
- const window = isRecord$4(data.window) ? data.window : void 0;
56711
+ const window = isRecord$5(data.window) ? data.window : void 0;
56449
56712
  const oldest = typeof window?.oldest_at === "string" ? window.oldest_at : void 0;
56450
56713
  const newest = typeof window?.newest_at === "string" ? window.newest_at : void 0;
56451
56714
  if (!window || !oldest || !newest) return [];
@@ -56453,19 +56716,19 @@ function windowLine(data, tested) {
56453
56716
  }
56454
56717
  /** The stderr report and exit code of a test answer. */
56455
56718
  function testEmailRuleReport(data) {
56456
- if (!isRecord$4(data)) return { lines: [] };
56719
+ if (!isRecord$5(data)) return { lines: [] };
56457
56720
  const name = sampleNamer();
56458
56721
  const result = data;
56459
56722
  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;
56723
+ const summary = isRecord$5(result.summary) ? result.summary : void 0;
56724
+ const counts = isRecord$5(data.counts) ? data.counts : void 0;
56462
56725
  return {
56463
56726
  lines: [
56464
56727
  ...windowLine(data, (typeof counts?.emails === "number" ? counts.emails : results.length) - (typeof counts?.not_found === "number" ? counts.not_found : 0)),
56465
56728
  ...ruleNotesLines(data),
56466
56729
  ...conditionLines(summary),
56467
56730
  ...questionLines(summary, results),
56468
- ...changesLines(data.changes, isRecord$4(data.rule) ? data.rule.kind : void 0),
56731
+ ...changesLines(data.changes, isRecord$5(data.rule) ? data.rule.kind : void 0),
56469
56732
  ...expectationsLines(result.expectations, name),
56470
56733
  ...matchedLines(results, result.expectations),
56471
56734
  ...notMatchedLines(results, result.expectations)
@@ -56589,7 +56852,7 @@ const EMAIL_RULE_OPERATION_EXTENSIONS = {
56589
56852
  }
56590
56853
  };
56591
56854
  // src/oclif/email-rule-listings.ts
56592
- function isRecord$3(value) {
56855
+ function isRecord$4(value) {
56593
56856
  return value !== null && typeof value === "object" && !Array.isArray(value);
56594
56857
  }
56595
56858
  /** Rows as a table: every column padded to its widest cell but the last. */
@@ -56612,14 +56875,16 @@ function decisionOutcome(decision) {
56612
56875
  /**
56613
56876
  * A table of a rule's decisions (listEmailRuleDecisions and
56614
56877
  * 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.
56878
+ * the email, the mailbox it was received in, its sender and subject, and
56879
+ * under each row what the email carried (attachmentsSummary). An email you
56880
+ * are not shown shows `-` for those and no attachments line. Nothing for an
56881
+ * empty list.
56617
56882
  */
56618
56883
  function decisionLines(data) {
56619
- const rows = Array.isArray(data) ? data.filter(isRecord$3) : [];
56884
+ const rows = Array.isArray(data) ? data.filter(isRecord$4) : [];
56620
56885
  if (rows.length === 0) return [];
56621
56886
  const cell = (value) => shownText(value) || "-";
56622
- return tableLines([[
56887
+ const [header = "", ...table] = tableLines([[
56623
56888
  "DECIDED",
56624
56889
  "OUTCOME",
56625
56890
  "EMAIL",
@@ -56634,11 +56899,21 @@ function decisionLines(data) {
56634
56899
  cell(row.from_address),
56635
56900
  cell(row.subject)
56636
56901
  ])]);
56902
+ return [header, ...table.flatMap((line, i) => [line, ...attachmentsLines(rows[i], " ").map(terminalLine)])];
56903
+ }
56904
+ /**
56905
+ * The rule results on one email (listEmailRuleResults): what the email
56906
+ * carried, once for every rule listed, after any notes the answer carries.
56907
+ * Nothing when the answer says neither.
56908
+ */
56909
+ function ruleResultsLines(data) {
56910
+ const summary = attachmentsSummary(data);
56911
+ return [...ruleNotesLines(data), ...summary === void 0 ? [] : [terminalLine(`Email: ${summary}`)]];
56637
56912
  }
56638
56913
  /** At most this many scope addresses and domains are named in COVERS. */
56639
56914
  const COVERS_NAMED = 3;
56640
56915
  function ruleAuthor(rule) {
56641
- const author = isRecord$3(rule.author) ? rule.author : {};
56916
+ const author = isRecord$4(rule.author) ? rule.author : {};
56642
56917
  const name = shownText(author.name) || shownText(author.email) || shownLine(author.user_id).slice(0, 8) || "-";
56643
56918
  return rule.is_author === true ? `${name} (you)` : name;
56644
56919
  }
@@ -56648,7 +56923,7 @@ function ruleCovers(rule) {
56648
56923
  case "own_mailboxes": return "author's own mailboxes";
56649
56924
  case "author": return "all mail the author reads";
56650
56925
  case "selected": {
56651
- const selection = isRecord$3(rule.scope_selection) ? rule.scope_selection : {};
56926
+ const selection = isRecord$4(rule.scope_selection) ? rule.scope_selection : {};
56652
56927
  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
56928
  if (names.length === 0) return "selected";
56654
56929
  const named = names.slice(0, COVERS_NAMED).join(", ");
@@ -56658,7 +56933,7 @@ function ruleCovers(rule) {
56658
56933
  }
56659
56934
  }
56660
56935
  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;
56936
+ return Array.isArray(list) ? list.reduce((sum, entry) => sum + (isRecord$4(entry) && typeof entry.count === "number" ? entry.count : 0), 0) : 0;
56662
56937
  }
56663
56938
  /**
56664
56939
  * Who receives what a rule matches now, from receivers (the --all list
@@ -56666,7 +56941,7 @@ function countSum(list) {
56666
56941
  * `unknown` when it could not be read in time.
56667
56942
  */
56668
56943
  function ruleReceivers(rule) {
56669
- if (!isRecord$3(rule.receivers)) return "unknown";
56944
+ if (!isRecord$4(rule.receivers)) return "unknown";
56670
56945
  const keys = countSum(rule.receivers.keys);
56671
56946
  const webhooks = countSum(rule.receivers.webhooks);
56672
56947
  const shares = countSum(rule.receivers.shares);
@@ -56679,7 +56954,7 @@ function ruleReceivers(rule) {
56679
56954
  * with --all who receives what it matches. Nothing for an empty list.
56680
56955
  */
56681
56956
  function ruleListLines(data, all) {
56682
- const rows = Array.isArray(data) ? data.filter(isRecord$3) : [];
56957
+ const rows = Array.isArray(data) ? data.filter(isRecord$4) : [];
56683
56958
  if (rows.length === 0) return [];
56684
56959
  return tableLines([[
56685
56960
  "NAME",
@@ -56705,8 +56980,8 @@ function ruleListLines(data, all) {
56705
56980
  */
56706
56981
  function listEmailRulesErrorHint(code, payload, flags = {}) {
56707
56982
  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 : {};
56983
+ const error = isRecord$4(payload) && isRecord$4(payload.error) ? payload.error : payload;
56984
+ const details = isRecord$4(error) && isRecord$4(error.details) ? error.details : {};
56710
56985
  switch (details.reason) {
56711
56986
  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
56987
  case "person_credential": return "Listing every rule needs your own CLI login, not an API key or agent sign-in.";
@@ -56731,7 +57006,7 @@ const EMAIL_RULE_LISTING_EXTENSIONS = {
56731
57006
  const rows = Array.isArray(data) ? data : [];
56732
57007
  const lines = ruleListLines(data, flags.all === true);
56733
57008
  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;
57009
+ const cursor = isRecord$4(meta) ? meta.cursor : void 0;
56735
57010
  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
57011
  return { lines };
56737
57012
  }
@@ -56743,6 +57018,91 @@ const EMAIL_RULE_LISTING_EXTENSIONS = {
56743
57018
  listEmailRuleDecisionsOnMyMail: {
56744
57019
  flags: {},
56745
57020
  report: (data) => ({ lines: decisionLines(data) })
57021
+ },
57022
+ listEmailRuleResults: {
57023
+ flags: {},
57024
+ report: (data) => ({ lines: ruleResultsLines(data) })
57025
+ }
57026
+ };
57027
+ // src/oclif/email-rule-shares.ts
57028
+ function isRecord$3(value) {
57029
+ return value !== null && typeof value === "object" && !Array.isArray(value);
57030
+ }
57031
+ /** A person on a share: their name, else their email, else `-`. */
57032
+ function person(value) {
57033
+ if (!isRecord$3(value)) return "-";
57034
+ return shownText(value.name) || shownText(value.email) || "-";
57035
+ }
57036
+ /** The rule's name: the live rule's, else the name the share recorded. */
57037
+ function ruleName(share) {
57038
+ return shownText((isRecord$3(share.rule) ? share.rule : null)?.name) || shownText(share.rule_name) || "-";
57039
+ }
57040
+ /** The rule's id, or `-` when the share does not show it to you. */
57041
+ function ruleId(share) {
57042
+ return shownLine(share.rule_id) || "-";
57043
+ }
57044
+ /** Live, or why not: ended (with its reason) or not live because someone left. */
57045
+ function shareState(share) {
57046
+ if (share.live === true) return "live";
57047
+ const reason = shownLine(share.end_reason);
57048
+ if (typeof share.ended_at === "string") return reason ? `ended (${reason})` : "ended";
57049
+ return "not live";
57050
+ }
57051
+ /** The other person on the share, from the caller's side of it. */
57052
+ function otherSide(share) {
57053
+ if (share.is_granter === true) return `to ${person(share.beneficiary)}`;
57054
+ if (share.is_beneficiary === true) return `from ${person(share.granter)}`;
57055
+ return `${person(share.granter)} to ${person(share.beneficiary)}`;
57056
+ }
57057
+ /**
57058
+ * A table of shares (listEmailRuleShares, listGivenEmailRuleShares): each
57059
+ * share's id, its rule's name and id (`-` where the share does not show the
57060
+ * id), who it is with and whether it is live. Nothing for an empty list.
57061
+ */
57062
+ function shareListLines(data) {
57063
+ const rows = Array.isArray(data) ? data.filter(isRecord$3) : [];
57064
+ if (rows.length === 0) return [];
57065
+ return [...tableLines([[
57066
+ "SHARE ID",
57067
+ "RULE",
57068
+ "RULE ID",
57069
+ "WITH",
57070
+ "STATE"
57071
+ ], ...rows.map((share) => [
57072
+ shownLine(share.id) || "-",
57073
+ ruleName(share),
57074
+ ruleId(share),
57075
+ otherSide(share),
57076
+ shareState(share)
57077
+ ])]), ...rows.some(showsReceivedRuleId) ? [KEY_NOTE] : []];
57078
+ }
57079
+ /** A share made with the caller that shows them its rule's id. */
57080
+ function showsReceivedRuleId(share) {
57081
+ return share.is_beneficiary === true && typeof share.rule_id === "string";
57082
+ }
57083
+ /** Said under a share made with the caller: which id goes where. */
57084
+ 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.";
57085
+ /** One share (getEmailRuleShare): the same facts as a list row, one per line. */
57086
+ function shareLines(data) {
57087
+ if (!isRecord$3(data)) return [];
57088
+ return [
57089
+ `Share ${shownLine(data.id) || "-"}: ${shareState(data)}, ${otherSide(data)}`,
57090
+ `Rule: ${ruleName(data)} (${typeof data.rule_id === "string" ? `id ${ruleId(data)}` : "id not shown to you"})`,
57091
+ ...showsReceivedRuleId(data) ? [KEY_NOTE] : []
57092
+ ];
57093
+ }
57094
+ const EMAIL_RULE_SHARE_EXTENSIONS = {
57095
+ listEmailRuleShares: {
57096
+ flags: {},
57097
+ report: (data) => ({ lines: shareListLines(data) })
57098
+ },
57099
+ listGivenEmailRuleShares: {
57100
+ flags: {},
57101
+ report: (data) => ({ lines: shareListLines(data) })
57102
+ },
57103
+ getEmailRuleShare: {
57104
+ flags: {},
57105
+ report: (data) => ({ lines: shareLines(data) })
56746
57106
  }
56747
57107
  };
56748
57108
  // src/oclif/empty-mail-hint.ts
@@ -57371,18 +57731,25 @@ const DOMAINS_TIMEOUT_MS = 5e3;
57371
57731
  /**
57372
57732
  * The verified domains this credential can read mail on, from GET /domains,
57373
57733
  * which lists only the domains a credential confined to some mailboxes
57374
- * reaches. Null when they cannot be read.
57734
+ * reaches, or why the server refused to list them for good. Neither when they
57735
+ * could not be read this time.
57375
57736
  */
57376
- async function readReadableDomains(client, timeoutMs = DOMAINS_TIMEOUT_MS) {
57737
+ async function readDomainsOrRefusal(client, timeoutMs = DOMAINS_TIMEOUT_MS) {
57377
57738
  try {
57378
57739
  const result = await listDomains({
57379
57740
  client,
57380
57741
  responseStyle: "fields",
57381
57742
  signal: AbortSignal.timeout(timeoutMs)
57382
57743
  });
57383
- if (result.error) return null;
57744
+ if (result.error) return {
57745
+ readable: null,
57746
+ refusal: refusalOf(result.error, result.response?.status)
57747
+ };
57384
57748
  const rows = result.data?.data;
57385
- if (!Array.isArray(rows)) return null;
57749
+ if (!Array.isArray(rows)) return {
57750
+ readable: null,
57751
+ refusal: null
57752
+ };
57386
57753
  let orgId = null;
57387
57754
  const domains = [];
57388
57755
  for (const row of rows) {
@@ -57396,13 +57763,37 @@ async function readReadableDomains(client, timeoutMs = DOMAINS_TIMEOUT_MS) {
57396
57763
  }
57397
57764
  domains.sort((a, b) => a.name.localeCompare(b.name));
57398
57765
  return {
57399
- orgId,
57400
- domains
57766
+ readable: {
57767
+ orgId,
57768
+ domains
57769
+ },
57770
+ refusal: null
57401
57771
  };
57402
57772
  } catch {
57403
- return null;
57773
+ return {
57774
+ readable: null,
57775
+ refusal: null
57776
+ };
57404
57777
  }
57405
57778
  }
57779
+ /** The most characters of the server's refusal shown. */
57780
+ const REFUSAL_MAX = 400;
57781
+ /**
57782
+ * A refusal asking again will not change, from an error answer: a 403 with a
57783
+ * code and message. Null for anything else, which may pass next time or has
57784
+ * its own hint (a 401), or that cannot be read.
57785
+ */
57786
+ function refusalOf(error, status) {
57787
+ if (status !== 403) return null;
57788
+ const body = error?.error;
57789
+ const code = typeof body?.code === "string" && /^[a-z0-9_]{1,80}$/.test(body.code) ? body.code : null;
57790
+ const shown = typeof body?.message === "string" ? shownLine(body.message).trim() : "";
57791
+ const message = shown.length > REFUSAL_MAX ? `${shown.slice(0, 397)}...` : shown;
57792
+ return code && message ? {
57793
+ code,
57794
+ message
57795
+ } : null;
57796
+ }
57406
57797
  function focusError(message, code, exit, details) {
57407
57798
  const error = new Errors.CLIError(message, {
57408
57799
  exit,
@@ -57516,7 +57907,10 @@ async function resolveFocus(params) {
57516
57907
  }
57517
57908
  };
57518
57909
  const profile = focusProfile(params.configDir, params.auth);
57519
- const readable = await (params.readDomains ?? readReadableDomains)(params.client);
57910
+ const { readable, refusal } = params.readDomains ? {
57911
+ readable: await params.readDomains(params.client),
57912
+ refusal: null
57913
+ } : await readDomainsOrRefusal(params.client);
57520
57914
  const orgId = readable?.orgId ?? params.auth.connectedAgent?.orgId ?? params.auth.credentials?.org_id ?? null;
57521
57915
  if (asked?.source === "env" && readable && readable.domains.length <= 1) return NO_FOCUS;
57522
57916
  if (asked && "all" in asked) return {
@@ -57530,6 +57924,10 @@ async function resolveFocus(params) {
57530
57924
  }
57531
57925
  };
57532
57926
  if (asked) {
57927
+ if (!readable && refusal) {
57928
+ const fromEnv = asked.source === "env" ? ` The names come from ${FOCUS_ENV}: unset it, or pass --all-domains.` : "";
57929
+ throw focusError(`Cannot look up ${joinNames(asked.names)}: ${refusal.message.replace(/\.?$/, ".")}${fromEnv}`, refusal.code, 1);
57930
+ }
57533
57931
  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
57932
  const domains = resolveDomainNames(asked.names, readable.domains, asked.source === "flag" ? "--domain" : FOCUS_ENV);
57535
57933
  return focusedOutcome(params.surface, domains, asked.source, readable);
@@ -57947,59 +58345,6 @@ function metaNoteLines(meta) {
57947
58345
  function metaExplainsEmptyList(meta) {
57948
58346
  return meta !== null && typeof meta === "object" && meta.recipient_outside_access === true;
57949
58347
  }
57950
- // src/oclif/runtime-session.ts
57951
- /**
57952
- * The variables each runtime sets to its exact session ID, first match wins.
57953
- * The loaded Codex thread is the receiving identity; the process session ID
57954
- * is only a fallback when no thread ID is exposed.
57955
- */
57956
- const RUNTIME_SESSION_VARIABLES = {
57957
- claude: ["CLAUDE_CODE_SESSION_ID"],
57958
- codex: ["CODEX_THREAD_ID", "CODEX_SESSION_ID"]
57959
- };
57960
- const UUID$3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
57961
- /** Each runtime whose environment names a session UUID. Never guessed from history or cwd. */
57962
- function runtimeSessions(env) {
57963
- return Object.keys(RUNTIME_SESSION_VARIABLES).flatMap((runtime) => {
57964
- for (const variable of RUNTIME_SESSION_VARIABLES[runtime]) {
57965
- const value = env[variable]?.trim().toLowerCase();
57966
- if (!value) continue;
57967
- return UUID$3.test(value) ? [{
57968
- runtime,
57969
- session: value,
57970
- variable
57971
- }] : [];
57972
- }
57973
- return [];
57974
- });
57975
- }
57976
- /** The one session the runtime environment names, if exactly one runtime names one. */
57977
- function detectRuntimeSession(env = process.env) {
57978
- const candidates = runtimeSessions(env);
57979
- const [only] = candidates;
57980
- if (!only) return { kind: "none" };
57981
- return candidates.length === 1 ? {
57982
- kind: "detected",
57983
- ...only
57984
- } : {
57985
- kind: "ambiguous",
57986
- candidates
57987
- };
57988
- }
57989
- /**
57990
- * The runtime whose tool environment names this exact session. A session ID
57991
- * that matches neither runtime's variable, or both, has no detectable runtime.
57992
- */
57993
- function detectAgentRuntime(session, env = process.env) {
57994
- const wanted = session.trim().toLowerCase();
57995
- const matches = runtimeSessions(env).filter((candidate) => candidate.session === wanted);
57996
- return matches.length === 1 ? matches[0]?.runtime ?? null : null;
57997
- }
57998
- /** Every variable a runtime may name its session in, for messages. */
57999
- function runtimeSessionVariableList() {
58000
- const names = Object.values(RUNTIME_SESSION_VARIABLES).flat();
58001
- return `${names.slice(0, -1).join(", ")} or ${names.at(-1)}`;
58002
- }
58003
58348
  // src/oclif/mail-session.ts
58004
58349
  /** Runtime-provided identity only. Never guess a session from history or cwd. */
58005
58350
  function currentMailSessionKey(env = process.env) {
@@ -59456,7 +59801,7 @@ function savedConnectedProfiles(configDir, exclude) {
59456
59801
  */
59457
59802
  async function otherProfiles(configDir, session, current) {
59458
59803
  if (session) try {
59459
- const { connectedProfilesForSession } = await import("./machine-session-cfgMKQ_U.js").then((n) => n.s);
59804
+ const { connectedProfilesForSession } = await import("./machine-session-CE31cwx2.js").then((n) => n.s);
59460
59805
  return {
59461
59806
  inSession: true,
59462
59807
  profiles: connectedProfilesForSession(configDir, session, current)
@@ -60622,6 +60967,7 @@ const OPERATION_EXTRA_BODY_FLAGS = { addDomain: { "mail-relay": {
60622
60967
  const OPERATION_EXTENSIONS = {
60623
60968
  ...EMAIL_RULE_OPERATION_EXTENSIONS,
60624
60969
  ...EMAIL_RULE_LISTING_EXTENSIONS,
60970
+ ...EMAIL_RULE_SHARE_EXTENSIONS,
60625
60971
  ...ENDPOINT_HEADER_EXTENSIONS,
60626
60972
  ...ANSWER_REPORT_EXTENSIONS
60627
60973
  };
@@ -60847,41 +61193,21 @@ function createOperationCommand(operation) {
60847
61193
  }
60848
61194
  let pagingNote;
60849
61195
  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, {
61196
+ const page = await fetchBoundedPages({
61197
+ wanted,
61198
+ maximum: pageMaximum ?? wanted,
61199
+ cursor: typeof query.cursor === "string" ? query.cursor : void 0,
61200
+ call: (limit, cursor) => callOperation(void 0, {
60880
61201
  ...query,
60881
- cursor,
60882
- limit: Math.min(max, wanted - rows.length)
60883
- });
60884
- }
61202
+ limit,
61203
+ cursor
61204
+ })
61205
+ });
61206
+ pagingNote = page.note;
61207
+ return page.envelope ? {
61208
+ ...page.result,
61209
+ data: page.envelope
61210
+ } : page.result;
60885
61211
  };
60886
61212
  if (operation.sdkName === "setMemberRole") {
60887
61213
  const role = body && typeof body === "object" ? body.role : void 0;
@@ -60970,10 +61296,11 @@ function createOperationCommand(operation) {
60970
61296
  return;
60971
61297
  }
60972
61298
  const jsonOutput = parsedFlags.json === true;
61299
+ if (jsonOutput && operation.sdkName === "listEndpoints" && envelope) envelope.meta ??= {};
60973
61300
  writeFocusLine(focus, jsonOutput);
60974
61301
  const cursor = envelope?.meta?.cursor;
60975
61302
  if (cursor && !jsonOutput) process.stderr.write(`next cursor: ${cursor}\n`);
60976
- if (pagingNote && !jsonOutput) process.stderr.write(`${pagingNote}\n`);
61303
+ if (pagingNote) process.stderr.write(`${pagingNote}\n`);
60977
61304
  const summary = [];
60978
61305
  if (Array.isArray(envelope?.data) && envelope.data.length === 0 && (jsonOutput || !metaExplainsEmptyList(envelope?.meta))) {
60979
61306
  const tail = query.since !== void 0;
@@ -60987,7 +61314,7 @@ function createOperationCommand(operation) {
60987
61314
  if (hint && jsonOutput) summary.push(hint);
60988
61315
  else if (hint) process.stderr.write(`${hint}\n`);
60989
61316
  }
60990
- if (Array.isArray(envelope?.data) && envelope.data.length === 0 && focus.focused && query.since === void 0 && query.cursor === void 0) {
61317
+ if (Array.isArray(envelope?.data) && envelope.data.length === 0 && focus.focused && query.since === void 0 && query.cursor === void 0 && !envelope?.meta?.cursor) {
60991
61318
  const countParam = focusSpec?.countParam;
60992
61319
  const note = await focusEmptyHint(focus, async () => {
60993
61320
  const counted = await callOperation(void 0, {
@@ -61094,4 +61421,4 @@ function emptyDeliveriesHint(sdkName, query) {
61094
61421
  function canonicalizeCliReferences(description) {
61095
61422
  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
61423
  }
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 };
61424
+ export { replyInteractionWarning as $, resolveDomainNames as $t, describeWake as A, revokeUserLogin as An, connectNextSteps as At, wakeRecipientField as B, countFromMeta as Bt, withApproval as C, selectedOrgFromEnv as Cn, sendWaitClampNotice as Ct, openBrowser as D, displayedRoleKey as Dn, thrownErrorExitCode as Dt, listenForCopyHotkey as E, credentialsFromUserLogin as En, successfulSendOutcome as Et, sentInThread as F, sanitizeForTerminal as Fn, currentMailSessionKey as Ft, pendingMailPath as G, focusProfile as Gt, claimPendingMail as H, focusFlagValues as Ht, serverMuted as I, shownLine as In, formatAlreadySentNotice as It, removePendingMail as J, manyDomainsSupported as Jt, readPendingMail as K, joinNames as Kt, serverRelationship as L, setKnownCommands as Ln, FOCUS_ENV as Lt, formatMailWakeLine as M, roleKeyText as Mn, generatedAgentName as Mt, latestOwnOutbound as N, switchCurrentOrg as Nn, identitySuggestions as Nt, explainPendingMailNotFound as O, fetchCliOrgs as On, DEFAULT_ENROLL_NAME as Ot, readThreadContext as P, routeWarningLines as Pn, loadSkillLine as Pt, replyExpectation as Q, readDomainsOrRefusal as Qt, skillFirstLine as R, operationManifest as Rn, FOCUS_SERVER_SUPPORT as Rt, terminalApprovalIo as S, resolveCliApiRequestConfig as Sn, sendOutcomeExitCode as St, formatBrowserLoginInstructions as T, RESTRICTED_ROLE_NOTE as Tn, serializeErrorPayload as Tt, clearConsumedPendingMail as U, focusFlags as Ut, wakeRelationship as V, focusEmptyHint as Vt, clearReadPendingMail as W, focusForCorpus as Wt, interactionNextActions as X, oneDomainAtATimeError as Xt, interactionHumanLine as Y, normalizeDomainNames as Yt, readEmailInteraction as Z, queryScopesItself as Zt, BROWSER_FLAG_DESCRIPTION as _, SAVED_CLI_OAUTH_SESSION_EXPIRED_MESSAGE as _n, formatSendRecordFailureSummary as _t, createOperationCommand as a, withFlagSuggestion as an, assertValidIdempotencyKey as at, approveThenRerunHint as b, refreshStoredCliCredentials as bn, sendErrorMessage as bt, formatErrorPayload as c, readCallerMailFor as cn, checkPriorReplies as ct, networkErrorHint as d, fetchBoundedPages as dn, excludeSignalReplies as dt, resolveFocus as en, wakeInteractionSentence as et, readTextFileFlag as f, withBooleanFlagValues as fn, followUpCommandPrefix as ft, writeErrorWithHints as g, ConnectedAgentKeyRequiredError as gn, formatSendFailureSummary as gt, surfaceUnauthorizedHint as h, withAttachmentWait as hn, formatPriorRepliesWarning as ht, TIME_FLAG_DESCRIPTION as i, writeFocusLine as in, apiResultHttpStatus as it, displayAddress as j, roleKeyLabel as jn, defaultConnectionName as jt, bareAddress as k, isBuiltInRoleKey as kn, cliInvocation as kt, hasControlCharacter as l, formatFact as ln, classifySendError as lt, runWithTiming as m, ATTACHMENT_WAIT_MAX_MS as mn, formatPriorRepliesCheckSkipped as mt, API_ERROR_CODES as n, withFocusMeta as nn, MAX_SEND_WAIT_TIMEOUT_MS as nt, extractErrorCode as o, emptyEmailListHint as on, buildFollowUpCommand as ot, refusesCredential as p, ATTACHMENT_WAIT_FLAG_DESCRIPTION as pn, formatDeletedEarlierSendNotice as pt, recordPendingMail as q, loadSavedFocus as qt, PAGED_LIMIT_MAX as r, withoutFocus as rn, SEND_OUTCOME_HELP as rt, extractErrorPayload as s, mailReach as sn, buildThrownSendFailureEnvelope as st, API_BASE_URL_FLAG_DESCRIPTION as t, saveFocus as tn, IDEMPOTENCY_KEY_FLAG_DESCRIPTION as tt, isGrantRefusal as u, isEmailId as un, deriveSendIdempotencyKey as ut, STEP_UP_HEADER as v, createAuthenticatedCliApiClient as vn, priorRepliesThatWentOut as vt, canOfferCopyHotkey as w, CliOrgRefusedError as wn, sentHistoryWindowStart as wt, promptLine as x, refuseOrgSelectionForProfile as xn, sendIdentityFields as xt, STEP_UP_TOKEN_FLAG_DESCRIPTION as y, createCliApiClient as yn, reportSendCommandResult as yt, wakeReadCommand as z, NO_FOCUS as zt };