primcli 1.74.1 → 3.0.0-preview.1

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.
Files changed (31) hide show
  1. package/README.md +165 -72
  2. package/bin/claude-pending-mail.mjs +1 -1
  3. package/bin/run.js +14 -0
  4. package/dist/{api-command-fKP3NYa7.js → api-command-ctHBqTL5.js} +825 -95
  5. package/dist/{cli-config-C0Y_Ppol.js → cli-config-Ms_0vNjq.js} +66 -28
  6. package/dist/{client.gen-CaaMP86o.js → client.gen-6rZvmHfx.js} +7 -14
  7. package/dist/{json-output-Ce10AsSb.js → json-output-BzSBR-KX.js} +1 -2
  8. package/dist/{listen-background-cD6n8VYO.js → listen-background-C0F9gNDD.js} +2 -3
  9. package/dist/{machine-session-B6V5-grn.js → machine-session-Cp_eQ9t_.js} +164 -99
  10. package/dist/{notify-session-DJAb9SGm.js → notify-session-BN0JTPZ3.js} +341 -31
  11. package/dist/oclif/auto-signal-worker.js +5 -6
  12. package/dist/oclif/auto-signals.js +4 -5
  13. package/dist/oclif/global-org-flag.js +76 -0
  14. package/dist/oclif/help.js +127 -0
  15. package/dist/oclif/index.js +93239 -31954
  16. package/dist/oclif/listen-supervisor.js +1 -1
  17. package/dist/oclif/proxy-auto-detect.js +2 -3
  18. package/dist/oclif/receiver-heal.js +6 -6
  19. package/dist/oclif/root-signup-hint.js +3 -4
  20. package/dist/receiver.d.ts +95 -0
  21. package/dist/receiver.js +569 -0
  22. package/dist/{repeats-BL7ZC-_6-B_ESsWTH.js → repeats-Dj_o6c-X-Bf9G0xds.js} +4617 -1744
  23. package/dist/{scoped-chat-DAiOb622.js → scoped-chat-DZ42V3jq.js} +3 -5
  24. package/dist/{shared-mail-files-CZfm7E2k.js → shared-mail-files-BAQSGxxz.js} +2 -4
  25. package/dist/{shared-mail-watch-DyQB0MK0.js → shared-mail-watch-BAPMsFNv.js} +2 -3
  26. package/dist/{signal-command-Cte4mAL3.js → signal-command-CRUMUCNa.js} +19 -27
  27. package/dist/skills/primitive-connect/references/connect.md +3 -1
  28. package/dist/skills/primitive-connect/references/contacts.md +9 -4
  29. package/dist/skills/primitive-connect.json +4 -4
  30. package/man/primitive.1 +44 -3
  31. package/package.json +65 -15
@@ -1 +1 @@
1
- export { s as runBackgroundListenSupervisor } from "../listen-background-cD6n8VYO.js";
1
+ export { s as runBackgroundListenSupervisor } from "../listen-background-C0F9gNDD.js";
@@ -1,6 +1,6 @@
1
- import { n as jsonOutputRequested } from "../json-output-Ce10AsSb.js";
1
+ import { n as jsonOutputRequested } from "../json-output-BzSBR-KX.js";
2
2
  import { spawnSync } from "node:child_process";
3
- //#region src/oclif/proxy-auto-detect.ts
3
+ // src/oclif/proxy-auto-detect.ts
4
4
  const PROXY_ENV_VARS = [
5
5
  "HTTP_PROXY",
6
6
  "HTTPS_PROXY",
@@ -68,5 +68,4 @@ function restartWithProxyEnvIfNeeded(options = {}) {
68
68
  }
69
69
  return exit(child.status ?? 1);
70
70
  }
71
- //#endregion
72
71
  export { _resetHintLatchForTest, restartWithProxyEnvIfNeeded };
@@ -1,11 +1,12 @@
1
- import { F as agentProfileName, M as AGENT_PROFILE_ENV, P as agentProfileDirectory, z as loadConnectedAgentProfile } from "../cli-config-C0Y_Ppol.js";
2
- import { d as readMailJson } from "../shared-mail-files-CZfm7E2k.js";
3
- import { _ as detectAgentRuntime, l as SESSION_UUID, t as notificationScope } from "../notify-session-DJAb9SGm.js";
4
- import { a as claimBackgroundListenRestart, n as backgroundListenRestartable, r as backgroundListenStatus } from "../listen-background-cD6n8VYO.js";
1
+ import { N as agentProfileDirectory, P as agentProfileName, R as loadConnectedAgentProfile, j as AGENT_PROFILE_ENV } from "../cli-config-Ms_0vNjq.js";
2
+ import { a as claimBackgroundListenRestart, n as backgroundListenRestartable, r as backgroundListenStatus } from "../listen-background-C0F9gNDD.js";
3
+ import { d as SESSION_UUID, t as notificationScope } from "../notify-session-BN0JTPZ3.js";
4
+ import { St as detectAgentRuntime } from "../api-command-ctHBqTL5.js";
5
+ import { d as readMailJson } from "../shared-mail-files-BAQSGxxz.js";
5
6
  import { join } from "node:path";
6
7
  import { spawn } from "node:child_process";
7
8
  import { homedir } from "node:os";
8
- //#region src/oclif/receiver-heal.ts
9
+ // src/oclif/receiver-heal.ts
9
10
  /** Set to 0 to turn off restarting a stopped receiver from ordinary commands. */
10
11
  const RECEIVER_HEAL_ENV = "PRIMITIVE_RECEIVER_HEAL";
11
12
  function activeConfigDir(env, home) {
@@ -88,5 +89,4 @@ function healSelectedReceiverQuietly() {
88
89
  healSelectedReceiver();
89
90
  } catch {}
90
91
  }
91
- //#endregion
92
92
  export { RECEIVER_HEAL_ENV, healSelectedReceiver, healSelectedReceiverQuietly };
@@ -1,8 +1,8 @@
1
- import { S as normalizeApiBaseUrl, c as resolveConfigEnvironment, i as loadCliConfig } from "../cli-config-C0Y_Ppol.js";
1
+ import { c as resolveConfigEnvironment, i as loadCliConfig, x as normalizeApiBaseUrl } from "../cli-config-Ms_0vNjq.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { homedir } from "node:os";
5
- //#region src/oclif/root-signup-hint.ts
5
+ // src/oclif/root-signup-hint.ts
6
6
  const CREDENTIALS_FILE = "credentials.json";
7
7
  const ROOT_AUTH_TIMEOUT_MS = 1e3;
8
8
  function activeConfigDir(env, home) {
@@ -19,7 +19,7 @@ function readRootCredentials(configDir) {
19
19
  }
20
20
  try {
21
21
  const parsed = JSON.parse(raw);
22
- if (parsed.auth_method !== "oauth") return null;
22
+ if (parsed.auth_method !== "oauth" && parsed.auth_method !== "user_grant") return null;
23
23
  if (typeof parsed.access_token !== "string" || !parsed.access_token.trim()) return null;
24
24
  const apiBaseUrl = parsed.api_base_url ?? parsed.api_base_url_1;
25
25
  if (typeof apiBaseUrl !== "string" || !apiBaseUrl.trim()) return null;
@@ -134,5 +134,4 @@ async function writeRootAuthContextIfNeeded(options = {}) {
134
134
  }
135
135
  writeLoggedOutSignupHintIfNeeded(options);
136
136
  }
137
- //#endregion
138
137
  export { loggedOutSignupHint, rootSignedInSummary, shouldShowLoggedOutSignupHint, writeLoggedOutSignupHintIfNeeded, writeRootAuthContextIfNeeded };
@@ -0,0 +1,95 @@
1
+ /** One page of `listAgentContacts` (`primitive agent contacts list`). */
2
+ export type ContactPage = {
3
+ readonly data: readonly unknown[];
4
+ /** The cursor for the next page, or null on the last page. */
5
+ readonly cursor: string | null;
6
+ };
7
+ /**
8
+ * The `checkDefaultNetworkContactAdmission` result for one email
9
+ * (`primitive agent-networks check-default-network-contact-admission`).
10
+ */
11
+ export type NetworkAdmission = {
12
+ readonly allowed: boolean;
13
+ readonly allowed_since: string | null;
14
+ readonly pending: boolean;
15
+ readonly member_policy_required: boolean;
16
+ readonly sender_relation?: "owner" | "member" | undefined;
17
+ };
18
+ /**
19
+ * Reads the policy from the API as the connected address. A reader that hits
20
+ * a temporary failure, such as a rate limit, a 5xx response or a dropped
21
+ * connection, throws `new WakePolicyError("policy_read_failed")`. Any other
22
+ * error from a reader makes the policy unavailable.
23
+ */
24
+ export type WakePolicyOptions = {
25
+ /** The connected address that receives the mail. */
26
+ readonly recipient: string;
27
+ /**
28
+ * Admit first mail from unknown senders as `request` when the owner allows
29
+ * contact requests. Defaults to false.
30
+ */
31
+ readonly contactRequests?: boolean | undefined;
32
+ /** The `data` of `getAgentContactPolicy` for the recipient. */
33
+ readonly readContactPolicy: (signal: AbortSignal) => Promise<unknown>;
34
+ /** One page of the recipient's contacts, 100 rows at most. */
35
+ readonly readContactPage: (cursor: string | undefined, signal: AbortSignal) => Promise<ContactPage>;
36
+ /** The network admission decision for one exact email. */
37
+ readonly readNetworkAdmission: (emailId: string, sender: string, signal: AbortSignal) => Promise<NetworkAdmission>;
38
+ };
39
+ /** The facts of one received email, from the email detail. */
40
+ export type InboundEmail = {
41
+ readonly emailId: string;
42
+ /** The authenticated sender address. Check it before admission. */
43
+ readonly sender: string;
44
+ readonly receivedAt: string;
45
+ };
46
+ /**
47
+ * `allowed` may wake the session. `request` is a first-contact request from
48
+ * an unknown sender: show it as a request, never as a task.
49
+ */
50
+ export type WakeAdmission = (InboundEmail & {
51
+ readonly kind: "allowed";
52
+ }) | (InboundEmail & {
53
+ readonly kind: "request";
54
+ });
55
+ /** `denied` must not wake the session. */
56
+ export type WakeDecision = WakeAdmission | {
57
+ readonly kind: "denied";
58
+ };
59
+ /**
60
+ * Call synchronously immediately before you wake the session. It throws
61
+ * `WakePolicyError` with `permission_changed` when the permission it confirms
62
+ * was refreshed or is older than 30 seconds; recheck and try again.
63
+ */
64
+ export type ConfirmWake = () => void;
65
+ export type WakePolicy = {
66
+ /** Decide whether one email may wake the session. */
67
+ admit(email: InboundEmail, signal: AbortSignal): Promise<WakeDecision>;
68
+ /**
69
+ * Read the policy again for an admission from this policy's `admit`, right
70
+ * before dispatch. Throws `permission_changed` if the admission no longer
71
+ * holds.
72
+ */
73
+ recheck(admission: WakeAdmission, signal: AbortSignal): Promise<ConfirmWake>;
74
+ };
75
+ /**
76
+ * - `policy_read_failed`: a policy read failed temporarily. Retry later; the
77
+ * policy paces repeated reads itself.
78
+ * - `network_admission_pending`: the server has not settled network admission
79
+ * for this email. Retry in a few seconds.
80
+ * - `permission_changed`: permission changed or expired before dispatch.
81
+ * Admit the email again.
82
+ * - `policy_unavailable`: the policy is invalid or access is lost. Do not
83
+ * wake; retrying will not help until access is restored.
84
+ */
85
+ export type WakePolicyErrorCode = "policy_read_failed" | "network_admission_pending" | "permission_changed" | "policy_unavailable";
86
+ export declare class WakePolicyError extends Error {
87
+ readonly code: WakePolicyErrorCode;
88
+ /** Whether the same email may be admitted later without operator action. */
89
+ readonly retryable: boolean;
90
+ constructor(code: WakePolicyErrorCode, options?: {
91
+ cause?: unknown;
92
+ });
93
+ }
94
+ /** Create the contact admission policy for one connected address. */
95
+ export declare function createWakePolicy(options: WakePolicyOptions): WakePolicy;