@episoda/cli 0.2.194 → 0.2.196
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.
|
@@ -3046,7 +3046,7 @@ var require_package = __commonJS({
|
|
|
3046
3046
|
"package.json"(exports2, module2) {
|
|
3047
3047
|
module2.exports = {
|
|
3048
3048
|
name: "@episoda/cli",
|
|
3049
|
-
version: "0.2.
|
|
3049
|
+
version: "0.2.196",
|
|
3050
3050
|
description: "CLI tool for Episoda local development workflow orchestration",
|
|
3051
3051
|
main: "dist/index.js",
|
|
3052
3052
|
types: "dist/index.d.ts",
|
|
@@ -12927,7 +12927,8 @@ async function handlePtySpawn(payload, client) {
|
|
|
12927
12927
|
startedAt: Date.now(),
|
|
12928
12928
|
lastOutputAt: Date.now(),
|
|
12929
12929
|
watchdogTimer: null,
|
|
12930
|
-
credentialDirs: bootstrap.cleanupDirs
|
|
12930
|
+
credentialDirs: bootstrap.cleanupDirs,
|
|
12931
|
+
credentialAuthPath: bootstrap.authPath
|
|
12931
12932
|
};
|
|
12932
12933
|
sessions.set(agent_run_id, session);
|
|
12933
12934
|
const resetWatchdog = () => {
|
|
@@ -12961,7 +12962,6 @@ async function handlePtySpawn(payload, client) {
|
|
|
12961
12962
|
if (session.watchdogTimer) clearTimeout(session.watchdogTimer);
|
|
12962
12963
|
console.log(`[PTY] Process exited for ${agent_run_id} with code ${exitCode} after ${durationMs}ms`);
|
|
12963
12964
|
sessions.delete(agent_run_id);
|
|
12964
|
-
cleanupCredentialDirs(session.credentialDirs);
|
|
12965
12965
|
client.send({
|
|
12966
12966
|
type: "pty_exit",
|
|
12967
12967
|
moduleUid,
|
|
@@ -12971,6 +12971,7 @@ async function handlePtySpawn(payload, client) {
|
|
|
12971
12971
|
}).catch((err) => {
|
|
12972
12972
|
console.error(`[PTY] Failed to send pty_exit for ${agent_run_id}:`, err.message);
|
|
12973
12973
|
});
|
|
12974
|
+
syncCredentialUpdateAfterExit(session, agent_run_id, client);
|
|
12974
12975
|
});
|
|
12975
12976
|
}
|
|
12976
12977
|
function handlePtyResize(payload) {
|
|
@@ -12995,11 +12996,13 @@ function handlePtyKill(payload) {
|
|
|
12995
12996
|
}
|
|
12996
12997
|
try {
|
|
12997
12998
|
session.pty.kill();
|
|
12999
|
+
console.log(`[PTY] Kill signal sent for session ${agent_run_id}`);
|
|
12998
13000
|
} catch {
|
|
13001
|
+
if (session.watchdogTimer) clearTimeout(session.watchdogTimer);
|
|
13002
|
+
cleanupCredentialDirs(session.credentialDirs);
|
|
13003
|
+
sessions.delete(agent_run_id);
|
|
13004
|
+
console.warn(`[PTY] Kill failed for ${agent_run_id}; performed fallback cleanup`);
|
|
12999
13005
|
}
|
|
13000
|
-
cleanupCredentialDirs(session.credentialDirs);
|
|
13001
|
-
sessions.delete(agent_run_id);
|
|
13002
|
-
console.log(`[PTY] Killed session ${agent_run_id}`);
|
|
13003
13006
|
}
|
|
13004
13007
|
function createCredentialBootstrap(payload, agentRunId) {
|
|
13005
13008
|
const bootstrap = payload.credential_bootstrap;
|
|
@@ -13040,9 +13043,65 @@ function createCredentialBootstrap(payload, agentRunId) {
|
|
|
13040
13043
|
fs30.writeFileSync(authPath, JSON.stringify(authPayload, null, 2), { mode: 384 });
|
|
13041
13044
|
return {
|
|
13042
13045
|
env: { CODEX_HOME: codexHome },
|
|
13043
|
-
cleanupDirs
|
|
13046
|
+
cleanupDirs,
|
|
13047
|
+
authPath
|
|
13044
13048
|
};
|
|
13045
13049
|
}
|
|
13050
|
+
function syncCredentialUpdateAfterExit(session, agent_run_id, client) {
|
|
13051
|
+
const authPath = session.credentialAuthPath;
|
|
13052
|
+
if (!authPath) {
|
|
13053
|
+
cleanupCredentialDirs(session.credentialDirs);
|
|
13054
|
+
return;
|
|
13055
|
+
}
|
|
13056
|
+
void fs30.promises.readFile(authPath, "utf8").then((raw) => {
|
|
13057
|
+
const tokens = extractCredentialTokens(raw);
|
|
13058
|
+
if (!tokens.access_token) {
|
|
13059
|
+
console.warn(`[PTY] EP1472: No access_token in auth.json for ${agent_run_id}, skipping credential update`);
|
|
13060
|
+
return;
|
|
13061
|
+
}
|
|
13062
|
+
return client.send({
|
|
13063
|
+
type: "pty_credential_update",
|
|
13064
|
+
agent_run_id,
|
|
13065
|
+
provider: "codex",
|
|
13066
|
+
access_token: tokens.access_token,
|
|
13067
|
+
refresh_token: tokens.refresh_token,
|
|
13068
|
+
id_token: tokens.id_token,
|
|
13069
|
+
account_id: tokens.account_id
|
|
13070
|
+
}).then(() => {
|
|
13071
|
+
console.log(`[PTY] EP1472: pty_credential_update sent for ${agent_run_id}`);
|
|
13072
|
+
}).catch((err) => {
|
|
13073
|
+
console.warn(`[PTY] Failed to send pty_credential_update for ${agent_run_id}:`, err.message);
|
|
13074
|
+
});
|
|
13075
|
+
}).catch((err) => {
|
|
13076
|
+
console.warn(`[PTY] EP1472: Failed to read auth.json for ${agent_run_id}:`, getErrorMessage(err));
|
|
13077
|
+
}).finally(() => {
|
|
13078
|
+
cleanupCredentialDirs(session.credentialDirs);
|
|
13079
|
+
});
|
|
13080
|
+
}
|
|
13081
|
+
function extractCredentialTokens(raw) {
|
|
13082
|
+
const parsed = JSON.parse(raw);
|
|
13083
|
+
const authRecord = asRecord(parsed);
|
|
13084
|
+
if (!authRecord) return {};
|
|
13085
|
+
const nestedTokens = asRecord(authRecord.tokens);
|
|
13086
|
+
const source = nestedTokens ?? authRecord;
|
|
13087
|
+
return {
|
|
13088
|
+
access_token: pickString(source, "access_token"),
|
|
13089
|
+
refresh_token: pickString(source, "refresh_token"),
|
|
13090
|
+
id_token: pickString(source, "id_token"),
|
|
13091
|
+
account_id: pickString(source, "account_id")
|
|
13092
|
+
};
|
|
13093
|
+
}
|
|
13094
|
+
function asRecord(value) {
|
|
13095
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
13096
|
+
return value;
|
|
13097
|
+
}
|
|
13098
|
+
function pickString(record, key) {
|
|
13099
|
+
const value = record[key];
|
|
13100
|
+
return typeof value === "string" ? value : void 0;
|
|
13101
|
+
}
|
|
13102
|
+
function getErrorMessage(error) {
|
|
13103
|
+
return error instanceof Error ? error.message : String(error);
|
|
13104
|
+
}
|
|
13046
13105
|
function cleanupCredentialDirs(dirs) {
|
|
13047
13106
|
for (const dirPath of dirs) {
|
|
13048
13107
|
try {
|