shadok-ai 0.17.34 → 0.17.36
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/dist/group-exec.d.ts +7 -1
- package/dist/group-exec.js +8 -1
- package/dist/group-exec.js.map +1 -1
- package/dist/peers.d.ts +43 -6
- package/dist/peers.js +42 -7
- package/dist/peers.js.map +1 -1
- package/dist/server.js +49 -3
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/public/index.html +106 -24
package/dist/group-exec.d.ts
CHANGED
|
@@ -112,7 +112,12 @@ export declare const CHECK_ENV_ALLOW: RegExp;
|
|
|
112
112
|
* 2. the target profile's secrets (what the check was always promised);
|
|
113
113
|
* 3. the session plumbing a script needs to call back the local API
|
|
114
114
|
* (`SHADOK_SESSION_ID`/`_PORT`/`_KEY` — the agent's own, never the admin
|
|
115
|
-
* cookie `SHADOK_AUTH`)
|
|
115
|
+
* cookie `SHADOK_AUTH`) and to reach another instance's agents
|
|
116
|
+
* (`SHADOK_PEERS_FILE`, the agent's OWN tier registry). The peers file is
|
|
117
|
+
* plumbing, not a credential of the server's: a guard that may drive the
|
|
118
|
+
* local fleet may drive the peers its tier enrolled, and leaving it out is
|
|
119
|
+
* what forced a production dispatch loop to hard-code a path under `/root`
|
|
120
|
+
* that the drop user could not read;
|
|
116
121
|
* 4. the drop user's HOME/USER/LOGNAME (`dropEnv`), so a dropped guard never
|
|
117
122
|
* keeps the server's `HOME=/root`.
|
|
118
123
|
*/
|
|
@@ -123,6 +128,7 @@ export declare function cronCheckEnv(input: {
|
|
|
123
128
|
id: string;
|
|
124
129
|
port: string;
|
|
125
130
|
key: string;
|
|
131
|
+
peersFile?: string;
|
|
126
132
|
};
|
|
127
133
|
user: string | null;
|
|
128
134
|
home: string | null;
|
package/dist/group-exec.js
CHANGED
|
@@ -118,7 +118,12 @@ const SELF_IDENTITY = new Set(["HOME", "USER", "LOGNAME"]);
|
|
|
118
118
|
* 2. the target profile's secrets (what the check was always promised);
|
|
119
119
|
* 3. the session plumbing a script needs to call back the local API
|
|
120
120
|
* (`SHADOK_SESSION_ID`/`_PORT`/`_KEY` — the agent's own, never the admin
|
|
121
|
-
* cookie `SHADOK_AUTH`)
|
|
121
|
+
* cookie `SHADOK_AUTH`) and to reach another instance's agents
|
|
122
|
+
* (`SHADOK_PEERS_FILE`, the agent's OWN tier registry). The peers file is
|
|
123
|
+
* plumbing, not a credential of the server's: a guard that may drive the
|
|
124
|
+
* local fleet may drive the peers its tier enrolled, and leaving it out is
|
|
125
|
+
* what forced a production dispatch loop to hard-code a path under `/root`
|
|
126
|
+
* that the drop user could not read;
|
|
122
127
|
* 4. the drop user's HOME/USER/LOGNAME (`dropEnv`), so a dropped guard never
|
|
123
128
|
* keeps the server's `HOME=/root`.
|
|
124
129
|
*/
|
|
@@ -134,6 +139,8 @@ export function cronCheckEnv(input) {
|
|
|
134
139
|
env.SHADOK_SESSION_ID = input.session.id;
|
|
135
140
|
env.SHADOK_PORT = input.session.port;
|
|
136
141
|
env.SHADOK_SESSION_KEY = input.session.key;
|
|
142
|
+
if (input.session.peersFile)
|
|
143
|
+
env.SHADOK_PEERS_FILE = input.session.peersFile;
|
|
137
144
|
Object.assign(env, dropEnv(input.user, input.home));
|
|
138
145
|
return env;
|
|
139
146
|
}
|
package/dist/group-exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-exec.js","sourceRoot":"","sources":["../src/group-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AAGnE;;;;;;;;;;GAUG;AAEH,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,KAQ/B;IACC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc;QAAE,OAAO,IAAI,CAAC;IAC/C,IAAI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S,EACT,KAA6C;IAE7C,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACnD,IAAI,KAAK;QAAE,GAAG,CAAC,IAAI,CAAC,wCAAwC,EAAE,QAAQ,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7H,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAmD,EACnD,GAAiC;IAEjC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpF,OAAO,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC;AAC5D,CAAC"}
|
package/dist/peers.d.ts
CHANGED
|
@@ -75,12 +75,49 @@ export declare function peerScope(peer: {
|
|
|
75
75
|
export declare const PEER_INVITE_TTL_MS: number;
|
|
76
76
|
/** INBOUND registry, per launch dir, 600 — peers allowed to reach THIS instance. */
|
|
77
77
|
export declare function peerFileFor(cwd?: string): string;
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
78
|
+
/**
|
|
79
|
+
* OUTBOUND registry, per launch dir AND per tier, 600 — peers THIS instance can
|
|
80
|
+
* reach (`{ alias: { url, token } }`, managed by `pilotctl peer add`). The server
|
|
81
|
+
* hands its path to every agent as SHADOK_PEERS_FILE (twin of the ledger file),
|
|
82
|
+
* since an agent's cwd is a worktree, not the launch dir. Written and read by the
|
|
83
|
+
* CLIENT (pilotctl); the server only computes the path.
|
|
84
|
+
*
|
|
85
|
+
* `stateHome` is invariant 54's correction, and this file was missed by it: the
|
|
86
|
+
* path was anchored on `os.homedir()`, i.e. the SERVER's home, so every dropped
|
|
87
|
+
* agent was handed a path under `/root` (mode 700) that it cannot read — making
|
|
88
|
+
* `pilotctl --peer <alias>` dead for every agent in multi-tenant, silently,
|
|
89
|
+
* because an unreadable registry parses as "no peers configured". Callers pass
|
|
90
|
+
* the agent's own state home (`agentStateHome`); the default keeps mono-tenant
|
|
91
|
+
* byte-for-byte unchanged.
|
|
92
|
+
*
|
|
93
|
+
* One consequence, and it is the right one: the registry becomes PER TIER. A
|
|
94
|
+
* peer credential an agent obtained belongs to its own tier, not to the machine
|
|
95
|
+
* — the same rule the secret vault already applies. A private group starts with
|
|
96
|
+
* an empty registry and enrols its own peers; only the COMMONS inherits the
|
|
97
|
+
* pre-tier file, which is what that single shared registry already meant back
|
|
98
|
+
* when every agent ran as root (`tierPeersOutSeed`).
|
|
99
|
+
*/
|
|
100
|
+
export declare function peersOutFileFor(cwd?: string, stateHome?: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Should the pre-tier outbound registry (the one in the SERVER's home) be seeded
|
|
103
|
+
* into this tier's own? Only for the COMMONS, and only when the tier has none of
|
|
104
|
+
* its own yet.
|
|
105
|
+
*
|
|
106
|
+
* Carrying it to every tier would be a widening: it would hand a private group a
|
|
107
|
+
* bearer token for another instance that nobody granted it. Carrying it nowhere
|
|
108
|
+
* would be a silent regression at the moment the path moves — a working `--peer`
|
|
109
|
+
* alias would just stop resolving. The commons is the honest middle: before the
|
|
110
|
+
* tiers existed every agent ran as root and read exactly this file, so the
|
|
111
|
+
* commons inheriting it changes nothing about who holds what.
|
|
112
|
+
*
|
|
113
|
+
* Never an overwrite: a tier that already has a registry has been managing its
|
|
114
|
+
* own, and the server's copy may be older.
|
|
115
|
+
*/
|
|
116
|
+
export declare function tierPeersOutSeed(input: {
|
|
117
|
+
tier: "commons" | "group";
|
|
118
|
+
serverHasFile: boolean;
|
|
119
|
+
tierHasFile: boolean;
|
|
120
|
+
}): boolean;
|
|
84
121
|
export declare function loadPeers(file: string): Peer[];
|
|
85
122
|
export declare function savePeers(file: string, peers: Peer[]): void;
|
|
86
123
|
/** A peer name is a slug: lowercased, safe chars, non-empty. null if nothing
|
package/dist/peers.js
CHANGED
|
@@ -16,13 +16,48 @@ export const PEER_INVITE_TTL_MS = 7 * 24 * 60 * 60_000;
|
|
|
16
16
|
export function peerFileFor(cwd = process.cwd()) {
|
|
17
17
|
return path.join(os.homedir(), ".shadok-ai", "peers", instanceKey(cwd) + ".json");
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
/**
|
|
20
|
+
* OUTBOUND registry, per launch dir AND per tier, 600 — peers THIS instance can
|
|
21
|
+
* reach (`{ alias: { url, token } }`, managed by `pilotctl peer add`). The server
|
|
22
|
+
* hands its path to every agent as SHADOK_PEERS_FILE (twin of the ledger file),
|
|
23
|
+
* since an agent's cwd is a worktree, not the launch dir. Written and read by the
|
|
24
|
+
* CLIENT (pilotctl); the server only computes the path.
|
|
25
|
+
*
|
|
26
|
+
* `stateHome` is invariant 54's correction, and this file was missed by it: the
|
|
27
|
+
* path was anchored on `os.homedir()`, i.e. the SERVER's home, so every dropped
|
|
28
|
+
* agent was handed a path under `/root` (mode 700) that it cannot read — making
|
|
29
|
+
* `pilotctl --peer <alias>` dead for every agent in multi-tenant, silently,
|
|
30
|
+
* because an unreadable registry parses as "no peers configured". Callers pass
|
|
31
|
+
* the agent's own state home (`agentStateHome`); the default keeps mono-tenant
|
|
32
|
+
* byte-for-byte unchanged.
|
|
33
|
+
*
|
|
34
|
+
* One consequence, and it is the right one: the registry becomes PER TIER. A
|
|
35
|
+
* peer credential an agent obtained belongs to its own tier, not to the machine
|
|
36
|
+
* — the same rule the secret vault already applies. A private group starts with
|
|
37
|
+
* an empty registry and enrols its own peers; only the COMMONS inherits the
|
|
38
|
+
* pre-tier file, which is what that single shared registry already meant back
|
|
39
|
+
* when every agent ran as root (`tierPeersOutSeed`).
|
|
40
|
+
*/
|
|
41
|
+
export function peersOutFileFor(cwd = process.cwd(), stateHome = os.homedir()) {
|
|
42
|
+
return path.join(stateHome, ".shadok-ai", "peers-out", instanceKey(cwd) + ".json");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Should the pre-tier outbound registry (the one in the SERVER's home) be seeded
|
|
46
|
+
* into this tier's own? Only for the COMMONS, and only when the tier has none of
|
|
47
|
+
* its own yet.
|
|
48
|
+
*
|
|
49
|
+
* Carrying it to every tier would be a widening: it would hand a private group a
|
|
50
|
+
* bearer token for another instance that nobody granted it. Carrying it nowhere
|
|
51
|
+
* would be a silent regression at the moment the path moves — a working `--peer`
|
|
52
|
+
* alias would just stop resolving. The commons is the honest middle: before the
|
|
53
|
+
* tiers existed every agent ran as root and read exactly this file, so the
|
|
54
|
+
* commons inheriting it changes nothing about who holds what.
|
|
55
|
+
*
|
|
56
|
+
* Never an overwrite: a tier that already has a registry has been managing its
|
|
57
|
+
* own, and the server's copy may be older.
|
|
58
|
+
*/
|
|
59
|
+
export function tierPeersOutSeed(input) {
|
|
60
|
+
return input.tier === "commons" && input.serverHasFile && !input.tierHasFile;
|
|
26
61
|
}
|
|
27
62
|
export function loadPeers(file) {
|
|
28
63
|
try {
|
package/dist/peers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peers.js","sourceRoot":"","sources":["../src/peers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuEzC;;wEAEwE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EAA2E;QACnG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,EAAE;QACF,mFAAmF;KACpF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -56,7 +56,7 @@ import { mediaDirForGroup, mediaFileMode, parseMediaRequest, groupForMediaKey, p
|
|
|
56
56
|
import { runPrivileged, TREE_OP_TIMEOUT_MS } from "./privileged.js";
|
|
57
57
|
import { HOME_SKILLS_BASE, rewriteSkillsBase } from "./skill-paths.js";
|
|
58
58
|
import { instanceKey } from "./paths.js";
|
|
59
|
-
import { peerFileFor, loadPeers, savePeers, peerFromToken, signPeerToken, newPeer, withSalts, redeemVerdict, redeemPeer, normPeerName, removePeer, ownedByPeer, peersOutFileFor, agentInvitePrompt, peerScope, } from "./peers.js";
|
|
59
|
+
import { peerFileFor, loadPeers, savePeers, peerFromToken, signPeerToken, newPeer, withSalts, redeemVerdict, redeemPeer, normPeerName, removePeer, ownedByPeer, peersOutFileFor, tierPeersOutSeed, agentInvitePrompt, peerScope, } from "./peers.js";
|
|
60
60
|
import { loadCrons, saveCrons, upsertCron, removeCron, resolveCronId, nextRunFor, nextRunAfterFailure, isTransient, CRON_MAX_RETRIES, markCronPrompt, normalizeSchedule, onceAt, stateAfterFire, scheduleLabel, cronTimeZone, defaultTimeZone, systemTimeZone, isValidTimeZone, } from "./crons.js";
|
|
61
61
|
import { isSlashCommand, promptMetaHeader, connectionOrigin } from "./promptmeta.js";
|
|
62
62
|
import { markHumanPrompt } from "./prompt-kind.js";
|
|
@@ -378,7 +378,13 @@ function runCronCheck(c, target) {
|
|
|
378
378
|
const env = cronCheckEnv({
|
|
379
379
|
base: process.env,
|
|
380
380
|
secrets: secretEnv,
|
|
381
|
-
session: {
|
|
381
|
+
session: {
|
|
382
|
+
id: c.sessionId,
|
|
383
|
+
port: String(boundPort || START_PORT),
|
|
384
|
+
key: sessionKeyFor(c.sessionId),
|
|
385
|
+
// The TARGET agent's own registry, resolved exactly like its spawn's.
|
|
386
|
+
peersFile: peersOutFileFor(process.cwd(), agentStateHome(user)),
|
|
387
|
+
},
|
|
382
388
|
user,
|
|
383
389
|
home: user ? homeForUser(user, GROUP_HOME_BASE) : null,
|
|
384
390
|
});
|
|
@@ -5944,6 +5950,42 @@ function seedGroupAgentHome(user, home, cwd) {
|
|
|
5944
5950
|
* while `/root`'s — volume-backed — had it). Best-effort; mono-tenant or
|
|
5945
5951
|
* un-migrated → no drop users → no-op.
|
|
5946
5952
|
*/
|
|
5953
|
+
/**
|
|
5954
|
+
* Carry the PRE-TIER outbound peers registry (the one in the server's home) into
|
|
5955
|
+
* the COMMONS tier's own, once. See `tierPeersOutSeed` for why the commons and
|
|
5956
|
+
* nowhere else: before the tiers existed every agent ran as root and read exactly
|
|
5957
|
+
* this file, so the commons inheriting it changes nothing about who holds what,
|
|
5958
|
+
* while copying it into a private group would hand it a credential nobody granted.
|
|
5959
|
+
*
|
|
5960
|
+
* Copied AS the commons user (`writeAsUserAtomic`), so the new file is owned by
|
|
5961
|
+
* the tier and root never writes through a home it does not own. Best-effort:
|
|
5962
|
+
* an instance with no peers configured has nothing to carry, and a failure leaves
|
|
5963
|
+
* `--peer` exactly as broken as it already was, with nothing new to diagnose.
|
|
5964
|
+
*/
|
|
5965
|
+
function seedCommonsPeersOut() {
|
|
5966
|
+
if (DEPLOYMENT_MODE !== "multi-tenant" || !groupsMigrated)
|
|
5967
|
+
return;
|
|
5968
|
+
const user = commonsOsUser({ migrated: groupsMigrated, mode: DEPLOYMENT_MODE });
|
|
5969
|
+
if (!user)
|
|
5970
|
+
return;
|
|
5971
|
+
const serverFile = peersOutFileFor(process.cwd(), os.homedir());
|
|
5972
|
+
const tierFile = peersOutFileFor(process.cwd(), agentStateHome(user));
|
|
5973
|
+
try {
|
|
5974
|
+
const seed = tierPeersOutSeed({
|
|
5975
|
+
tier: "commons",
|
|
5976
|
+
serverHasFile: fs.existsSync(serverFile),
|
|
5977
|
+
tierHasFile: fs.existsSync(tierFile),
|
|
5978
|
+
});
|
|
5979
|
+
if (!seed)
|
|
5980
|
+
return;
|
|
5981
|
+
writeAsUserAtomic(user, tierFile, fs.readFileSync(serverFile, "utf8"));
|
|
5982
|
+
spawnAsUserSync(user, "chmod", ["600", tierFile]);
|
|
5983
|
+
console.log(`peers: carried the outbound registry into ${tierFile}`);
|
|
5984
|
+
}
|
|
5985
|
+
catch (e) {
|
|
5986
|
+
console.log(`peers: could not seed ${tierFile} — ${e instanceof Error ? e.message : String(e)}`);
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5947
5989
|
function preseedGroupHomes() {
|
|
5948
5990
|
if (DEPLOYMENT_MODE !== "multi-tenant" || !groupsMigrated)
|
|
5949
5991
|
return;
|
|
@@ -5952,6 +5994,7 @@ function preseedGroupHomes() {
|
|
|
5952
5994
|
seedHomeTrust(user, home, [...cwds]);
|
|
5953
5995
|
ensureTierStateDir(user, home);
|
|
5954
5996
|
}
|
|
5997
|
+
seedCommonsPeersOut();
|
|
5955
5998
|
}
|
|
5956
5999
|
function makePilot(id, cwd, args, profileName, model, effort,
|
|
5957
6000
|
/**
|
|
@@ -6013,7 +6056,10 @@ group) {
|
|
|
6013
6056
|
env.SHADOK_LEDGER_FILE = ledgerFileFor(process.cwd());
|
|
6014
6057
|
// The PER-INSTANCE outbound-peers file (same reason): `pilotctl --peer <alias>`
|
|
6015
6058
|
// reads it to reach another instance's agents. See src/peers.ts.
|
|
6016
|
-
|
|
6059
|
+
// Per TIER, not per server home: the path used to be derived from `os.homedir()`,
|
|
6060
|
+
// so a dropped agent was handed a registry under /root (700) it cannot read and
|
|
6061
|
+
// `--peer` died silently (an unreadable file parses as "no peers"). Invariant 54.
|
|
6062
|
+
env.SHADOK_PEERS_FILE = peersOutFileFor(process.cwd(), agentStateHome(user));
|
|
6017
6063
|
// Args = base + profile flags (role / guardrails / model) + a note listing the
|
|
6018
6064
|
// injected env-var names (so the agent knows what it has) + the cockpit pilot
|
|
6019
6065
|
// prompt. Profile flags first so a profile never overrides the cockpit context.
|