@agimon-ai/po 0.0.0-alpha.21 → 0.0.0-alpha.23

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.
@@ -33,6 +33,7 @@ import { loadServerPackages, selectedServerProviderOverrides } from "@agimon-ai/
33
33
  import crypto from "node:crypto";
34
34
  import { createOpenSessionRegistry, createRequestReceipts, createWorkspaceRegistry, identifyWorkspace, listSavedSessionRecords, listSavedSessions, readSqliteTranscript, readWorkspaceMarker, writeWorkspaceMarker } from "@agimon-ai/po-core/history";
35
35
  import { createNodePlatform } from "@agimon-ai/po-core/nodePlatform";
36
+ import { readSessionFileDirectories, removeSessionFiles } from "@agimon-ai/po-core/platform";
36
37
  import { readPoBackgroundWorkService } from "@agimon-ai/po-core/backgroundWork";
37
38
  import { createHeadlessHub } from "@agimon-ai/po-core/headlessHub";
38
39
  import { serveHeadlessServer } from "@agimon-ai/po-core/headlessServer";
@@ -77,6 +78,7 @@ async function runServerRuntime(options, runtime) {
77
78
  const serverDirectory = path.join(piAgentDirectory(baseEnvironment), "server");
78
79
  const platform = createNodePlatform({
79
80
  homeDirectory,
81
+ temporaryDirectory: path.resolve(baseEnvironment.TMPDIR || baseEnvironment.TMP || baseEnvironment.TEMP || os.tmpdir()),
80
82
  sessionsRoot: path.join(serverDirectory, "sessions")
81
83
  });
82
84
  /** Called on a watched change; assigned once every scope can be checked. */
@@ -206,6 +208,17 @@ async function runServerRuntime(options, runtime) {
206
208
  * it exists to survive.
207
209
  */
208
210
  let shuttingDown = false;
211
+ const removeSessionOutputs = async (sessionId) => {
212
+ const directories = await readSessionFileDirectories(platform.sessions, sessionId);
213
+ await removeSessionFiles({
214
+ platform,
215
+ sessionId,
216
+ environment: baseEnvironment,
217
+ artifactDirectory: path.join(directories?.agentDirectory ?? piAgentDirectory(baseEnvironment, homeDirectory), "po-artifacts", sessionId),
218
+ ...directories === void 0 ? {} : { directories }
219
+ });
220
+ openSessions.remove(sessionId);
221
+ };
209
222
  const closeManagedSession = async (sessionId, options) => {
210
223
  if (!shuttingDown && options?.keepDormant !== true) openSessions.remove(sessionId);
211
224
  const artifacts = sessionArtifacts.get(sessionId);
@@ -1298,7 +1311,8 @@ async function runServerRuntime(options, runtime) {
1298
1311
  return target.summary.id;
1299
1312
  },
1300
1313
  dormantSessions: () => openSessions.list(),
1301
- removeDormantSession: (record) => openSessions.remove(record.sessionId),
1314
+ removeDormantSession: (record) => removeSessionOutputs(record.sessionId),
1315
+ removeSessionFiles: removeSessionOutputs,
1302
1316
  setDormantGroups: (record, groups) => {
1303
1317
  if (!openSessions.add({
1304
1318
  ...record,