@openape/nest 2.1.1 → 2.1.3

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 (2) hide show
  1. package/dist/index.mjs +27 -11
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -8,8 +8,14 @@ import process4 from "process";
8
8
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
9
9
  import { homedir } from "os";
10
10
  import { join } from "path";
11
- var REGISTRY_DIR = homedir();
12
- var REGISTRY_PATH = join(REGISTRY_DIR, "agents.json");
11
+ function resolveRegistryPath() {
12
+ if (process.env.OPENAPE_NEST_REGISTRY_PATH) return process.env.OPENAPE_NEST_REGISTRY_PATH;
13
+ if (existsSync("/var/openape/nest/agents.json")) return "/var/openape/nest/agents.json";
14
+ if (existsSync("/var/openape/nest")) return "/var/openape/nest/agents.json";
15
+ return join(homedir(), "agents.json");
16
+ }
17
+ var REGISTRY_PATH = resolveRegistryPath();
18
+ var REGISTRY_DIR = REGISTRY_PATH.replace(/\/agents\.json$/, "");
13
19
  function emptyRegistry() {
14
20
  return { version: 1, agents: [] };
15
21
  }
@@ -29,12 +35,22 @@ function listAgents() {
29
35
 
30
36
  // src/lib/pm2-supervisor.ts
31
37
  import { execFile } from "child_process";
32
- import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
38
+ import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
33
39
  import { join as join2 } from "path";
34
40
  import process2 from "process";
35
41
  import { promisify } from "util";
36
42
  var execFileAsync = promisify(execFile);
37
43
  var AGENTS_DIR = "/var/openape/agents";
44
+ var SHARED_DIR_MODE = 1533;
45
+ function ensureSharedDir(path) {
46
+ mkdirSync2(path, { recursive: true, mode: SHARED_DIR_MODE });
47
+ if (existsSync2(path)) {
48
+ try {
49
+ chmodSync(path, SHARED_DIR_MODE);
50
+ } catch {
51
+ }
52
+ }
53
+ }
38
54
  function pm2AppName(agentName) {
39
55
  return `openape-bridge-${agentName}`;
40
56
  }
@@ -113,13 +129,13 @@ var Pm2Supervisor = class {
113
129
  async stopAll() {
114
130
  }
115
131
  async startOrReload(agentName) {
116
- mkdirSync2(AGENTS_DIR, { recursive: true, mode: 493 });
132
+ ensureSharedDir(AGENTS_DIR);
117
133
  const dir = join2(AGENTS_DIR, agentName);
118
- mkdirSync2(dir, { recursive: true, mode: 493 });
134
+ ensureSharedDir(dir);
119
135
  const path = ecosystemPath(agentName);
120
- writeFileSync2(path, ecosystemContents(this.deps.apesBin, agentName), { mode: 420 });
136
+ writeFileSync2(path, ecosystemContents(this.deps.apesBin, agentName), { mode: 436 });
121
137
  const startPath = startScriptPath(agentName);
122
- writeFileSync2(startPath, startScriptContents(agentName), { mode: 493 });
138
+ writeFileSync2(startPath, startScriptContents(agentName), { mode: 509 });
123
139
  void path;
124
140
  try {
125
141
  await this.runAsAgent(agentName, ["bash", startPath]);
@@ -225,7 +241,7 @@ import { hostname, networkInterfaces } from "os";
225
241
 
226
242
  // ../../packages/cli-auth/dist/index.js
227
243
  import { ofetch } from "ofetch";
228
- import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync2, readdirSync, unlinkSync, writeFileSync as writeFileSync3 } from "fs";
244
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, readdirSync, unlinkSync, writeFileSync as writeFileSync3 } from "fs";
229
245
  import { homedir as homedir2 } from "os";
230
246
  import { join as join3 } from "path";
231
247
  import { ofetch as ofetch3 } from "ofetch";
@@ -248,13 +264,13 @@ function getAuthFile() {
248
264
  }
249
265
  function ensureConfigDir() {
250
266
  const dir = getConfigDir();
251
- if (!existsSync2(dir)) {
267
+ if (!existsSync3(dir)) {
252
268
  mkdirSync3(dir, { recursive: true, mode: 448 });
253
269
  }
254
270
  }
255
271
  function loadIdpAuth() {
256
272
  const file = getAuthFile();
257
- if (!existsSync2(file)) return null;
273
+ if (!existsSync3(file)) return null;
258
274
  try {
259
275
  const raw = readFileSync2(file, "utf-8");
260
276
  if (!raw.trim()) return null;
@@ -267,7 +283,7 @@ function saveIdpAuth(auth) {
267
283
  ensureConfigDir();
268
284
  const file = getAuthFile();
269
285
  let extra = {};
270
- if (existsSync2(file)) {
286
+ if (existsSync3(file)) {
271
287
  try {
272
288
  const raw = readFileSync2(file, "utf-8");
273
289
  if (raw.trim()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openape/nest",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "OpenApe Nest — local control-plane daemon that supervises agent processes on this computer. Talks to troop SP for ownership state, spawns/destroys agents via DDISA always-grants, supervises chat-bridge children (replacing per-agent launchd plists).",
5
5
  "type": "module",
6
6
  "license": "MIT",