primcli 1.35.0 → 1.37.0

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 (32) hide show
  1. package/README.md +73 -10
  2. package/bin/run.js +37 -0
  3. package/dist/auto-signals-UPcJmV3j.js +702 -0
  4. package/dist/{cli-config-DmhlcS3s.js → cli-config-UOlrfcPz.js} +2 -711
  5. package/dist/connect-skill-DednypYJ.js +1084 -0
  6. package/dist/connected-agent-profile-8tpOMdq3.js +730 -0
  7. package/dist/{listen-background-D6UhIbkO.js → listen-background-Bsofqq_6.js} +243 -50
  8. package/dist/oclif/auto-signal-worker.js +167 -0
  9. package/dist/oclif/auto-signals.js +2 -0
  10. package/dist/oclif/index.js +31501 -48161
  11. package/dist/oclif/listen-supervisor.js +1 -1
  12. package/dist/oclif/proxy-auto-detect.js +1 -1
  13. package/dist/oclif/receiver-heal.js +91 -0
  14. package/dist/oclif/root-signup-hint.js +1 -1
  15. package/dist/repeats-CQmyvUGQ-CMnOmWgL.js +10442 -0
  16. package/dist/sdk.gen-CugwPoCf.js +3281 -0
  17. package/dist/{shared-mail-files-Cbwnf79a.js → shared-mail-files-CZqI1kj6.js} +5 -2
  18. package/dist/signal-command-CKaEqXro.js +4514 -0
  19. package/dist/skills/primitive-connect/SKILL.md +896 -0
  20. package/dist/skills/primitive-connect/package-lock.json +1033 -0
  21. package/dist/skills/primitive-connect/package.json +8 -0
  22. package/dist/skills/primitive-connect/references/communication.md +207 -0
  23. package/dist/skills/primitive-connect/references/contact-requests.md +161 -0
  24. package/dist/skills/primitive-connect/references/native-session.md +165 -0
  25. package/dist/skills/primitive-connect/references/private-api-fallback.md +107 -0
  26. package/dist/skills/primitive-connect/scripts/check-cli-capabilities.mjs +48 -0
  27. package/dist/skills/primitive-connect/scripts/connection.mjs +197 -0
  28. package/dist/skills/primitive-connect/scripts/mail.mjs +189 -0
  29. package/dist/skills/primitive-connect.json +21 -0
  30. package/man/primitive.1 +35 -4
  31. package/package.json +10 -1
  32. /package/dist/{json-output-KAIuP9rG.js → json-output-BVRgl6jf.js} +0 -0
@@ -1,2 +1,2 @@
1
- import { i as runBackgroundListenSupervisor } from "../listen-background-D6UhIbkO.js";
1
+ import { s as runBackgroundListenSupervisor } from "../listen-background-Bsofqq_6.js";
2
2
  export { runBackgroundListenSupervisor };
@@ -1,4 +1,4 @@
1
- import { n as jsonOutputRequested } from "../json-output-KAIuP9rG.js";
1
+ import { n as jsonOutputRequested } from "../json-output-BVRgl6jf.js";
2
2
  import { spawnSync } from "node:child_process";
3
3
  //#region src/oclif/proxy-auto-detect.ts
4
4
  const PROXY_ENV_VARS = [
@@ -0,0 +1,91 @@
1
+ import { c as loadConnectedAgentProfile, i as agentProfileName, r as agentProfileDirectory, t as AGENT_PROFILE_ENV } from "../connected-agent-profile-8tpOMdq3.js";
2
+ import { d as readMailJson } from "../shared-mail-files-CZqI1kj6.js";
3
+ import { f as SESSION_UUID, i as notificationScope, t as detectAgentRuntime } from "../connect-skill-DednypYJ.js";
4
+ import { a as claimBackgroundListenRestart, n as backgroundListenRestartable, r as backgroundListenStatus } from "../listen-background-Bsofqq_6.js";
5
+ import { join } from "node:path";
6
+ import { spawn } from "node:child_process";
7
+ import { homedir } from "node:os";
8
+ //#region src/oclif/receiver-heal.ts
9
+ /** Set to 0 to turn off restarting a stopped receiver from ordinary commands. */
10
+ const RECEIVER_HEAL_ENV = "PRIMITIVE_RECEIVER_HEAL";
11
+ function activeConfigDir(env, home) {
12
+ if (env.PRIMITIVE_CONFIG_DIR) return env.PRIMITIVE_CONFIG_DIR;
13
+ return join(env.XDG_CONFIG_HOME || join(home, ".config"), "primitive");
14
+ }
15
+ /**
16
+ * Restart the selected agent profile's native receiver when it died without
17
+ * being stopped. It acts only for a command run from inside the exact session
18
+ * the profile is bound to, so a receiver is never revived for a session that
19
+ * is gone, and it never waits: the restart runs in a detached process.
20
+ */
21
+ function healSelectedReceiver(options = {}) {
22
+ const env = options.env ?? process.env;
23
+ const none = (reason) => ({
24
+ action: "none",
25
+ reason
26
+ });
27
+ if (env["PRIMITIVE_RECEIVER_HEAL"] === "0") return none("disabled");
28
+ if (env["PRIMITIVE_LISTEN_BACKGROUND_TOKEN"] || env.PRIMITIVE_LISTEN_SUPERVISOR) return none("receiver_process");
29
+ const argv = options.argv ?? process.argv.slice(2);
30
+ if (argv[0] === "listen" && argv.includes("--stop") || argv[0] === "agent" && argv[1] === "disconnect" || argv[0] === "agent:disconnect") return none("stopping");
31
+ const selected = env[AGENT_PROFILE_ENV]?.trim();
32
+ if (!selected) return none("no_profile");
33
+ const entry = options.entry ?? process.argv[1];
34
+ if (!entry) return none("no_entrypoint");
35
+ const configDir = options.configDir ?? activeConfigDir(env, homedir());
36
+ const profileName = agentProfileName(selected);
37
+ const setup = readMailJson(join(agentProfileDirectory(configDir, profileName), "setup.json"));
38
+ if (!setup || typeof setup !== "object" || Array.isArray(setup)) return none("no_setup");
39
+ const saved = setup;
40
+ const session = saved.session;
41
+ if (typeof session !== "string" || !SESSION_UUID.test(session) || saved.receiverMode === "external" || saved.phase !== "sent") return none("not_native_receiver");
42
+ if (detectAgentRuntime(session, env) === null) return none("other_session");
43
+ const profile = loadConnectedAgentProfile(configDir, profileName);
44
+ if (!profile) return none("no_profile");
45
+ const target = {
46
+ configDir,
47
+ scope: notificationScope(profile.api_base_url, profile.api_key),
48
+ threadId: session
49
+ };
50
+ if (!backgroundListenRestartable(backgroundListenStatus(target))) return none("not_restartable");
51
+ if (!claimBackgroundListenRestart(target, options.now)) return none("recently_attempted");
52
+ const listenArgv = [
53
+ entry,
54
+ "listen",
55
+ "--background",
56
+ "--notify-session",
57
+ session,
58
+ "--contacts",
59
+ ...saved.contactRequests === true ? ["--contact-requests"] : []
60
+ ];
61
+ const childEnv = {
62
+ ...env,
63
+ [AGENT_PROFILE_ENV]: profileName,
64
+ PRIMITIVE_CONFIG_DIR: configDir,
65
+ [RECEIVER_HEAL_ENV]: "0"
66
+ };
67
+ (options.spawnListener ?? spawnDetached)(listenArgv, childEnv);
68
+ return {
69
+ action: "restarting",
70
+ profile: profileName,
71
+ session
72
+ };
73
+ }
74
+ function spawnDetached(argv, env) {
75
+ const child = spawn(process.execPath, argv, {
76
+ env,
77
+ detached: true,
78
+ windowsHide: true,
79
+ stdio: "ignore"
80
+ });
81
+ child.on("error", () => {});
82
+ child.unref();
83
+ }
84
+ /** Never let receiver recovery change what the requested command does. */
85
+ function healSelectedReceiverQuietly() {
86
+ try {
87
+ healSelectedReceiver();
88
+ } catch {}
89
+ }
90
+ //#endregion
91
+ export { RECEIVER_HEAL_ENV, healSelectedReceiver, healSelectedReceiverQuietly };
@@ -1,4 +1,4 @@
1
- import { S as normalizeApiBaseUrl, c as resolveConfigEnvironment, i as loadCliConfig } from "../cli-config-DmhlcS3s.js";
1
+ import { S as normalizeApiBaseUrl, c as resolveConfigEnvironment, i as loadCliConfig } from "../cli-config-UOlrfcPz.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { homedir } from "node:os";