@agimon-ai/po-core 0.0.0-alpha.20 → 0.0.0-alpha.21
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/LICENSE +149 -21
- package/NOTICE +41 -0
- package/dist/apiContracts.d.mts +54 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/headlessHub.cjs +4 -0
- package/dist/headlessHub.cjs.map +1 -1
- package/dist/headlessHub.mjs +4 -0
- package/dist/headlessHub.mjs.map +1 -1
- package/dist/headlessServer.cjs +7 -2
- package/dist/headlessServer.cjs.map +1 -1
- package/dist/headlessServer.d.mts +2 -0
- package/dist/headlessServer.d.mts.map +1 -1
- package/dist/headlessServer.mjs +7 -2
- package/dist/headlessServer.mjs.map +1 -1
- package/dist/moduleResolution.cjs +24 -2
- package/dist/moduleResolution.cjs.map +1 -1
- package/dist/moduleResolution.d.mts +6 -0
- package/dist/moduleResolution.d.mts.map +1 -1
- package/dist/moduleResolution.mjs +24 -3
- package/dist/moduleResolution.mjs.map +1 -1
- package/dist/native.cjs +1 -0
- package/dist/native.d.mts +3 -3
- package/dist/native.mjs +2 -2
- package/dist/nodePlatform.cjs +1 -0
- package/dist/nodePlatform.cjs.map +1 -1
- package/dist/nodePlatform.d.mts +2 -0
- package/dist/nodePlatform.d.mts.map +1 -1
- package/dist/nodePlatform.mjs +1 -0
- package/dist/nodePlatform.mjs.map +1 -1
- package/dist/packageApiServer.cjs +11 -5
- package/dist/packageApiServer.cjs.map +1 -1
- package/dist/packageApiServer.d.mts.map +1 -1
- package/dist/packageApiServer.mjs +7 -1
- package/dist/packageApiServer.mjs.map +1 -1
- package/dist/platform.cjs +6 -0
- package/dist/platform.d.mts +2 -1
- package/dist/platform.mjs +2 -1
- package/dist/src/schemas/hubChannel.cjs.map +1 -1
- package/dist/src/schemas/hubChannel.d.mts +4 -0
- package/dist/src/schemas/hubChannel.d.mts.map +1 -1
- package/dist/src/schemas/hubChannel.mjs.map +1 -1
- package/dist/src/schemas/packageApi.cjs.map +1 -1
- package/dist/src/schemas/packageApi.d.mts +3 -0
- package/dist/src/schemas/packageApi.d.mts.map +1 -1
- package/dist/src/schemas/packageApi.mjs.map +1 -1
- package/dist/src/schemas/platform.cjs.map +1 -1
- package/dist/src/schemas/platform.d.mts +5 -0
- package/dist/src/schemas/platform.d.mts.map +1 -1
- package/dist/src/schemas/platform.mjs.map +1 -1
- package/dist/src/server/serverScope.cjs +4 -1
- package/dist/src/server/serverScope.cjs.map +1 -1
- package/dist/src/server/serverScope.d.mts.map +1 -1
- package/dist/src/server/serverScope.mjs +4 -1
- package/dist/src/server/serverScope.mjs.map +1 -1
- package/dist/src/services/sessionFiles/index.cjs +96 -0
- package/dist/src/services/sessionFiles/index.cjs.map +1 -0
- package/dist/src/services/sessionFiles/index.d.mts +33 -0
- package/dist/src/services/sessionFiles/index.d.mts.map +1 -0
- package/dist/src/services/sessionFiles/index.mjs +89 -0
- package/dist/src/services/sessionFiles/index.mjs.map +1 -0
- package/dist/src/services/sessionFiles/sessionDirectory.cjs +66 -0
- package/dist/src/services/sessionFiles/sessionDirectory.cjs.map +1 -0
- package/dist/src/services/sessionFiles/sessionDirectory.mjs +62 -0
- package/dist/src/services/sessionFiles/sessionDirectory.mjs.map +1 -0
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs +18 -6
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs +16 -4
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
- package/dist/src/web/types/nativeTemplate.d.mts +1 -1
- package/dist/src/web/types/nativeTemplate.d.mts.map +1 -1
- package/licenses/Codex-Apache-2.0.txt +201 -0
- package/package.json +8 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionDirectory.mjs","names":[],"sources":["../../../../src/services/sessionFiles/sessionDirectory.ts"],"sourcesContent":["import { lstat, mkdir, realpath, rm } from 'node:fs/promises';\nimport { userInfo } from 'node:os';\nimport path from 'node:path';\n\nimport type { PoPlatform } from '../../schemas/platform';\n\n/** Validate every Po-owned ancestor. OS temp itself may be shared. */\nasync function checkedSessionDirectory(platform: PoPlatform, directory: string, create: boolean): Promise<string> {\n const base = await realpath(platform.temporaryDirectory!);\n const relative = path.relative(platform.temporaryDirectory!, directory);\n if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) throw new Error('Unsafe session temp root.');\n let current = base;\n const uid = userInfo().uid;\n for (const segment of relative.split(path.sep)) {\n current = path.join(current, segment);\n if (create) {\n try {\n await mkdir(current, { mode: 0o700 });\n } catch (error) {\n if (!(error instanceof Error && 'code' in error && error.code === 'EEXIST')) throw error;\n }\n }\n const info = await lstat(current);\n if (!info.isDirectory() || info.isSymbolicLink() || info.uid !== uid || (info.mode & 0o077) !== 0)\n throw new Error('Unsafe session temporary directory.');\n if ((await realpath(current)) !== current) throw new Error('Session temporary directory changed during access.');\n }\n return current;\n}\n\nexport async function prepareSessionDirectory(platform: PoPlatform, directory: string): Promise<string> {\n return checkedSessionDirectory(platform, directory, true);\n}\n\n/** Remove only an existing session temp tree, never creating missing cleanup targets. */\nexport async function removeSessionDirectory(platform: PoPlatform, directory: string): Promise<void> {\n try {\n const checked = await checkedSessionDirectory(platform, directory, false);\n await rm(checked, { recursive: true, force: true });\n } catch (error) {\n if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) throw error;\n }\n}\n\n/** Persistent output roots may contain symlinks as files, but the owned root and parent must not redirect removal. */\nexport async function removeSessionOutputDirectory(_platform: PoPlatform, directory: string): Promise<void> {\n try {\n const parent = path.dirname(directory);\n for (const target of [parent, directory]) {\n const info = await lstat(target);\n if (!info.isDirectory() || info.isSymbolicLink()) throw new Error('Unsafe session output cleanup target.');\n }\n const realParent = await realpath(parent);\n const realDirectory = await realpath(directory);\n if (realDirectory !== path.join(realParent, path.basename(directory)))\n throw new Error('Session output cleanup target changed during access.');\n await rm(realDirectory, { recursive: true, force: true });\n } catch (error) {\n if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) throw error;\n }\n}\n"],"mappings":";;;;;AAOA,eAAe,wBAAwB,UAAsB,WAAmB,QAAkC;CAChH,MAAM,OAAO,MAAM,SAAS,SAAS,kBAAmB;CACxD,MAAM,WAAW,KAAK,SAAS,SAAS,oBAAqB,SAAS;CACtE,IAAI,CAAC,YAAY,SAAS,WAAW,IAAI,KAAK,KAAK,WAAW,QAAQ,GAAG,MAAM,IAAI,MAAM,2BAA2B;CACpH,IAAI,UAAU;CACd,MAAM,MAAM,SAAS,CAAC,CAAC;CACvB,KAAK,MAAM,WAAW,SAAS,MAAM,KAAK,GAAG,GAAG;EAC9C,UAAU,KAAK,KAAK,SAAS,OAAO;EACpC,IAAI,QACF,IAAI;GACF,MAAM,MAAM,SAAS,EAAE,MAAM,IAAM,CAAC;EACtC,SAAS,OAAO;GACd,IAAI,EAAE,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,WAAW,MAAM;EACrF;EAEF,MAAM,OAAO,MAAM,MAAM,OAAO;EAChC,IAAI,CAAC,KAAK,YAAY,KAAK,KAAK,eAAe,KAAK,KAAK,QAAQ,QAAQ,KAAK,OAAO,QAAW,GAC9F,MAAM,IAAI,MAAM,qCAAqC;EACvD,IAAK,MAAM,SAAS,OAAO,MAAO,SAAS,MAAM,IAAI,MAAM,oDAAoD;CACjH;CACA,OAAO;AACT;AAEA,eAAsB,wBAAwB,UAAsB,WAAoC;CACtG,OAAO,wBAAwB,UAAU,WAAW,IAAI;AAC1D;;AAGA,eAAsB,uBAAuB,UAAsB,WAAkC;CACnG,IAAI;EACF,MAAM,UAAU,MAAM,wBAAwB,UAAU,WAAW,KAAK;EACxE,MAAM,GAAG,SAAS;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;CACpD,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,WAAW,MAAM;CACrF;AACF;;AAGA,eAAsB,6BAA6B,WAAuB,WAAkC;CAC1G,IAAI;EACF,MAAM,SAAS,KAAK,QAAQ,SAAS;EACrC,KAAK,MAAM,UAAU,CAAC,QAAQ,SAAS,GAAG;GACxC,MAAM,OAAO,MAAM,MAAM,MAAM;GAC/B,IAAI,CAAC,KAAK,YAAY,KAAK,KAAK,eAAe,GAAG,MAAM,IAAI,MAAM,uCAAuC;EAC3G;EACA,MAAM,aAAa,MAAM,SAAS,MAAM;EACxC,MAAM,gBAAgB,MAAM,SAAS,SAAS;EAC9C,IAAI,kBAAkB,KAAK,KAAK,YAAY,KAAK,SAAS,SAAS,CAAC,GAClE,MAAM,IAAI,MAAM,sDAAsD;EACxE,MAAM,GAAG,eAAe;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;CAC1D,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,WAAW,MAAM;CACrF;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_runtime = require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_core = require("../../../services/piSettings/core.cjs");
|
|
2
3
|
const require_agentModel = require("../../../schemas/agentModel.cjs");
|
|
3
4
|
const require_backgroundWork = require("../../../schemas/backgroundWork.cjs");
|
|
4
5
|
require("../../../../backgroundWork.cjs");
|
|
@@ -24,7 +25,8 @@ const require_index$6 = require("../../../services/nodeModelDependencies/index.c
|
|
|
24
25
|
const require_index$7 = require("../../../services/piArgs/index.cjs");
|
|
25
26
|
const require_index$8 = require("../../../services/piSummary/index.cjs");
|
|
26
27
|
const require_serverTelemetry = require("../../../../serverTelemetry.cjs");
|
|
27
|
-
const require_index$9 = require("../../../services/
|
|
28
|
+
const require_index$9 = require("../../../services/sessionFiles/index.cjs");
|
|
29
|
+
const require_index$10 = require("../../../services/toolPrompt/index.cjs");
|
|
28
30
|
const require_headlessChildSessionService = require("../../child/adapters/headlessChildSessionService.cjs");
|
|
29
31
|
let node_crypto = require("node:crypto");
|
|
30
32
|
let node_path = require("node:path");
|
|
@@ -362,12 +364,17 @@ async function repositoryInstructions(platform, repoRoot, agentDir, files) {
|
|
|
362
364
|
* registered under its id for them to read instead of `process.env`, and released with it.
|
|
363
365
|
*/
|
|
364
366
|
async function createHeadlessSessionHost(options) {
|
|
365
|
-
|
|
367
|
+
let releaseEnvironment;
|
|
366
368
|
try {
|
|
369
|
+
options = {
|
|
370
|
+
...options,
|
|
371
|
+
environment: await require_index$9.prepareSessionEnvironment(options)
|
|
372
|
+
};
|
|
373
|
+
releaseEnvironment = require_runtimeCordisHost.registerPoSessionEnvironment(options.sessionId, options.environment);
|
|
367
374
|
return await composeHeadlessSessionHost(options, releaseEnvironment);
|
|
368
375
|
} catch (error) {
|
|
369
376
|
require_contextDetailStore.removeContextDetail(options.sessionId, options.environment);
|
|
370
|
-
releaseEnvironment();
|
|
377
|
+
releaseEnvironment?.();
|
|
371
378
|
throw error;
|
|
372
379
|
}
|
|
373
380
|
}
|
|
@@ -429,10 +436,11 @@ async function composeHeadlessSessionHost(options, releaseEnvironment) {
|
|
|
429
436
|
return [
|
|
430
437
|
initialSystemPrompt,
|
|
431
438
|
projectContextBlock,
|
|
432
|
-
require_index$
|
|
439
|
+
require_index$10.formatToolPrompt(toolGuidance),
|
|
433
440
|
skills,
|
|
434
441
|
...mapped.context,
|
|
435
|
-
workingDirectoryLine
|
|
442
|
+
workingDirectoryLine,
|
|
443
|
+
options.environment["PO_SESSION_TEMP_DIR"] ? `Session temporary folder: ${options.environment[require_index$9.PO_SESSION_TEMP_DIR]}\nUse this folder for generated scratch files outside the workspace. Keep workspace edits in place and save important deliverables in session artifacts. Temporary files may be removed by the operating system.` : ""
|
|
436
444
|
].filter(Boolean).join("\n\n");
|
|
437
445
|
};
|
|
438
446
|
/** The last prompt a turn actually built, once one has. */
|
|
@@ -675,7 +683,11 @@ async function composeHeadlessSessionHost(options, releaseEnvironment) {
|
|
|
675
683
|
workspaceId: options.workspaceId,
|
|
676
684
|
groupingRoot: options.groupingRoot ?? options.repoRoot,
|
|
677
685
|
parentSessionId: options.parentSessionId,
|
|
678
|
-
sessionProvenance: options.sessionProvenance
|
|
686
|
+
sessionProvenance: options.sessionProvenance,
|
|
687
|
+
files: {
|
|
688
|
+
agentDirectory: node_path.default.resolve(require_core.piAgentDirectory(options.environment, options.platform.homeDirectory)),
|
|
689
|
+
...options.environment["PO_SESSION_TEMP_DIR"] === void 0 ? {} : { temporaryDirectory: options.environment[require_index$9.PO_SESSION_TEMP_DIR] }
|
|
690
|
+
}
|
|
679
691
|
});
|
|
680
692
|
}, dist_interop_chordContext_mjs.BACKGROUND_CONTEXT);
|
|
681
693
|
const agent = await runtime.lane.agent(dist_interop_chordContext_mjs.BACKGROUND_CONTEXT);
|