@docyrus/docyrus 0.0.26 → 0.0.27
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/main.js +334 -108
- package/main.js.map +3 -3
- 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 +202 -2
- 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();
|
|
@@ -124691,7 +124691,7 @@ function buildInputSchema(args, env2, options2) {
|
|
|
124691
124691
|
// package.json
|
|
124692
124692
|
var package_default = {
|
|
124693
124693
|
name: "@docyrus/docyrus",
|
|
124694
|
-
version: "0.0.
|
|
124694
|
+
version: "0.0.27",
|
|
124695
124695
|
private: false,
|
|
124696
124696
|
description: "Docyrus API CLI",
|
|
124697
124697
|
main: "./main.js",
|
|
@@ -124906,6 +124906,7 @@ function createServerCli(dependencies) {
|
|
|
124906
124906
|
thinking: external_exports.enum(PI_AGENT_THINKING_LEVELS2).optional().describe("Thinking level"),
|
|
124907
124907
|
sessionDir: external_exports.string().optional().describe("Override session storage directory"),
|
|
124908
124908
|
apiKey: external_exports.string().optional().describe("Temporary provider API key override for this run"),
|
|
124909
|
+
auth: external_exports.string().optional().describe("Require this bearer token for all HTTP requests"),
|
|
124909
124910
|
verbose: external_exports.boolean().optional().describe("Enable verbose pi startup output")
|
|
124910
124911
|
}),
|
|
124911
124912
|
run: async (context) => {
|
|
@@ -124917,6 +124918,7 @@ function createServerCli(dependencies) {
|
|
|
124917
124918
|
thinking: context.options.thinking,
|
|
124918
124919
|
sessionDir: context.options.sessionDir,
|
|
124919
124920
|
apiKey: context.options.apiKey,
|
|
124921
|
+
auth: context.options.auth,
|
|
124920
124922
|
verbose: context.options.verbose || hasRawVerboseFlag2() ? true : void 0
|
|
124921
124923
|
});
|
|
124922
124924
|
}
|
|
@@ -126251,7 +126253,46 @@ function createCurlCli(dependencies) {
|
|
|
126251
126253
|
}
|
|
126252
126254
|
|
|
126253
126255
|
// src/commands/dsCommands.ts
|
|
126256
|
+
var import_promises3 = require("node:fs/promises");
|
|
126257
|
+
var import_node_path6 = require("node:path");
|
|
126254
126258
|
var BULK_OPERATION_LIMIT = 50;
|
|
126259
|
+
var FILE_EXTENSION_TO_CONTENT_TYPE = {
|
|
126260
|
+
".avi": "video/x-msvideo",
|
|
126261
|
+
".bmp": "image/bmp",
|
|
126262
|
+
".csv": "text/csv",
|
|
126263
|
+
".doc": "application/msword",
|
|
126264
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
126265
|
+
".flac": "audio/flac",
|
|
126266
|
+
".gif": "image/gif",
|
|
126267
|
+
".jpeg": "image/jpeg",
|
|
126268
|
+
".jpg": "image/jpeg",
|
|
126269
|
+
".json": "application/json",
|
|
126270
|
+
".m4a": "audio/m4a",
|
|
126271
|
+
".mov": "video/quicktime",
|
|
126272
|
+
".mp3": "audio/mpeg",
|
|
126273
|
+
".mp4": "video/mp4",
|
|
126274
|
+
".mpga": "audio/mpga",
|
|
126275
|
+
".ogg": "audio/ogg",
|
|
126276
|
+
".opus": "audio/opus",
|
|
126277
|
+
".pdf": "application/pdf",
|
|
126278
|
+
".png": "image/png",
|
|
126279
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
126280
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
126281
|
+
".rar": "application/x-rar-compressed",
|
|
126282
|
+
".rtf": "text/rtf",
|
|
126283
|
+
".tif": "image/tiff",
|
|
126284
|
+
".tiff": "image/tiff",
|
|
126285
|
+
".txt": "text/plain",
|
|
126286
|
+
".wav": "audio/wav",
|
|
126287
|
+
".webm": "video/webm",
|
|
126288
|
+
".webp": "image/webp",
|
|
126289
|
+
".xls": "application/vnd.ms-excel",
|
|
126290
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
126291
|
+
".yaml": "application/yaml",
|
|
126292
|
+
".yml": "application/yaml",
|
|
126293
|
+
".zip": "application/zip",
|
|
126294
|
+
".7z": "application/x-7z-compressed"
|
|
126295
|
+
};
|
|
126255
126296
|
function isRecord(value) {
|
|
126256
126297
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
126257
126298
|
}
|
|
@@ -126301,6 +126342,87 @@ function toSinglePayload(payload) {
|
|
|
126301
126342
|
}
|
|
126302
126343
|
return payload;
|
|
126303
126344
|
}
|
|
126345
|
+
async function toCommentPayload(params) {
|
|
126346
|
+
const hasStructuredPayload = normalizeOptionalString(params.data) !== void 0 || normalizeOptionalString(params.fromFile) !== void 0;
|
|
126347
|
+
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;
|
|
126348
|
+
if (hasStructuredPayload) {
|
|
126349
|
+
if (hasFieldOptions) {
|
|
126350
|
+
throw new UserInputError(
|
|
126351
|
+
"Do not mix --data/--fromFile with comment field options. Use one input style only."
|
|
126352
|
+
);
|
|
126353
|
+
}
|
|
126354
|
+
const payload2 = await readDataInput({
|
|
126355
|
+
data: params.data,
|
|
126356
|
+
fromFile: params.fromFile
|
|
126357
|
+
});
|
|
126358
|
+
return toSinglePayload(payload2);
|
|
126359
|
+
}
|
|
126360
|
+
const message = normalizeOptionalString(params.message);
|
|
126361
|
+
if (!message) {
|
|
126362
|
+
throw new UserInputError("Comment message is required. Pass --message, --data, or --fromFile.");
|
|
126363
|
+
}
|
|
126364
|
+
const payload = {
|
|
126365
|
+
message
|
|
126366
|
+
};
|
|
126367
|
+
const parentId = normalizeOptionalString(params.parentId);
|
|
126368
|
+
const assignedTo = normalizeOptionalString(params.assignedTo);
|
|
126369
|
+
const attachments = normalizeOptionalString(params.attachments);
|
|
126370
|
+
if (parentId) {
|
|
126371
|
+
payload.parentId = parentId;
|
|
126372
|
+
}
|
|
126373
|
+
if (assignedTo) {
|
|
126374
|
+
payload.assignedTo = assignedTo;
|
|
126375
|
+
}
|
|
126376
|
+
if (attachments) {
|
|
126377
|
+
payload.attachments = parseJsonData(attachments, "--attachments");
|
|
126378
|
+
}
|
|
126379
|
+
if (params.level !== void 0) {
|
|
126380
|
+
payload.level = params.level;
|
|
126381
|
+
}
|
|
126382
|
+
if (params.status !== void 0) {
|
|
126383
|
+
payload.status = params.status;
|
|
126384
|
+
}
|
|
126385
|
+
if (params.done !== void 0) {
|
|
126386
|
+
payload.done = params.done;
|
|
126387
|
+
}
|
|
126388
|
+
return payload;
|
|
126389
|
+
}
|
|
126390
|
+
function resolveAttachmentContentType(params) {
|
|
126391
|
+
const contentType = normalizeOptionalString(params.contentType);
|
|
126392
|
+
if (contentType) {
|
|
126393
|
+
return contentType;
|
|
126394
|
+
}
|
|
126395
|
+
const extension = (0, import_node_path6.extname)(params.filePath).toLowerCase();
|
|
126396
|
+
const inferredContentType = FILE_EXTENSION_TO_CONTENT_TYPE[extension];
|
|
126397
|
+
if (inferredContentType) {
|
|
126398
|
+
return inferredContentType;
|
|
126399
|
+
}
|
|
126400
|
+
throw new UserInputError(
|
|
126401
|
+
`Unable to infer content type for '${params.filePath}'. Pass --contentType explicitly.`
|
|
126402
|
+
);
|
|
126403
|
+
}
|
|
126404
|
+
async function toFileUploadBody(params) {
|
|
126405
|
+
const filePath = normalizeOptionalString(params.filePath);
|
|
126406
|
+
if (!filePath) {
|
|
126407
|
+
throw new UserInputError("File path is required.");
|
|
126408
|
+
}
|
|
126409
|
+
let fileBuffer;
|
|
126410
|
+
try {
|
|
126411
|
+
fileBuffer = await (0, import_promises3.readFile)(filePath);
|
|
126412
|
+
} catch (error48) {
|
|
126413
|
+
const message = error48 instanceof Error ? error48.message : "Unknown error";
|
|
126414
|
+
throw new UserInputError(`Unable to read file '${filePath}': ${message}`);
|
|
126415
|
+
}
|
|
126416
|
+
const fileName = (0, import_node_path6.basename)(filePath);
|
|
126417
|
+
const contentType = resolveAttachmentContentType({
|
|
126418
|
+
filePath,
|
|
126419
|
+
contentType: params.contentType
|
|
126420
|
+
});
|
|
126421
|
+
const formData = new FormData();
|
|
126422
|
+
const fileBytes = new Uint8Array(fileBuffer);
|
|
126423
|
+
formData.set("file", new Blob([fileBytes], { type: contentType }), fileName);
|
|
126424
|
+
return formData;
|
|
126425
|
+
}
|
|
126304
126426
|
function createDsCli(dependencies) {
|
|
126305
126427
|
const dsCli = Cli_exports.create("ds", {
|
|
126306
126428
|
description: "Data source commands",
|
|
@@ -126481,11 +126603,99 @@ function createDsCli(dependencies) {
|
|
|
126481
126603
|
});
|
|
126482
126604
|
}
|
|
126483
126605
|
});
|
|
126606
|
+
const commentsCli = Cli_exports.create("comments", {
|
|
126607
|
+
description: "Record comment commands",
|
|
126608
|
+
env: EnvSchema
|
|
126609
|
+
});
|
|
126610
|
+
commentsCli.command("create", {
|
|
126611
|
+
description: "Create a comment for a data source record",
|
|
126612
|
+
args: external_exports.object({
|
|
126613
|
+
appSlug: external_exports.string().min(1),
|
|
126614
|
+
dataSourceSlug: external_exports.string().min(1),
|
|
126615
|
+
recordId: external_exports.string().min(1)
|
|
126616
|
+
}),
|
|
126617
|
+
options: external_exports.object({
|
|
126618
|
+
message: external_exports.string().optional().describe("Comment message"),
|
|
126619
|
+
data: external_exports.string().optional().describe("Full JSON payload for comment DTO"),
|
|
126620
|
+
fromFile: external_exports.string().optional().describe("Path to JSON payload file"),
|
|
126621
|
+
parentId: external_exports.string().optional().describe("Parent comment ID"),
|
|
126622
|
+
assignedTo: external_exports.string().optional().describe("Assigned user ID"),
|
|
126623
|
+
attachments: external_exports.string().optional().describe("JSON attachments payload"),
|
|
126624
|
+
level: external_exports.number().optional().describe("Comment level"),
|
|
126625
|
+
status: external_exports.number().optional().describe("Comment status"),
|
|
126626
|
+
done: external_exports.boolean().optional().describe("Mark comment as done")
|
|
126627
|
+
}),
|
|
126628
|
+
run: async (context) => {
|
|
126629
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
126630
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
126631
|
+
const payload = await toCommentPayload({
|
|
126632
|
+
message: context.options.message,
|
|
126633
|
+
data: context.options.data,
|
|
126634
|
+
fromFile: context.options.fromFile,
|
|
126635
|
+
parentId: context.options.parentId,
|
|
126636
|
+
assignedTo: context.options.assignedTo,
|
|
126637
|
+
attachments: context.options.attachments,
|
|
126638
|
+
level: context.options.level,
|
|
126639
|
+
status: context.options.status,
|
|
126640
|
+
done: context.options.done
|
|
126641
|
+
});
|
|
126642
|
+
const response = await apiClient.request({
|
|
126643
|
+
method: "POST",
|
|
126644
|
+
path: `/apps/${context.args.appSlug}/data-sources/${context.args.dataSourceSlug}/items/${context.args.recordId}/comments`,
|
|
126645
|
+
body: payload
|
|
126646
|
+
});
|
|
126647
|
+
return await injectContext({
|
|
126648
|
+
apiBaseUrl,
|
|
126649
|
+
authStore: dependencies.authStore,
|
|
126650
|
+
payload: response.data
|
|
126651
|
+
});
|
|
126652
|
+
}
|
|
126653
|
+
});
|
|
126654
|
+
dsCli.command(commentsCli);
|
|
126655
|
+
const filesCli = Cli_exports.create("files", {
|
|
126656
|
+
description: "Record file attachment commands",
|
|
126657
|
+
env: EnvSchema
|
|
126658
|
+
});
|
|
126659
|
+
filesCli.command("upload", {
|
|
126660
|
+
description: "Upload a file attachment for a data source record",
|
|
126661
|
+
args: external_exports.object({
|
|
126662
|
+
appSlug: external_exports.string().min(1),
|
|
126663
|
+
dataSourceSlug: external_exports.string().min(1),
|
|
126664
|
+
recordId: external_exports.string().min(1)
|
|
126665
|
+
}),
|
|
126666
|
+
options: external_exports.object({
|
|
126667
|
+
file: external_exports.string().min(1).describe("Path to local file"),
|
|
126668
|
+
contentType: external_exports.string().optional().describe("Override file content type"),
|
|
126669
|
+
publicFile: external_exports.boolean().optional().describe("Store file in public tenant bucket")
|
|
126670
|
+
}),
|
|
126671
|
+
run: async (context) => {
|
|
126672
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
126673
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
126674
|
+
const body = await toFileUploadBody({
|
|
126675
|
+
filePath: context.options.file,
|
|
126676
|
+
contentType: context.options.contentType
|
|
126677
|
+
});
|
|
126678
|
+
const response = await apiClient.request({
|
|
126679
|
+
method: "POST",
|
|
126680
|
+
path: `/apps/${context.args.appSlug}/data-sources/${context.args.dataSourceSlug}/items/${context.args.recordId}/files/upload`,
|
|
126681
|
+
query: {
|
|
126682
|
+
publicFile: context.options.publicFile
|
|
126683
|
+
},
|
|
126684
|
+
body
|
|
126685
|
+
});
|
|
126686
|
+
return await injectContext({
|
|
126687
|
+
apiBaseUrl,
|
|
126688
|
+
authStore: dependencies.authStore,
|
|
126689
|
+
payload: response.data
|
|
126690
|
+
});
|
|
126691
|
+
}
|
|
126692
|
+
});
|
|
126693
|
+
dsCli.command(filesCli);
|
|
126484
126694
|
return dsCli;
|
|
126485
126695
|
}
|
|
126486
126696
|
|
|
126487
126697
|
// src/commands/discoverCommands.ts
|
|
126488
|
-
var
|
|
126698
|
+
var import_promises4 = require("node:fs/promises");
|
|
126489
126699
|
var SUPPORTED_HTTP_METHODS2 = [
|
|
126490
126700
|
"GET",
|
|
126491
126701
|
"POST",
|
|
@@ -126630,7 +126840,7 @@ async function loadOpenApiSpec(dependencies, tenantId, options2) {
|
|
|
126630
126840
|
let sourceUrl;
|
|
126631
126841
|
let content;
|
|
126632
126842
|
try {
|
|
126633
|
-
content = await (0,
|
|
126843
|
+
content = await (0, import_promises4.readFile)(filePath, "utf8");
|
|
126634
126844
|
} catch (error48) {
|
|
126635
126845
|
if (!isEnoentError(error48)) {
|
|
126636
126846
|
throw new UserInputError("Failed to read downloaded OpenAPI spec file.", {
|
|
@@ -126642,7 +126852,7 @@ async function loadOpenApiSpec(dependencies, tenantId, options2) {
|
|
|
126642
126852
|
downloaded = true;
|
|
126643
126853
|
sourceUrl = downloadResult.sourceUrl;
|
|
126644
126854
|
filePath = downloadResult.filePath;
|
|
126645
|
-
content = await (0,
|
|
126855
|
+
content = await (0, import_promises4.readFile)(filePath, "utf8");
|
|
126646
126856
|
}
|
|
126647
126857
|
return {
|
|
126648
126858
|
filePath,
|
|
@@ -126889,8 +127099,8 @@ function createEnvCli(dependencies) {
|
|
|
126889
127099
|
}
|
|
126890
127100
|
|
|
126891
127101
|
// src/services/studioPayload.ts
|
|
126892
|
-
var
|
|
126893
|
-
var
|
|
127102
|
+
var import_promises5 = require("node:fs/promises");
|
|
127103
|
+
var import_node_path7 = require("node:path");
|
|
126894
127104
|
async function readStdinText2() {
|
|
126895
127105
|
if (process.stdin.isTTY) {
|
|
126896
127106
|
return "";
|
|
@@ -126913,7 +127123,7 @@ async function readStudioWriteInput(params) {
|
|
|
126913
127123
|
data,
|
|
126914
127124
|
fromFile,
|
|
126915
127125
|
readStdin = readStdinText2,
|
|
126916
|
-
readFileFn = async (path3, encoding) => await (0,
|
|
127126
|
+
readFileFn = async (path3, encoding) => await (0, import_promises5.readFile)(path3, encoding)
|
|
126917
127127
|
} = params;
|
|
126918
127128
|
const trimmedData = data?.trim();
|
|
126919
127129
|
const trimmedFromFile = fromFile?.trim();
|
|
@@ -126921,7 +127131,7 @@ async function readStudioWriteInput(params) {
|
|
|
126921
127131
|
throw new UserInputError("Provide either --data or --from-file, not both.");
|
|
126922
127132
|
}
|
|
126923
127133
|
if (trimmedFromFile) {
|
|
126924
|
-
const extension = (0,
|
|
127134
|
+
const extension = (0, import_node_path7.extname)(trimmedFromFile).toLowerCase();
|
|
126925
127135
|
if (extension && extension !== ".json") {
|
|
126926
127136
|
throw new UserInputError("Studio commands support only JSON files in --from-file.");
|
|
126927
127137
|
}
|
|
@@ -127926,7 +128136,7 @@ function createStudioCli(dependencies) {
|
|
|
127926
128136
|
// src/commands/tuiCommand.ts
|
|
127927
128137
|
var import_node_child_process3 = require("node:child_process");
|
|
127928
128138
|
var import_node_fs4 = require("node:fs");
|
|
127929
|
-
var
|
|
128139
|
+
var import_node_path8 = require("node:path");
|
|
127930
128140
|
function summarizeFailure2(result) {
|
|
127931
128141
|
const stderr = result.stderr?.toString().trim();
|
|
127932
128142
|
if (stderr && stderr.length > 0) {
|
|
@@ -127943,7 +128153,7 @@ function summarizeFailure2(result) {
|
|
|
127943
128153
|
function resolveCliScriptPath() {
|
|
127944
128154
|
const argvScript = process.argv[1];
|
|
127945
128155
|
if (argvScript && argvScript.trim().length > 0) {
|
|
127946
|
-
return (0,
|
|
128156
|
+
return (0, import_node_path8.isAbsolute)(argvScript) ? argvScript : (0, import_node_path8.resolve)(process.cwd(), argvScript);
|
|
127947
128157
|
}
|
|
127948
128158
|
return __filename;
|
|
127949
128159
|
}
|
|
@@ -127954,12 +128164,12 @@ function resolveOpenTuiEntryPath(options2 = {}) {
|
|
|
127954
128164
|
const candidates = [
|
|
127955
128165
|
// Source/dev mode in monorepo. Prefer this first so Bun resolves deps via
|
|
127956
128166
|
// apps/api-cli/node_modules in workspace runs (e.g. `pnpm docyrus tui`).
|
|
127957
|
-
(0,
|
|
127958
|
-
(0,
|
|
128167
|
+
(0, import_node_path8.resolve)(cwd, "apps/api-cli/src/tui/opentuiMain.tsx"),
|
|
128168
|
+
(0, import_node_path8.resolve)(dirname7, "../tui/opentuiMain.tsx"),
|
|
127959
128169
|
// Dist mode (bundled command runtime)
|
|
127960
|
-
(0,
|
|
127961
|
-
(0,
|
|
127962
|
-
(0,
|
|
128170
|
+
(0, import_node_path8.resolve)(dirname7, "tui.mjs"),
|
|
128171
|
+
(0, import_node_path8.resolve)(dirname7, "../tui.mjs"),
|
|
128172
|
+
(0, import_node_path8.resolve)(cwd, "dist/apps/api-cli/tui.mjs")
|
|
127963
128173
|
];
|
|
127964
128174
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
127965
128175
|
if (!resolved) {
|
|
@@ -128027,6 +128237,18 @@ function createTuiCli(dependencies) {
|
|
|
128027
128237
|
|
|
128028
128238
|
// src/services/apiClient.ts
|
|
128029
128239
|
var insecureLocalhostDispatcherPromise = null;
|
|
128240
|
+
function isFormData(value) {
|
|
128241
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
128242
|
+
}
|
|
128243
|
+
function isUrlSearchParams(value) {
|
|
128244
|
+
return typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams;
|
|
128245
|
+
}
|
|
128246
|
+
function isBlob(value) {
|
|
128247
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
128248
|
+
}
|
|
128249
|
+
function isBinaryBody(value) {
|
|
128250
|
+
return isFormData(value) || isUrlSearchParams(value) || isBlob(value) || value instanceof ArrayBuffer || ArrayBuffer.isView(value);
|
|
128251
|
+
}
|
|
128030
128252
|
function normalizeResponseHeaders(headers) {
|
|
128031
128253
|
const normalized = {};
|
|
128032
128254
|
headers.forEach((value, key) => {
|
|
@@ -128137,6 +128359,8 @@ async function requestDocyrusApi(options2) {
|
|
|
128137
128359
|
if (!requestHeaders["Content-Type"] && !requestHeaders["content-type"]) {
|
|
128138
128360
|
requestHeaders["Content-Type"] = "text/plain; charset=utf-8";
|
|
128139
128361
|
}
|
|
128362
|
+
} else if (isBinaryBody(body)) {
|
|
128363
|
+
requestBody = body;
|
|
128140
128364
|
} else {
|
|
128141
128365
|
requestBody = JSON.stringify(body);
|
|
128142
128366
|
if (!requestHeaders["Content-Type"] && !requestHeaders["content-type"]) {
|
|
@@ -128744,8 +128968,8 @@ var AuthSessionService = class {
|
|
|
128744
128968
|
};
|
|
128745
128969
|
|
|
128746
128970
|
// src/services/authStore.ts
|
|
128747
|
-
var
|
|
128748
|
-
var
|
|
128971
|
+
var import_promises6 = require("node:fs/promises");
|
|
128972
|
+
var import_node_path9 = require("node:path");
|
|
128749
128973
|
function createEmptyState() {
|
|
128750
128974
|
return {
|
|
128751
128975
|
version: 2,
|
|
@@ -128784,7 +129008,7 @@ var AuthStore = class {
|
|
|
128784
129008
|
}
|
|
128785
129009
|
async readState() {
|
|
128786
129010
|
try {
|
|
128787
|
-
const raw = await (0,
|
|
129011
|
+
const raw = await (0, import_promises6.readFile)(this.authFilePath, "utf8");
|
|
128788
129012
|
const parsed = JSON.parse(raw);
|
|
128789
129013
|
const legacy = LegacyAuthSessionSchema.safeParse(parsed);
|
|
128790
129014
|
if (legacy.success) {
|
|
@@ -128820,17 +129044,17 @@ var AuthStore = class {
|
|
|
128820
129044
|
});
|
|
128821
129045
|
}
|
|
128822
129046
|
const normalized = normalizeState(validated.data);
|
|
128823
|
-
const directory = (0,
|
|
128824
|
-
await (0,
|
|
129047
|
+
const directory = (0, import_node_path9.dirname)(this.authFilePath);
|
|
129048
|
+
await (0, import_promises6.mkdir)(directory, {
|
|
128825
129049
|
recursive: true,
|
|
128826
129050
|
mode: 448
|
|
128827
129051
|
});
|
|
128828
|
-
await (0,
|
|
129052
|
+
await (0, import_promises6.writeFile)(this.authFilePath, `${JSON.stringify(normalized, null, 2)}
|
|
128829
129053
|
`, {
|
|
128830
129054
|
encoding: "utf8",
|
|
128831
129055
|
mode: 384
|
|
128832
129056
|
});
|
|
128833
|
-
await (0,
|
|
129057
|
+
await (0, import_promises6.chmod)(this.authFilePath, 384);
|
|
128834
129058
|
}
|
|
128835
129059
|
async getActiveProfile(apiBaseUrl) {
|
|
128836
129060
|
const normalizedApiBaseUrl = normalizeApiBaseUrl(apiBaseUrl);
|
|
@@ -129027,15 +129251,15 @@ var AuthStore = class {
|
|
|
129027
129251
|
await this.writeState(state);
|
|
129028
129252
|
}
|
|
129029
129253
|
async clear() {
|
|
129030
|
-
await (0,
|
|
129254
|
+
await (0, import_promises6.rm)(this.authFilePath, {
|
|
129031
129255
|
force: true
|
|
129032
129256
|
});
|
|
129033
129257
|
}
|
|
129034
129258
|
};
|
|
129035
129259
|
|
|
129036
129260
|
// src/services/environmentConfig.ts
|
|
129037
|
-
var
|
|
129038
|
-
var
|
|
129261
|
+
var import_promises7 = require("node:fs/promises");
|
|
129262
|
+
var import_node_path10 = require("node:path");
|
|
129039
129263
|
var ENVIRONMENT_ID_ALIASES = {
|
|
129040
129264
|
"local-development": "dev",
|
|
129041
129265
|
prod: "live"
|
|
@@ -129121,7 +129345,7 @@ var EnvironmentConfigService = class {
|
|
|
129121
129345
|
}
|
|
129122
129346
|
async readState() {
|
|
129123
129347
|
try {
|
|
129124
|
-
const raw = await (0,
|
|
129348
|
+
const raw = await (0, import_promises7.readFile)(this.configFilePath, "utf8");
|
|
129125
129349
|
const parsed = JSON.parse(raw);
|
|
129126
129350
|
const validated = EnvironmentConfigStateSchema.safeParse(parsed);
|
|
129127
129351
|
if (!validated.success) {
|
|
@@ -129155,17 +129379,17 @@ var EnvironmentConfigService = class {
|
|
|
129155
129379
|
});
|
|
129156
129380
|
}
|
|
129157
129381
|
const normalized = normalizeState2(validated.data);
|
|
129158
|
-
const directory = (0,
|
|
129159
|
-
await (0,
|
|
129382
|
+
const directory = (0, import_node_path10.dirname)(this.configFilePath);
|
|
129383
|
+
await (0, import_promises7.mkdir)(directory, {
|
|
129160
129384
|
recursive: true,
|
|
129161
129385
|
mode: 448
|
|
129162
129386
|
});
|
|
129163
|
-
await (0,
|
|
129387
|
+
await (0, import_promises7.writeFile)(this.configFilePath, `${JSON.stringify(normalized, null, 2)}
|
|
129164
129388
|
`, {
|
|
129165
129389
|
encoding: "utf8",
|
|
129166
129390
|
mode: 384
|
|
129167
129391
|
});
|
|
129168
|
-
await (0,
|
|
129392
|
+
await (0, import_promises7.chmod)(this.configFilePath, 384);
|
|
129169
129393
|
}
|
|
129170
129394
|
async getActiveEnvironment() {
|
|
129171
129395
|
const state = await this.#readStateWithDefaults();
|
|
@@ -129233,8 +129457,8 @@ var EnvironmentConfigService = class {
|
|
|
129233
129457
|
// src/services/piAgentLauncher.ts
|
|
129234
129458
|
var import_node_child_process4 = require("node:child_process");
|
|
129235
129459
|
var import_node_fs5 = require("node:fs");
|
|
129236
|
-
var
|
|
129237
|
-
var
|
|
129460
|
+
var import_promises8 = require("node:fs/promises");
|
|
129461
|
+
var import_node_path11 = require("node:path");
|
|
129238
129462
|
var DOCYRUS_EXTERNAL_SKILL_SOURCE = "docyrus/agent-skills";
|
|
129239
129463
|
var DOCYRUS_PACKAGED_PLATFORM_SKILL_NAME = "docyrus-platform";
|
|
129240
129464
|
var DOCYRUS_MIGRATED_SKILL_NAMES = [
|
|
@@ -129271,10 +129495,10 @@ function resolvePackagedPiResourceRoot(options2 = {}) {
|
|
|
129271
129495
|
const dirname7 = options2.dirname ?? __dirname;
|
|
129272
129496
|
const fileExists = options2.existsSyncFn ?? import_node_fs5.existsSync;
|
|
129273
129497
|
const candidates = [
|
|
129274
|
-
(0,
|
|
129275
|
-
(0,
|
|
129276
|
-
(0,
|
|
129277
|
-
(0,
|
|
129498
|
+
(0, import_node_path11.resolve)(cwd, "apps/api-cli/resources/pi-agent"),
|
|
129499
|
+
(0, import_node_path11.resolve)(dirname7, "../resources/pi-agent"),
|
|
129500
|
+
(0, import_node_path11.resolve)(dirname7, "resources/pi-agent"),
|
|
129501
|
+
(0, import_node_path11.resolve)(cwd, "dist/apps/api-cli/resources/pi-agent")
|
|
129278
129502
|
];
|
|
129279
129503
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
129280
129504
|
if (!resolved) {
|
|
@@ -129295,23 +129519,23 @@ function resolveDocyrusPiLoaderEntryPath(options2 = {}) {
|
|
|
129295
129519
|
}
|
|
129296
129520
|
};
|
|
129297
129521
|
const collectAncestorCandidates = (startDir) => {
|
|
129298
|
-
let currentDir = (0,
|
|
129522
|
+
let currentDir = (0, import_node_path11.resolve)(startDir);
|
|
129299
129523
|
while (true) {
|
|
129300
|
-
addCandidate((0,
|
|
129301
|
-
addCandidate((0,
|
|
129302
|
-
if ((0,
|
|
129303
|
-
addCandidate((0,
|
|
129524
|
+
addCandidate((0, import_node_path11.join)(currentDir, "dist", "apps", "api-cli", "agent-loader.js"));
|
|
129525
|
+
addCandidate((0, import_node_path11.join)(currentDir, "agent-loader.js"));
|
|
129526
|
+
if ((0, import_node_path11.basename)(currentDir) === "dist") {
|
|
129527
|
+
addCandidate((0, import_node_path11.join)(currentDir, "apps", "api-cli", "agent-loader.js"));
|
|
129304
129528
|
}
|
|
129305
|
-
const parentDir = (0,
|
|
129529
|
+
const parentDir = (0, import_node_path11.resolve)(currentDir, "..");
|
|
129306
129530
|
if (parentDir === currentDir) {
|
|
129307
129531
|
break;
|
|
129308
129532
|
}
|
|
129309
129533
|
currentDir = parentDir;
|
|
129310
129534
|
}
|
|
129311
129535
|
};
|
|
129312
|
-
addCandidate((0,
|
|
129313
|
-
addCandidate((0,
|
|
129314
|
-
addCandidate((0,
|
|
129536
|
+
addCandidate((0, import_node_path11.resolve)(cwd, "dist/apps/api-cli/agent-loader.js"));
|
|
129537
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "../agent-loader.js"));
|
|
129538
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "agent-loader.js"));
|
|
129315
129539
|
collectAncestorCandidates(cwd);
|
|
129316
129540
|
collectAncestorCandidates(dirname7);
|
|
129317
129541
|
const resolved = candidates.find((candidate) => fileExists(candidate));
|
|
@@ -129331,20 +129555,20 @@ function resolveDocyrusCliEntryPath(options2 = {}) {
|
|
|
129331
129555
|
if (!candidate) {
|
|
129332
129556
|
return;
|
|
129333
129557
|
}
|
|
129334
|
-
const resolvedCandidate = (0,
|
|
129558
|
+
const resolvedCandidate = (0, import_node_path11.resolve)(candidate);
|
|
129335
129559
|
if (!seen.has(resolvedCandidate)) {
|
|
129336
129560
|
seen.add(resolvedCandidate);
|
|
129337
129561
|
candidates.push(resolvedCandidate);
|
|
129338
129562
|
}
|
|
129339
129563
|
};
|
|
129340
129564
|
const argvScript = argv[1]?.trim();
|
|
129341
|
-
const normalizedArgvScript = argvScript ? argvScript.startsWith("/") ? argvScript : (0,
|
|
129565
|
+
const normalizedArgvScript = argvScript ? argvScript.startsWith("/") ? argvScript : (0, import_node_path11.resolve)(cwd, argvScript) : void 0;
|
|
129342
129566
|
if (normalizedArgvScript && normalizedArgvScript.endsWith(".js")) {
|
|
129343
129567
|
addCandidate(normalizedArgvScript);
|
|
129344
129568
|
}
|
|
129345
|
-
addCandidate((0,
|
|
129346
|
-
addCandidate((0,
|
|
129347
|
-
addCandidate((0,
|
|
129569
|
+
addCandidate((0, import_node_path11.resolve)(cwd, "dist/apps/api-cli/main.js"));
|
|
129570
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "../main.js"));
|
|
129571
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "main.js"));
|
|
129348
129572
|
if (normalizedArgvScript) {
|
|
129349
129573
|
addCandidate(normalizedArgvScript);
|
|
129350
129574
|
}
|
|
@@ -129367,28 +129591,28 @@ function resolveInstalledPiPackageRootPath(options2 = {}) {
|
|
|
129367
129591
|
}
|
|
129368
129592
|
};
|
|
129369
129593
|
const collectAncestorCandidates = (startDir) => {
|
|
129370
|
-
let currentDir = (0,
|
|
129594
|
+
let currentDir = (0, import_node_path11.resolve)(startDir);
|
|
129371
129595
|
while (true) {
|
|
129372
|
-
addCandidate((0,
|
|
129373
|
-
if ((0,
|
|
129374
|
-
addCandidate((0,
|
|
129596
|
+
addCandidate((0, import_node_path11.join)(currentDir, "node_modules", "@mariozechner", "pi-coding-agent", "package.json"));
|
|
129597
|
+
if ((0, import_node_path11.basename)(currentDir) === "node_modules") {
|
|
129598
|
+
addCandidate((0, import_node_path11.join)(currentDir, "@mariozechner", "pi-coding-agent", "package.json"));
|
|
129375
129599
|
}
|
|
129376
|
-
const parentDir = (0,
|
|
129600
|
+
const parentDir = (0, import_node_path11.resolve)(currentDir, "..");
|
|
129377
129601
|
if (parentDir === currentDir) {
|
|
129378
129602
|
break;
|
|
129379
129603
|
}
|
|
129380
129604
|
currentDir = parentDir;
|
|
129381
129605
|
}
|
|
129382
129606
|
};
|
|
129383
|
-
addCandidate((0,
|
|
129384
|
-
addCandidate((0,
|
|
129607
|
+
addCandidate((0, import_node_path11.resolve)(cwd, "apps/api-cli/node_modules/@mariozechner/pi-coding-agent/package.json"));
|
|
129608
|
+
addCandidate((0, import_node_path11.resolve)(dirname7, "../../../apps/api-cli/node_modules/@mariozechner/pi-coding-agent/package.json"));
|
|
129385
129609
|
collectAncestorCandidates(cwd);
|
|
129386
129610
|
collectAncestorCandidates(dirname7);
|
|
129387
129611
|
const resolvedPackageJson = candidates.find((candidate) => fileExists(candidate));
|
|
129388
129612
|
if (!resolvedPackageJson) {
|
|
129389
129613
|
throw new UserInputError(`Unable to locate the installed pi package root. Checked: ${candidates.join(", ")}`);
|
|
129390
129614
|
}
|
|
129391
|
-
return (0,
|
|
129615
|
+
return (0, import_node_path11.resolve)(resolvedPackageJson, "..");
|
|
129392
129616
|
}
|
|
129393
129617
|
function createPiAgentRuntimeSkill(params) {
|
|
129394
129618
|
const commandPrefix = params.scope === "global" ? "docyrus -g" : "docyrus";
|
|
@@ -129435,35 +129659,35 @@ function createPiAgentRuntimeSkill(params) {
|
|
|
129435
129659
|
].join("\n");
|
|
129436
129660
|
}
|
|
129437
129661
|
async function syncPackagedSkills(params) {
|
|
129438
|
-
const sourceSkillsRoot = (0,
|
|
129439
|
-
const targetSkillsRoot = (0,
|
|
129440
|
-
await (0,
|
|
129662
|
+
const sourceSkillsRoot = (0, import_node_path11.join)(params.resourceRoot, "skills");
|
|
129663
|
+
const targetSkillsRoot = (0, import_node_path11.join)(params.agentRootPath, "skills");
|
|
129664
|
+
await (0, import_promises8.mkdir)(targetSkillsRoot, {
|
|
129441
129665
|
recursive: true,
|
|
129442
129666
|
mode: 448
|
|
129443
129667
|
});
|
|
129444
|
-
const entries = await (0,
|
|
129668
|
+
const entries = await (0, import_promises8.readdir)(sourceSkillsRoot, {
|
|
129445
129669
|
withFileTypes: true
|
|
129446
129670
|
});
|
|
129447
129671
|
await Promise.all(DOCYRUS_MIGRATED_SKILL_NAMES.map(async (skillName) => {
|
|
129448
|
-
await (0,
|
|
129672
|
+
await (0, import_promises8.rm)((0, import_node_path11.join)(targetSkillsRoot, skillName), {
|
|
129449
129673
|
recursive: true,
|
|
129450
129674
|
force: true
|
|
129451
129675
|
});
|
|
129452
129676
|
}));
|
|
129453
129677
|
await Promise.all(entries.map(async (entry) => {
|
|
129454
|
-
await (0,
|
|
129678
|
+
await (0, import_promises8.cp)((0, import_node_path11.join)(sourceSkillsRoot, entry.name), (0, import_node_path11.join)(targetSkillsRoot, entry.name), {
|
|
129455
129679
|
recursive: true,
|
|
129456
129680
|
force: true
|
|
129457
129681
|
});
|
|
129458
129682
|
}));
|
|
129459
129683
|
}
|
|
129460
129684
|
async function writeRuntimeSkill(params) {
|
|
129461
|
-
const runtimeSkillDir = (0,
|
|
129462
|
-
await (0,
|
|
129685
|
+
const runtimeSkillDir = (0, import_node_path11.join)(params.agentRootPath, "skills", "docyrus-runtime-context");
|
|
129686
|
+
await (0, import_promises8.mkdir)(runtimeSkillDir, {
|
|
129463
129687
|
recursive: true,
|
|
129464
129688
|
mode: 448
|
|
129465
129689
|
});
|
|
129466
|
-
await (0,
|
|
129690
|
+
await (0, import_promises8.writeFile)((0, import_node_path11.join)(runtimeSkillDir, "SKILL.md"), `${params.content}
|
|
129467
129691
|
`, {
|
|
129468
129692
|
encoding: "utf8",
|
|
129469
129693
|
mode: 384
|
|
@@ -129476,10 +129700,10 @@ function resolveNpmCommand() {
|
|
|
129476
129700
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
129477
129701
|
}
|
|
129478
129702
|
function resolveManagedDiffityInstallRoot(agentRootPath) {
|
|
129479
|
-
return (0,
|
|
129703
|
+
return (0, import_node_path11.join)(agentRootPath, "tools", "diffity");
|
|
129480
129704
|
}
|
|
129481
129705
|
function resolveManagedDiffityExecutablePath(agentRootPath) {
|
|
129482
|
-
return (0,
|
|
129706
|
+
return (0, import_node_path11.join)(
|
|
129483
129707
|
resolveManagedDiffityInstallRoot(agentRootPath),
|
|
129484
129708
|
"node_modules",
|
|
129485
129709
|
".bin",
|
|
@@ -129487,10 +129711,10 @@ function resolveManagedDiffityExecutablePath(agentRootPath) {
|
|
|
129487
129711
|
);
|
|
129488
129712
|
}
|
|
129489
129713
|
function prependPathEntry(entry, existingPath) {
|
|
129490
|
-
const values = existingPath ? existingPath.split(
|
|
129714
|
+
const values = existingPath ? existingPath.split(import_node_path11.delimiter).filter((value) => value.trim().length > 0) : [];
|
|
129491
129715
|
const normalizedEntry = entry.trim();
|
|
129492
129716
|
const remaining = values.filter((value) => value !== normalizedEntry);
|
|
129493
|
-
return [normalizedEntry, ...remaining].join(
|
|
129717
|
+
return [normalizedEntry, ...remaining].join(import_node_path11.delimiter);
|
|
129494
129718
|
}
|
|
129495
129719
|
function createDocyrusSkillsInstallArgs(scope) {
|
|
129496
129720
|
const args = [
|
|
@@ -129528,7 +129752,7 @@ function createPackagedDocyrusPlatformInstallArgs(params) {
|
|
|
129528
129752
|
return args;
|
|
129529
129753
|
}
|
|
129530
129754
|
async function installExternalDocyrusSkillsOnce(params) {
|
|
129531
|
-
const markerPath = (0,
|
|
129755
|
+
const markerPath = (0, import_node_path11.join)(params.agentRootPath, DOCYRUS_EXTERNAL_SKILL_MARKER_FILE);
|
|
129532
129756
|
if ((0, import_node_fs5.existsSync)(markerPath)) {
|
|
129533
129757
|
return;
|
|
129534
129758
|
}
|
|
@@ -129547,7 +129771,7 @@ async function installExternalDocyrusSkillsOnce(params) {
|
|
|
129547
129771
|
);
|
|
129548
129772
|
return;
|
|
129549
129773
|
}
|
|
129550
|
-
await (0,
|
|
129774
|
+
await (0, import_promises8.writeFile)(markerPath, `${JSON.stringify({
|
|
129551
129775
|
source: DOCYRUS_EXTERNAL_SKILL_SOURCE,
|
|
129552
129776
|
skills: DOCYRUS_MIGRATED_SKILL_NAMES,
|
|
129553
129777
|
agents: DOCYRUS_EXTERNAL_SKILL_AGENT_IDS,
|
|
@@ -129561,7 +129785,7 @@ async function installExternalDocyrusSkillsOnce(params) {
|
|
|
129561
129785
|
}
|
|
129562
129786
|
async function ensureManagedDiffityInstalled(params) {
|
|
129563
129787
|
const executablePath = resolveManagedDiffityExecutablePath(params.agentRootPath);
|
|
129564
|
-
const binDir = (0,
|
|
129788
|
+
const binDir = (0, import_node_path11.dirname)(executablePath);
|
|
129565
129789
|
if ((0, import_node_fs5.existsSync)(executablePath)) {
|
|
129566
129790
|
return {
|
|
129567
129791
|
available: true,
|
|
@@ -129600,7 +129824,7 @@ async function ensureManagedDiffityInstalled(params) {
|
|
|
129600
129824
|
};
|
|
129601
129825
|
}
|
|
129602
129826
|
function resolvePackagedDocyrusPlatformSkillPath(resourceRoot) {
|
|
129603
|
-
return (0,
|
|
129827
|
+
return (0, import_node_path11.join)(resourceRoot, "skills", DOCYRUS_PACKAGED_PLATFORM_SKILL_NAME);
|
|
129604
129828
|
}
|
|
129605
129829
|
function installPackagedDocyrusPlatformSkill(params) {
|
|
129606
129830
|
const skillSourcePath = resolvePackagedDocyrusPlatformSkillPath(params.resourceRoot);
|
|
@@ -129721,8 +129945,10 @@ function createPiAgentLauncher(options2) {
|
|
|
129721
129945
|
// src/services/piAgentServerLauncher.ts
|
|
129722
129946
|
var import_node_child_process5 = require("node:child_process");
|
|
129723
129947
|
var import_node_fs6 = require("node:fs");
|
|
129724
|
-
var
|
|
129725
|
-
|
|
129948
|
+
var import_node_path12 = require("node:path");
|
|
129949
|
+
function serializePiAgentServerRequest(request) {
|
|
129950
|
+
return JSON.stringify(request);
|
|
129951
|
+
}
|
|
129726
129952
|
function resolveServerLoaderEntryPath(cwd, dirname7) {
|
|
129727
129953
|
const seen = /* @__PURE__ */ new Set();
|
|
129728
129954
|
const candidates = [];
|
|
@@ -129733,23 +129959,23 @@ function resolveServerLoaderEntryPath(cwd, dirname7) {
|
|
|
129733
129959
|
}
|
|
129734
129960
|
};
|
|
129735
129961
|
const collectAncestorCandidates = (startDir) => {
|
|
129736
|
-
let currentDir = (0,
|
|
129962
|
+
let currentDir = (0, import_node_path12.resolve)(startDir);
|
|
129737
129963
|
while (true) {
|
|
129738
|
-
addCandidate((0,
|
|
129739
|
-
addCandidate((0,
|
|
129740
|
-
if ((0,
|
|
129741
|
-
addCandidate((0,
|
|
129964
|
+
addCandidate((0, import_node_path12.join)(currentDir, "dist", "apps", "api-cli", "server-loader.js"));
|
|
129965
|
+
addCandidate((0, import_node_path12.join)(currentDir, "server-loader.js"));
|
|
129966
|
+
if ((0, import_node_path12.basename)(currentDir) === "dist") {
|
|
129967
|
+
addCandidate((0, import_node_path12.join)(currentDir, "apps", "api-cli", "server-loader.js"));
|
|
129742
129968
|
}
|
|
129743
|
-
const parentDir = (0,
|
|
129969
|
+
const parentDir = (0, import_node_path12.resolve)(currentDir, "..");
|
|
129744
129970
|
if (parentDir === currentDir) {
|
|
129745
129971
|
break;
|
|
129746
129972
|
}
|
|
129747
129973
|
currentDir = parentDir;
|
|
129748
129974
|
}
|
|
129749
129975
|
};
|
|
129750
|
-
addCandidate((0,
|
|
129751
|
-
addCandidate((0,
|
|
129752
|
-
addCandidate((0,
|
|
129976
|
+
addCandidate((0, import_node_path12.resolve)(cwd, "dist/apps/api-cli/server-loader.js"));
|
|
129977
|
+
addCandidate((0, import_node_path12.resolve)(dirname7, "../server-loader.js"));
|
|
129978
|
+
addCandidate((0, import_node_path12.resolve)(dirname7, "server-loader.js"));
|
|
129753
129979
|
collectAncestorCandidates(cwd);
|
|
129754
129980
|
collectAncestorCandidates(dirname7);
|
|
129755
129981
|
const resolved = candidates.find((candidate) => (0, import_node_fs6.existsSync)(candidate));
|
|
@@ -129784,13 +130010,13 @@ function createPiAgentServerLauncher(options2) {
|
|
|
129784
130010
|
agentRootPath,
|
|
129785
130011
|
cwd,
|
|
129786
130012
|
scope: options2.settingsPaths.scope,
|
|
129787
|
-
spawnCommand:
|
|
130013
|
+
spawnCommand: import_node_child_process5.spawnSync
|
|
129788
130014
|
});
|
|
129789
130015
|
installPackagedDocyrusPlatformSkill({
|
|
129790
130016
|
resourceRoot,
|
|
129791
130017
|
cwd,
|
|
129792
130018
|
scope: options2.settingsPaths.scope,
|
|
129793
|
-
spawnCommand:
|
|
130019
|
+
spawnCommand: import_node_child_process5.spawnSync
|
|
129794
130020
|
});
|
|
129795
130021
|
const loaderEntryPath = resolveServerLoaderEntryPath(cwd, __dirname);
|
|
129796
130022
|
const piPackageRoot = resolveInstalledPiPackageRootPath({ cwd });
|
|
@@ -129801,7 +130027,7 @@ function createPiAgentServerLauncher(options2) {
|
|
|
129801
130027
|
...process.env,
|
|
129802
130028
|
PI_CODING_AGENT_DIR: agentRootPath,
|
|
129803
130029
|
PI_PACKAGE_DIR: piPackageRoot,
|
|
129804
|
-
DOCYRUS_PI_REQUEST:
|
|
130030
|
+
DOCYRUS_PI_REQUEST: serializePiAgentServerRequest(request),
|
|
129805
130031
|
DOCYRUS_PI_VERSION: options2.version || "dev"
|
|
129806
130032
|
}
|
|
129807
130033
|
});
|
|
@@ -129851,8 +130077,8 @@ async function runWithIncurSkillsOutOfDateWarningSuppressed(params) {
|
|
|
129851
130077
|
}
|
|
129852
130078
|
|
|
129853
130079
|
// src/services/tenantOpenApi.ts
|
|
129854
|
-
var
|
|
129855
|
-
var
|
|
130080
|
+
var import_promises9 = require("node:fs/promises");
|
|
130081
|
+
var import_node_path13 = require("node:path");
|
|
129856
130082
|
function resolveSourceUrl(tenantId, template) {
|
|
129857
130083
|
return template.replace("{tenantId}", encodeURIComponent(tenantId));
|
|
129858
130084
|
}
|
|
@@ -129876,16 +130102,16 @@ var TenantOpenApiService = class {
|
|
|
129876
130102
|
}
|
|
129877
130103
|
async #writeOpenApiFile(tenantId, parsedContent) {
|
|
129878
130104
|
const filePath = this.getTenantOpenApiFilePath(tenantId);
|
|
129879
|
-
await (0,
|
|
130105
|
+
await (0, import_promises9.mkdir)((0, import_node_path13.dirname)(filePath), {
|
|
129880
130106
|
recursive: true,
|
|
129881
130107
|
mode: 448
|
|
129882
130108
|
});
|
|
129883
|
-
await (0,
|
|
130109
|
+
await (0, import_promises9.writeFile)(filePath, `${JSON.stringify(parsedContent, null, 2)}
|
|
129884
130110
|
`, {
|
|
129885
130111
|
encoding: "utf8",
|
|
129886
130112
|
mode: 384
|
|
129887
130113
|
});
|
|
129888
|
-
await (0,
|
|
130114
|
+
await (0, import_promises9.chmod)(filePath, 384);
|
|
129889
130115
|
return filePath;
|
|
129890
130116
|
}
|
|
129891
130117
|
async #generateTenantOpenApiViaAuthenticatedEndpoint(tenantId, options2) {
|
|
@@ -129922,7 +130148,7 @@ var TenantOpenApiService = class {
|
|
|
129922
130148
|
throw new AuthSessionError("Tenant ID is required to resolve OpenAPI spec path.");
|
|
129923
130149
|
}
|
|
129924
130150
|
const rootPath = this.params?.rootPath || TENANT_OPENAPI_ROOT_PATH;
|
|
129925
|
-
return (0,
|
|
130151
|
+
return (0, import_node_path13.join)(rootPath, normalizedTenantId, "openapi.json");
|
|
129926
130152
|
}
|
|
129927
130153
|
async downloadTenantOpenApi(tenantId, options2 = {}) {
|
|
129928
130154
|
const normalizedTenantId = tenantId.trim();
|