primcli 1.36.0 → 1.38.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.
- package/README.md +110 -4
- package/bin/run.js +37 -0
- package/dist/auto-signals-UPcJmV3j.js +702 -0
- package/dist/{cli-config-DmhlcS3s.js → cli-config-UOlrfcPz.js} +2 -711
- package/dist/connect-skill-HJNQC3A9.js +1085 -0
- package/dist/connected-agent-profile-8tpOMdq3.js +730 -0
- package/dist/{listen-background-D6UhIbkO.js → listen-background-Bsofqq_6.js} +243 -50
- package/dist/oclif/auto-signal-worker.js +167 -0
- package/dist/oclif/auto-signals.js +2 -0
- package/dist/oclif/index.js +34366 -49091
- package/dist/oclif/listen-supervisor.js +1 -1
- package/dist/oclif/proxy-auto-detect.js +1 -1
- package/dist/oclif/receiver-heal.js +91 -0
- package/dist/oclif/root-signup-hint.js +1 -1
- package/dist/repeats-CQmyvUGQ-CMnOmWgL.js +10442 -0
- package/dist/sdk.gen-CugwPoCf.js +3281 -0
- package/dist/{shared-mail-files-Cbwnf79a.js → shared-mail-files-CZqI1kj6.js} +5 -2
- package/dist/signal-command-CKaEqXro.js +4514 -0
- package/dist/skills/primitive-connect/SKILL.md +123 -30
- package/dist/skills/primitive-connect/references/private-api-fallback.md +12 -6
- package/dist/skills/primitive-connect/scripts/connection.mjs +5 -1
- package/dist/skills/primitive-connect.json +5 -5
- package/man/primitive.1 +35 -4
- package/package.json +13 -1
- /package/dist/{json-output-KAIuP9rG.js → json-output-BVRgl6jf.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as runBackgroundListenSupervisor } from "../listen-background-Bsofqq_6.js";
|
|
2
2
|
export { runBackgroundListenSupervisor };
|
|
@@ -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 { m as SESSION_UUID, n as detectAgentRuntime, o as notificationScope } from "../connect-skill-HJNQC3A9.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-
|
|
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";
|