@docyrus/docyrus 0.0.26 → 0.0.28
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 +7 -0
- package/agent-loader.js +33 -3
- package/agent-loader.js.map +4 -4
- package/main.js +443 -108
- package/main.js.map +4 -4
- package/package.json +1 -1
- package/resources/pi-agent/skills/docyrus-platform/SKILL.md +1 -1
- package/resources/pi-agent/skills/docyrus-platform/references/developer-tools.md +1 -1
- package/resources/pi-agent/skills/docyrus-platform/references/docyrus-cli-usage.md +46 -0
- package/resources/pi-agent/skills/docyrus-platform/references/querying-and-data-operations.md +7 -0
- package/server-loader.js +234 -5
- package/server-loader.js.map +4 -4
package/main.js
CHANGED
|
@@ -80769,7 +80769,7 @@ var require_formdata = __commonJS({
|
|
|
80769
80769
|
var { kEnumerableProperty } = require_util3();
|
|
80770
80770
|
var { webidl } = require_webidl();
|
|
80771
80771
|
var nodeUtil = require("node:util");
|
|
80772
|
-
var
|
|
80772
|
+
var FormData2 = class _FormData {
|
|
80773
80773
|
#state = [];
|
|
80774
80774
|
constructor(form = void 0) {
|
|
80775
80775
|
webidl.util.markAsUncloneable(this);
|
|
@@ -80886,11 +80886,11 @@ var require_formdata = __commonJS({
|
|
|
80886
80886
|
formData.#state = newState;
|
|
80887
80887
|
}
|
|
80888
80888
|
};
|
|
80889
|
-
var { getFormDataState, setFormDataState } =
|
|
80890
|
-
Reflect.deleteProperty(
|
|
80891
|
-
Reflect.deleteProperty(
|
|
80892
|
-
iteratorMixin("FormData",
|
|
80893
|
-
Object.defineProperties(
|
|
80889
|
+
var { getFormDataState, setFormDataState } = FormData2;
|
|
80890
|
+
Reflect.deleteProperty(FormData2, "getFormDataState");
|
|
80891
|
+
Reflect.deleteProperty(FormData2, "setFormDataState");
|
|
80892
|
+
iteratorMixin("FormData", FormData2, getFormDataState, "name", "value");
|
|
80893
|
+
Object.defineProperties(FormData2.prototype, {
|
|
80894
80894
|
append: kEnumerableProperty,
|
|
80895
80895
|
delete: kEnumerableProperty,
|
|
80896
80896
|
get: kEnumerableProperty,
|
|
@@ -80918,8 +80918,8 @@ var require_formdata = __commonJS({
|
|
|
80918
80918
|
}
|
|
80919
80919
|
return { name, value };
|
|
80920
80920
|
}
|
|
80921
|
-
webidl.is.FormData = webidl.util.MakeTypeAssertion(
|
|
80922
|
-
module2.exports = { FormData, makeEntry, setFormDataState };
|
|
80921
|
+
webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData2);
|
|
80922
|
+
module2.exports = { FormData: FormData2, makeEntry, setFormDataState };
|
|
80923
80923
|
}
|
|
80924
80924
|
});
|
|
80925
80925
|
|
|
@@ -81277,7 +81277,7 @@ var require_body = __commonJS({
|
|
|
81277
81277
|
fullyReadBody,
|
|
81278
81278
|
extractMimeType
|
|
81279
81279
|
} = require_util4();
|
|
81280
|
-
var { FormData, setFormDataState } = require_formdata();
|
|
81280
|
+
var { FormData: FormData2, setFormDataState } = require_formdata();
|
|
81281
81281
|
var { webidl } = require_webidl();
|
|
81282
81282
|
var assert2 = require("node:assert");
|
|
81283
81283
|
var { isErrored, isDisturbed } = require("node:stream");
|
|
@@ -81470,13 +81470,13 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
81470
81470
|
switch (mimeType.essence) {
|
|
81471
81471
|
case "multipart/form-data": {
|
|
81472
81472
|
const parsed = multipartFormDataParser(value, mimeType);
|
|
81473
|
-
const fd = new
|
|
81473
|
+
const fd = new FormData2();
|
|
81474
81474
|
setFormDataState(fd, parsed);
|
|
81475
81475
|
return fd;
|
|
81476
81476
|
}
|
|
81477
81477
|
case "application/x-www-form-urlencoded": {
|
|
81478
81478
|
const entries = new URLSearchParams(value.toString());
|
|
81479
|
-
const fd = new
|
|
81479
|
+
const fd = new FormData2();
|
|
81480
81480
|
for (const [name, value2] of entries) {
|
|
81481
81481
|
fd.append(name, value2);
|
|
81482
81482
|
}
|
|
@@ -87863,7 +87863,7 @@ var require_snapshot_utils = __commonJS({
|
|
|
87863
87863
|
var require_snapshot_recorder = __commonJS({
|
|
87864
87864
|
"../../node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
|
|
87865
87865
|
"use strict";
|
|
87866
|
-
var { writeFile: writeFile5, readFile:
|
|
87866
|
+
var { writeFile: writeFile5, readFile: readFile7, mkdir: mkdir5 } = require("node:fs/promises");
|
|
87867
87867
|
var { dirname: dirname7, resolve } = require("node:path");
|
|
87868
87868
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require("node:timers");
|
|
87869
87869
|
var { InvalidArgumentError, UndiciError } = require_errors3();
|
|
@@ -88065,7 +88065,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
88065
88065
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
88066
88066
|
}
|
|
88067
88067
|
try {
|
|
88068
|
-
const data = await
|
|
88068
|
+
const data = await readFile7(resolve(path3), "utf8");
|
|
88069
88069
|
const parsed = JSON.parse(data);
|
|
88070
88070
|
if (Array.isArray(parsed)) {
|
|
88071
88071
|
this.#snapshots.clear();
|
|
@@ -98830,6 +98830,79 @@ ${captureLines}` : capture.stack;
|
|
|
98830
98830
|
}
|
|
98831
98831
|
});
|
|
98832
98832
|
|
|
98833
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
98834
|
+
var require_picocolors = __commonJS({
|
|
98835
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
98836
|
+
"use strict";
|
|
98837
|
+
var p = process || {};
|
|
98838
|
+
var argv = p.argv || [];
|
|
98839
|
+
var env2 = p.env || {};
|
|
98840
|
+
var isColorSupported = !(!!env2.NO_COLOR || argv.includes("--no-color")) && (!!env2.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI);
|
|
98841
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
98842
|
+
let string4 = "" + input, index = string4.indexOf(close, open.length);
|
|
98843
|
+
return ~index ? open + replaceClose(string4, close, replace, index) + close : open + string4 + close;
|
|
98844
|
+
};
|
|
98845
|
+
var replaceClose = (string4, close, replace, index) => {
|
|
98846
|
+
let result = "", cursor = 0;
|
|
98847
|
+
do {
|
|
98848
|
+
result += string4.substring(cursor, index) + replace;
|
|
98849
|
+
cursor = index + close.length;
|
|
98850
|
+
index = string4.indexOf(close, cursor);
|
|
98851
|
+
} while (~index);
|
|
98852
|
+
return result + string4.substring(cursor);
|
|
98853
|
+
};
|
|
98854
|
+
var createColors = (enabled = isColorSupported) => {
|
|
98855
|
+
let f = enabled ? formatter : () => String;
|
|
98856
|
+
return {
|
|
98857
|
+
isColorSupported: enabled,
|
|
98858
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
98859
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
98860
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
98861
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
98862
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
98863
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
98864
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
98865
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
98866
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
98867
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
98868
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
98869
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
98870
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
98871
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
98872
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
98873
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
98874
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
98875
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
98876
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
98877
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
98878
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
98879
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
98880
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
98881
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
98882
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
98883
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
98884
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
98885
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
98886
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
98887
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
98888
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
98889
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
98890
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
98891
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
98892
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
98893
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
98894
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
98895
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
98896
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
98897
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
98898
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
98899
|
+
};
|
|
98900
|
+
};
|
|
98901
|
+
module2.exports = createColors();
|
|
98902
|
+
module2.exports.createColors = createColors;
|
|
98903
|
+
}
|
|
98904
|
+
});
|
|
98905
|
+
|
|
98833
98906
|
// src/main.ts
|
|
98834
98907
|
var main_exports = {};
|
|
98835
98908
|
__export(main_exports, {
|
|
@@ -124691,7 +124764,7 @@ function buildInputSchema(args, env2, options2) {
|
|
|
124691
124764
|
// package.json
|
|
124692
124765
|
var package_default = {
|
|
124693
124766
|
name: "@docyrus/docyrus",
|
|
124694
|
-
version: "0.0.
|
|
124767
|
+
version: "0.0.28",
|
|
124695
124768
|
private: false,
|
|
124696
124769
|
description: "Docyrus API CLI",
|
|
124697
124770
|
main: "./main.js",
|
|
@@ -124906,6 +124979,7 @@ function createServerCli(dependencies) {
|
|
|
124906
124979
|
thinking: external_exports.enum(PI_AGENT_THINKING_LEVELS2).optional().describe("Thinking level"),
|
|
124907
124980
|
sessionDir: external_exports.string().optional().describe("Override session storage directory"),
|
|
124908
124981
|
apiKey: external_exports.string().optional().describe("Temporary provider API key override for this run"),
|
|
124982
|
+
auth: external_exports.string().optional().describe("Require this bearer token for all HTTP requests"),
|
|
124909
124983
|
verbose: external_exports.boolean().optional().describe("Enable verbose pi startup output")
|
|
124910
124984
|
}),
|
|
124911
124985
|
run: async (context) => {
|
|
@@ -124917,6 +124991,7 @@ function createServerCli(dependencies) {
|
|
|
124917
124991
|
thinking: context.options.thinking,
|
|
124918
124992
|
sessionDir: context.options.sessionDir,
|
|
124919
124993
|
apiKey: context.options.apiKey,
|
|
124994
|
+
auth: context.options.auth,
|
|
124920
124995
|
verbose: context.options.verbose || hasRawVerboseFlag2() ? true : void 0
|
|
124921
124996
|
});
|
|
124922
124997
|
}
|
|
@@ -126251,7 +126326,46 @@ function createCurlCli(dependencies) {
|
|
|
126251
126326
|
}
|
|
126252
126327
|
|
|
126253
126328
|
// src/commands/dsCommands.ts
|
|
126329
|
+
var import_promises3 = require("node:fs/promises");
|
|
126330
|
+
var import_node_path6 = require("node:path");
|
|
126254
126331
|
var BULK_OPERATION_LIMIT = 50;
|
|
126332
|
+
var FILE_EXTENSION_TO_CONTENT_TYPE = {
|
|
126333
|
+
".avi": "video/x-msvideo",
|
|
126334
|
+
".bmp": "image/bmp",
|
|
126335
|
+
".csv": "text/csv",
|
|
126336
|
+
".doc": "application/msword",
|
|
126337
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
126338
|
+
".flac": "audio/flac",
|
|
126339
|
+
".gif": "image/gif",
|
|
126340
|
+
".jpeg": "image/jpeg",
|
|
126341
|
+
".jpg": "image/jpeg",
|
|
126342
|
+
".json": "application/json",
|
|
126343
|
+
".m4a": "audio/m4a",
|
|
126344
|
+
".mov": "video/quicktime",
|
|
126345
|
+
".mp3": "audio/mpeg",
|
|
126346
|
+
".mp4": "video/mp4",
|
|
126347
|
+
".mpga": "audio/mpga",
|
|
126348
|
+
".ogg": "audio/ogg",
|
|
126349
|
+
".opus": "audio/opus",
|
|
126350
|
+
".pdf": "application/pdf",
|
|
126351
|
+
".png": "image/png",
|
|
126352
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
126353
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
126354
|
+
".rar": "application/x-rar-compressed",
|
|
126355
|
+
".rtf": "text/rtf",
|
|
126356
|
+
".tif": "image/tiff",
|
|
126357
|
+
".tiff": "image/tiff",
|
|
126358
|
+
".txt": "text/plain",
|
|
126359
|
+
".wav": "audio/wav",
|
|
126360
|
+
".webm": "video/webm",
|
|
126361
|
+
".webp": "image/webp",
|
|
126362
|
+
".xls": "application/vnd.ms-excel",
|
|
126363
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
126364
|
+
".yaml": "application/yaml",
|
|
126365
|
+
".yml": "application/yaml",
|
|
126366
|
+
".zip": "application/zip",
|
|
126367
|
+
".7z": "application/x-7z-compressed"
|
|
126368
|
+
};
|
|
126255
126369
|
function isRecord(value) {
|
|
126256
126370
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
126257
126371
|
}
|
|
@@ -126301,6 +126415,87 @@ function toSinglePayload(payload) {
|
|
|
126301
126415
|
}
|
|
126302
126416
|
return payload;
|
|
126303
126417
|
}
|
|
126418
|
+
async function toCommentPayload(params) {
|
|
126419
|
+
const hasStructuredPayload = normalizeOptionalString(params.data) !== void 0 || normalizeOptionalString(params.fromFile) !== void 0;
|
|
126420
|
+
const hasFieldOptions = normalizeOptionalString(params.message) !== void 0 || normalizeOptionalString(params.parentId) !== void 0 || normalizeOptionalString(params.assignedTo) !== void 0 || normalizeOptionalString(params.attachments) !== void 0 || params.level !== void 0 || params.status !== void 0 || params.done !== void 0;
|
|
126421
|
+
if (hasStructuredPayload) {
|
|
126422
|
+
if (hasFieldOptions) {
|
|
126423
|
+
throw new UserInputError(
|
|
126424
|
+
"Do not mix --data/--fromFile with comment field options. Use one input style only."
|
|
126425
|
+
);
|
|
126426
|
+
}
|
|
126427
|
+
const payload2 = await readDataInput({
|
|
126428
|
+
data: params.data,
|
|
126429
|
+
fromFile: params.fromFile
|
|
126430
|
+
});
|
|
126431
|
+
return toSinglePayload(payload2);
|
|
126432
|
+
}
|
|
126433
|
+
const message = normalizeOptionalString(params.message);
|
|
126434
|
+
if (!message) {
|
|
126435
|
+
throw new UserInputError("Comment message is required. Pass --message, --data, or --fromFile.");
|
|
126436
|
+
}
|
|
126437
|
+
const payload = {
|
|
126438
|
+
message
|
|
126439
|
+
};
|
|
126440
|
+
const parentId = normalizeOptionalString(params.parentId);
|
|
126441
|
+
const assignedTo = normalizeOptionalString(params.assignedTo);
|
|
126442
|
+
const attachments = normalizeOptionalString(params.attachments);
|
|
126443
|
+
if (parentId) {
|
|
126444
|
+
payload.parentId = parentId;
|
|
126445
|
+
}
|
|
126446
|
+
if (assignedTo) {
|
|
126447
|
+
payload.assignedTo = assignedTo;
|
|
126448
|
+
}
|
|
126449
|
+
if (attachments) {
|
|
126450
|
+
payload.attachments = parseJsonData(attachments, "--attachments");
|
|
126451
|
+
}
|
|
126452
|
+
if (params.level !== void 0) {
|
|
126453
|
+
payload.level = params.level;
|
|
126454
|
+
}
|
|
126455
|
+
if (params.status !== void 0) {
|
|
126456
|
+
payload.status = params.status;
|
|
126457
|
+
}
|
|
126458
|
+
if (params.done !== void 0) {
|
|
126459
|
+
payload.done = params.done;
|
|
126460
|
+
}
|
|
126461
|
+
return payload;
|
|
126462
|
+
}
|
|
126463
|
+
function resolveAttachmentContentType(params) {
|
|
126464
|
+
const contentType = normalizeOptionalString(params.contentType);
|
|
126465
|
+
if (contentType) {
|
|
126466
|
+
return contentType;
|
|
126467
|
+
}
|
|
126468
|
+
const extension = (0, import_node_path6.extname)(params.filePath).toLowerCase();
|
|
126469
|
+
const inferredContentType = FILE_EXTENSION_TO_CONTENT_TYPE[extension];
|
|
126470
|
+
if (inferredContentType) {
|
|
126471
|
+
return inferredContentType;
|
|
126472
|
+
}
|
|
126473
|
+
throw new UserInputError(
|
|
126474
|
+
`Unable to infer content type for '${params.filePath}'. Pass --contentType explicitly.`
|
|
126475
|
+
);
|
|
126476
|
+
}
|
|
126477
|
+
async function toFileUploadBody(params) {
|
|
126478
|
+
const filePath = normalizeOptionalString(params.filePath);
|
|
126479
|
+
if (!filePath) {
|
|
126480
|
+
throw new UserInputError("File path is required.");
|
|
126481
|
+
}
|
|
126482
|
+
let fileBuffer;
|
|
126483
|
+
try {
|
|
126484
|
+
fileBuffer = await (0, import_promises3.readFile)(filePath);
|
|
126485
|
+
} catch (error48) {
|
|
126486
|
+
const message = error48 instanceof Error ? error48.message : "Unknown error";
|
|
126487
|
+
throw new UserInputError(`Unable to read file '${filePath}': ${message}`);
|
|
126488
|
+
}
|
|
126489
|
+
const fileName = (0, import_node_path6.basename)(filePath);
|
|
126490
|
+
const contentType = resolveAttachmentContentType({
|
|
126491
|
+
filePath,
|
|
126492
|
+
contentType: params.contentType
|
|
126493
|
+
});
|
|
126494
|
+
const formData = new FormData();
|
|
126495
|
+
const fileBytes = new Uint8Array(fileBuffer);
|
|
126496
|
+
formData.set("file", new Blob([fileBytes], { type: contentType }), fileName);
|
|
126497
|
+
return formData;
|
|
126498
|
+
}
|
|
126304
126499
|
function createDsCli(dependencies) {
|
|
126305
126500
|
const dsCli = Cli_exports.create("ds", {
|
|
126306
126501
|
description: "Data source commands",
|
|
@@ -126481,11 +126676,99 @@ function createDsCli(dependencies) {
|
|
|
126481
126676
|
});
|
|
126482
126677
|
}
|
|
126483
126678
|
});
|
|
126679
|
+
const commentsCli = Cli_exports.create("comments", {
|
|
126680
|
+
description: "Record comment commands",
|
|
126681
|
+
env: EnvSchema
|
|
126682
|
+
});
|
|
126683
|
+
commentsCli.command("create", {
|
|
126684
|
+
description: "Create a comment for a data source record",
|
|
126685
|
+
args: external_exports.object({
|
|
126686
|
+
appSlug: external_exports.string().min(1),
|
|
126687
|
+
dataSourceSlug: external_exports.string().min(1),
|
|
126688
|
+
recordId: external_exports.string().min(1)
|
|
126689
|
+
}),
|
|
126690
|
+
options: external_exports.object({
|
|
126691
|
+
message: external_exports.string().optional().describe("Comment message"),
|
|
126692
|
+
data: external_exports.string().optional().describe("Full JSON payload for comment DTO"),
|
|
126693
|
+
fromFile: external_exports.string().optional().describe("Path to JSON payload file"),
|
|
126694
|
+
parentId: external_exports.string().optional().describe("Parent comment ID"),
|
|
126695
|
+
assignedTo: external_exports.string().optional().describe("Assigned user ID"),
|
|
126696
|
+
attachments: external_exports.string().optional().describe("JSON attachments payload"),
|
|
126697
|
+
level: external_exports.number().optional().describe("Comment level"),
|
|
126698
|
+
status: external_exports.number().optional().describe("Comment status"),
|
|
126699
|
+
done: external_exports.boolean().optional().describe("Mark comment as done")
|
|
126700
|
+
}),
|
|
126701
|
+
run: async (context) => {
|
|
126702
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
126703
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
126704
|
+
const payload = await toCommentPayload({
|
|
126705
|
+
message: context.options.message,
|
|
126706
|
+
data: context.options.data,
|
|
126707
|
+
fromFile: context.options.fromFile,
|
|
126708
|
+
parentId: context.options.parentId,
|
|
126709
|
+
assignedTo: context.options.assignedTo,
|
|
126710
|
+
attachments: context.options.attachments,
|
|
126711
|
+
level: context.options.level,
|
|
126712
|
+
status: context.options.status,
|
|
126713
|
+
done: context.options.done
|
|
126714
|
+
});
|
|
126715
|
+
const response = await apiClient.request({
|
|
126716
|
+
method: "POST",
|
|
126717
|
+
path: `/apps/${context.args.appSlug}/data-sources/${context.args.dataSourceSlug}/items/${context.args.recordId}/comments`,
|
|
126718
|
+
body: payload
|
|
126719
|
+
});
|
|
126720
|
+
return await injectContext({
|
|
126721
|
+
apiBaseUrl,
|
|
126722
|
+
authStore: dependencies.authStore,
|
|
126723
|
+
payload: response.data
|
|
126724
|
+
});
|
|
126725
|
+
}
|
|
126726
|
+
});
|
|
126727
|
+
dsCli.command(commentsCli);
|
|
126728
|
+
const filesCli = Cli_exports.create("files", {
|
|
126729
|
+
description: "Record file attachment commands",
|
|
126730
|
+
env: EnvSchema
|
|
126731
|
+
});
|
|
126732
|
+
filesCli.command("upload", {
|
|
126733
|
+
description: "Upload a file attachment for a data source record",
|
|
126734
|
+
args: external_exports.object({
|
|
126735
|
+
appSlug: external_exports.string().min(1),
|
|
126736
|
+
dataSourceSlug: external_exports.string().min(1),
|
|
126737
|
+
recordId: external_exports.string().min(1)
|
|
126738
|
+
}),
|
|
126739
|
+
options: external_exports.object({
|
|
126740
|
+
file: external_exports.string().min(1).describe("Path to local file"),
|
|
126741
|
+
contentType: external_exports.string().optional().describe("Override file content type"),
|
|
126742
|
+
publicFile: external_exports.boolean().optional().describe("Store file in public tenant bucket")
|
|
126743
|
+
}),
|
|
126744
|
+
run: async (context) => {
|
|
126745
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
126746
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
126747
|
+
const body = await toFileUploadBody({
|
|
126748
|
+
filePath: context.options.file,
|
|
126749
|
+
contentType: context.options.contentType
|
|
126750
|
+
});
|
|
126751
|
+
const response = await apiClient.request({
|
|
126752
|
+
method: "POST",
|
|
126753
|
+
path: `/apps/${context.args.appSlug}/data-sources/${context.args.dataSourceSlug}/items/${context.args.recordId}/files/upload`,
|
|
126754
|
+
query: {
|
|
126755
|
+
publicFile: context.options.publicFile
|
|
126756
|
+
},
|
|
126757
|
+
body
|
|
126758
|
+
});
|
|
126759
|
+
return await injectContext({
|
|
126760
|
+
apiBaseUrl,
|
|
126761
|
+
authStore: dependencies.authStore,
|
|
126762
|
+
payload: response.data
|
|
126763
|
+
});
|
|
126764
|
+
}
|
|
126765
|
+
});
|
|
126766
|
+
dsCli.command(filesCli);
|
|
126484
126767
|
return dsCli;
|
|
126485
126768
|
}
|
|
126486
126769
|
|
|
126487
126770
|
// src/commands/discoverCommands.ts
|
|
126488
|
-
var
|
|
126771
|
+
var import_promises4 = require("node:fs/promises");
|
|
126489
126772
|
var SUPPORTED_HTTP_METHODS2 = [
|
|
126490
126773
|
"GET",
|
|
126491
126774
|
"POST",
|
|
@@ -126630,7 +126913,7 @@ async function loadOpenApiSpec(dependencies, tenantId, options2) {
|
|
|
126630
126913
|
let sourceUrl;
|
|
126631
126914
|
let content;
|
|
126632
126915
|
try {
|
|
126633
|
-
content = await (0,
|
|
126916
|
+
content = await (0, import_promises4.readFile)(filePath, "utf8");
|
|
126634
126917
|
} catch (error48) {
|
|
126635
126918
|
if (!isEnoentError(error48)) {
|
|
126636
126919
|
throw new UserInputError("Failed to read downloaded OpenAPI spec file.", {
|
|
@@ -126642,7 +126925,7 @@ async function loadOpenApiSpec(dependencies, tenantId, options2) {
|
|
|
126642
126925
|
downloaded = true;
|
|
126643
126926
|
sourceUrl = downloadResult.sourceUrl;
|
|
126644
126927
|
filePath = downloadResult.filePath;
|
|
126645
|
-
content = await (0,
|
|
126928
|
+
content = await (0, import_promises4.readFile)(filePath, "utf8");
|
|
126646
126929
|
}
|
|
126647
126930
|
return {
|
|
126648
126931
|
filePath,
|
|
@@ -126889,8 +127172,8 @@ function createEnvCli(dependencies) {
|
|
|
126889
127172
|
}
|
|
126890
127173
|
|
|
126891
127174
|
// src/services/studioPayload.ts
|
|
126892
|
-
var
|
|
126893
|
-
var
|
|
127175
|
+
var import_promises5 = require("node:fs/promises");
|
|
127176
|
+
var import_node_path7 = require("node:path");
|
|
126894
127177
|
async function readStdinText2() {
|
|
126895
127178
|
if (process.stdin.isTTY) {
|
|
126896
127179
|
return "";
|
|
@@ -126913,7 +127196,7 @@ async function readStudioWriteInput(params) {
|
|
|
126913
127196
|
data,
|
|
126914
127197
|
fromFile,
|
|
126915
127198
|
readStdin = readStdinText2,
|
|
126916
|
-
readFileFn = async (path3, encoding) => await (0,
|
|
127199
|
+
readFileFn = async (path3, encoding) => await (0, import_promises5.readFile)(path3, encoding)
|
|
126917
127200
|
} = params;
|
|
126918
127201
|
const trimmedData = data?.trim();
|
|
126919
127202
|
const trimmedFromFile = fromFile?.trim();
|
|
@@ -126921,7 +127204,7 @@ async function readStudioWriteInput(params) {
|
|
|
126921
127204
|
throw new UserInputError("Provide either --data or --from-file, not both.");
|
|
126922
127205
|
}
|
|
126923
127206
|
if (trimmedFromFile) {
|
|
126924
|
-
const extension = (0,
|
|
127207
|
+
const extension = (0, import_node_path7.extname)(trimmedFromFile).toLowerCase();
|
|
126925
127208
|
if (extension && extension !== ".json") {
|
|
126926
127209
|
throw new UserInputError("Studio commands support only JSON files in --from-file.");
|
|
126927
127210
|
}
|
|
@@ -127926,7 +128209,7 @@ function createStudioCli(dependencies) {
|
|
|
127926
128209
|
// src/commands/tuiCommand.ts
|
|
127927
128210
|
var import_node_child_process3 = require("node:child_process");
|
|
127928
128211
|
var import_node_fs4 = require("node:fs");
|
|
127929
|
-
var
|
|
128212
|
+
var import_node_path8 = require("node:path");
|
|
127930
128213
|
function summarizeFailure2(result) {
|
|
127931
128214
|
const stderr = result.stderr?.toString().trim();
|
|
127932
128215
|
if (stderr && stderr.length > 0) {
|
|
@@ -127943,7 +128226,7 @@ function summarizeFailure2(result) {
|
|
|
127943
128226
|
function resolveCliScriptPath() {
|
|
127944
128227
|
const argvScript = process.argv[1];
|
|
127945
128228
|
if (argvScript && argvScript.trim().length > 0) {
|
|
127946
|
-
return (0,
|
|
128229
|
+
return (0, import_node_path8.isAbsolute)(argvScript) ? argvScript : (0, import_node_path8.resolve)(process.cwd(), argvScript);
|
|
127947
128230
|
}
|
|
127948
128231
|
return __filename;
|
|
127949
128232
|
}
|
|
@@ -127954,12 +128237,12 @@ function resolveOpenTuiEntryPath(options2 = {}) {
|
|
|
127954
128237
|
const candidates = [
|
|
127955
128238
|
// Source/dev mode in monorepo. Prefer this first so Bun resolves deps via
|
|
127956
128239
|
// apps/api-cli/node_modules in workspace runs (e.g. `pnpm docyrus tui`).
|
|
127957
|
-
(0,
|
|
127958
|
-
(0,
|
|
128240
|
+
(0, import_node_path8.resolve)(cwd, "apps/api-cli/src/tui/opentuiMain.tsx"),
|
|
128241
|
+
(0, import_node_path8.resolve)(dirname7, "../tui/opentuiMain.tsx"),
|
|
127959
128242
|
// Dist mode (bundled command runtime)
|
|
127960
|
-
(0,
|
|
127961
|
-
(0,
|
|
127962
|
-
(0,
|
|
128243
|
+
(0, import_node_path8.resolve)(dirname7, "tui.mjs"),
|
|
128244
|
+
(0, import_node_path8.resolve)(dirname7, "../tui.mjs"),
|
|
128245
|
+
(0, import_node_path8.resolve)(cwd, "dist/apps/api-cli/tui.mjs")
|
|
127963
128246
|
];
|
|
127964
128247
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
127965
128248
|
if (!resolved) {
|
|
@@ -128027,6 +128310,18 @@ function createTuiCli(dependencies) {
|
|
|
128027
128310
|
|
|
128028
128311
|
// src/services/apiClient.ts
|
|
128029
128312
|
var insecureLocalhostDispatcherPromise = null;
|
|
128313
|
+
function isFormData(value) {
|
|
128314
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
128315
|
+
}
|
|
128316
|
+
function isUrlSearchParams(value) {
|
|
128317
|
+
return typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams;
|
|
128318
|
+
}
|
|
128319
|
+
function isBlob(value) {
|
|
128320
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
128321
|
+
}
|
|
128322
|
+
function isBinaryBody(value) {
|
|
128323
|
+
return isFormData(value) || isUrlSearchParams(value) || isBlob(value) || value instanceof ArrayBuffer || ArrayBuffer.isView(value);
|
|
128324
|
+
}
|
|
128030
128325
|
function normalizeResponseHeaders(headers) {
|
|
128031
128326
|
const normalized = {};
|
|
128032
128327
|
headers.forEach((value, key) => {
|
|
@@ -128137,6 +128432,8 @@ async function requestDocyrusApi(options2) {
|
|
|
128137
128432
|
if (!requestHeaders["Content-Type"] && !requestHeaders["content-type"]) {
|
|
128138
128433
|
requestHeaders["Content-Type"] = "text/plain; charset=utf-8";
|
|
128139
128434
|
}
|
|
128435
|
+
} else if (isBinaryBody(body)) {
|
|
128436
|
+
requestBody = body;
|
|
128140
128437
|
} else {
|
|
128141
128438
|
requestBody = JSON.stringify(body);
|
|
128142
128439
|
if (!requestHeaders["Content-Type"] && !requestHeaders["content-type"]) {
|
|
@@ -128744,8 +129041,8 @@ var AuthSessionService = class {
|
|
|
128744
129041
|
};
|
|
128745
129042
|
|
|
128746
129043
|
// src/services/authStore.ts
|
|
128747
|
-
var
|
|
128748
|
-
var
|
|
129044
|
+
var import_promises6 = require("node:fs/promises");
|
|
129045
|
+
var import_node_path9 = require("node:path");
|
|
128749
129046
|
function createEmptyState() {
|
|
128750
129047
|
return {
|
|
128751
129048
|
version: 2,
|
|
@@ -128784,7 +129081,7 @@ var AuthStore = class {
|
|
|
128784
129081
|
}
|
|
128785
129082
|
async readState() {
|
|
128786
129083
|
try {
|
|
128787
|
-
const raw = await (0,
|
|
129084
|
+
const raw = await (0, import_promises6.readFile)(this.authFilePath, "utf8");
|
|
128788
129085
|
const parsed = JSON.parse(raw);
|
|
128789
129086
|
const legacy = LegacyAuthSessionSchema.safeParse(parsed);
|
|
128790
129087
|
if (legacy.success) {
|
|
@@ -128820,17 +129117,17 @@ var AuthStore = class {
|
|
|
128820
129117
|
});
|
|
128821
129118
|
}
|
|
128822
129119
|
const normalized = normalizeState(validated.data);
|
|
128823
|
-
const directory = (0,
|
|
128824
|
-
await (0,
|
|
129120
|
+
const directory = (0, import_node_path9.dirname)(this.authFilePath);
|
|
129121
|
+
await (0, import_promises6.mkdir)(directory, {
|
|
128825
129122
|
recursive: true,
|
|
128826
129123
|
mode: 448
|
|
128827
129124
|
});
|
|
128828
|
-
await (0,
|
|
129125
|
+
await (0, import_promises6.writeFile)(this.authFilePath, `${JSON.stringify(normalized, null, 2)}
|
|
128829
129126
|
`, {
|
|
128830
129127
|
encoding: "utf8",
|
|
128831
129128
|
mode: 384
|
|
128832
129129
|
});
|
|
128833
|
-
await (0,
|
|
129130
|
+
await (0, import_promises6.chmod)(this.authFilePath, 384);
|
|
128834
129131
|
}
|
|
128835
129132
|
async getActiveProfile(apiBaseUrl) {
|
|
128836
129133
|
const normalizedApiBaseUrl = normalizeApiBaseUrl(apiBaseUrl);
|
|
@@ -129027,15 +129324,15 @@ var AuthStore = class {
|
|
|
129027
129324
|
await this.writeState(state);
|
|
129028
129325
|
}
|
|
129029
129326
|
async clear() {
|
|
129030
|
-
await (0,
|
|
129327
|
+
await (0, import_promises6.rm)(this.authFilePath, {
|
|
129031
129328
|
force: true
|
|
129032
129329
|
});
|
|
129033
129330
|
}
|
|
129034
129331
|
};
|
|
129035
129332
|
|
|
129036
129333
|
// src/services/environmentConfig.ts
|
|
129037
|
-
var
|
|
129038
|
-
var
|
|
129334
|
+
var import_promises7 = require("node:fs/promises");
|
|
129335
|
+
var import_node_path10 = require("node:path");
|
|
129039
129336
|
var ENVIRONMENT_ID_ALIASES = {
|
|
129040
129337
|
"local-development": "dev",
|
|
129041
129338
|
prod: "live"
|
|
@@ -129121,7 +129418,7 @@ var EnvironmentConfigService = class {
|
|
|
129121
129418
|
}
|
|
129122
129419
|
async readState() {
|
|
129123
129420
|
try {
|
|
129124
|
-
const raw = await (0,
|
|
129421
|
+
const raw = await (0, import_promises7.readFile)(this.configFilePath, "utf8");
|
|
129125
129422
|
const parsed = JSON.parse(raw);
|
|
129126
129423
|
const validated = EnvironmentConfigStateSchema.safeParse(parsed);
|
|
129127
129424
|
if (!validated.success) {
|
|
@@ -129155,17 +129452,17 @@ var EnvironmentConfigService = class {
|
|
|
129155
129452
|
});
|
|
129156
129453
|
}
|
|
129157
129454
|
const normalized = normalizeState2(validated.data);
|
|
129158
|
-
const directory = (0,
|
|
129159
|
-
await (0,
|
|
129455
|
+
const directory = (0, import_node_path10.dirname)(this.configFilePath);
|
|
129456
|
+
await (0, import_promises7.mkdir)(directory, {
|
|
129160
129457
|
recursive: true,
|
|
129161
129458
|
mode: 448
|
|
129162
129459
|
});
|
|
129163
|
-
await (0,
|
|
129460
|
+
await (0, import_promises7.writeFile)(this.configFilePath, `${JSON.stringify(normalized, null, 2)}
|
|
129164
129461
|
`, {
|
|
129165
129462
|
encoding: "utf8",
|
|
129166
129463
|
mode: 384
|
|
129167
129464
|
});
|
|
129168
|
-
await (0,
|
|
129465
|
+
await (0, import_promises7.chmod)(this.configFilePath, 384);
|
|
129169
129466
|
}
|
|
129170
129467
|
async getActiveEnvironment() {
|
|
129171
129468
|
const state = await this.#readStateWithDefaults();
|
|
@@ -129233,8 +129530,35 @@ var EnvironmentConfigService = class {
|
|
|
129233
129530
|
// src/services/piAgentLauncher.ts
|
|
129234
129531
|
var import_node_child_process4 = require("node:child_process");
|
|
129235
129532
|
var import_node_fs5 = require("node:fs");
|
|
129236
|
-
var
|
|
129237
|
-
var
|
|
129533
|
+
var import_promises8 = require("node:fs/promises");
|
|
129534
|
+
var import_node_path11 = require("node:path");
|
|
129535
|
+
|
|
129536
|
+
// src/services/spinner.ts
|
|
129537
|
+
var import_picocolors = __toESM(require_picocolors());
|
|
129538
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
129539
|
+
var SPINNER_INTERVAL_MS = 80;
|
|
129540
|
+
function createSpinner(message) {
|
|
129541
|
+
let frameIndex = 0;
|
|
129542
|
+
let currentMessage = message;
|
|
129543
|
+
const render = () => {
|
|
129544
|
+
const frame = import_picocolors.default.cyan(SPINNER_FRAMES[frameIndex]);
|
|
129545
|
+
process.stderr.write(`\r ${frame} ${import_picocolors.default.dim(currentMessage)}`);
|
|
129546
|
+
frameIndex = (frameIndex + 1) % SPINNER_FRAMES.length;
|
|
129547
|
+
};
|
|
129548
|
+
render();
|
|
129549
|
+
const interval = setInterval(render, SPINNER_INTERVAL_MS);
|
|
129550
|
+
return {
|
|
129551
|
+
update(newMessage) {
|
|
129552
|
+
currentMessage = newMessage;
|
|
129553
|
+
},
|
|
129554
|
+
stop() {
|
|
129555
|
+
clearInterval(interval);
|
|
129556
|
+
process.stderr.write(`\r${" ".repeat(currentMessage.length + 10)}\r`);
|
|
129557
|
+
}
|
|
129558
|
+
};
|
|
129559
|
+
}
|
|
129560
|
+
|
|
129561
|
+
// src/services/piAgentLauncher.ts
|
|
129238
129562
|
var DOCYRUS_EXTERNAL_SKILL_SOURCE = "docyrus/agent-skills";
|
|
129239
129563
|
var DOCYRUS_PACKAGED_PLATFORM_SKILL_NAME = "docyrus-platform";
|
|
129240
129564
|
var DOCYRUS_MIGRATED_SKILL_NAMES = [
|
|
@@ -129271,10 +129595,10 @@ function resolvePackagedPiResourceRoot(options2 = {}) {
|
|
|
129271
129595
|
const dirname7 = options2.dirname ?? __dirname;
|
|
129272
129596
|
const fileExists = options2.existsSyncFn ?? import_node_fs5.existsSync;
|
|
129273
129597
|
const candidates = [
|
|
129274
|
-
(0,
|
|
129275
|
-
(0,
|
|
129276
|
-
(0,
|
|
129277
|
-
(0,
|
|
129598
|
+
(0, import_node_path11.resolve)(cwd, "apps/api-cli/resources/pi-agent"),
|
|
129599
|
+
(0, import_node_path11.resolve)(dirname7, "../resources/pi-agent"),
|
|
129600
|
+
(0, import_node_path11.resolve)(dirname7, "resources/pi-agent"),
|
|
129601
|
+
(0, import_node_path11.resolve)(cwd, "dist/apps/api-cli/resources/pi-agent")
|
|
129278
129602
|
];
|
|
129279
129603
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
129280
129604
|
if (!resolved) {
|
|
@@ -129295,23 +129619,23 @@ function resolveDocyrusPiLoaderEntryPath(options2 = {}) {
|
|
|
129295
129619
|
}
|
|
129296
129620
|
};
|
|
129297
129621
|
const collectAncestorCandidates = (startDir) => {
|
|
129298
|
-
let currentDir = (0,
|
|
129622
|
+
let currentDir = (0, import_node_path11.resolve)(startDir);
|
|
129299
129623
|
while (true) {
|
|
129300
|
-
addCandidate((0,
|
|
129301
|
-
addCandidate((0,
|
|
129302
|
-
if ((0,
|
|
129303
|
-
addCandidate((0,
|
|
129624
|
+
addCandidate((0, import_node_path11.join)(currentDir, "dist", "apps", "api-cli", "agent-loader.js"));
|
|
129625
|
+
addCandidate((0, import_node_path11.join)(currentDir, "agent-loader.js"));
|
|
129626
|
+
if ((0, import_node_path11.basename)(currentDir) === "dist") {
|
|
129627
|
+
addCandidate((0, import_node_path11.join)(currentDir, "apps", "api-cli", "agent-loader.js"));
|
|
129304
129628
|
}
|
|
129305
|
-
const parentDir = (0,
|
|
129629
|
+
const parentDir = (0, import_node_path11.resolve)(currentDir, "..");
|
|
129306
129630
|
if (parentDir === currentDir) {
|
|
129307
129631
|
break;
|
|
129308
129632
|
}
|
|
129309
129633
|
currentDir = parentDir;
|
|
129310
129634
|
}
|
|
129311
129635
|
};
|
|
129312
|
-
addCandidate((0,
|
|
129313
|
-
addCandidate((0,
|
|
129314
|
-
addCandidate((0,
|
|
129636
|
+
addCandidate((0, import_node_path11.resolve)(cwd, "dist/apps/api-cli/agent-loader.js"));
|
|
129637
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "../agent-loader.js"));
|
|
129638
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "agent-loader.js"));
|
|
129315
129639
|
collectAncestorCandidates(cwd);
|
|
129316
129640
|
collectAncestorCandidates(dirname7);
|
|
129317
129641
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
@@ -129331,20 +129655,20 @@ function resolveDocyrusCliEntryPath(options2 = {}) {
|
|
|
129331
129655
|
if (!candidate) {
|
|
129332
129656
|
return;
|
|
129333
129657
|
}
|
|
129334
|
-
const resolvedCandidate = (0,
|
|
129658
|
+
const resolvedCandidate = (0, import_node_path11.resolve)(candidate);
|
|
129335
129659
|
if (!seen.has(resolvedCandidate)) {
|
|
129336
129660
|
seen.add(resolvedCandidate);
|
|
129337
129661
|
candidates.push(resolvedCandidate);
|
|
129338
129662
|
}
|
|
129339
129663
|
};
|
|
129340
129664
|
const argvScript = argv[1]?.trim();
|
|
129341
|
-
const normalizedArgvScript = argvScript ? argvScript.startsWith("/") ? argvScript : (0,
|
|
129665
|
+
const normalizedArgvScript = argvScript ? argvScript.startsWith("/") ? argvScript : (0, import_node_path11.resolve)(cwd, argvScript) : void 0;
|
|
129342
129666
|
if (normalizedArgvScript && normalizedArgvScript.endsWith(".js")) {
|
|
129343
129667
|
addCandidate(normalizedArgvScript);
|
|
129344
129668
|
}
|
|
129345
|
-
addCandidate((0,
|
|
129346
|
-
addCandidate((0,
|
|
129347
|
-
addCandidate((0,
|
|
129669
|
+
addCandidate((0, import_node_path11.resolve)(cwd, "dist/apps/api-cli/main.js"));
|
|
129670
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "../main.js"));
|
|
129671
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "main.js"));
|
|
129348
129672
|
if (normalizedArgvScript) {
|
|
129349
129673
|
addCandidate(normalizedArgvScript);
|
|
129350
129674
|
}
|
|
@@ -129367,28 +129691,28 @@ function resolveInstalledPiPackageRootPath(options2 = {}) {
|
|
|
129367
129691
|
}
|
|
129368
129692
|
};
|
|
129369
129693
|
const collectAncestorCandidates = (startDir) => {
|
|
129370
|
-
let currentDir = (0,
|
|
129694
|
+
let currentDir = (0, import_node_path11.resolve)(startDir);
|
|
129371
129695
|
while (true) {
|
|
129372
|
-
addCandidate((0,
|
|
129373
|
-
if ((0,
|
|
129374
|
-
addCandidate((0,
|
|
129696
|
+
addCandidate((0, import_node_path11.join)(currentDir, "node_modules", "@mariozechner", "pi-coding-agent", "package.json"));
|
|
129697
|
+
if ((0, import_node_path11.basename)(currentDir) === "node_modules") {
|
|
129698
|
+
addCandidate((0, import_node_path11.join)(currentDir, "@mariozechner", "pi-coding-agent", "package.json"));
|
|
129375
129699
|
}
|
|
129376
|
-
const parentDir = (0,
|
|
129700
|
+
const parentDir = (0, import_node_path11.resolve)(currentDir, "..");
|
|
129377
129701
|
if (parentDir === currentDir) {
|
|
129378
129702
|
break;
|
|
129379
129703
|
}
|
|
129380
129704
|
currentDir = parentDir;
|
|
129381
129705
|
}
|
|
129382
129706
|
};
|
|
129383
|
-
addCandidate((0,
|
|
129384
|
-
addCandidate((0,
|
|
129707
|
+
addCandidate((0, import_node_path11.resolve)(cwd, "apps/api-cli/node_modules/@mariozechner/pi-coding-agent/package.json"));
|
|
129708
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "../../../apps/api-cli/node_modules/@mariozechner/pi-coding-agent/package.json"));
|
|
129385
129709
|
collectAncestorCandidates(cwd);
|
|
129386
129710
|
collectAncestorCandidates(dirname7);
|
|
129387
129711
|
const resolvedPackageJson = candidates.find((candidate) => fileExists(candidate));
|
|
129388
129712
|
if (!resolvedPackageJson) {
|
|
129389
129713
|
throw new UserInputError(`Unable to locate the installed pi package root. Checked: ${candidates.join(", ")}`);
|
|
129390
129714
|
}
|
|
129391
|
-
return (0,
|
|
129715
|
+
return (0, import_node_path11.resolve)(resolvedPackageJson, "..");
|
|
129392
129716
|
}
|
|
129393
129717
|
function createPiAgentRuntimeSkill(params) {
|
|
129394
129718
|
const commandPrefix = params.scope === "global" ? "docyrus -g" : "docyrus";
|
|
@@ -129435,35 +129759,35 @@ function createPiAgentRuntimeSkill(params) {
|
|
|
129435
129759
|
].join("\n");
|
|
129436
129760
|
}
|
|
129437
129761
|
async function syncPackagedSkills(params) {
|
|
129438
|
-
const sourceSkillsRoot = (0,
|
|
129439
|
-
const targetSkillsRoot = (0,
|
|
129440
|
-
await (0,
|
|
129762
|
+
const sourceSkillsRoot = (0, import_node_path11.join)(params.resourceRoot, "skills");
|
|
129763
|
+
const targetSkillsRoot = (0, import_node_path11.join)(params.agentRootPath, "skills");
|
|
129764
|
+
await (0, import_promises8.mkdir)(targetSkillsRoot, {
|
|
129441
129765
|
recursive: true,
|
|
129442
129766
|
mode: 448
|
|
129443
129767
|
});
|
|
129444
|
-
const entries = await (0,
|
|
129768
|
+
const entries = await (0, import_promises8.readdir)(sourceSkillsRoot, {
|
|
129445
129769
|
withFileTypes: true
|
|
129446
129770
|
});
|
|
129447
129771
|
await Promise.all(DOCYRUS_MIGRATED_SKILL_NAMES.map(async (skillName) => {
|
|
129448
|
-
await (0,
|
|
129772
|
+
await (0, import_promises8.rm)((0, import_node_path11.join)(targetSkillsRoot, skillName), {
|
|
129449
129773
|
recursive: true,
|
|
129450
129774
|
force: true
|
|
129451
129775
|
});
|
|
129452
129776
|
}));
|
|
129453
129777
|
await Promise.all(entries.map(async (entry) => {
|
|
129454
|
-
await (0,
|
|
129778
|
+
await (0, import_promises8.cp)((0, import_node_path11.join)(sourceSkillsRoot, entry.name), (0, import_node_path11.join)(targetSkillsRoot, entry.name), {
|
|
129455
129779
|
recursive: true,
|
|
129456
129780
|
force: true
|
|
129457
129781
|
});
|
|
129458
129782
|
}));
|
|
129459
129783
|
}
|
|
129460
129784
|
async function writeRuntimeSkill(params) {
|
|
129461
|
-
const runtimeSkillDir = (0,
|
|
129462
|
-
await (0,
|
|
129785
|
+
const runtimeSkillDir = (0, import_node_path11.join)(params.agentRootPath, "skills", "docyrus-runtime-context");
|
|
129786
|
+
await (0, import_promises8.mkdir)(runtimeSkillDir, {
|
|
129463
129787
|
recursive: true,
|
|
129464
129788
|
mode: 448
|
|
129465
129789
|
});
|
|
129466
|
-
await (0,
|
|
129790
|
+
await (0, import_promises8.writeFile)((0, import_node_path11.join)(runtimeSkillDir, "SKILL.md"), `${params.content}
|
|
129467
129791
|
`, {
|
|
129468
129792
|
encoding: "utf8",
|
|
129469
129793
|
mode: 384
|
|
@@ -129476,10 +129800,10 @@ function resolveNpmCommand() {
|
|
|
129476
129800
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
129477
129801
|
}
|
|
129478
129802
|
function resolveManagedDiffityInstallRoot(agentRootPath) {
|
|
129479
|
-
return (0,
|
|
129803
|
+
return (0, import_node_path11.join)(agentRootPath, "tools", "diffity");
|
|
129480
129804
|
}
|
|
129481
129805
|
function resolveManagedDiffityExecutablePath(agentRootPath) {
|
|
129482
|
-
return (0,
|
|
129806
|
+
return (0, import_node_path11.join)(
|
|
129483
129807
|
resolveManagedDiffityInstallRoot(agentRootPath),
|
|
129484
129808
|
"node_modules",
|
|
129485
129809
|
".bin",
|
|
@@ -129487,10 +129811,10 @@ function resolveManagedDiffityExecutablePath(agentRootPath) {
|
|
|
129487
129811
|
);
|
|
129488
129812
|
}
|
|
129489
129813
|
function prependPathEntry(entry, existingPath) {
|
|
129490
|
-
const values = existingPath ? existingPath.split(
|
|
129814
|
+
const values = existingPath ? existingPath.split(import_node_path11.delimiter).filter((value) => value.trim().length > 0) : [];
|
|
129491
129815
|
const normalizedEntry = entry.trim();
|
|
129492
129816
|
const remaining = values.filter((value) => value !== normalizedEntry);
|
|
129493
|
-
return [normalizedEntry, ...remaining].join(
|
|
129817
|
+
return [normalizedEntry, ...remaining].join(import_node_path11.delimiter);
|
|
129494
129818
|
}
|
|
129495
129819
|
function createDocyrusSkillsInstallArgs(scope) {
|
|
129496
129820
|
const args = [
|
|
@@ -129528,7 +129852,7 @@ function createPackagedDocyrusPlatformInstallArgs(params) {
|
|
|
129528
129852
|
return args;
|
|
129529
129853
|
}
|
|
129530
129854
|
async function installExternalDocyrusSkillsOnce(params) {
|
|
129531
|
-
const markerPath = (0,
|
|
129855
|
+
const markerPath = (0, import_node_path11.join)(params.agentRootPath, DOCYRUS_EXTERNAL_SKILL_MARKER_FILE);
|
|
129532
129856
|
if ((0, import_node_fs5.existsSync)(markerPath)) {
|
|
129533
129857
|
return;
|
|
129534
129858
|
}
|
|
@@ -129547,7 +129871,7 @@ async function installExternalDocyrusSkillsOnce(params) {
|
|
|
129547
129871
|
);
|
|
129548
129872
|
return;
|
|
129549
129873
|
}
|
|
129550
|
-
await (0,
|
|
129874
|
+
await (0, import_promises8.writeFile)(markerPath, `${JSON.stringify({
|
|
129551
129875
|
source: DOCYRUS_EXTERNAL_SKILL_SOURCE,
|
|
129552
129876
|
skills: DOCYRUS_MIGRATED_SKILL_NAMES,
|
|
129553
129877
|
agents: DOCYRUS_EXTERNAL_SKILL_AGENT_IDS,
|
|
@@ -129561,7 +129885,7 @@ async function installExternalDocyrusSkillsOnce(params) {
|
|
|
129561
129885
|
}
|
|
129562
129886
|
async function ensureManagedDiffityInstalled(params) {
|
|
129563
129887
|
const executablePath = resolveManagedDiffityExecutablePath(params.agentRootPath);
|
|
129564
|
-
const binDir = (0,
|
|
129888
|
+
const binDir = (0, import_node_path11.dirname)(executablePath);
|
|
129565
129889
|
if ((0, import_node_fs5.existsSync)(executablePath)) {
|
|
129566
129890
|
return {
|
|
129567
129891
|
available: true,
|
|
@@ -129600,7 +129924,7 @@ async function ensureManagedDiffityInstalled(params) {
|
|
|
129600
129924
|
};
|
|
129601
129925
|
}
|
|
129602
129926
|
function resolvePackagedDocyrusPlatformSkillPath(resourceRoot) {
|
|
129603
|
-
return (0,
|
|
129927
|
+
return (0, import_node_path11.join)(resourceRoot, "skills", DOCYRUS_PACKAGED_PLATFORM_SKILL_NAME);
|
|
129604
129928
|
}
|
|
129605
129929
|
function installPackagedDocyrusPlatformSkill(params) {
|
|
129606
129930
|
const skillSourcePath = resolvePackagedDocyrusPlatformSkillPath(params.resourceRoot);
|
|
@@ -129652,11 +129976,13 @@ function createPiAgentLauncher(options2) {
|
|
|
129652
129976
|
request,
|
|
129653
129977
|
stdinIsTTY
|
|
129654
129978
|
});
|
|
129979
|
+
const spinner = createSpinner("Initializing...");
|
|
129655
129980
|
const activeEnvironment = await options2.environmentConfigService.getActiveEnvironment();
|
|
129656
129981
|
const activeProfile = await options2.authStore.getActiveProfile(activeEnvironment.apiBaseUrl);
|
|
129657
129982
|
const settingsRootPath = options2.settingsPaths.rootPath;
|
|
129658
129983
|
const agentRootPath = resolveDocyrusPiAgentRootPath(settingsRootPath);
|
|
129659
129984
|
const resourceRoot = resolveResourceRoot({ cwd });
|
|
129985
|
+
spinner.update("Syncing skills...");
|
|
129660
129986
|
await syncPackagedSkills({
|
|
129661
129987
|
resourceRoot,
|
|
129662
129988
|
agentRootPath
|
|
@@ -129671,6 +129997,7 @@ function createPiAgentLauncher(options2) {
|
|
|
129671
129997
|
settingsRootPath
|
|
129672
129998
|
})
|
|
129673
129999
|
});
|
|
130000
|
+
spinner.update("Installing skills...");
|
|
129674
130001
|
await installExternalDocyrusSkillsOnce({
|
|
129675
130002
|
agentRootPath,
|
|
129676
130003
|
cwd,
|
|
@@ -129683,11 +130010,13 @@ function createPiAgentLauncher(options2) {
|
|
|
129683
130010
|
scope: options2.settingsPaths.scope,
|
|
129684
130011
|
spawnCommand
|
|
129685
130012
|
});
|
|
130013
|
+
spinner.update("Installing tools...");
|
|
129686
130014
|
const diffity = await ensureManagedDiffityInstalled({
|
|
129687
130015
|
agentRootPath,
|
|
129688
130016
|
cwd,
|
|
129689
130017
|
spawnCommand
|
|
129690
130018
|
});
|
|
130019
|
+
spinner.stop();
|
|
129691
130020
|
const loaderEntryPath = resolveLoaderPath({ cwd });
|
|
129692
130021
|
const cliEntryPath = resolveCliEntryPath({ cwd });
|
|
129693
130022
|
const piPackageRoot = resolvePiPackageRoot({ cwd });
|
|
@@ -129721,8 +130050,10 @@ function createPiAgentLauncher(options2) {
|
|
|
129721
130050
|
// src/services/piAgentServerLauncher.ts
|
|
129722
130051
|
var import_node_child_process5 = require("node:child_process");
|
|
129723
130052
|
var import_node_fs6 = require("node:fs");
|
|
129724
|
-
var
|
|
129725
|
-
|
|
130053
|
+
var import_node_path12 = require("node:path");
|
|
130054
|
+
function serializePiAgentServerRequest(request) {
|
|
130055
|
+
return JSON.stringify(request);
|
|
130056
|
+
}
|
|
129726
130057
|
function resolveServerLoaderEntryPath(cwd, dirname7) {
|
|
129727
130058
|
const seen = /* @__PURE__ */ new Set();
|
|
129728
130059
|
const candidates = [];
|
|
@@ -129733,23 +130064,23 @@ function resolveServerLoaderEntryPath(cwd, dirname7) {
|
|
|
129733
130064
|
}
|
|
129734
130065
|
};
|
|
129735
130066
|
const collectAncestorCandidates = (startDir) => {
|
|
129736
|
-
let currentDir = (0,
|
|
130067
|
+
let currentDir = (0, import_node_path12.resolve)(startDir);
|
|
129737
130068
|
while (true) {
|
|
129738
|
-
addCandidate((0,
|
|
129739
|
-
addCandidate((0,
|
|
129740
|
-
if ((0,
|
|
129741
|
-
addCandidate((0,
|
|
130069
|
+
addCandidate((0, import_node_path12.join)(currentDir, "dist", "apps", "api-cli", "server-loader.js"));
|
|
130070
|
+
addCandidate((0, import_node_path12.join)(currentDir, "server-loader.js"));
|
|
130071
|
+
if ((0, import_node_path12.basename)(currentDir) === "dist") {
|
|
130072
|
+
addCandidate((0, import_node_path12.join)(currentDir, "apps", "api-cli", "server-loader.js"));
|
|
129742
130073
|
}
|
|
129743
|
-
const parentDir = (0,
|
|
130074
|
+
const parentDir = (0, import_node_path12.resolve)(currentDir, "..");
|
|
129744
130075
|
if (parentDir === currentDir) {
|
|
129745
130076
|
break;
|
|
129746
130077
|
}
|
|
129747
130078
|
currentDir = parentDir;
|
|
129748
130079
|
}
|
|
129749
130080
|
};
|
|
129750
|
-
addCandidate((0,
|
|
129751
|
-
addCandidate((0,
|
|
129752
|
-
addCandidate((0,
|
|
130081
|
+
addCandidate((0, import_node_path12.resolve)(cwd, "dist/apps/api-cli/server-loader.js"));
|
|
130082
|
+
addCandidate((0, import_node_path12.resolve)(dirname7, "../server-loader.js"));
|
|
130083
|
+
addCandidate((0, import_node_path12.resolve)(dirname7, "server-loader.js"));
|
|
129753
130084
|
collectAncestorCandidates(cwd);
|
|
129754
130085
|
collectAncestorCandidates(dirname7);
|
|
129755
130086
|
const resolved = candidates.find((candidate) => (0, import_node_fs6.existsSync)(candidate));
|
|
@@ -129761,11 +130092,13 @@ function resolveServerLoaderEntryPath(cwd, dirname7) {
|
|
|
129761
130092
|
function createPiAgentServerLauncher(options2) {
|
|
129762
130093
|
const cwd = options2.cwd ?? process.cwd();
|
|
129763
130094
|
return async (request) => {
|
|
130095
|
+
const spinner = createSpinner("Initializing...");
|
|
129764
130096
|
const activeEnvironment = await options2.environmentConfigService.getActiveEnvironment();
|
|
129765
130097
|
const activeProfile = await options2.authStore.getActiveProfile(activeEnvironment.apiBaseUrl);
|
|
129766
130098
|
const settingsRootPath = options2.settingsPaths.rootPath;
|
|
129767
130099
|
const agentRootPath = resolveDocyrusPiAgentRootPath(settingsRootPath);
|
|
129768
130100
|
const resourceRoot = resolvePackagedPiResourceRoot({ cwd });
|
|
130101
|
+
spinner.update("Syncing skills...");
|
|
129769
130102
|
await syncPackagedSkills({
|
|
129770
130103
|
resourceRoot,
|
|
129771
130104
|
agentRootPath
|
|
@@ -129780,18 +130113,20 @@ function createPiAgentServerLauncher(options2) {
|
|
|
129780
130113
|
settingsRootPath
|
|
129781
130114
|
})
|
|
129782
130115
|
});
|
|
130116
|
+
spinner.update("Installing skills...");
|
|
129783
130117
|
await installExternalDocyrusSkillsOnce({
|
|
129784
130118
|
agentRootPath,
|
|
129785
130119
|
cwd,
|
|
129786
130120
|
scope: options2.settingsPaths.scope,
|
|
129787
|
-
spawnCommand:
|
|
130121
|
+
spawnCommand: import_node_child_process5.spawnSync
|
|
129788
130122
|
});
|
|
129789
130123
|
installPackagedDocyrusPlatformSkill({
|
|
129790
130124
|
resourceRoot,
|
|
129791
130125
|
cwd,
|
|
129792
130126
|
scope: options2.settingsPaths.scope,
|
|
129793
|
-
spawnCommand:
|
|
130127
|
+
spawnCommand: import_node_child_process5.spawnSync
|
|
129794
130128
|
});
|
|
130129
|
+
spinner.stop();
|
|
129795
130130
|
const loaderEntryPath = resolveServerLoaderEntryPath(cwd, __dirname);
|
|
129796
130131
|
const piPackageRoot = resolveInstalledPiPackageRootPath({ cwd });
|
|
129797
130132
|
const child = (0, import_node_child_process5.spawn)(process.execPath, [loaderEntryPath], {
|
|
@@ -129801,7 +130136,7 @@ function createPiAgentServerLauncher(options2) {
|
|
|
129801
130136
|
...process.env,
|
|
129802
130137
|
PI_CODING_AGENT_DIR: agentRootPath,
|
|
129803
130138
|
PI_PACKAGE_DIR: piPackageRoot,
|
|
129804
|
-
DOCYRUS_PI_REQUEST:
|
|
130139
|
+
DOCYRUS_PI_REQUEST: serializePiAgentServerRequest(request),
|
|
129805
130140
|
DOCYRUS_PI_VERSION: options2.version || "dev"
|
|
129806
130141
|
}
|
|
129807
130142
|
});
|
|
@@ -129851,8 +130186,8 @@ async function runWithIncurSkillsOutOfDateWarningSuppressed(params) {
|
|
|
129851
130186
|
}
|
|
129852
130187
|
|
|
129853
130188
|
// src/services/tenantOpenApi.ts
|
|
129854
|
-
var
|
|
129855
|
-
var
|
|
130189
|
+
var import_promises9 = require("node:fs/promises");
|
|
130190
|
+
var import_node_path13 = require("node:path");
|
|
129856
130191
|
function resolveSourceUrl(tenantId, template) {
|
|
129857
130192
|
return template.replace("{tenantId}", encodeURIComponent(tenantId));
|
|
129858
130193
|
}
|
|
@@ -129876,16 +130211,16 @@ var TenantOpenApiService = class {
|
|
|
129876
130211
|
}
|
|
129877
130212
|
async #writeOpenApiFile(tenantId, parsedContent) {
|
|
129878
130213
|
const filePath = this.getTenantOpenApiFilePath(tenantId);
|
|
129879
|
-
await (0,
|
|
130214
|
+
await (0, import_promises9.mkdir)((0, import_node_path13.dirname)(filePath), {
|
|
129880
130215
|
recursive: true,
|
|
129881
130216
|
mode: 448
|
|
129882
130217
|
});
|
|
129883
|
-
await (0,
|
|
130218
|
+
await (0, import_promises9.writeFile)(filePath, `${JSON.stringify(parsedContent, null, 2)}
|
|
129884
130219
|
`, {
|
|
129885
130220
|
encoding: "utf8",
|
|
129886
130221
|
mode: 384
|
|
129887
130222
|
});
|
|
129888
|
-
await (0,
|
|
130223
|
+
await (0, import_promises9.chmod)(filePath, 384);
|
|
129889
130224
|
return filePath;
|
|
129890
130225
|
}
|
|
129891
130226
|
async #generateTenantOpenApiViaAuthenticatedEndpoint(tenantId, options2) {
|
|
@@ -129922,7 +130257,7 @@ var TenantOpenApiService = class {
|
|
|
129922
130257
|
throw new AuthSessionError("Tenant ID is required to resolve OpenAPI spec path.");
|
|
129923
130258
|
}
|
|
129924
130259
|
const rootPath = this.params?.rootPath || TENANT_OPENAPI_ROOT_PATH;
|
|
129925
|
-
return (0,
|
|
130260
|
+
return (0, import_node_path13.join)(rootPath, normalizedTenantId, "openapi.json");
|
|
129926
130261
|
}
|
|
129927
130262
|
async downloadTenantOpenApi(tenantId, options2 = {}) {
|
|
129928
130263
|
const normalizedTenantId = tenantId.trim();
|