@docyrus/docyrus 0.0.62 → 0.0.64
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/README.md +19 -0
- package/agent-loader.js +1 -1
- package/agent-loader.js.map +2 -2
- package/main.js +268 -105
- package/main.js.map +4 -4
- package/package.json +1 -1
- package/resources/pi-agent/extensions/soul.ts +183 -0
- package/resources/pi-agent/skills/grill-me/SKILL.md +11 -8
- package/resources/pi-agent/skills/release-manager/SKILL.md +469 -30
- package/resources/pi-agent/souls/boomer-parent.md +23 -0
- package/resources/pi-agent/souls/bro.md +22 -0
- package/resources/pi-agent/souls/catalog.ts +79 -0
- package/resources/pi-agent/souls/caveman.md +21 -0
- package/resources/pi-agent/souls/linkedin-influencer.md +60 -0
- package/resources/pi-agent/souls/master-yoda.md +22 -0
- package/resources/pi-agent/souls/noir-detective.md +24 -0
- package/resources/pi-agent/souls/nonsense-engineer.md +23 -0
- package/resources/pi-agent/souls/pirate.md +24 -0
- package/resources/pi-agent/souls/shakespeare.md +24 -0
- package/server-loader.js +703 -74
- package/server-loader.js.map +4 -4
- package/resources/pi-agent/skills/changelog-generator/SKILL.md +0 -461
package/main.js
CHANGED
|
@@ -18864,7 +18864,7 @@ var require_core3 = __commonJS({
|
|
|
18864
18864
|
return match && match.index === 0;
|
|
18865
18865
|
}
|
|
18866
18866
|
var BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
18867
|
-
function
|
|
18867
|
+
function join19(regexps, separator = "|") {
|
|
18868
18868
|
let numCaptures = 0;
|
|
18869
18869
|
return regexps.map((regex) => {
|
|
18870
18870
|
numCaptures += 1;
|
|
@@ -19168,7 +19168,7 @@ var require_core3 = __commonJS({
|
|
|
19168
19168
|
this.exec = () => null;
|
|
19169
19169
|
}
|
|
19170
19170
|
const terminators = this.regexes.map((el) => el[1]);
|
|
19171
|
-
this.matcherRe = langRe(
|
|
19171
|
+
this.matcherRe = langRe(join19(terminators), true);
|
|
19172
19172
|
this.lastIndex = 0;
|
|
19173
19173
|
}
|
|
19174
19174
|
/** @param {string} s */
|
|
@@ -85749,9 +85749,9 @@ var init_lib10 = __esm({
|
|
|
85749
85749
|
* @returns {undefined}
|
|
85750
85750
|
* Nothing.
|
|
85751
85751
|
*/
|
|
85752
|
-
set dirname(
|
|
85752
|
+
set dirname(dirname14) {
|
|
85753
85753
|
assertPath(this.basename, "dirname");
|
|
85754
|
-
this.path = import_node_path7.default.join(
|
|
85754
|
+
this.path = import_node_path7.default.join(dirname14 || "", this.basename);
|
|
85755
85755
|
}
|
|
85756
85756
|
/**
|
|
85757
85757
|
* Get the extname (including dot) (example: `'.js'`).
|
|
@@ -102181,8 +102181,8 @@ var require_snapshot_utils = __commonJS({
|
|
|
102181
102181
|
var require_snapshot_recorder = __commonJS({
|
|
102182
102182
|
"../../node_modules/.pnpm/undici@7.24.7/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
|
|
102183
102183
|
"use strict";
|
|
102184
|
-
var { writeFile:
|
|
102185
|
-
var { dirname:
|
|
102184
|
+
var { writeFile: writeFile10, readFile: readFile18, mkdir: mkdir11 } = require("node:fs/promises");
|
|
102185
|
+
var { dirname: dirname14, resolve: resolve2 } = require("node:path");
|
|
102186
102186
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require("node:timers");
|
|
102187
102187
|
var { InvalidArgumentError, UndiciError } = require_errors3();
|
|
102188
102188
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -102383,7 +102383,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
102383
102383
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
102384
102384
|
}
|
|
102385
102385
|
try {
|
|
102386
|
-
const data = await
|
|
102386
|
+
const data = await readFile18(resolve2(path8), "utf8");
|
|
102387
102387
|
const parsed = JSON.parse(data);
|
|
102388
102388
|
if (Array.isArray(parsed)) {
|
|
102389
102389
|
this.#snapshots.clear();
|
|
@@ -102413,12 +102413,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
102413
102413
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
102414
102414
|
}
|
|
102415
102415
|
const resolvedPath = resolve2(path8);
|
|
102416
|
-
await
|
|
102416
|
+
await mkdir11(dirname14(resolvedPath), { recursive: true });
|
|
102417
102417
|
const data = Array.from(this.#snapshots.entries()).map(([hash3, snapshot]) => ({
|
|
102418
102418
|
hash: hash3,
|
|
102419
102419
|
snapshot
|
|
102420
102420
|
}));
|
|
102421
|
-
await
|
|
102421
|
+
await writeFile10(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
|
|
102422
102422
|
}
|
|
102423
102423
|
/**
|
|
102424
102424
|
* Clears all recorded snapshots
|
|
@@ -139349,7 +139349,7 @@ function buildInputSchema(args2, env2, options2) {
|
|
|
139349
139349
|
// package.json
|
|
139350
139350
|
var package_default = {
|
|
139351
139351
|
name: "@docyrus/docyrus",
|
|
139352
|
-
version: "0.0.
|
|
139352
|
+
version: "0.0.64",
|
|
139353
139353
|
private: false,
|
|
139354
139354
|
description: "Docyrus API CLI",
|
|
139355
139355
|
main: "./main.js",
|
|
@@ -139423,7 +139423,8 @@ var EnvironmentConfigStateSchema = external_exports.object({
|
|
|
139423
139423
|
version: external_exports.literal(1),
|
|
139424
139424
|
activeEnvironmentId: external_exports.string().min(1),
|
|
139425
139425
|
environments: external_exports.array(EnvironmentConfigItemSchema).min(1),
|
|
139426
|
-
defaultClientId: external_exports.string().min(1).optional()
|
|
139426
|
+
defaultClientId: external_exports.string().min(1).optional(),
|
|
139427
|
+
activeSoulId: external_exports.string().min(1).optional()
|
|
139427
139428
|
});
|
|
139428
139429
|
var LegacyAuthSessionSchema = external_exports.object({
|
|
139429
139430
|
apiBaseUrl: external_exports.string().min(1),
|
|
@@ -140782,12 +140783,12 @@ function summarizeFailure(result) {
|
|
|
140782
140783
|
}
|
|
140783
140784
|
function resolveBrowserToolsResourceRoot(options2 = {}) {
|
|
140784
140785
|
const cwd = options2.cwd ?? process.cwd();
|
|
140785
|
-
const
|
|
140786
|
+
const dirname14 = options2.dirname ?? __dirname;
|
|
140786
140787
|
const fileExists = options2.existsSyncFn ?? import_node_fs3.existsSync;
|
|
140787
140788
|
const candidates = options2.candidatePaths ?? [
|
|
140788
140789
|
(0, import_node_path4.resolve)(cwd, "apps/api-cli/resources/browser-tools"),
|
|
140789
|
-
(0, import_node_path4.resolve)(
|
|
140790
|
-
(0, import_node_path4.resolve)(
|
|
140790
|
+
(0, import_node_path4.resolve)(dirname14, "../resources/browser-tools"),
|
|
140791
|
+
(0, import_node_path4.resolve)(dirname14, "resources/browser-tools"),
|
|
140791
140792
|
(0, import_node_path4.resolve)(cwd, "dist/apps/api-cli/resources/browser-tools")
|
|
140792
140793
|
];
|
|
140793
140794
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
@@ -152537,16 +152538,16 @@ function resolveCliScriptPath() {
|
|
|
152537
152538
|
}
|
|
152538
152539
|
function resolveOpenTuiEntryPath(options2 = {}) {
|
|
152539
152540
|
const cwd = options2.cwd ?? process.cwd();
|
|
152540
|
-
const
|
|
152541
|
+
const dirname14 = options2.dirname ?? __dirname;
|
|
152541
152542
|
const fileExists = options2.existsSyncFn ?? import_node_fs16.existsSync;
|
|
152542
152543
|
const candidates = [
|
|
152543
152544
|
// Source/dev mode in monorepo. Prefer this first so Bun resolves deps via
|
|
152544
152545
|
// apps/api-cli/node_modules in workspace runs (e.g. `pnpm docyrus tui`).
|
|
152545
152546
|
(0, import_node_path25.resolve)(cwd, "apps/api-cli/src/tui/opentuiMain.tsx"),
|
|
152546
|
-
(0, import_node_path25.resolve)(
|
|
152547
|
+
(0, import_node_path25.resolve)(dirname14, "../tui/opentuiMain.tsx"),
|
|
152547
152548
|
// Dist mode (bundled command runtime)
|
|
152548
|
-
(0, import_node_path25.resolve)(
|
|
152549
|
-
(0, import_node_path25.resolve)(
|
|
152549
|
+
(0, import_node_path25.resolve)(dirname14, "tui.mjs"),
|
|
152550
|
+
(0, import_node_path25.resolve)(dirname14, "../tui.mjs"),
|
|
152550
152551
|
(0, import_node_path25.resolve)(cwd, "dist/apps/api-cli/tui.mjs")
|
|
152551
152552
|
];
|
|
152552
152553
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
@@ -153641,6 +153642,76 @@ var AuthStore = class {
|
|
|
153641
153642
|
// src/services/environmentConfig.ts
|
|
153642
153643
|
var import_promises21 = require("node:fs/promises");
|
|
153643
153644
|
var import_node_path27 = require("node:path");
|
|
153645
|
+
|
|
153646
|
+
// resources/pi-agent/souls/catalog.ts
|
|
153647
|
+
var DEFAULT_SOUL_ID = "default";
|
|
153648
|
+
var SOULS = [
|
|
153649
|
+
{
|
|
153650
|
+
id: "default",
|
|
153651
|
+
name: "Default",
|
|
153652
|
+
description: "Standard Docyrus operator voice. No style overlay.",
|
|
153653
|
+
promptFile: null
|
|
153654
|
+
},
|
|
153655
|
+
{
|
|
153656
|
+
id: "caveman",
|
|
153657
|
+
name: "Caveman",
|
|
153658
|
+
description: "Short grunts. Agent talk simple. Fire good.",
|
|
153659
|
+
promptFile: "caveman.md"
|
|
153660
|
+
},
|
|
153661
|
+
{
|
|
153662
|
+
id: "boomer-parent",
|
|
153663
|
+
name: "Boomer Parent",
|
|
153664
|
+
description: "Overly proud dad-jokes energy with 'back in my day' asides.",
|
|
153665
|
+
promptFile: "boomer-parent.md"
|
|
153666
|
+
},
|
|
153667
|
+
{
|
|
153668
|
+
id: "master-yoda",
|
|
153669
|
+
name: "Master Yoda",
|
|
153670
|
+
description: "Inverted syntax the agent speaks. Mystical brevity, hmm.",
|
|
153671
|
+
promptFile: "master-yoda.md"
|
|
153672
|
+
},
|
|
153673
|
+
{
|
|
153674
|
+
id: "bro",
|
|
153675
|
+
name: "Bro",
|
|
153676
|
+
description: "Pure gym-bro hype energy. 'Lit, fam, let's go.'",
|
|
153677
|
+
promptFile: "bro.md"
|
|
153678
|
+
},
|
|
153679
|
+
{
|
|
153680
|
+
id: "nonsense-engineer",
|
|
153681
|
+
name: "Nonsense Engineer",
|
|
153682
|
+
description: "Maximum jargon, minimum meaning. 'Leveraging synergistic abstractions.'",
|
|
153683
|
+
promptFile: "nonsense-engineer.md"
|
|
153684
|
+
},
|
|
153685
|
+
{
|
|
153686
|
+
id: "shakespeare",
|
|
153687
|
+
name: "Shakespeare",
|
|
153688
|
+
description: "Thee/thou, dramatic flair, iambic vibes.",
|
|
153689
|
+
promptFile: "shakespeare.md"
|
|
153690
|
+
},
|
|
153691
|
+
{
|
|
153692
|
+
id: "noir-detective",
|
|
153693
|
+
name: "Noir Detective",
|
|
153694
|
+
description: "Hard-boiled 1940s narrator. Every bug is a dame.",
|
|
153695
|
+
promptFile: "noir-detective.md"
|
|
153696
|
+
},
|
|
153697
|
+
{
|
|
153698
|
+
id: "pirate",
|
|
153699
|
+
name: "Pirate",
|
|
153700
|
+
description: "Aye matey, every task a seafaring metaphor, arrr.",
|
|
153701
|
+
promptFile: "pirate.md"
|
|
153702
|
+
},
|
|
153703
|
+
{
|
|
153704
|
+
id: "linkedin-influencer",
|
|
153705
|
+
name: "LinkedIn Influencer",
|
|
153706
|
+
description: "Every reply is a mini-post. Single-sentence paragraphs. Humble-brags. 'Agree? \u{1F447}'",
|
|
153707
|
+
promptFile: "linkedin-influencer.md"
|
|
153708
|
+
}
|
|
153709
|
+
];
|
|
153710
|
+
function findSoul(id) {
|
|
153711
|
+
return SOULS.find((soul) => soul.id === id);
|
|
153712
|
+
}
|
|
153713
|
+
|
|
153714
|
+
// src/services/environmentConfig.ts
|
|
153644
153715
|
var ENVIRONMENT_ID_ALIASES = {
|
|
153645
153716
|
"local-development": "dev",
|
|
153646
153717
|
prod: "live"
|
|
@@ -153664,9 +153735,20 @@ function createDefaultState3() {
|
|
|
153664
153735
|
name: environment.name,
|
|
153665
153736
|
apiBaseUrl: environment.apiBaseUrl
|
|
153666
153737
|
})),
|
|
153667
|
-
defaultClientId: void 0
|
|
153738
|
+
defaultClientId: void 0,
|
|
153739
|
+
activeSoulId: DEFAULT_SOUL_ID
|
|
153668
153740
|
};
|
|
153669
153741
|
}
|
|
153742
|
+
function normalizeSoulId(value2) {
|
|
153743
|
+
if (!value2) {
|
|
153744
|
+
return DEFAULT_SOUL_ID;
|
|
153745
|
+
}
|
|
153746
|
+
const trimmed = value2.trim();
|
|
153747
|
+
if (!trimmed) {
|
|
153748
|
+
return DEFAULT_SOUL_ID;
|
|
153749
|
+
}
|
|
153750
|
+
return findSoul(trimmed) ? trimmed : DEFAULT_SOUL_ID;
|
|
153751
|
+
}
|
|
153670
153752
|
function normalizeState3(state) {
|
|
153671
153753
|
const defaultsById = new Map(
|
|
153672
153754
|
DEFAULT_ENVIRONMENTS.map((environment) => [
|
|
@@ -153717,7 +153799,8 @@ function normalizeState3(state) {
|
|
|
153717
153799
|
version: 1,
|
|
153718
153800
|
activeEnvironmentId: hasActiveEnvironment ? canonicalActiveEnvironmentId : fallbackActiveEnvironment,
|
|
153719
153801
|
environments,
|
|
153720
|
-
defaultClientId: state.defaultClientId?.trim() || void 0
|
|
153802
|
+
defaultClientId: state.defaultClientId?.trim() || void 0,
|
|
153803
|
+
activeSoulId: normalizeSoulId(state.activeSoulId)
|
|
153721
153804
|
};
|
|
153722
153805
|
}
|
|
153723
153806
|
var EnvironmentConfigService = class {
|
|
@@ -153822,6 +153905,25 @@ var EnvironmentConfigService = class {
|
|
|
153822
153905
|
defaultClientId: trimmedClientId
|
|
153823
153906
|
});
|
|
153824
153907
|
}
|
|
153908
|
+
async getActiveSoulId() {
|
|
153909
|
+
const state = await this.#readStateWithDefaults();
|
|
153910
|
+
return normalizeSoulId(state.activeSoulId);
|
|
153911
|
+
}
|
|
153912
|
+
async setActiveSoulId(soulId) {
|
|
153913
|
+
const trimmed = soulId.trim();
|
|
153914
|
+
if (!trimmed) {
|
|
153915
|
+
throw new UserInputError("Soul ID cannot be empty.");
|
|
153916
|
+
}
|
|
153917
|
+
if (!findSoul(trimmed)) {
|
|
153918
|
+
throw new UserInputError(`Unknown soul '${soulId}'. Use /souls inside the pi agent or GET /api/souls to view options.`);
|
|
153919
|
+
}
|
|
153920
|
+
const state = await this.#readStateWithDefaults();
|
|
153921
|
+
await this.writeState({
|
|
153922
|
+
...state,
|
|
153923
|
+
activeSoulId: trimmed
|
|
153924
|
+
});
|
|
153925
|
+
return trimmed;
|
|
153926
|
+
}
|
|
153825
153927
|
async #readStateWithDefaults() {
|
|
153826
153928
|
const state = await this.readState();
|
|
153827
153929
|
if (state.environments.length > 0) {
|
|
@@ -153839,8 +153941,51 @@ var EnvironmentConfigService = class {
|
|
|
153839
153941
|
// src/services/piAgentLauncher.ts
|
|
153840
153942
|
var import_node_child_process8 = require("node:child_process");
|
|
153841
153943
|
var import_node_fs17 = require("node:fs");
|
|
153944
|
+
var import_promises23 = require("node:fs/promises");
|
|
153945
|
+
var import_node_path29 = require("node:path");
|
|
153946
|
+
|
|
153947
|
+
// src/services/soulRegistry.ts
|
|
153842
153948
|
var import_promises22 = require("node:fs/promises");
|
|
153843
153949
|
var import_node_path28 = require("node:path");
|
|
153950
|
+
function resolveBasePromptPath(params) {
|
|
153951
|
+
const filename = params.profile === "agent" ? "agent-system.md" : "coder-system.md";
|
|
153952
|
+
return (0, import_node_path28.join)(params.resourceRoot, "prompts", filename);
|
|
153953
|
+
}
|
|
153954
|
+
async function composeSystemPrompt(params) {
|
|
153955
|
+
const soul = findSoul(params.soulId) ?? findSoul(DEFAULT_SOUL_ID);
|
|
153956
|
+
if (!soul) {
|
|
153957
|
+
throw new Error(`Soul catalog is missing the '${DEFAULT_SOUL_ID}' entry.`);
|
|
153958
|
+
}
|
|
153959
|
+
const basePromptPath = resolveBasePromptPath({
|
|
153960
|
+
resourceRoot: params.resourceRoot,
|
|
153961
|
+
profile: params.profile
|
|
153962
|
+
});
|
|
153963
|
+
if (!soul.promptFile) {
|
|
153964
|
+
return basePromptPath;
|
|
153965
|
+
}
|
|
153966
|
+
const overlayPath = (0, import_node_path28.join)(params.resourceRoot, "souls", soul.promptFile);
|
|
153967
|
+
const [basePrompt, overlayPrompt] = await Promise.all([
|
|
153968
|
+
(0, import_promises22.readFile)(basePromptPath, "utf8"),
|
|
153969
|
+
(0, import_promises22.readFile)(overlayPath, "utf8")
|
|
153970
|
+
]);
|
|
153971
|
+
const composedPath = (0, import_node_path28.join)(params.agentRootPath, `system-prompt-${params.profile}.md`);
|
|
153972
|
+
const composed = `${basePrompt.trimEnd()}
|
|
153973
|
+
|
|
153974
|
+
---
|
|
153975
|
+
|
|
153976
|
+
${overlayPrompt.trimEnd()}
|
|
153977
|
+
`;
|
|
153978
|
+
await (0, import_promises22.mkdir)((0, import_node_path28.dirname)(composedPath), {
|
|
153979
|
+
recursive: true,
|
|
153980
|
+
mode: 448
|
|
153981
|
+
});
|
|
153982
|
+
await (0, import_promises22.writeFile)(composedPath, composed, {
|
|
153983
|
+
encoding: "utf8",
|
|
153984
|
+
mode: 384
|
|
153985
|
+
});
|
|
153986
|
+
await (0, import_promises22.chmod)(composedPath, 384);
|
|
153987
|
+
return composedPath;
|
|
153988
|
+
}
|
|
153844
153989
|
|
|
153845
153990
|
// src/services/spinner.ts
|
|
153846
153991
|
var import_picocolors2 = __toESM(require_picocolors());
|
|
@@ -153902,13 +154047,13 @@ function summarizeFailure3(result, commandLabel = "Command") {
|
|
|
153902
154047
|
}
|
|
153903
154048
|
function resolvePackagedPiResourceRoot(options2 = {}) {
|
|
153904
154049
|
const cwd = options2.cwd ?? process.cwd();
|
|
153905
|
-
const
|
|
154050
|
+
const dirname14 = options2.dirname ?? __dirname;
|
|
153906
154051
|
const fileExists = options2.existsSyncFn ?? import_node_fs17.existsSync;
|
|
153907
154052
|
const candidates = [
|
|
153908
|
-
(0,
|
|
153909
|
-
(0,
|
|
153910
|
-
(0,
|
|
153911
|
-
(0,
|
|
154053
|
+
(0, import_node_path29.resolve)(cwd, "apps/api-cli/resources/pi-agent"),
|
|
154054
|
+
(0, import_node_path29.resolve)(dirname14, "../resources/pi-agent"),
|
|
154055
|
+
(0, import_node_path29.resolve)(dirname14, "resources/pi-agent"),
|
|
154056
|
+
(0, import_node_path29.resolve)(cwd, "dist/apps/api-cli/resources/pi-agent")
|
|
153912
154057
|
];
|
|
153913
154058
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
153914
154059
|
if (!resolved) {
|
|
@@ -153918,7 +154063,7 @@ function resolvePackagedPiResourceRoot(options2 = {}) {
|
|
|
153918
154063
|
}
|
|
153919
154064
|
function resolveDocyrusPiLoaderEntryPath(options2 = {}) {
|
|
153920
154065
|
const cwd = options2.cwd ?? process.cwd();
|
|
153921
|
-
const
|
|
154066
|
+
const dirname14 = options2.dirname ?? __dirname;
|
|
153922
154067
|
const fileExists = options2.existsSyncFn ?? import_node_fs17.existsSync;
|
|
153923
154068
|
const seen = /* @__PURE__ */ new Set();
|
|
153924
154069
|
const candidates = options2.candidatePaths ?? [];
|
|
@@ -153929,25 +154074,25 @@ function resolveDocyrusPiLoaderEntryPath(options2 = {}) {
|
|
|
153929
154074
|
}
|
|
153930
154075
|
};
|
|
153931
154076
|
const collectAncestorCandidates = (startDir) => {
|
|
153932
|
-
let currentDir = (0,
|
|
154077
|
+
let currentDir = (0, import_node_path29.resolve)(startDir);
|
|
153933
154078
|
while (true) {
|
|
153934
|
-
addCandidate((0,
|
|
153935
|
-
addCandidate((0,
|
|
153936
|
-
if ((0,
|
|
153937
|
-
addCandidate((0,
|
|
154079
|
+
addCandidate((0, import_node_path29.join)(currentDir, "dist", "apps", "api-cli", "agent-loader.js"));
|
|
154080
|
+
addCandidate((0, import_node_path29.join)(currentDir, "agent-loader.js"));
|
|
154081
|
+
if ((0, import_node_path29.basename)(currentDir) === "dist") {
|
|
154082
|
+
addCandidate((0, import_node_path29.join)(currentDir, "apps", "api-cli", "agent-loader.js"));
|
|
153938
154083
|
}
|
|
153939
|
-
const parentDir = (0,
|
|
154084
|
+
const parentDir = (0, import_node_path29.resolve)(currentDir, "..");
|
|
153940
154085
|
if (parentDir === currentDir) {
|
|
153941
154086
|
break;
|
|
153942
154087
|
}
|
|
153943
154088
|
currentDir = parentDir;
|
|
153944
154089
|
}
|
|
153945
154090
|
};
|
|
153946
|
-
addCandidate((0,
|
|
153947
|
-
addCandidate((0,
|
|
153948
|
-
addCandidate((0,
|
|
154091
|
+
addCandidate((0, import_node_path29.resolve)(cwd, "dist/apps/api-cli/agent-loader.js"));
|
|
154092
|
+
addCandidate((0, import_node_path29.resolve)(dirname14, "../agent-loader.js"));
|
|
154093
|
+
addCandidate((0, import_node_path29.resolve)(dirname14, "agent-loader.js"));
|
|
153949
154094
|
collectAncestorCandidates(cwd);
|
|
153950
|
-
collectAncestorCandidates(
|
|
154095
|
+
collectAncestorCandidates(dirname14);
|
|
153951
154096
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
153952
154097
|
if (!resolved) {
|
|
153953
154098
|
throw new UserInputError(`Unable to locate Docyrus pi loader entry file. Checked: ${candidates.join(", ")}`);
|
|
@@ -153956,7 +154101,7 @@ function resolveDocyrusPiLoaderEntryPath(options2 = {}) {
|
|
|
153956
154101
|
}
|
|
153957
154102
|
function resolveDocyrusCliEntryPath(options2 = {}) {
|
|
153958
154103
|
const cwd = options2.cwd ?? process.cwd();
|
|
153959
|
-
const
|
|
154104
|
+
const dirname14 = options2.dirname ?? __dirname;
|
|
153960
154105
|
const argv = options2.argv ?? process.argv;
|
|
153961
154106
|
const fileExists = options2.existsSyncFn ?? import_node_fs17.existsSync;
|
|
153962
154107
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -153965,20 +154110,20 @@ function resolveDocyrusCliEntryPath(options2 = {}) {
|
|
|
153965
154110
|
if (!candidate) {
|
|
153966
154111
|
return;
|
|
153967
154112
|
}
|
|
153968
|
-
const resolvedCandidate = (0,
|
|
154113
|
+
const resolvedCandidate = (0, import_node_path29.resolve)(candidate);
|
|
153969
154114
|
if (!seen.has(resolvedCandidate)) {
|
|
153970
154115
|
seen.add(resolvedCandidate);
|
|
153971
154116
|
candidates.push(resolvedCandidate);
|
|
153972
154117
|
}
|
|
153973
154118
|
};
|
|
153974
154119
|
const argvScript = argv[1]?.trim();
|
|
153975
|
-
const normalizedArgvScript = argvScript ? argvScript.startsWith("/") ? argvScript : (0,
|
|
154120
|
+
const normalizedArgvScript = argvScript ? argvScript.startsWith("/") ? argvScript : (0, import_node_path29.resolve)(cwd, argvScript) : void 0;
|
|
153976
154121
|
if (normalizedArgvScript && normalizedArgvScript.endsWith(".js")) {
|
|
153977
154122
|
addCandidate(normalizedArgvScript);
|
|
153978
154123
|
}
|
|
153979
|
-
addCandidate((0,
|
|
153980
|
-
addCandidate((0,
|
|
153981
|
-
addCandidate((0,
|
|
154124
|
+
addCandidate((0, import_node_path29.resolve)(cwd, "dist/apps/api-cli/main.js"));
|
|
154125
|
+
addCandidate((0, import_node_path29.resolve)(dirname14, "../main.js"));
|
|
154126
|
+
addCandidate((0, import_node_path29.resolve)(dirname14, "main.js"));
|
|
153982
154127
|
if (normalizedArgvScript) {
|
|
153983
154128
|
addCandidate(normalizedArgvScript);
|
|
153984
154129
|
}
|
|
@@ -153990,7 +154135,7 @@ function resolveDocyrusCliEntryPath(options2 = {}) {
|
|
|
153990
154135
|
}
|
|
153991
154136
|
function resolveInstalledPiPackageRootPath(options2 = {}) {
|
|
153992
154137
|
const cwd = options2.cwd ?? process.cwd();
|
|
153993
|
-
const
|
|
154138
|
+
const dirname14 = options2.dirname ?? __dirname;
|
|
153994
154139
|
const fileExists = options2.existsSyncFn ?? import_node_fs17.existsSync;
|
|
153995
154140
|
const seen = /* @__PURE__ */ new Set();
|
|
153996
154141
|
const candidates = options2.candidatePaths ?? [];
|
|
@@ -154001,32 +154146,32 @@ function resolveInstalledPiPackageRootPath(options2 = {}) {
|
|
|
154001
154146
|
}
|
|
154002
154147
|
};
|
|
154003
154148
|
const collectAncestorCandidates = (startDir) => {
|
|
154004
|
-
let currentDir = (0,
|
|
154149
|
+
let currentDir = (0, import_node_path29.resolve)(startDir);
|
|
154005
154150
|
while (true) {
|
|
154006
|
-
addCandidate((0,
|
|
154007
|
-
if ((0,
|
|
154008
|
-
addCandidate((0,
|
|
154151
|
+
addCandidate((0, import_node_path29.join)(currentDir, "node_modules", "@mariozechner", "pi-coding-agent", "package.json"));
|
|
154152
|
+
if ((0, import_node_path29.basename)(currentDir) === "node_modules") {
|
|
154153
|
+
addCandidate((0, import_node_path29.join)(currentDir, "@mariozechner", "pi-coding-agent", "package.json"));
|
|
154009
154154
|
}
|
|
154010
|
-
const parentDir = (0,
|
|
154155
|
+
const parentDir = (0, import_node_path29.resolve)(currentDir, "..");
|
|
154011
154156
|
if (parentDir === currentDir) {
|
|
154012
154157
|
break;
|
|
154013
154158
|
}
|
|
154014
154159
|
currentDir = parentDir;
|
|
154015
154160
|
}
|
|
154016
154161
|
};
|
|
154017
|
-
addCandidate((0,
|
|
154018
|
-
addCandidate((0,
|
|
154162
|
+
addCandidate((0, import_node_path29.resolve)(cwd, "apps/api-cli/node_modules/@mariozechner/pi-coding-agent/package.json"));
|
|
154163
|
+
addCandidate((0, import_node_path29.resolve)(dirname14, "../../../apps/api-cli/node_modules/@mariozechner/pi-coding-agent/package.json"));
|
|
154019
154164
|
collectAncestorCandidates(cwd);
|
|
154020
|
-
collectAncestorCandidates(
|
|
154165
|
+
collectAncestorCandidates(dirname14);
|
|
154021
154166
|
const resolvedPackageJson = candidates.find((candidate) => fileExists(candidate));
|
|
154022
154167
|
if (!resolvedPackageJson) {
|
|
154023
154168
|
throw new UserInputError(`Unable to locate the installed pi package root. Checked: ${candidates.join(", ")}`);
|
|
154024
154169
|
}
|
|
154025
|
-
return (0,
|
|
154170
|
+
return (0, import_node_path29.resolve)(resolvedPackageJson, "..");
|
|
154026
154171
|
}
|
|
154027
154172
|
function createPiAgentRuntimeSkill(params) {
|
|
154028
154173
|
const commandPrefix = params.scope === "global" ? "docyrus -g" : "docyrus";
|
|
154029
|
-
const knowledgeDir = (0,
|
|
154174
|
+
const knowledgeDir = (0, import_node_path29.join)(params.cwd, "docyrus", "knowledge");
|
|
154030
154175
|
const hasKnowledgeGraph = (0, import_node_fs17.existsSync)(knowledgeDir);
|
|
154031
154176
|
const authLines = params.activeProfile ? [
|
|
154032
154177
|
`- email: \`${params.activeProfile.email}\``,
|
|
@@ -154080,35 +154225,35 @@ function createPiAgentRuntimeSkill(params) {
|
|
|
154080
154225
|
].join("\n");
|
|
154081
154226
|
}
|
|
154082
154227
|
async function syncPackagedSkills(params) {
|
|
154083
|
-
const sourceSkillsRoot = (0,
|
|
154084
|
-
const targetSkillsRoot = (0,
|
|
154085
|
-
await (0,
|
|
154228
|
+
const sourceSkillsRoot = (0, import_node_path29.join)(params.resourceRoot, "skills");
|
|
154229
|
+
const targetSkillsRoot = (0, import_node_path29.join)(params.agentRootPath, "skills");
|
|
154230
|
+
await (0, import_promises23.mkdir)(targetSkillsRoot, {
|
|
154086
154231
|
recursive: true,
|
|
154087
154232
|
mode: 448
|
|
154088
154233
|
});
|
|
154089
|
-
const entries = await (0,
|
|
154234
|
+
const entries = await (0, import_promises23.readdir)(sourceSkillsRoot, {
|
|
154090
154235
|
withFileTypes: true
|
|
154091
154236
|
});
|
|
154092
154237
|
await Promise.all(DOCYRUS_MIGRATED_SKILL_NAMES.map(async (skillName) => {
|
|
154093
|
-
await (0,
|
|
154238
|
+
await (0, import_promises23.rm)((0, import_node_path29.join)(targetSkillsRoot, skillName), {
|
|
154094
154239
|
recursive: true,
|
|
154095
154240
|
force: true
|
|
154096
154241
|
});
|
|
154097
154242
|
}));
|
|
154098
154243
|
await Promise.all(entries.map(async (entry) => {
|
|
154099
|
-
await (0,
|
|
154244
|
+
await (0, import_promises23.cp)((0, import_node_path29.join)(sourceSkillsRoot, entry.name), (0, import_node_path29.join)(targetSkillsRoot, entry.name), {
|
|
154100
154245
|
recursive: true,
|
|
154101
154246
|
force: true
|
|
154102
154247
|
});
|
|
154103
154248
|
}));
|
|
154104
154249
|
}
|
|
154105
154250
|
async function writeRuntimeSkill(params) {
|
|
154106
|
-
const runtimeSkillDir = (0,
|
|
154107
|
-
await (0,
|
|
154251
|
+
const runtimeSkillDir = (0, import_node_path29.join)(params.agentRootPath, "skills", "docyrus-runtime-context");
|
|
154252
|
+
await (0, import_promises23.mkdir)(runtimeSkillDir, {
|
|
154108
154253
|
recursive: true,
|
|
154109
154254
|
mode: 448
|
|
154110
154255
|
});
|
|
154111
|
-
await (0,
|
|
154256
|
+
await (0, import_promises23.writeFile)((0, import_node_path29.join)(runtimeSkillDir, "SKILL.md"), `${params.content}
|
|
154112
154257
|
`, {
|
|
154113
154258
|
encoding: "utf8",
|
|
154114
154259
|
mode: 384
|
|
@@ -154121,10 +154266,10 @@ function resolveNpmCommand() {
|
|
|
154121
154266
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
154122
154267
|
}
|
|
154123
154268
|
function resolveManagedDiffityInstallRoot(agentRootPath) {
|
|
154124
|
-
return (0,
|
|
154269
|
+
return (0, import_node_path29.join)(agentRootPath, "tools", "diffity");
|
|
154125
154270
|
}
|
|
154126
154271
|
function resolveManagedDiffityExecutablePath(agentRootPath) {
|
|
154127
|
-
return (0,
|
|
154272
|
+
return (0, import_node_path29.join)(
|
|
154128
154273
|
resolveManagedDiffityInstallRoot(agentRootPath),
|
|
154129
154274
|
"node_modules",
|
|
154130
154275
|
".bin",
|
|
@@ -154132,10 +154277,10 @@ function resolveManagedDiffityExecutablePath(agentRootPath) {
|
|
|
154132
154277
|
);
|
|
154133
154278
|
}
|
|
154134
154279
|
function prependPathEntry(entry, existingPath) {
|
|
154135
|
-
const values = existingPath ? existingPath.split(
|
|
154280
|
+
const values = existingPath ? existingPath.split(import_node_path29.delimiter).filter((value2) => value2.trim().length > 0) : [];
|
|
154136
154281
|
const normalizedEntry = entry.trim();
|
|
154137
154282
|
const remaining = values.filter((value2) => value2 !== normalizedEntry);
|
|
154138
|
-
return [normalizedEntry, ...remaining].join(
|
|
154283
|
+
return [normalizedEntry, ...remaining].join(import_node_path29.delimiter);
|
|
154139
154284
|
}
|
|
154140
154285
|
function createDocyrusSkillsInstallArgs(scope) {
|
|
154141
154286
|
const args2 = [
|
|
@@ -154173,7 +154318,7 @@ function createPackagedDocyrusPlatformInstallArgs(params) {
|
|
|
154173
154318
|
return args2;
|
|
154174
154319
|
}
|
|
154175
154320
|
async function installExternalDocyrusSkillsOnce(params) {
|
|
154176
|
-
const markerPath = (0,
|
|
154321
|
+
const markerPath = (0, import_node_path29.join)(params.agentRootPath, DOCYRUS_EXTERNAL_SKILL_MARKER_FILE);
|
|
154177
154322
|
if ((0, import_node_fs17.existsSync)(markerPath)) {
|
|
154178
154323
|
return;
|
|
154179
154324
|
}
|
|
@@ -154192,7 +154337,7 @@ async function installExternalDocyrusSkillsOnce(params) {
|
|
|
154192
154337
|
);
|
|
154193
154338
|
return;
|
|
154194
154339
|
}
|
|
154195
|
-
await (0,
|
|
154340
|
+
await (0, import_promises23.writeFile)(markerPath, `${JSON.stringify({
|
|
154196
154341
|
source: DOCYRUS_EXTERNAL_SKILL_SOURCE,
|
|
154197
154342
|
skills: DOCYRUS_MIGRATED_SKILL_NAMES,
|
|
154198
154343
|
agents: DOCYRUS_EXTERNAL_SKILL_AGENT_IDS,
|
|
@@ -154206,7 +154351,7 @@ async function installExternalDocyrusSkillsOnce(params) {
|
|
|
154206
154351
|
}
|
|
154207
154352
|
async function ensureManagedDiffityInstalled(params) {
|
|
154208
154353
|
const executablePath = resolveManagedDiffityExecutablePath(params.agentRootPath);
|
|
154209
|
-
const binDir = (0,
|
|
154354
|
+
const binDir = (0, import_node_path29.dirname)(executablePath);
|
|
154210
154355
|
if ((0, import_node_fs17.existsSync)(executablePath)) {
|
|
154211
154356
|
return {
|
|
154212
154357
|
available: true,
|
|
@@ -154245,19 +154390,19 @@ async function ensureManagedDiffityInstalled(params) {
|
|
|
154245
154390
|
};
|
|
154246
154391
|
}
|
|
154247
154392
|
function resolvePackagedDocyrusPlatformSkillPath(resourceRoot) {
|
|
154248
|
-
return (0,
|
|
154393
|
+
return (0, import_node_path29.join)(resourceRoot, "skills", DOCYRUS_PACKAGED_PLATFORM_SKILL_NAME);
|
|
154249
154394
|
}
|
|
154250
154395
|
function resolvePackagedOfficeCliRootPath(resourceRoot) {
|
|
154251
|
-
return (0,
|
|
154396
|
+
return (0, import_node_path29.join)((0, import_node_path29.resolve)(resourceRoot, ".."), "officecli");
|
|
154252
154397
|
}
|
|
154253
154398
|
function resolvePackagedOfficeCliManifestPath(resourceRoot) {
|
|
154254
|
-
return (0,
|
|
154399
|
+
return (0, import_node_path29.join)(resolvePackagedOfficeCliRootPath(resourceRoot), DOCYRUS_OFFICECLI_MANIFEST_FILE_NAME);
|
|
154255
154400
|
}
|
|
154256
154401
|
function resolveManagedOfficeCliInstallRoot(agentRootPath) {
|
|
154257
|
-
return (0,
|
|
154402
|
+
return (0, import_node_path29.join)(agentRootPath, "tools", "officecli");
|
|
154258
154403
|
}
|
|
154259
154404
|
function resolveManagedOfficeCliExecutablePath(agentRootPath) {
|
|
154260
|
-
return (0,
|
|
154405
|
+
return (0, import_node_path29.join)(
|
|
154261
154406
|
resolveManagedOfficeCliInstallRoot(agentRootPath),
|
|
154262
154407
|
process.platform === "win32" ? "officecli.exe" : "officecli"
|
|
154263
154408
|
);
|
|
@@ -154299,14 +154444,14 @@ function resolveOfficeCliReleaseAssetName(options2 = {}) {
|
|
|
154299
154444
|
throw new UserInputError(`OfficeCLI is not supported on ${platform2}/${arch}.`);
|
|
154300
154445
|
}
|
|
154301
154446
|
function resolvePackagedOfficeCliExecutablePath(resourceRoot, options2) {
|
|
154302
|
-
return (0,
|
|
154447
|
+
return (0, import_node_path29.join)(
|
|
154303
154448
|
resolvePackagedOfficeCliRootPath(resourceRoot),
|
|
154304
154449
|
"bundled",
|
|
154305
154450
|
resolveOfficeCliReleaseAssetName(options2)
|
|
154306
154451
|
);
|
|
154307
154452
|
}
|
|
154308
154453
|
async function readPackagedOfficeCliVersion(resourceRoot) {
|
|
154309
|
-
const manifestRaw = await (0,
|
|
154454
|
+
const manifestRaw = await (0, import_promises23.readFile)(resolvePackagedOfficeCliManifestPath(resourceRoot), "utf8");
|
|
154310
154455
|
const manifest = JSON.parse(manifestRaw);
|
|
154311
154456
|
const version2 = typeof manifest.version === "string" ? manifest.version.trim() : "";
|
|
154312
154457
|
if (version2.length === 0) {
|
|
@@ -154322,12 +154467,12 @@ async function downloadOfficeCliBinary(params) {
|
|
|
154322
154467
|
throw new UserInputError(`OfficeCLI download failed with status ${response.status}.`);
|
|
154323
154468
|
}
|
|
154324
154469
|
const binary2 = Buffer.from(await response.arrayBuffer());
|
|
154325
|
-
await (0,
|
|
154470
|
+
await (0, import_promises23.writeFile)(params.destinationPath, binary2, {
|
|
154326
154471
|
mode: process.platform === "win32" ? 384 : 448
|
|
154327
154472
|
});
|
|
154328
154473
|
}
|
|
154329
154474
|
function resolveManagedOfficeCliConfigMarkerPath(agentRootPath) {
|
|
154330
|
-
return (0,
|
|
154475
|
+
return (0, import_node_path29.join)(resolveManagedOfficeCliInstallRoot(agentRootPath), ".docyrus-officecli-configured.json");
|
|
154331
154476
|
}
|
|
154332
154477
|
async function disableManagedOfficeCliAutoUpdate(params) {
|
|
154333
154478
|
const markerPath = resolveManagedOfficeCliConfigMarkerPath(params.agentRootPath);
|
|
@@ -154350,7 +154495,7 @@ async function disableManagedOfficeCliAutoUpdate(params) {
|
|
|
154350
154495
|
);
|
|
154351
154496
|
return;
|
|
154352
154497
|
}
|
|
154353
|
-
await (0,
|
|
154498
|
+
await (0, import_promises23.writeFile)(markerPath, `${JSON.stringify({
|
|
154354
154499
|
configuredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
154355
154500
|
}, null, 2)}
|
|
154356
154501
|
`, {
|
|
@@ -154360,7 +154505,7 @@ async function disableManagedOfficeCliAutoUpdate(params) {
|
|
|
154360
154505
|
}
|
|
154361
154506
|
async function ensureManagedOfficeCliInstalled(params) {
|
|
154362
154507
|
const executablePath = resolveManagedOfficeCliExecutablePath(params.agentRootPath);
|
|
154363
|
-
const binDir = (0,
|
|
154508
|
+
const binDir = (0, import_node_path29.dirname)(executablePath);
|
|
154364
154509
|
if ((0, import_node_fs17.existsSync)(executablePath)) {
|
|
154365
154510
|
await disableManagedOfficeCliAutoUpdate({
|
|
154366
154511
|
agentRootPath: params.agentRootPath,
|
|
@@ -154376,13 +154521,13 @@ async function ensureManagedOfficeCliInstalled(params) {
|
|
|
154376
154521
|
}
|
|
154377
154522
|
const tempPath = `${executablePath}.download${process.platform === "win32" ? ".exe" : ""}`;
|
|
154378
154523
|
try {
|
|
154379
|
-
await (0,
|
|
154524
|
+
await (0, import_promises23.mkdir)(binDir, {
|
|
154380
154525
|
recursive: true,
|
|
154381
154526
|
mode: 448
|
|
154382
154527
|
});
|
|
154383
154528
|
const bundledExecutablePath = resolvePackagedOfficeCliExecutablePath(params.resourceRoot);
|
|
154384
154529
|
if ((0, import_node_fs17.existsSync)(bundledExecutablePath)) {
|
|
154385
|
-
await (0,
|
|
154530
|
+
await (0, import_promises23.cp)(bundledExecutablePath, tempPath, {
|
|
154386
154531
|
force: true
|
|
154387
154532
|
});
|
|
154388
154533
|
} else {
|
|
@@ -154392,7 +154537,7 @@ async function ensureManagedOfficeCliInstalled(params) {
|
|
|
154392
154537
|
});
|
|
154393
154538
|
}
|
|
154394
154539
|
if (process.platform !== "win32") {
|
|
154395
|
-
await (0,
|
|
154540
|
+
await (0, import_promises23.chmod)(tempPath, 448);
|
|
154396
154541
|
}
|
|
154397
154542
|
const verificationResult = params.spawnCommand(tempPath, ["--version"], {
|
|
154398
154543
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -154408,9 +154553,9 @@ async function ensureManagedOfficeCliInstalled(params) {
|
|
|
154408
154553
|
verificationResult.error?.message || summarizeFailure3(verificationResult, "officecli --version")
|
|
154409
154554
|
);
|
|
154410
154555
|
}
|
|
154411
|
-
await (0,
|
|
154556
|
+
await (0, import_promises23.rename)(tempPath, executablePath);
|
|
154412
154557
|
if (process.platform !== "win32") {
|
|
154413
|
-
await (0,
|
|
154558
|
+
await (0, import_promises23.chmod)(executablePath, 448);
|
|
154414
154559
|
}
|
|
154415
154560
|
await disableManagedOfficeCliAutoUpdate({
|
|
154416
154561
|
agentRootPath: params.agentRootPath,
|
|
@@ -154424,7 +154569,7 @@ async function ensureManagedOfficeCliInstalled(params) {
|
|
|
154424
154569
|
binDir
|
|
154425
154570
|
};
|
|
154426
154571
|
} catch (error48) {
|
|
154427
|
-
await (0,
|
|
154572
|
+
await (0, import_promises23.rm)(tempPath, {
|
|
154428
154573
|
force: true
|
|
154429
154574
|
});
|
|
154430
154575
|
process.stderr.write(
|
|
@@ -154543,6 +154688,13 @@ function createPiAgentLauncher(options2) {
|
|
|
154543
154688
|
cwd,
|
|
154544
154689
|
spawnCommand
|
|
154545
154690
|
});
|
|
154691
|
+
const soulId = request.soul?.trim() || await options2.environmentConfigService.getActiveSoulId();
|
|
154692
|
+
const systemPromptPath = await composeSystemPrompt({
|
|
154693
|
+
profile: request.profile,
|
|
154694
|
+
soulId,
|
|
154695
|
+
resourceRoot,
|
|
154696
|
+
agentRootPath
|
|
154697
|
+
});
|
|
154546
154698
|
spinner.stop();
|
|
154547
154699
|
const loaderEntryPath = resolveLoaderPath({ cwd });
|
|
154548
154700
|
const cliEntryPath = resolveCliEntryPath({ cwd });
|
|
@@ -154558,6 +154710,8 @@ function createPiAgentLauncher(options2) {
|
|
|
154558
154710
|
PI_PACKAGE_DIR: piPackageRoot,
|
|
154559
154711
|
DOCYRUS_PI_REQUEST: JSON.stringify(request),
|
|
154560
154712
|
DOCYRUS_PI_VERSION: options2.version || "dev",
|
|
154713
|
+
DOCYRUS_PI_SYSTEM_PROMPT_PATH: systemPromptPath,
|
|
154714
|
+
DOCYRUS_PI_SOUL_ID: soulId,
|
|
154561
154715
|
DOCYRUS_CLI_EXECUTABLE: processExecPath,
|
|
154562
154716
|
DOCYRUS_CLI_ENTRY: cliEntryPath,
|
|
154563
154717
|
DOCYRUS_CLI_SCOPE: options2.settingsPaths.scope,
|
|
@@ -154579,11 +154733,11 @@ function createPiAgentLauncher(options2) {
|
|
|
154579
154733
|
// src/services/piAgentServerLauncher.ts
|
|
154580
154734
|
var import_node_child_process9 = require("node:child_process");
|
|
154581
154735
|
var import_node_fs18 = require("node:fs");
|
|
154582
|
-
var
|
|
154736
|
+
var import_node_path30 = require("node:path");
|
|
154583
154737
|
function serializePiAgentServerRequest(request) {
|
|
154584
154738
|
return JSON.stringify(request);
|
|
154585
154739
|
}
|
|
154586
|
-
function resolveServerLoaderEntryPath(cwd,
|
|
154740
|
+
function resolveServerLoaderEntryPath(cwd, dirname14) {
|
|
154587
154741
|
const seen = /* @__PURE__ */ new Set();
|
|
154588
154742
|
const candidates = [];
|
|
154589
154743
|
const addCandidate = (candidate) => {
|
|
@@ -154593,25 +154747,25 @@ function resolveServerLoaderEntryPath(cwd, dirname13) {
|
|
|
154593
154747
|
}
|
|
154594
154748
|
};
|
|
154595
154749
|
const collectAncestorCandidates = (startDir) => {
|
|
154596
|
-
let currentDir = (0,
|
|
154750
|
+
let currentDir = (0, import_node_path30.resolve)(startDir);
|
|
154597
154751
|
while (true) {
|
|
154598
|
-
addCandidate((0,
|
|
154599
|
-
addCandidate((0,
|
|
154600
|
-
if ((0,
|
|
154601
|
-
addCandidate((0,
|
|
154752
|
+
addCandidate((0, import_node_path30.join)(currentDir, "dist", "apps", "api-cli", "server-loader.js"));
|
|
154753
|
+
addCandidate((0, import_node_path30.join)(currentDir, "server-loader.js"));
|
|
154754
|
+
if ((0, import_node_path30.basename)(currentDir) === "dist") {
|
|
154755
|
+
addCandidate((0, import_node_path30.join)(currentDir, "apps", "api-cli", "server-loader.js"));
|
|
154602
154756
|
}
|
|
154603
|
-
const parentDir = (0,
|
|
154757
|
+
const parentDir = (0, import_node_path30.resolve)(currentDir, "..");
|
|
154604
154758
|
if (parentDir === currentDir) {
|
|
154605
154759
|
break;
|
|
154606
154760
|
}
|
|
154607
154761
|
currentDir = parentDir;
|
|
154608
154762
|
}
|
|
154609
154763
|
};
|
|
154610
|
-
addCandidate((0,
|
|
154611
|
-
addCandidate((0,
|
|
154612
|
-
addCandidate((0,
|
|
154764
|
+
addCandidate((0, import_node_path30.resolve)(cwd, "dist/apps/api-cli/server-loader.js"));
|
|
154765
|
+
addCandidate((0, import_node_path30.resolve)(dirname14, "../server-loader.js"));
|
|
154766
|
+
addCandidate((0, import_node_path30.resolve)(dirname14, "server-loader.js"));
|
|
154613
154767
|
collectAncestorCandidates(cwd);
|
|
154614
|
-
collectAncestorCandidates(
|
|
154768
|
+
collectAncestorCandidates(dirname14);
|
|
154615
154769
|
const resolved = candidates.find((candidate) => (0, import_node_fs18.existsSync)(candidate));
|
|
154616
154770
|
if (!resolved) {
|
|
154617
154771
|
throw new UserInputError(`Unable to locate Docyrus pi server loader entry file. Checked: ${candidates.join(", ")}`);
|
|
@@ -154665,13 +154819,20 @@ function createPiAgentServerLauncher(options2) {
|
|
|
154665
154819
|
if (request.sandbox) {
|
|
154666
154820
|
const browserConfigDir = settingsRootPath;
|
|
154667
154821
|
(0, import_node_fs18.mkdirSync)(browserConfigDir, { recursive: true, mode: 448 });
|
|
154668
|
-
const browserConfigPath = (0,
|
|
154822
|
+
const browserConfigPath = (0, import_node_path30.join)(browserConfigDir, "browser.json");
|
|
154669
154823
|
const appId = process.env.DOCYRUS_SANDBOX_APP_ID || "";
|
|
154670
154824
|
(0, import_node_fs18.writeFileSync)(browserConfigPath, JSON.stringify({ mode: "sandbox", appId }, null, 2) + "\n", {
|
|
154671
154825
|
encoding: "utf8",
|
|
154672
154826
|
mode: 384
|
|
154673
154827
|
});
|
|
154674
154828
|
}
|
|
154829
|
+
const soulId = request.soul?.trim() || await options2.environmentConfigService.getActiveSoulId();
|
|
154830
|
+
const systemPromptPath = await composeSystemPrompt({
|
|
154831
|
+
profile: request.profile,
|
|
154832
|
+
soulId,
|
|
154833
|
+
resourceRoot,
|
|
154834
|
+
agentRootPath
|
|
154835
|
+
});
|
|
154675
154836
|
spinner.stop();
|
|
154676
154837
|
const loaderEntryPath = resolveServerLoaderEntryPath(cwd, __dirname);
|
|
154677
154838
|
const piPackageRoot = resolveInstalledPiPackageRootPath({ cwd });
|
|
@@ -154687,6 +154848,8 @@ function createPiAgentServerLauncher(options2) {
|
|
|
154687
154848
|
PI_PACKAGE_DIR: piPackageRoot,
|
|
154688
154849
|
DOCYRUS_PI_REQUEST: serializePiAgentServerRequest(request),
|
|
154689
154850
|
DOCYRUS_PI_VERSION: options2.version || "dev",
|
|
154851
|
+
DOCYRUS_PI_SYSTEM_PROMPT_PATH: systemPromptPath,
|
|
154852
|
+
DOCYRUS_PI_SOUL_ID: soulId,
|
|
154690
154853
|
DOCYRUS_CLI_EXECUTABLE: process.execPath,
|
|
154691
154854
|
DOCYRUS_CLI_ENTRY: cliEntryPath,
|
|
154692
154855
|
DOCYRUS_CLI_SCOPE: options2.settingsPaths.scope,
|
|
@@ -154741,8 +154904,8 @@ async function runWithIncurSkillsOutOfDateWarningSuppressed(params) {
|
|
|
154741
154904
|
}
|
|
154742
154905
|
|
|
154743
154906
|
// src/services/tenantOpenApi.ts
|
|
154744
|
-
var
|
|
154745
|
-
var
|
|
154907
|
+
var import_promises24 = require("node:fs/promises");
|
|
154908
|
+
var import_node_path31 = require("node:path");
|
|
154746
154909
|
function resolveSourceUrl(tenantId, template) {
|
|
154747
154910
|
return template.replace("{tenantId}", encodeURIComponent(tenantId));
|
|
154748
154911
|
}
|
|
@@ -154767,16 +154930,16 @@ var TenantOpenApiService = class {
|
|
|
154767
154930
|
params;
|
|
154768
154931
|
async #writeOpenApiFile(tenantId, parsedContent) {
|
|
154769
154932
|
const filePath = this.getTenantOpenApiFilePath(tenantId);
|
|
154770
|
-
await (0,
|
|
154933
|
+
await (0, import_promises24.mkdir)((0, import_node_path31.dirname)(filePath), {
|
|
154771
154934
|
recursive: true,
|
|
154772
154935
|
mode: 448
|
|
154773
154936
|
});
|
|
154774
|
-
await (0,
|
|
154937
|
+
await (0, import_promises24.writeFile)(filePath, `${JSON.stringify(parsedContent, null, 2)}
|
|
154775
154938
|
`, {
|
|
154776
154939
|
encoding: "utf8",
|
|
154777
154940
|
mode: 384
|
|
154778
154941
|
});
|
|
154779
|
-
await (0,
|
|
154942
|
+
await (0, import_promises24.chmod)(filePath, 384);
|
|
154780
154943
|
return filePath;
|
|
154781
154944
|
}
|
|
154782
154945
|
async #generateTenantOpenApiViaAuthenticatedEndpoint(tenantId, options2) {
|
|
@@ -154813,7 +154976,7 @@ var TenantOpenApiService = class {
|
|
|
154813
154976
|
throw new AuthSessionError("Tenant ID is required to resolve OpenAPI spec path.");
|
|
154814
154977
|
}
|
|
154815
154978
|
const rootPath = this.params?.rootPath || TENANT_OPENAPI_ROOT_PATH;
|
|
154816
|
-
return (0,
|
|
154979
|
+
return (0, import_node_path31.join)(rootPath, normalizedTenantId, "openapi.json");
|
|
154817
154980
|
}
|
|
154818
154981
|
async downloadTenantOpenApi(tenantId, options2 = {}) {
|
|
154819
154982
|
const normalizedTenantId = tenantId.trim();
|