@docyrus/docyrus 0.0.69 → 0.0.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docyrus/docyrus",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "private": false,
5
5
  "description": "Docyrus API CLI",
6
6
  "main": "./main.js",
@@ -14,8 +14,8 @@
14
14
  "@clack/prompts": "^0.11.0",
15
15
  "@ff-labs/fff-node": "0.6.4",
16
16
  "@hono/node-server": "^1.19.13",
17
- "@mariozechner/pi-ai": "0.70.6",
18
- "@mariozechner/pi-coding-agent": "0.70.6",
17
+ "@mariozechner/pi-ai": "0.71.1",
18
+ "@mariozechner/pi-coding-agent": "0.71.1",
19
19
  "@modelcontextprotocol/ext-apps": "^1.2.2",
20
20
  "@modelcontextprotocol/sdk": "^1.25.1",
21
21
  "@mozilla/readability": "^0.6.0",
package/server-loader.js CHANGED
@@ -18788,6 +18788,11 @@ var DEFAULT_LOGIN_SCOPES = [
18788
18788
  var DOCYRUS_SETTINGS_DIR_NAME = ".docyrus";
18789
18789
  var DOCYRUS_PI_DIR_NAME = "pi";
18790
18790
  var DOCYRUS_PI_AGENT_DIR_NAME = "agent";
18791
+ var DOCYRUS_TRACKED_DIR_NAME = "docyrus";
18792
+ var DOCYRUS_TRACKED_AGENT_DIR_NAME = "agent";
18793
+ var DOCYRUS_TRACKED_KNOWLEDGE_INDEX_DIR_NAME = "knowledge-index";
18794
+ var DOCYRUS_TRACKED_SESSION_CONFIG_DIR_NAME = "session-config";
18795
+ var DOCYRUS_TRACKED_SKILLS_DIR_NAME = "skills";
18791
18796
  var AUTH_DIR_PATH = (0, import_node_path3.join)((0, import_node_os.homedir)(), DOCYRUS_SETTINGS_DIR_NAME);
18792
18797
  var AUTH_FILE_PATH = (0, import_node_path3.join)(AUTH_DIR_PATH, "auth.json");
18793
18798
  var CONFIG_FILE_PATH = (0, import_node_path3.join)(AUTH_DIR_PATH, "config.json");
@@ -18823,6 +18828,21 @@ var DEFAULT_ENVIRONMENTS = [
18823
18828
  apiBaseUrl: "https://localhost:3366"
18824
18829
  }
18825
18830
  ];
18831
+ function getLocalDocyrusTrackedRootPath(cwd = process.cwd()) {
18832
+ return (0, import_node_path3.join)(cwd, DOCYRUS_TRACKED_DIR_NAME);
18833
+ }
18834
+ function resolveDocyrusTrackedAgentRootPath(cwd = process.cwd()) {
18835
+ return (0, import_node_path3.join)(getLocalDocyrusTrackedRootPath(cwd), DOCYRUS_TRACKED_AGENT_DIR_NAME);
18836
+ }
18837
+ function resolveDocyrusTrackedSessionConfigRootPath(cwd = process.cwd()) {
18838
+ return (0, import_node_path3.join)(resolveDocyrusTrackedAgentRootPath(cwd), DOCYRUS_TRACKED_SESSION_CONFIG_DIR_NAME);
18839
+ }
18840
+ function resolveDocyrusTrackedSkillsRootPath(cwd = process.cwd()) {
18841
+ return (0, import_node_path3.join)(resolveDocyrusTrackedAgentRootPath(cwd), DOCYRUS_TRACKED_SKILLS_DIR_NAME);
18842
+ }
18843
+ function resolveDocyrusKnowledgeIndexRootPath(cwd = process.cwd()) {
18844
+ return (0, import_node_path3.join)(getLocalDocyrusTrackedRootPath(cwd), DOCYRUS_TRACKED_KNOWLEDGE_INDEX_DIR_NAME);
18845
+ }
18826
18846
  function normalizeApiBaseUrl(apiBaseUrl) {
18827
18847
  const trimmed = apiBaseUrl.trim();
18828
18848
  if (!trimmed) {
@@ -35602,6 +35622,25 @@ function parseAskUserResponseFromToolOutput(output) {
35602
35622
  }
35603
35623
 
35604
35624
  // src/server/eventBridge.ts
35625
+ function extractAssistantEventErrorMessage(error48) {
35626
+ if (error48 instanceof Error) {
35627
+ return error48.message;
35628
+ }
35629
+ if (typeof error48 === "string") {
35630
+ return error48;
35631
+ }
35632
+ if (error48 && typeof error48 === "object") {
35633
+ const candidate = error48.errorMessage;
35634
+ if (typeof candidate === "string" && candidate.trim().length > 0) {
35635
+ return candidate;
35636
+ }
35637
+ const reason = error48.stopReason;
35638
+ if (typeof reason === "string" && reason.trim().length > 0) {
35639
+ return `Agent stopped: ${reason}`;
35640
+ }
35641
+ }
35642
+ return "Unknown agent error";
35643
+ }
35605
35644
  function createEventBridge(params) {
35606
35645
  const { messageId, onChunk, onDone, onError, onAskUser } = params;
35607
35646
  const activeToolCalls = /* @__PURE__ */ new Map();
@@ -35653,12 +35692,27 @@ function createEventBridge(params) {
35653
35692
  handleToolExecutionEnd(event);
35654
35693
  break;
35655
35694
  }
35695
+ case "message_end": {
35696
+ handleMessageEnd(event);
35697
+ break;
35698
+ }
35656
35699
  case "agent_end": {
35657
35700
  onDone();
35658
35701
  break;
35659
35702
  }
35660
35703
  }
35661
35704
  }
35705
+ function handleMessageEnd(event) {
35706
+ const message = event.message;
35707
+ if (!message) {
35708
+ return;
35709
+ }
35710
+ const stopReason = message.stopReason;
35711
+ if (stopReason !== "error" && stopReason !== "aborted") {
35712
+ return;
35713
+ }
35714
+ onError(extractAssistantEventErrorMessage(message));
35715
+ }
35662
35716
  function handleMessageUpdate(event) {
35663
35717
  const assistantEvent = event.assistantMessageEvent;
35664
35718
  if (!assistantEvent) {
@@ -35759,8 +35813,7 @@ function createEventBridge(params) {
35759
35813
  break;
35760
35814
  }
35761
35815
  case "error": {
35762
- const errorMessage = assistantEvent.error instanceof Error ? assistantEvent.error.message : typeof assistantEvent.error === "string" ? assistantEvent.error : "Unknown agent error";
35763
- onError(errorMessage);
35816
+ onError(extractAssistantEventErrorMessage(assistantEvent.error));
35764
35817
  break;
35765
35818
  }
35766
35819
  }
@@ -41120,14 +41173,11 @@ function readJsonFile(filePath) {
41120
41173
  return null;
41121
41174
  }
41122
41175
  }
41123
- function hashWorkspace(projectRoot) {
41124
- return (0, import_node_crypto.createHash)("sha256").update((0, import_node_path12.resolve)(projectRoot)).digest("hex").slice(0, 16);
41125
- }
41126
- function resolveKnowledgeCacheRoot(settingsRootPath, projectRoot) {
41127
- return (0, import_node_path12.join)(settingsRootPath, "knowledge", hashWorkspace(projectRoot));
41176
+ function resolveKnowledgeCacheRoot(projectRoot) {
41177
+ return resolveDocyrusKnowledgeIndexRootPath(projectRoot);
41128
41178
  }
41129
- function resolveKnowledgeVectorsDbPath(settingsRootPath, projectRoot) {
41130
- return (0, import_node_path12.join)(resolveKnowledgeCacheRoot(settingsRootPath, projectRoot), "vectors.db");
41179
+ function resolveKnowledgeVectorsDbPath(projectRoot) {
41180
+ return (0, import_node_path12.join)(resolveKnowledgeCacheRoot(projectRoot), "vectors.db");
41131
41181
  }
41132
41182
  function normalizeApiBase(apiBase) {
41133
41183
  const trimmed = apiBase.trim().replace(/\/+$/u, "");
@@ -41304,12 +41354,12 @@ function createKnowledgeDb(db) {
41304
41354
  }
41305
41355
  };
41306
41356
  }
41307
- function openKnowledgeDb(settingsRootPath, projectRoot) {
41308
- const cacheRoot = resolveKnowledgeCacheRoot(settingsRootPath, projectRoot);
41357
+ function openKnowledgeDb(projectRoot) {
41358
+ const cacheRoot = resolveKnowledgeCacheRoot(projectRoot);
41309
41359
  if (!(0, import_node_fs4.existsSync)(cacheRoot)) {
41310
41360
  (0, import_node_fs4.mkdirSync)(cacheRoot, { recursive: true });
41311
41361
  }
41312
- return createKnowledgeDb(new import_promise.default(resolveKnowledgeVectorsDbPath(settingsRootPath, projectRoot), {}));
41362
+ return createKnowledgeDb(new import_promise.default(resolveKnowledgeVectorsDbPath(projectRoot), {}));
41313
41363
  }
41314
41364
  async function ensureKnowledgeSchema(db, dimensions) {
41315
41365
  await db.execute(
@@ -41364,7 +41414,7 @@ function hashContent(text3) {
41364
41414
  return (0, import_node_crypto.createHash)("sha256").update(text3).digest("hex");
41365
41415
  }
41366
41416
  async function indexKnowledgeSections(params) {
41367
- const db = openKnowledgeDb(params.settingsRootPath, params.projectRoot);
41417
+ const db = openKnowledgeDb(params.projectRoot);
41368
41418
  try {
41369
41419
  await ensureKnowledgeSchema(db, params.provider.dimensions);
41370
41420
  const sections = flattenSections(await loadAllSections(params.knowledgeDir));
@@ -41434,7 +41484,7 @@ async function indexKnowledgeSections(params) {
41434
41484
  }
41435
41485
  }
41436
41486
  async function searchKnowledgeSections(params) {
41437
- const db = openKnowledgeDb(params.settingsRootPath, params.projectRoot);
41487
+ const db = openKnowledgeDb(params.projectRoot);
41438
41488
  try {
41439
41489
  await ensureKnowledgeSchema(db, params.provider.dimensions);
41440
41490
  const [queryVector] = await embedTexts([params.query], params.provider);
@@ -42890,9 +42940,7 @@ async function clearProviderConfig(params) {
42890
42940
  // src/agent/providerCatalog.ts
42891
42941
  var OAUTH_ONLY_PROVIDER_IDS = /* @__PURE__ */ new Set([
42892
42942
  "github-copilot",
42893
- "openai-codex",
42894
- "google-gemini-cli",
42895
- "google-antigravity"
42943
+ "openai-codex"
42896
42944
  ]);
42897
42945
  var PROVIDER_LABELS = {
42898
42946
  anthropic: "Anthropic (Claude)",
@@ -42916,8 +42964,6 @@ var PROVIDER_LABELS = {
42916
42964
  "opencode-go": "OpenCode Go",
42917
42965
  "kimi-coding": "Kimi Coding",
42918
42966
  "custom-openai": "Custom OpenAI-Compatible",
42919
- "google-gemini-cli": "Google Gemini CLI",
42920
- "google-antigravity": "Google Antigravity",
42921
42967
  "openai-codex": "OpenAI Codex",
42922
42968
  "github-copilot": "GitHub Copilot"
42923
42969
  };
@@ -42928,9 +42974,7 @@ var PROVIDER_HINTS = {
42928
42974
  "azure-openai-responses": "API key + base URL/resource + deployment",
42929
42975
  "amazon-bedrock": "AWS profile or access key pair",
42930
42976
  "openai-codex": "browser auth",
42931
- "github-copilot": "browser auth",
42932
- "google-gemini-cli": "browser auth",
42933
- "google-antigravity": "browser auth"
42977
+ "github-copilot": "browser auth"
42934
42978
  };
42935
42979
  function humanizeProviderId(providerId) {
42936
42980
  return providerId.split("-").map((part) => {
@@ -44394,34 +44438,48 @@ async function installSkill(params) {
44394
44438
  );
44395
44439
  }
44396
44440
  }
44397
- const skillsDir = getSkillsDir(params.agentDir);
44398
- const destination = (0, import_node_path21.join)(skillsDir, skillName);
44399
- const existed = await dirExists(destination);
44441
+ const tracked = params.request.track !== false;
44442
+ const runtimeSkillsDir = getSkillsDir(params.agentDir);
44443
+ const runtimeDestination = (0, import_node_path21.join)(runtimeSkillsDir, skillName);
44444
+ const trackedDestination = tracked ? (0, import_node_path21.join)(params.trackedSkillsRoot, skillName) : "";
44445
+ const runtimeExisted = await dirExists(runtimeDestination);
44446
+ const trackedExisted = tracked ? await dirExists(trackedDestination) : false;
44447
+ const existed = runtimeExisted || trackedExisted;
44400
44448
  if (existed && !params.request.overwrite) {
44401
44449
  throw new SkillError(
44402
44450
  "ALREADY_EXISTS",
44403
44451
  `Skill "${skillName}" already exists. Set overwrite=true to replace it.`
44404
44452
  );
44405
44453
  }
44406
- await (0, import_promises17.mkdir)(skillsDir, { recursive: true });
44454
+ if (tracked) {
44455
+ await (0, import_promises17.mkdir)(params.trackedSkillsRoot, { recursive: true });
44456
+ }
44457
+ await (0, import_promises17.mkdir)(runtimeSkillsDir, { recursive: true });
44407
44458
  switch (params.request.sourceType) {
44408
- case "local":
44459
+ case "local": {
44460
+ const primaryDestination = tracked ? trackedDestination : runtimeDestination;
44409
44461
  await copyLocalSkill({
44410
44462
  source: params.request.source,
44411
44463
  cwd: params.cwd,
44412
- destination
44464
+ destination: primaryDestination
44413
44465
  });
44466
+ if (tracked) {
44467
+ await (0, import_promises17.rm)(runtimeDestination, { recursive: true, force: true });
44468
+ await (0, import_promises17.cp)(trackedDestination, runtimeDestination, { recursive: true });
44469
+ }
44414
44470
  break;
44471
+ }
44415
44472
  }
44416
- const fmName = await readSkillFrontmatterName(destination);
44417
- const computedHash = await computeSkillHash(destination);
44473
+ const fmName = await readSkillFrontmatterName(runtimeDestination);
44474
+ const computedHash = await computeSkillHash(runtimeDestination);
44418
44475
  const installedAt = (/* @__PURE__ */ new Date()).toISOString();
44419
44476
  const lock = await readSkillsLockFile(params.agentDir);
44420
44477
  lock.skills[skillName] = {
44421
44478
  source: params.request.source,
44422
44479
  sourceType: params.request.sourceType,
44423
44480
  computedHash,
44424
- installedAt
44481
+ installedAt,
44482
+ tracked
44425
44483
  };
44426
44484
  await writeSkillsLockFile(params.agentDir, lock);
44427
44485
  return {
@@ -44431,7 +44489,8 @@ async function installSkill(params) {
44431
44489
  sourceType: params.request.sourceType,
44432
44490
  computedHash,
44433
44491
  installedAt,
44434
- overwritten: existed
44492
+ overwritten: existed,
44493
+ tracked
44435
44494
  };
44436
44495
  }
44437
44496
  async function uninstallSkill(params) {
@@ -44450,9 +44509,11 @@ async function uninstallSkill(params) {
44450
44509
  targetDir = detail.skill.directory;
44451
44510
  }
44452
44511
  const destination = (0, import_node_path21.join)(skillsDir, targetDir);
44512
+ const trackedDestination = (0, import_node_path21.join)(params.trackedSkillsRoot, targetDir);
44453
44513
  const lock = await readSkillsLockFile(params.agentDir);
44454
44514
  const lockKey = lock.skills[targetDir] ? targetDir : lock.skills[params.name] ? params.name : null;
44455
44515
  await (0, import_promises17.rm)(destination, { recursive: true, force: true });
44516
+ await (0, import_promises17.rm)(trackedDestination, { recursive: true, force: true });
44456
44517
  if (lockKey) {
44457
44518
  delete lock.skills[lockKey];
44458
44519
  await writeSkillsLockFile(params.agentDir, lock);
@@ -44732,23 +44793,22 @@ var BROWSER_TOOL_SCHEMAS = [
44732
44793
  var import_node_fs13 = require("node:fs");
44733
44794
  var path5 = __toESM(require("node:path"));
44734
44795
  var DEFAULT_CONFIG = { autoCommit: false };
44735
- function configPath(agentDir, sessionId) {
44736
- return path5.join(agentDir, "session-config", `${sessionId}.json`);
44796
+ function configPath(sessionConfigDir, sessionId) {
44797
+ return path5.join(sessionConfigDir, `${sessionId}.json`);
44737
44798
  }
44738
- async function readSessionConfig(agentDir, sessionId) {
44799
+ async function readSessionConfig(sessionConfigDir, sessionId) {
44739
44800
  try {
44740
- const raw2 = await import_node_fs13.promises.readFile(configPath(agentDir, sessionId), "utf-8");
44801
+ const raw2 = await import_node_fs13.promises.readFile(configPath(sessionConfigDir, sessionId), "utf-8");
44741
44802
  return { ...DEFAULT_CONFIG, ...JSON.parse(raw2) };
44742
44803
  } catch {
44743
44804
  return { ...DEFAULT_CONFIG };
44744
44805
  }
44745
44806
  }
44746
- async function writeSessionConfig(agentDir, sessionId, patch) {
44747
- const dir = path5.join(agentDir, "session-config");
44748
- await import_node_fs13.promises.mkdir(dir, { recursive: true });
44749
- const current = await readSessionConfig(agentDir, sessionId);
44807
+ async function writeSessionConfig(sessionConfigDir, sessionId, patch) {
44808
+ await import_node_fs13.promises.mkdir(sessionConfigDir, { recursive: true });
44809
+ const current = await readSessionConfig(sessionConfigDir, sessionId);
44750
44810
  const next = { ...current, ...patch };
44751
- await import_node_fs13.promises.writeFile(configPath(agentDir, sessionId), JSON.stringify(next, null, 2), "utf-8");
44811
+ await import_node_fs13.promises.writeFile(configPath(sessionConfigDir, sessionId), JSON.stringify(next, null, 2), "utf-8");
44752
44812
  return next;
44753
44813
  }
44754
44814
 
@@ -44954,9 +45014,7 @@ async function searchKnowledgeForServer(params) {
44954
45014
  if (!knowledgeDir) {
44955
45015
  return { knowledgeDir: null, provider: null, matches: [] };
44956
45016
  }
44957
- const provider = await getKnowledgeSearchProviderInfo({
44958
- settingsRootPath: params.settingsRootPath
44959
- });
45017
+ const provider = await getKnowledgeSearchProviderInfo({});
44960
45018
  if (!provider.provider || !provider.info) {
44961
45019
  return {
44962
45020
  knowledgeDir,
@@ -44969,14 +45027,12 @@ async function searchKnowledgeForServer(params) {
44969
45027
  await indexKnowledgeSections({
44970
45028
  knowledgeDir,
44971
45029
  projectRoot: context.projectRoot,
44972
- settingsRootPath: params.settingsRootPath,
44973
45030
  provider: provider.provider
44974
45031
  });
44975
45032
  const matches = await searchKnowledgeSections({
44976
45033
  query: params.query,
44977
45034
  knowledgeDir,
44978
45035
  projectRoot: context.projectRoot,
44979
- settingsRootPath: params.settingsRootPath,
44980
45036
  limit: Math.max(1, Math.min(params.limit ?? 5, 50)),
44981
45037
  provider: provider.provider
44982
45038
  });
@@ -45420,13 +45476,27 @@ async function createAgentServer(params) {
45420
45476
  let extensionUICleanup;
45421
45477
  if (extensionUIBridge) {
45422
45478
  extensionUIBridge.setRequestHandler((request) => {
45423
- writeChunk(request);
45479
+ const { type: _omit, id, ...rest } = request;
45480
+ writeChunk({
45481
+ type: "data-extension-ui-request",
45482
+ id,
45483
+ data: { type: _omit, id, ...rest },
45484
+ transient: true
45485
+ });
45424
45486
  });
45425
45487
  extensionUICleanup = () => {
45426
45488
  extensionUIBridge.setRequestHandler(() => {
45427
45489
  });
45428
45490
  };
45429
45491
  }
45492
+ let errorChunkEmitted = false;
45493
+ function writeErrorChunk(errorText) {
45494
+ if (errorChunkEmitted) {
45495
+ return;
45496
+ }
45497
+ errorChunkEmitted = true;
45498
+ writeChunk({ type: "error", errorText });
45499
+ }
45430
45500
  const bridge = createEventBridge({
45431
45501
  messageId,
45432
45502
  onChunk: writeChunk,
@@ -45435,13 +45505,17 @@ async function createAgentServer(params) {
45435
45505
  },
45436
45506
  onDone: () => {
45437
45507
  extensionUICleanup?.();
45508
+ const sessionError = activeSession.errorMessage;
45509
+ if (sessionError && sessionError.trim().length > 0) {
45510
+ writeErrorChunk(sessionError);
45511
+ }
45438
45512
  writeChunk({ type: "finish-step" });
45439
45513
  writeChunk({ type: "finish" });
45440
45514
  closeController();
45441
45515
  },
45442
45516
  onError: (errorText) => {
45443
45517
  extensionUICleanup?.();
45444
- writeChunk({ type: "error", errorText });
45518
+ writeErrorChunk(errorText);
45445
45519
  writeChunk({ type: "finish-step" });
45446
45520
  writeChunk({ type: "finish" });
45447
45521
  closeController();
@@ -45457,6 +45531,10 @@ async function createAgentServer(params) {
45457
45531
  if (!activeSession.isStreaming) {
45458
45532
  unsubscribe();
45459
45533
  extensionUICleanup?.();
45534
+ const sessionError = activeSession.errorMessage;
45535
+ if (sessionError && sessionError.trim().length > 0) {
45536
+ writeErrorChunk(sessionError);
45537
+ }
45460
45538
  writeChunk({ type: "finish-step" });
45461
45539
  writeChunk({ type: "finish" });
45462
45540
  closeController();
@@ -45464,7 +45542,7 @@ async function createAgentServer(params) {
45464
45542
  }).catch((error48) => {
45465
45543
  const errorMessage = error48 instanceof Error ? error48.message : String(error48);
45466
45544
  extensionUICleanup?.();
45467
- writeChunk({ type: "error", errorText: errorMessage });
45545
+ writeErrorChunk(errorMessage);
45468
45546
  writeChunk({ type: "finish-step" });
45469
45547
  writeChunk({ type: "finish" });
45470
45548
  unsubscribe();
@@ -45543,7 +45621,7 @@ async function createAgentServer(params) {
45543
45621
  return c.json({ error: "Created session is missing an id" }, 500);
45544
45622
  }
45545
45623
  if (body2.autoCommit !== void 0) {
45546
- await writeSessionConfig(context.agentDir, sessionId, { autoCommit: body2.autoCommit });
45624
+ await writeSessionConfig(resolveDocyrusTrackedSessionConfigRootPath(context.cwd), sessionId, { autoCommit: body2.autoCommit });
45547
45625
  }
45548
45626
  const sessions = await sessionManager.list();
45549
45627
  const match2 = sessions.find((session) => session.id === sessionId);
@@ -45563,7 +45641,7 @@ async function createAgentServer(params) {
45563
45641
  app.get("/api/sessions/:sessionId/config", async (c) => {
45564
45642
  const sessionId = c.req.param("sessionId");
45565
45643
  try {
45566
- const config2 = await readSessionConfig(context.agentDir, sessionId);
45644
+ const config2 = await readSessionConfig(resolveDocyrusTrackedSessionConfigRootPath(context.cwd), sessionId);
45567
45645
  return c.json({ sessionId, ...config2 });
45568
45646
  } catch (error48) {
45569
45647
  const message = error48 instanceof Error ? error48.message : String(error48);
@@ -45574,13 +45652,42 @@ async function createAgentServer(params) {
45574
45652
  const sessionId = c.req.param("sessionId");
45575
45653
  try {
45576
45654
  const body2 = await c.req.json();
45577
- const config2 = await writeSessionConfig(context.agentDir, sessionId, body2);
45655
+ const config2 = await writeSessionConfig(resolveDocyrusTrackedSessionConfigRootPath(context.cwd), sessionId, body2);
45578
45656
  return c.json({ ok: true, sessionId, ...config2 });
45579
45657
  } catch (error48) {
45580
45658
  const message = error48 instanceof Error ? error48.message : String(error48);
45581
45659
  return c.json({ error: message }, 500);
45582
45660
  }
45583
45661
  });
45662
+ app.delete("/api/sessions/:sessionId", async (c) => {
45663
+ const sessionId = c.req.param("sessionId");
45664
+ try {
45665
+ const activeId = activeSession.id?.trim();
45666
+ if (activeId && activeId === sessionId) {
45667
+ return c.json({
45668
+ error: "Cannot delete the active session. Create or switch to a different session first."
45669
+ }, 409);
45670
+ }
45671
+ const sessions = await sessionManager.list();
45672
+ const match2 = sessions.find((s) => s.id === sessionId);
45673
+ if (!match2) {
45674
+ return c.json({ error: "Session not found" }, 404);
45675
+ }
45676
+ if (match2.path) {
45677
+ await (0, import_promises18.rm)(match2.path, { force: true });
45678
+ }
45679
+ const sessionConfigPath = (0, import_node_path22.join)(
45680
+ resolveDocyrusTrackedSessionConfigRootPath(context.cwd),
45681
+ `${sessionId}.json`
45682
+ );
45683
+ await (0, import_promises18.rm)(sessionConfigPath, { force: true }).catch(() => {
45684
+ });
45685
+ return c.body(null, 204);
45686
+ } catch (error48) {
45687
+ const message = error48 instanceof Error ? error48.message : String(error48);
45688
+ return c.json({ error: message }, 500);
45689
+ }
45690
+ });
45584
45691
  app.get("/api/sessions/:sessionId/messages", async (c) => {
45585
45692
  const sessionId = c.req.param("sessionId");
45586
45693
  try {
@@ -45780,7 +45887,6 @@ async function createAgentServer(params) {
45780
45887
  const limit = Number(c.req.query("limit") ?? 5);
45781
45888
  const result = await searchKnowledgeForServer({
45782
45889
  cwd: context.cwd,
45783
- settingsRootPath,
45784
45890
  query,
45785
45891
  limit: Number.isFinite(limit) ? limit : 5
45786
45892
  });
@@ -47132,10 +47238,12 @@ async function createAgentServer(params) {
47132
47238
  source: body2.source,
47133
47239
  sourceType: body2.sourceType,
47134
47240
  name: body2.name,
47135
- overwrite: body2.overwrite === true
47241
+ overwrite: body2.overwrite === true,
47242
+ track: body2.track !== false
47136
47243
  };
47137
47244
  const result = await installSkill({
47138
47245
  agentDir: context.agentDir,
47246
+ trackedSkillsRoot: resolveDocyrusTrackedSkillsRootPath(context.cwd),
47139
47247
  cwd: context.cwd,
47140
47248
  request
47141
47249
  });
@@ -47149,6 +47257,7 @@ async function createAgentServer(params) {
47149
47257
  try {
47150
47258
  const result = await uninstallSkill({
47151
47259
  agentDir: context.agentDir,
47260
+ trackedSkillsRoot: resolveDocyrusTrackedSkillsRootPath(context.cwd),
47152
47261
  name: skillName
47153
47262
  });
47154
47263
  return c.json({ ok: true, ...result });
@@ -47307,6 +47416,8 @@ async function createAgentServer(params) {
47307
47416
  process.stderr.write(` GET /api/sessions \u2014 list sessions
47308
47417
  `);
47309
47418
  process.stderr.write(` POST /api/sessions \u2014 create a new session
47419
+ `);
47420
+ process.stderr.write(` DEL /api/sessions/:sessionId \u2014 delete a session
47310
47421
  `);
47311
47422
  process.stderr.write(` GET /api/sessions/:sessionId/messages \u2014 session messages
47312
47423
  `);
@@ -47585,6 +47696,9 @@ function createServerSessionAdapter(params) {
47585
47696
  get isStreaming() {
47586
47697
  return params.session.isStreaming;
47587
47698
  },
47699
+ get errorMessage() {
47700
+ return params.session.errorMessage;
47701
+ },
47588
47702
  get model() {
47589
47703
  return params.session.model;
47590
47704
  },
@@ -47922,7 +48036,7 @@ async function main() {
47922
48036
  process.env.PI_SKIP_VERSION_CHECK = "1";
47923
48037
  settingsManager.setQuietStartup(true);
47924
48038
  settingsManager.setCollapseChangelog(true);
47925
- settingsManager.setLastChangelogVersion(version2);
48039
+ settingsManager.setLastChangelogVersion(pi.VERSION || version2);
47926
48040
  }
47927
48041
  renderStartupSplash(version2);
47928
48042
  const spinner = createSpinner("Loading agent...");