agentxl 1.0.0 → 1.1.2

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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +352 -197
  3. package/bin/agentxl-folder-picker.exe +0 -0
  4. package/bin/agentxl.js +44 -8
  5. package/dist/agent/models.d.ts +9 -9
  6. package/dist/agent/models.d.ts.map +1 -1
  7. package/dist/agent/models.js +44 -8
  8. package/dist/agent/models.js.map +1 -1
  9. package/dist/agent/prompt/folder-context.d.ts +26 -0
  10. package/dist/agent/prompt/folder-context.d.ts.map +1 -0
  11. package/dist/agent/prompt/folder-context.js +105 -0
  12. package/dist/agent/prompt/folder-context.js.map +1 -0
  13. package/dist/agent/prompt/system-prompt.d.ts +21 -0
  14. package/dist/agent/prompt/system-prompt.d.ts.map +1 -0
  15. package/dist/agent/prompt/system-prompt.js +130 -0
  16. package/dist/agent/prompt/system-prompt.js.map +1 -0
  17. package/dist/agent/session.d.ts +10 -4
  18. package/dist/agent/session.d.ts.map +1 -1
  19. package/dist/agent/session.js +53 -15
  20. package/dist/agent/session.js.map +1 -1
  21. package/dist/agent/tools/excel.d.ts +24 -0
  22. package/dist/agent/tools/excel.d.ts.map +1 -0
  23. package/dist/agent/tools/excel.js +132 -0
  24. package/dist/agent/tools/excel.js.map +1 -0
  25. package/dist/server/document-converter.d.ts +71 -0
  26. package/dist/server/document-converter.d.ts.map +1 -0
  27. package/dist/server/document-converter.js +353 -0
  28. package/dist/server/document-converter.js.map +1 -0
  29. package/dist/server/excel-bridge.d.ts +38 -0
  30. package/dist/server/excel-bridge.d.ts.map +1 -0
  31. package/dist/server/excel-bridge.js +75 -0
  32. package/dist/server/excel-bridge.js.map +1 -0
  33. package/dist/server/folder-picker.d.ts +9 -0
  34. package/dist/server/folder-picker.d.ts.map +1 -0
  35. package/dist/server/folder-picker.js +204 -0
  36. package/dist/server/folder-picker.js.map +1 -0
  37. package/dist/server/folder-scanner.d.ts +43 -0
  38. package/dist/server/folder-scanner.d.ts.map +1 -0
  39. package/dist/server/folder-scanner.js +161 -0
  40. package/dist/server/folder-scanner.js.map +1 -0
  41. package/dist/server/http.d.ts +19 -0
  42. package/dist/server/http.d.ts.map +1 -0
  43. package/dist/server/http.js +62 -0
  44. package/dist/server/http.js.map +1 -0
  45. package/dist/server/index.d.ts +16 -4
  46. package/dist/server/index.d.ts.map +1 -1
  47. package/dist/server/index.js +70 -246
  48. package/dist/server/index.js.map +1 -1
  49. package/dist/server/json-store.d.ts +19 -0
  50. package/dist/server/json-store.d.ts.map +1 -0
  51. package/dist/server/json-store.js +37 -0
  52. package/dist/server/json-store.js.map +1 -0
  53. package/dist/server/routes/agent.d.ts +16 -0
  54. package/dist/server/routes/agent.d.ts.map +1 -0
  55. package/dist/server/routes/agent.js +196 -0
  56. package/dist/server/routes/agent.js.map +1 -0
  57. package/dist/server/routes/excel.d.ts +10 -0
  58. package/dist/server/routes/excel.d.ts.map +1 -0
  59. package/dist/server/routes/excel.js +41 -0
  60. package/dist/server/routes/excel.js.map +1 -0
  61. package/dist/server/routes/folder.d.ts +15 -0
  62. package/dist/server/routes/folder.d.ts.map +1 -0
  63. package/dist/server/routes/folder.js +184 -0
  64. package/dist/server/routes/folder.js.map +1 -0
  65. package/dist/server/routes/workbook.d.ts +7 -0
  66. package/dist/server/routes/workbook.d.ts.map +1 -0
  67. package/dist/server/routes/workbook.js +31 -0
  68. package/dist/server/routes/workbook.js.map +1 -0
  69. package/dist/server/static.d.ts +12 -0
  70. package/dist/server/static.d.ts.map +1 -0
  71. package/dist/server/static.js +83 -0
  72. package/dist/server/static.js.map +1 -0
  73. package/dist/server/workbook-folder-store.d.ts +24 -0
  74. package/dist/server/workbook-folder-store.d.ts.map +1 -0
  75. package/dist/server/workbook-folder-store.js +76 -0
  76. package/dist/server/workbook-folder-store.js.map +1 -0
  77. package/dist/server/workbook-identity.d.ts +8 -0
  78. package/dist/server/workbook-identity.d.ts.map +1 -0
  79. package/dist/server/workbook-identity.js +57 -0
  80. package/dist/server/workbook-identity.js.map +1 -0
  81. package/manifest/manifest-hosted.xml +107 -0
  82. package/package.json +24 -10
  83. package/taskpane/dist/assets/index-BnD8psE_.js +224 -0
  84. package/taskpane/dist/assets/index-BuAcDfRq.css +1 -0
  85. package/taskpane/dist/index.html +2 -2
  86. package/taskpane/dist/assets/index-6sMpIYxE.css +0 -1
  87. package/taskpane/dist/assets/index-DyLrQ3Aa.js +0 -164
Binary file
package/bin/agentxl.js CHANGED
@@ -5,14 +5,18 @@ import { resolve, join, dirname } from "path";
5
5
  import { fileURLToPath } from "url";
6
6
  import { homedir } from "os";
7
7
  import { createInterface } from "readline";
8
+ import { config as loadDotenv } from "dotenv";
9
+
10
+ // Load .env from project root (before any other imports)
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+ const projectRoot = resolve(__dirname, "..");
14
+ loadDotenv({ path: join(projectRoot, ".env") });
8
15
 
9
16
  // ---------------------------------------------------------------------------
10
17
  // Package info
11
18
  // ---------------------------------------------------------------------------
12
19
 
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
15
-
16
20
  const pkgPath = join(__dirname, "..", "package.json");
17
21
  const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
18
22
  const VERSION = pkg.version;
@@ -91,19 +95,18 @@ async function checkAuth() {
91
95
  const piAuthPath = join(homedir(), ".pi", "agent", "auth.json");
92
96
  const agentxlAuthPath = join(homedir(), ".agentxl", "auth.json");
93
97
  const authPath = existsSync(piAuthPath) ? piAuthPath : agentxlAuthPath;
94
- const authStorage = new AuthStorage(authPath);
98
+ const authStorage = AuthStorage.create(authPath);
95
99
 
96
100
  return authStorage.list().length > 0;
97
101
  }
98
102
 
99
103
  async function runAuthFlow() {
100
104
  const { AuthStorage } = await import("@mariozechner/pi-coding-agent");
101
- const { getOAuthProviders } = await import("@mariozechner/pi-ai");
102
105
 
103
106
  const piAuthPath = join(homedir(), ".pi", "agent", "auth.json");
104
107
  const agentxlAuthPath = join(homedir(), ".agentxl", "auth.json");
105
108
  const authPath = existsSync(piAuthPath) ? piAuthPath : agentxlAuthPath;
106
- const authStorage = new AuthStorage(authPath);
109
+ const authStorage = AuthStorage.create(authPath);
107
110
 
108
111
  // Check if already authenticated
109
112
  if (authStorage.list().length > 0) {
@@ -130,7 +133,7 @@ async function runAuthFlow() {
130
133
  `);
131
134
 
132
135
  // Build choices — OAuth providers + API key
133
- const oauthProviders = getOAuthProviders();
136
+ const oauthProviders = authStorage.getOAuthProviders();
134
137
  const choices = [];
135
138
  for (const p of oauthProviders) {
136
139
  choices.push({ type: "oauth", id: p.id, name: p.name, provider: p });
@@ -254,14 +257,16 @@ async function start() {
254
257
  `);
255
258
 
256
259
  // ── Step 1: Load modules ───────────────────────────────────────────────
257
- let ensureCerts, startServer, stopServer, setVerbose;
260
+ let ensureCerts, startServer, stopServer, setVerbose, getFolderPickerStrategy;
258
261
  try {
259
262
  const certs = await import("../dist/server/certs.js");
260
263
  const server = await import("../dist/server/index.js");
264
+ const picker = await import("../dist/server/folder-picker.js");
261
265
  ensureCerts = certs.ensureCerts;
262
266
  startServer = server.startServer;
263
267
  stopServer = server.stopServer;
264
268
  setVerbose = server.setVerbose;
269
+ getFolderPickerStrategy = picker.getFolderPickerStrategy;
265
270
  } catch (err) {
266
271
  step("❌", "Could not load AgentXL server modules");
267
272
  console.error(" Run 'npm run build' first to compile TypeScript.");
@@ -293,6 +298,37 @@ async function start() {
293
298
  process.exit(1);
294
299
  }
295
300
 
301
+ // ── Step 5: OCR status ─────────────────────────────────────────────────
302
+ if (process.env.AZURE_MISTRAL_ENDPOINT && process.env.AZURE_MISTRAL_API_KEY) {
303
+ step("✅", "OCR ready (Azure Mistral)");
304
+ } else if (process.env.MISTRAL_API_KEY) {
305
+ step("✅", "OCR ready (Mistral direct)");
306
+ } else {
307
+ step("ℹ️", "OCR not configured — scanned PDFs won't be readable");
308
+ step(" ", "Set AZURE_MISTRAL_ENDPOINT + AZURE_MISTRAL_API_KEY in .env");
309
+ }
310
+
311
+ // ── Step 6: Folder picker strategy ────────────────────────────────────
312
+ const pickerStrategy = getFolderPickerStrategy();
313
+ const pickerLabels = {
314
+ "native-helper": "Native folder picker helper",
315
+ "powershell": "PowerShell folder picker (fallback)",
316
+ "osascript": "macOS folder picker (osascript)",
317
+ "manual-only": "Manual path entry only",
318
+ };
319
+ const pickerLabel = pickerLabels[pickerStrategy.method] || pickerStrategy.method;
320
+ if (pickerStrategy.method === "native-helper") {
321
+ step("✅", `Folder picker: ${pickerLabel}`);
322
+ } else if (pickerStrategy.method === "powershell" || pickerStrategy.method === "osascript") {
323
+ step("⚠️", `Folder picker: ${pickerLabel}`);
324
+ if (pickerStrategy.platform === "win32") {
325
+ step(" ", "Build the native helper for a better experience:");
326
+ step(" ", " npm run build:folder-picker:win");
327
+ }
328
+ } else {
329
+ step("ℹ️", `Folder picker: ${pickerLabel}`);
330
+ }
331
+
296
332
  // ── Post-start guidance ────────────────────────────────────────────────
297
333
  const manifestPath = resolve(__dirname, "..", "manifest", "manifest.xml");
298
334
  const manifestExists = existsSync(manifestPath);
@@ -1,21 +1,21 @@
1
1
  /**
2
- * Default model selection per provider.
2
+ * Default model selection.
3
3
  *
4
- * Checks providers in order: Anthropic OpenRouter OpenAI.
5
- * Prefers subscriptions (OAuth) over API keys subscriptions are already paid for.
6
- * Returns the first model that has auth configured.
4
+ * First honors the model configured in Pi settings (`defaultProvider` /
5
+ * `defaultModel`), then falls back to AgentXL's built-in preference order.
7
6
  */
8
7
  import type { Model, Api } from "@mariozechner/pi-ai";
9
- import type { ModelRegistry } from "@mariozechner/pi-coding-agent";
8
+ import { type ModelRegistry } from "@mariozechner/pi-coding-agent";
10
9
  /**
11
10
  * Get the best available model based on configured auth.
12
11
  *
13
12
  * Priority:
14
- * 1. Subscriptions (OAuth) Anthropic, OpenAI Codex (already paid for)
15
- * 2. API keys OpenRouter, OpenAI, etc.
13
+ * 1. Pi settings (`defaultProvider` / `defaultModel`) if that model is available
14
+ * 2. Subscriptions (OAuth) from AgentXL's preferred fallback list
15
+ * 3. API keys from AgentXL's preferred fallback list
16
+ * 4. First available authenticated model
16
17
  *
17
- * Within each tier, checks PREFERRED_MODELS in order.
18
18
  * Returns null if no provider has auth configured.
19
19
  */
20
- export declare function getDefaultModel(modelRegistry: ModelRegistry): Model<Api> | null;
20
+ export declare function getDefaultModel(modelRegistry: ModelRegistry, cwd?: string): Model<Api> | null;
21
21
  //# sourceMappingURL=models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/agent/models.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAUnE;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,aAAa,GAC3B,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAsBnB"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/agent/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AA8BpF;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,aAAa,EAC5B,GAAG,CAAC,EAAE,MAAM,GACX,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAyCnB"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Default model selection per provider.
2
+ * Default model selection.
3
3
  *
4
- * Checks providers in order: Anthropic OpenRouter OpenAI.
5
- * Prefers subscriptions (OAuth) over API keys subscriptions are already paid for.
6
- * Returns the first model that has auth configured.
4
+ * First honors the model configured in Pi settings (`defaultProvider` /
5
+ * `defaultModel`), then falls back to AgentXL's built-in preference order.
7
6
  */
7
+ import { SettingsManager } from "@mariozechner/pi-coding-agent";
8
8
  /** Provider → preferred model ID, checked in priority order. */
9
9
  const PREFERRED_MODELS = [
10
10
  { provider: "anthropic", modelId: "claude-sonnet-4-20250514" },
@@ -12,21 +12,57 @@ const PREFERRED_MODELS = [
12
12
  { provider: "openrouter", modelId: "anthropic/claude-sonnet-4" },
13
13
  { provider: "openai", modelId: "gpt-4o" },
14
14
  ];
15
+ /** Read the user's configured default model from Pi settings, if available. */
16
+ function getConfiguredModelPreference(cwd) {
17
+ try {
18
+ const settings = SettingsManager.create(cwd || process.cwd());
19
+ const provider = settings.getDefaultProvider()?.trim();
20
+ const modelId = settings.getDefaultModel()?.trim();
21
+ if (!provider && !modelId)
22
+ return null;
23
+ return {
24
+ provider: provider || undefined,
25
+ modelId: modelId || undefined,
26
+ };
27
+ }
28
+ catch {
29
+ // Invalid/missing settings should not break model resolution.
30
+ return null;
31
+ }
32
+ }
15
33
  /**
16
34
  * Get the best available model based on configured auth.
17
35
  *
18
36
  * Priority:
19
- * 1. Subscriptions (OAuth) Anthropic, OpenAI Codex (already paid for)
20
- * 2. API keys OpenRouter, OpenAI, etc.
37
+ * 1. Pi settings (`defaultProvider` / `defaultModel`) if that model is available
38
+ * 2. Subscriptions (OAuth) from AgentXL's preferred fallback list
39
+ * 3. API keys from AgentXL's preferred fallback list
40
+ * 4. First available authenticated model
21
41
  *
22
- * Within each tier, checks PREFERRED_MODELS in order.
23
42
  * Returns null if no provider has auth configured.
24
43
  */
25
- export function getDefaultModel(modelRegistry) {
44
+ export function getDefaultModel(modelRegistry, cwd) {
26
45
  // Only consider models that have auth configured
27
46
  const available = modelRegistry.getAvailable();
28
47
  if (available.length === 0)
29
48
  return null;
49
+ // First honor Pi's configured default model/provider when possible.
50
+ const configured = getConfiguredModelPreference(cwd);
51
+ if (configured?.provider && configured?.modelId) {
52
+ const exact = available.find((m) => m.provider === configured.provider && m.id === configured.modelId);
53
+ if (exact)
54
+ return exact;
55
+ }
56
+ if (configured?.modelId) {
57
+ const byId = available.find((m) => m.id === configured.modelId);
58
+ if (byId)
59
+ return byId;
60
+ }
61
+ if (configured?.provider) {
62
+ const byProvider = available.find((m) => m.provider === configured.provider);
63
+ if (byProvider)
64
+ return byProvider;
65
+ }
30
66
  // Split into OAuth (subscriptions) vs API key models
31
67
  const oauthModels = available.filter((m) => modelRegistry.isUsingOAuth(m));
32
68
  const apiKeyModels = available.filter((m) => !modelRegistry.isUsingOAuth(m));
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/agent/models.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,gEAAgE;AAChE,MAAM,gBAAgB,GAAiD;IACrE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,0BAA0B,EAAE;IAC9D,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE;IAChD,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,2BAA2B,EAAE;IAChE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE;CAC1C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAC7B,aAA4B;IAE5B,iDAAiD;IACjD,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAC;IAC/C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAExC,qDAAqD;IACrD,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,C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I,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;IACpC,CAAC;IAED,qDAAqD;IACrD,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7E,8DAA8D;IAC9D,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC;QAC/C,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,gBAAgB,EAAE,CAAC;YACrD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CACrB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,KAAK,OAAO,CACnD,CAAC;YACF,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Build the per-message folder context block.
3
+ *
4
+ * This block is prepended to every user message and tells the agent:
5
+ * - Which folder is linked
6
+ * - What files are available (with sizes)
7
+ * - Which PDFs have been pre-converted to markdown
8
+ * - How to access XLSX / DOCX files (binary → code)
9
+ * - How to access text / CSV / MD files (read tool)
10
+ *
11
+ * Behavioral rules (citation format, review-before-write, extraction
12
+ * workflow) live in the system prompt — see ./system-prompt.ts.
13
+ * This module is file-inventory only.
14
+ */
15
+ import type { FolderInventory } from "../../server/folder-scanner.js";
16
+ /** Max supported files to list individually in context. */
17
+ export declare const MAX_FILES_IN_CONTEXT = 50;
18
+ /** Format file size for human-readable display. */
19
+ export declare function formatFileSize(bytes: number): string;
20
+ /**
21
+ * Build a folder context block to prepend to the agent message.
22
+ * Contains only the file inventory and access instructions — no
23
+ * behavioral rules (those are in the system prompt).
24
+ */
25
+ export declare function buildFolderContext(folderPath: string, inventory: FolderInventory): string;
26
+ //# sourceMappingURL=folder-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder-context.d.ts","sourceRoot":"","sources":["../../../src/agent/prompt/folder-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,mDAAmD;AACnD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,eAAe,GACzB,MAAM,CA4GR"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Build the per-message folder context block.
3
+ *
4
+ * This block is prepended to every user message and tells the agent:
5
+ * - Which folder is linked
6
+ * - What files are available (with sizes)
7
+ * - Which PDFs have been pre-converted to markdown
8
+ * - How to access XLSX / DOCX files (binary → code)
9
+ * - How to access text / CSV / MD files (read tool)
10
+ *
11
+ * Behavioral rules (citation format, review-before-write, extraction
12
+ * workflow) live in the system prompt — see ./system-prompt.ts.
13
+ * This module is file-inventory only.
14
+ */
15
+ import { listConvertedFiles } from "../../server/document-converter.js";
16
+ /** Max supported files to list individually in context. */
17
+ export const MAX_FILES_IN_CONTEXT = 50;
18
+ /** Format file size for human-readable display. */
19
+ export function formatFileSize(bytes) {
20
+ if (bytes < 1024)
21
+ return `${bytes} B`;
22
+ if (bytes < 1024 * 1024)
23
+ return `${Math.round(bytes / 1024)} KB`;
24
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
25
+ }
26
+ /**
27
+ * Build a folder context block to prepend to the agent message.
28
+ * Contains only the file inventory and access instructions — no
29
+ * behavioral rules (those are in the system prompt).
30
+ */
31
+ export function buildFolderContext(folderPath, inventory) {
32
+ const lines = [];
33
+ lines.push("[AgentXL — Linked Folder]");
34
+ lines.push("");
35
+ lines.push(`Folder: ${folderPath}`);
36
+ lines.push(`${inventory.supportedFiles} supported file${inventory.supportedFiles !== 1 ? "s" : ""}, ${inventory.totalFiles} total`);
37
+ lines.push("");
38
+ lines.push("IMPORTANT: All file paths MUST be absolute paths under this folder.");
39
+ // ── Supported files ────────────────────────────────────────────────────
40
+ const supported = inventory.files.filter((f) => f.supported);
41
+ const unsupported = inventory.files.filter((f) => !f.supported);
42
+ if (supported.length > 0) {
43
+ lines.push("");
44
+ lines.push("Supported files:");
45
+ const shown = supported.slice(0, MAX_FILES_IN_CONTEXT);
46
+ for (const f of shown) {
47
+ lines.push(`- ${f.relativePath} (${formatFileSize(f.sizeBytes)})`);
48
+ }
49
+ if (supported.length > MAX_FILES_IN_CONTEXT) {
50
+ lines.push(` ... and ${supported.length - MAX_FILES_IN_CONTEXT} more supported files`);
51
+ }
52
+ }
53
+ if (unsupported.length > 0) {
54
+ lines.push("");
55
+ const unsupportedNames = unsupported
56
+ .slice(0, 10)
57
+ .map((f) => f.name)
58
+ .join(", ");
59
+ const suffix = unsupported.length > 10
60
+ ? ` and ${unsupported.length - 10} more`
61
+ : "";
62
+ lines.push(`Unsupported files (cannot read): ${unsupportedNames}${suffix}`);
63
+ }
64
+ // ── PDF conversions ────────────────────────────────────────────────────
65
+ const conversions = listConvertedFiles(inventory);
66
+ if (conversions.length > 0) {
67
+ lines.push("");
68
+ lines.push("📄 PDF files (pre-converted to Markdown):");
69
+ lines.push("Read the .md version, NOT the raw PDF.");
70
+ for (const c of conversions) {
71
+ lines.push(`- ${c.source} → READ: "${folderPath}/${c.converted}"`);
72
+ }
73
+ }
74
+ // ── XLSX handling ──────────────────────────────────────────────────────
75
+ const xlsxFiles = supported.filter((f) => f.extension === ".xlsx" || f.extension === ".xls");
76
+ if (xlsxFiles.length > 0) {
77
+ lines.push("");
78
+ lines.push("📊 Excel files — do NOT read with the read tool (binary).");
79
+ lines.push("Use bash + xlsx npm package:");
80
+ lines.push("```");
81
+ lines.push(`node -e "const XLSX = require('xlsx'); const wb = XLSX.readFile('${xlsxFiles[0].absolutePath}'); const ws = wb.Sheets[wb.SheetNames[0]]; console.log(JSON.stringify(XLSX.utils.sheet_to_json(ws), null, 2));"`);
82
+ lines.push("```");
83
+ }
84
+ // ── DOCX handling ──────────────────────────────────────────────────────
85
+ const docxFiles = supported.filter((f) => f.extension === ".docx" || f.extension === ".doc");
86
+ if (docxFiles.length > 0) {
87
+ lines.push("");
88
+ lines.push("📝 Word files — do NOT read with the read tool (binary).");
89
+ lines.push("Use bash + mammoth npm package:");
90
+ lines.push("```");
91
+ lines.push(`node -e "const mammoth = require('mammoth'); mammoth.convertToMarkdown({path: '${docxFiles[0].absolutePath}'}).then(r => console.log(r.value));"`);
92
+ lines.push("```");
93
+ }
94
+ // ── Quick access examples ──────────────────────────────────────────────
95
+ lines.push("");
96
+ lines.push("File access:");
97
+ lines.push(`- List: ls "${folderPath}"`);
98
+ const textExample = supported.find((f) => ![".pdf", ".xlsx", ".xls", ".docx", ".doc"].includes(f.extension));
99
+ if (textExample) {
100
+ lines.push(`- Read text file: read "${textExample.absolutePath}"`);
101
+ }
102
+ lines.push(`- Search: grep with path "${folderPath}"`);
103
+ return lines.join("\n");
104
+ }
105
+ //# sourceMappingURL=folder-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder-context.js","sourceRoot":"","sources":["../../../src/agent/prompt/folder-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;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,KAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;QACvE,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CACR,kFAAkF,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,uCAAuC,CACnJ,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,0EAA0E;IAE1E,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,eAAe,UAAU,GAAG,CAAC,CAAC;IAEzC,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAChC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CACzE,CAAC;IACF,IAAI,WAAW,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,2BAA2B,WAAW,CAAC,YAAY,GAAG,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,6BAA6B,UAAU,GAAG,CAAC,CAAC;IAEvD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * AgentXL system prompt — appended on top of Pi's built-in system prompt.
3
+ *
4
+ * This is the behavioral layer that makes the agent act like a
5
+ * document-to-Excel agent with show-your-work traceability.
6
+ *
7
+ * Pi's base prompt handles:
8
+ * - tool descriptions (read, bash, edit, write, custom tools)
9
+ * - tool usage guidelines
10
+ * - skills, context files, AGENTS.md
11
+ * - date/time, cwd
12
+ *
13
+ * This prompt adds:
14
+ * - AgentXL identity and workflow rules
15
+ * - Show-your-work traceability (not a permission gate)
16
+ * - Citation format and traceability rules
17
+ * - Excel comment API guidance (no .note)
18
+ * - _AgentXL_Sources audit sheet spec
19
+ */
20
+ export declare const AGENTXL_SYSTEM_PROMPT: string;
21
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/prompt/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,eAAO,MAAM,qBAAqB,QA0G1B,CAAC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * AgentXL system prompt — appended on top of Pi's built-in system prompt.
3
+ *
4
+ * This is the behavioral layer that makes the agent act like a
5
+ * document-to-Excel agent with show-your-work traceability.
6
+ *
7
+ * Pi's base prompt handles:
8
+ * - tool descriptions (read, bash, edit, write, custom tools)
9
+ * - tool usage guidelines
10
+ * - skills, context files, AGENTS.md
11
+ * - date/time, cwd
12
+ *
13
+ * This prompt adds:
14
+ * - AgentXL identity and workflow rules
15
+ * - Show-your-work traceability (not a permission gate)
16
+ * - Citation format and traceability rules
17
+ * - Excel comment API guidance (no .note)
18
+ * - _AgentXL_Sources audit sheet spec
19
+ */
20
+ // ---------------------------------------------------------------------------
21
+ // Core identity + behavioral rules (set once per session via appendSystemPrompt)
22
+ // ---------------------------------------------------------------------------
23
+ export const AGENTXL_SYSTEM_PROMPT = `
24
+ # AgentXL — Document-to-Excel Agent
25
+
26
+ You are AgentXL, a document-to-Excel agent. You help users turn source
27
+ documents into traceable Excel workpapers. You are NOT a generic
28
+ spreadsheet chatbot.
29
+
30
+ ## Core Principle
31
+
32
+ **Documents are the source. Excel is the destination.**
33
+
34
+ Every value you write into Excel must be grounded in evidence from the
35
+ user's linked document folder. If you cannot find evidence, say so.
36
+ Do not fabricate data.
37
+
38
+ ## Show Your Work
39
+
40
+ When you write values into Excel, always show the user what you found
41
+ and where it came from — in your response text, not as a separate
42
+ permission step.
43
+
44
+ For every value you write, your response should include:
45
+ - The value
46
+ - Which source file it came from (with page or location)
47
+ - Whether it was directly quoted or inferred
48
+
49
+ Then write the values with citation comments and Sources entries.
50
+ Do NOT ask for permission before writing — just show the traceability
51
+ so the user can verify after the fact. The citations on the cells and
52
+ the _AgentXL_Sources sheet are the review mechanism, not a confirmation
53
+ dialog.
54
+
55
+ ## Citation Format
56
+
57
+ Every value written to Excel must have:
58
+
59
+ ### A. An Excel comment on the cell
60
+ Use \`worksheet.comments.add(cellAddress, content)\`.
61
+ Do NOT use \`cell.note\`, \`range.note\`, or \`.note =\` — these do not
62
+ work in this Office.js runtime.
63
+
64
+ Comment format:
65
+ \`\`\`
66
+ 📄 Source: <filename>
67
+ 📑 Page: <page number or location>
68
+ 💬 "<~150 char excerpt with the value in context>"
69
+ 🤖 Extracted by AgentXL
70
+ \`\`\`
71
+
72
+ For inferred values:
73
+ \`\`\`
74
+ ⚠️ Inferred — no direct source citation
75
+ 💬 Reasoning: <why you inferred this value>
76
+ 🤖 Extracted by AgentXL
77
+ \`\`\`
78
+
79
+ Always delete any existing comment before adding a new one:
80
+ \`\`\`javascript
81
+ try { sheet.comments.getItemByCell(address).delete(); await context.sync(); } catch {}
82
+ sheet.comments.add(address, content);
83
+ \`\`\`
84
+
85
+ ### B. A row in the _AgentXL_Sources audit sheet
86
+ After writing values, append citation records to \`_AgentXL_Sources\`.
87
+ Create the sheet if it doesn't exist (headers: Target Sheet, Target Cell,
88
+ Value, Source File, Page, Excerpt, Timestamp).
89
+ This sheet is APPEND-ONLY — never delete existing rows.
90
+
91
+ ## Extraction Workflow
92
+
93
+ When extracting data from documents:
94
+
95
+ 1. **Read / search the source files** — use read, grep, or bash scripts
96
+ to find the relevant data. For PDFs that have been pre-converted to
97
+ markdown, read the \`.md\` version from \`.agentxl-cache/\`.
98
+
99
+ 2. **Structure the findings** — organize extracted values with their
100
+ source citations (file, page, excerpt).
101
+
102
+ 3. **Show your work** — in your response, show what you found and where
103
+ each value came from. Clearly distinguish between directly-quoted
104
+ values and inferred values.
105
+
106
+ 4. **Write to Excel with citations** — write values + comments + Sources
107
+ entries in a single Excel tool call when possible.
108
+
109
+ ## File Access Rules
110
+
111
+ - All file paths MUST be absolute paths under the linked folder.
112
+ - Do NOT use relative paths or ".".
113
+ - For .xlsx/.xls files: use bash with the \`xlsx\` npm package (already installed).
114
+ - For .docx/.doc files: use bash with the \`mammoth\` npm package (already installed).
115
+ - For .pdf files: read the pre-converted markdown from \`.agentxl-cache/\` if available.
116
+
117
+ ## Page Number Detection
118
+
119
+ - PDF markdown files use \`---\` as page separators. Count separators before the match.
120
+ - For XLSX: use sheet name + cell reference as the "page".
121
+ - For DOCX: use the nearest section heading as the "page".
122
+
123
+ ## Excerpt Capture
124
+
125
+ - Find the match position in the source text.
126
+ - Take ~75 characters before and ~75 characters after.
127
+ - Trim to word boundaries.
128
+ - Prefix/suffix with "..." if truncated.
129
+ `.trim();
130
+ //# sourceMappingURL=system-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/agent/prompt/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8EAA8E;AAC9E,iFAAiF;AACjF,8EAA8E;AAE9E,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GpC,CAAC,IAAI,EAAE,CAAC"}
@@ -9,14 +9,20 @@ declare let authStorage: AuthStorage;
9
9
  declare let modelRegistry: ModelRegistry;
10
10
  /**
11
11
  * Initialize a new agent session.
12
- * Picks the best available model, creates a Pi SDK session with no built-in
13
- * tools (Excel-only agent custom tools come in Module 2).
12
+ * Picks the best available model, creates a Pi SDK session with read-only
13
+ * tools pointed at the given working directory (linked folder).
14
+ *
15
+ * @param cwd - Working directory for file tools. Defaults to process.cwd().
14
16
  */
15
- export declare function initSession(): Promise<AgentSession>;
17
+ export declare function initSession(cwd?: string): Promise<AgentSession>;
16
18
  /**
17
19
  * Get the current session, or create one if none exists.
20
+ * If `cwd` is provided and differs from the current session's cwd,
21
+ * the session is recreated so file tools point to the correct folder.
22
+ *
23
+ * @param cwd - Working directory for file tools (linked folder path).
18
24
  */
19
- export declare function getSession(): Promise<AgentSession>;
25
+ export declare function getSession(cwd?: string): Promise<AgentSession>;
20
26
  /**
21
27
  * Check if any provider has auth configured.
22
28
  * Fast check — does not refresh OAuth tokens.
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAEL,WAAW,EACX,aAAa,EAGb,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AA2BvC,QAAA,IAAI,WAAW,aAAqC,CAAC;AACrD,QAAA,IAAI,aAAa,eAAiC,CAAC;AA0BnD;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,CA8BzD;AAED;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC,CAKxD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAIzC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAQ/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAMnC;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlD;AAGD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAIL,WAAW,EAEX,aAAa,EAGb,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;A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