aven-ai 0.0.2 → 0.0.3

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 (112) hide show
  1. package/README.md +10 -11
  2. package/dist/index.js +9 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/libs/lexa/index.d.ts +2 -0
  5. package/dist/libs/lexa/index.d.ts.map +1 -0
  6. package/dist/libs/lexa/index.js +2 -0
  7. package/dist/libs/lexa/index.js.map +1 -0
  8. package/dist/libs/lexa/lexa-runtime.d.ts +17 -0
  9. package/dist/libs/lexa/lexa-runtime.d.ts.map +1 -0
  10. package/dist/libs/lexa/lexa-runtime.js +66 -0
  11. package/dist/libs/lexa/lexa-runtime.js.map +1 -0
  12. package/dist/libs/pty/index.d.ts +1 -1
  13. package/dist/libs/pty/index.d.ts.map +1 -1
  14. package/dist/libs/pty/index.js +1 -1
  15. package/dist/libs/pty/index.js.map +1 -1
  16. package/dist/libs/pty/pty-runner.d.ts +5 -1
  17. package/dist/libs/pty/pty-runner.d.ts.map +1 -1
  18. package/dist/libs/pty/pty-runner.js +16 -5
  19. package/dist/libs/pty/pty-runner.js.map +1 -1
  20. package/dist/modules/agent/core.d.ts +3 -1
  21. package/dist/modules/agent/core.d.ts.map +1 -1
  22. package/dist/modules/agent/core.js +4 -3
  23. package/dist/modules/agent/core.js.map +1 -1
  24. package/dist/modules/agent/events/tool-message-adapter.d.ts +1 -0
  25. package/dist/modules/agent/events/tool-message-adapter.d.ts.map +1 -1
  26. package/dist/modules/agent/events/tool-message-adapter.js +30 -0
  27. package/dist/modules/agent/events/tool-message-adapter.js.map +1 -1
  28. package/dist/modules/agent/index.d.ts +1 -1
  29. package/dist/modules/agent/index.d.ts.map +1 -1
  30. package/dist/modules/agent/index.js.map +1 -1
  31. package/dist/modules/agent/prompts/identity.d.ts +1 -1
  32. package/dist/modules/agent/prompts/identity.d.ts.map +1 -1
  33. package/dist/modules/agent/prompts/identity.js +1 -4
  34. package/dist/modules/agent/prompts/identity.js.map +1 -1
  35. package/dist/modules/agent/prompts/project-instructions.d.ts +19 -0
  36. package/dist/modules/agent/prompts/project-instructions.d.ts.map +1 -0
  37. package/dist/modules/agent/prompts/project-instructions.js +121 -0
  38. package/dist/modules/agent/prompts/project-instructions.js.map +1 -0
  39. package/dist/modules/agent/prompts/system.d.ts +12 -1
  40. package/dist/modules/agent/prompts/system.d.ts.map +1 -1
  41. package/dist/modules/agent/prompts/system.js +54 -1
  42. package/dist/modules/agent/prompts/system.js.map +1 -1
  43. package/dist/modules/agent/prompts/workflow.d.ts +2 -0
  44. package/dist/modules/agent/prompts/workflow.d.ts.map +1 -0
  45. package/dist/modules/agent/prompts/workflow.js +12 -0
  46. package/dist/modules/agent/prompts/workflow.js.map +1 -0
  47. package/dist/modules/agent/services/agent-recovery.d.ts +16 -0
  48. package/dist/modules/agent/services/agent-recovery.d.ts.map +1 -0
  49. package/dist/modules/agent/services/agent-recovery.js +143 -0
  50. package/dist/modules/agent/services/agent-recovery.js.map +1 -0
  51. package/dist/modules/agent/services/prompt-turn-executor.d.ts +4 -2
  52. package/dist/modules/agent/services/prompt-turn-executor.d.ts.map +1 -1
  53. package/dist/modules/agent/services/prompt-turn-executor.js +21 -3
  54. package/dist/modules/agent/services/prompt-turn-executor.js.map +1 -1
  55. package/dist/modules/agent/tools/exec-command.d.ts +1 -0
  56. package/dist/modules/agent/tools/exec-command.d.ts.map +1 -1
  57. package/dist/modules/agent/tools/files/contracts.d.ts +12 -0
  58. package/dist/modules/agent/tools/files/contracts.d.ts.map +1 -1
  59. package/dist/modules/agent/tools/files/contracts.js +6 -0
  60. package/dist/modules/agent/tools/files/contracts.js.map +1 -1
  61. package/dist/modules/agent/tools/files/create-file-tools.d.ts +7 -0
  62. package/dist/modules/agent/tools/files/create-file-tools.d.ts.map +1 -1
  63. package/dist/modules/app/cli.d.ts +1 -0
  64. package/dist/modules/app/cli.d.ts.map +1 -1
  65. package/dist/modules/app/cli.js +5 -1
  66. package/dist/modules/app/cli.js.map +1 -1
  67. package/dist/modules/app/components/app.d.ts +2 -1
  68. package/dist/modules/app/components/app.d.ts.map +1 -1
  69. package/dist/modules/app/components/app.js +4 -4
  70. package/dist/modules/app/components/app.js.map +1 -1
  71. package/dist/modules/app/index.d.ts +1 -1
  72. package/dist/modules/app/index.d.ts.map +1 -1
  73. package/dist/modules/app/index.js +1 -1
  74. package/dist/modules/app/index.js.map +1 -1
  75. package/dist/modules/app/input/use-overlay-controller.d.ts.map +1 -1
  76. package/dist/modules/app/input/use-overlay-controller.js +1 -7
  77. package/dist/modules/app/input/use-overlay-controller.js.map +1 -1
  78. package/dist/modules/app/services/use-app-input.d.ts.map +1 -1
  79. package/dist/modules/app/services/use-app-input.js +0 -4
  80. package/dist/modules/app/services/use-app-input.js.map +1 -1
  81. package/dist/modules/commands/registry.d.ts +1 -1
  82. package/dist/modules/commands/registry.d.ts.map +1 -1
  83. package/dist/modules/commands/registry.js +0 -1
  84. package/dist/modules/commands/registry.js.map +1 -1
  85. package/dist/modules/composer/components/composer.d.ts +2 -1
  86. package/dist/modules/composer/components/composer.d.ts.map +1 -1
  87. package/dist/modules/composer/components/composer.js +4 -12
  88. package/dist/modules/composer/components/composer.js.map +1 -1
  89. package/dist/modules/conversation/components/virtual-transcript.d.ts.map +1 -1
  90. package/dist/modules/conversation/components/virtual-transcript.js +1 -10
  91. package/dist/modules/conversation/components/virtual-transcript.js.map +1 -1
  92. package/dist/modules/conversation/services/use-transcript-controller.d.ts +0 -3
  93. package/dist/modules/conversation/services/use-transcript-controller.d.ts.map +1 -1
  94. package/dist/modules/conversation/services/use-transcript-controller.js +3 -21
  95. package/dist/modules/conversation/services/use-transcript-controller.js.map +1 -1
  96. package/dist/modules/overlays/components/overlay.d.ts.map +1 -1
  97. package/dist/modules/overlays/components/overlay.js +1 -5
  98. package/dist/modules/overlays/components/overlay.js.map +1 -1
  99. package/dist/modules/overlays/services/overlay-items.d.ts +0 -1
  100. package/dist/modules/overlays/services/overlay-items.d.ts.map +1 -1
  101. package/dist/modules/overlays/services/overlay-items.js +0 -3
  102. package/dist/modules/overlays/services/overlay-items.js.map +1 -1
  103. package/dist/modules/overlays/services/overlay-registry.d.ts.map +1 -1
  104. package/dist/modules/overlays/services/overlay-registry.js +0 -3
  105. package/dist/modules/overlays/services/overlay-registry.js.map +1 -1
  106. package/dist/modules/overlays/services/overlay-selection.d.ts +0 -3
  107. package/dist/modules/overlays/services/overlay-selection.d.ts.map +1 -1
  108. package/dist/modules/overlays/services/overlay-selection.js +0 -2
  109. package/dist/modules/overlays/services/overlay-selection.js.map +1 -1
  110. package/dist/modules/overlays/types.d.ts +1 -1
  111. package/dist/modules/overlays/types.d.ts.map +1 -1
  112. package/package.json +2 -1
@@ -0,0 +1,121 @@
1
+ import { open, readdir } from 'node:fs/promises';
2
+ import { relative, resolve, sep } from 'node:path';
3
+ import { StringDecoder } from 'node:string_decoder';
4
+ export const defaultProjectInstructionLimits = {
5
+ maxFiles: 32,
6
+ maxFileBytes: 16 * 1024,
7
+ maxTotalBytes: 64 * 1024,
8
+ };
9
+ const maxReportedOmittedPaths = 32;
10
+ const ignoredDirectories = new Set([
11
+ '.cache',
12
+ '.git',
13
+ '.next',
14
+ 'build',
15
+ 'coverage',
16
+ 'dist',
17
+ 'node_modules',
18
+ 'target',
19
+ 'vendor',
20
+ ]);
21
+ const displayPath = (projectRoot, path) => {
22
+ const value = relative(projectRoot, path).split(sep).join('/');
23
+ return value || 'AGENTS.md';
24
+ };
25
+ const instructionScope = (path) => {
26
+ const parts = path.split('/');
27
+ parts.pop();
28
+ return parts.length === 0 ? '.' : parts.join('/');
29
+ };
30
+ const pathDepth = (path) => path.split('/').length;
31
+ const positiveLimit = (value, fallback) => Number.isSafeInteger(value) && value > 0 ? value : fallback;
32
+ const resolveLimits = (limits) => ({
33
+ maxFiles: positiveLimit(limits.maxFiles ?? 0, defaultProjectInstructionLimits.maxFiles),
34
+ maxFileBytes: positiveLimit(limits.maxFileBytes ?? 0, defaultProjectInstructionLimits.maxFileBytes),
35
+ maxTotalBytes: positiveLimit(limits.maxTotalBytes ?? 0, defaultProjectInstructionLimits.maxTotalBytes),
36
+ });
37
+ const utf8Prefix = (buffer, maximum) => {
38
+ const decoder = new StringDecoder('utf8');
39
+ return decoder.write(buffer.subarray(0, maximum));
40
+ };
41
+ const readPrefix = async (path, maximum) => {
42
+ const handle = await open(path, 'r');
43
+ try {
44
+ const buffer = Buffer.alloc(maximum + 1);
45
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
46
+ const truncated = bytesRead > maximum;
47
+ return {
48
+ content: truncated ? utf8Prefix(buffer, maximum) : buffer.subarray(0, bytesRead).toString('utf8'),
49
+ truncated,
50
+ };
51
+ }
52
+ finally {
53
+ await handle.close();
54
+ }
55
+ };
56
+ const discoverInstructionPaths = async (projectRoot, warnings) => {
57
+ const discovered = [];
58
+ const visit = async (directory) => {
59
+ let entries;
60
+ try {
61
+ entries = await readdir(directory, { withFileTypes: true });
62
+ }
63
+ catch (error) {
64
+ warnings.push(`Could not inspect ${displayPath(projectRoot, directory)}: ${error instanceof Error ? error.message : String(error)}`);
65
+ return;
66
+ }
67
+ entries.sort((left, right) => left.name.localeCompare(right.name));
68
+ for (const entry of entries) {
69
+ if (entry.isSymbolicLink())
70
+ continue;
71
+ const path = resolve(directory, entry.name);
72
+ if (entry.isDirectory()) {
73
+ if (!ignoredDirectories.has(entry.name))
74
+ await visit(path);
75
+ continue;
76
+ }
77
+ if (entry.isFile() && entry.name === 'AGENTS.md') {
78
+ discovered.push({ absolute: path, display: displayPath(projectRoot, path) });
79
+ }
80
+ }
81
+ };
82
+ await visit(projectRoot);
83
+ return discovered.sort((left, right) => pathDepth(left.display) - pathDepth(right.display) || left.display.localeCompare(right.display));
84
+ };
85
+ export const loadProjectInstructions = async (projectRoot, overrides = {}) => {
86
+ const limits = resolveLimits(overrides);
87
+ const warnings = [];
88
+ const candidates = await discoverInstructionPaths(projectRoot, warnings);
89
+ const files = [];
90
+ const omittedPaths = [];
91
+ let totalBytes = 0;
92
+ for (const [index, candidate] of candidates.entries()) {
93
+ if (files.length >= limits.maxFiles || totalBytes >= limits.maxTotalBytes) {
94
+ const omittedCandidates = candidates.slice(index);
95
+ omittedPaths.push(...omittedCandidates.slice(0, maxReportedOmittedPaths).map((item) => item.display));
96
+ const additionalCount = omittedCandidates.length - omittedPaths.length;
97
+ if (additionalCount > 0) {
98
+ warnings.push(`${additionalCount} additional AGENTS.md files were omitted from the prompt.`);
99
+ }
100
+ break;
101
+ }
102
+ try {
103
+ const remaining = limits.maxTotalBytes - totalBytes;
104
+ const maximum = Math.min(limits.maxFileBytes, remaining);
105
+ const result = await readPrefix(candidate.absolute, maximum);
106
+ const contentBytes = Buffer.byteLength(result.content);
107
+ files.push({
108
+ path: candidate.display,
109
+ scope: instructionScope(candidate.display),
110
+ content: result.content,
111
+ truncated: result.truncated,
112
+ });
113
+ totalBytes += contentBytes;
114
+ }
115
+ catch (error) {
116
+ warnings.push(`Could not read ${candidate.display}: ${error instanceof Error ? error.message : String(error)}`);
117
+ }
118
+ }
119
+ return { files, omittedPaths, warnings };
120
+ };
121
+ //# sourceMappingURL=project-instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-instructions.js","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/project-instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAqBlD,MAAM,CAAC,MAAM,+BAA+B,GAA6B;IACxE,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,EAAE,GAAG,IAAI;IACvB,aAAa,EAAE,EAAE,GAAG,IAAI;CACxB,CAAC;AAEF,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,MAAM,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;YACD,MAAM;QACP,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,GAAG,UAAU,CAAC;YACpD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;YACzD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7D,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvD,KAAK,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,SAAS,CAAC,OAAO;gBACvB,KAAK,EAAE,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC;gBAC1C,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC3B,CAAC,CAAC;YACH,UAAU,IAAI,YAAY,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,QAAQ,CAAC,IAAI,CAAC,kBAAkB,SAAS,CAAC,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjH,CAAC;IACF,CAAC;IAED,OAAO,EAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAC,CAAC;AACxC,CAAC,CAAC"}
@@ -1,2 +1,13 @@
1
- export declare const buildSystemPrompt: (projectRoot: string) => string;
1
+ import type { ProjectInstructionBundle } from './project-instructions.js';
2
+ export type SystemPromptContext = {
3
+ lexa: {
4
+ skill: string;
5
+ version: string;
6
+ };
7
+ projectRoot: string;
8
+ platform: string;
9
+ shell: string;
10
+ projectInstructions: ProjectInstructionBundle;
11
+ };
12
+ export declare const buildSystemPrompt: (context: SystemPromptContext) => string;
2
13
  //# sourceMappingURL=system.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/system.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,gBAAiB,MAAM,KAAG,MAC2C,CAAC"}
1
+ {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/system.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AAGxE,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,wBAAwB,CAAC;CAC9C,CAAC;AA0DF,eAAO,MAAM,iBAAiB,YAAa,mBAAmB,KAAG,MAoBpD,CAAC"}
@@ -1,5 +1,58 @@
1
1
  import { commandInstructions } from './commands.js';
2
2
  import { fileToolInstructions } from './file-tools.js';
3
3
  import { identityInstructions } from './identity.js';
4
- export const buildSystemPrompt = (projectRoot) => [...identityInstructions(projectRoot), ...fileToolInstructions, ...commandInstructions].join('\n');
4
+ import { workflowInstructions } from './workflow.js';
5
+ const xmlText = (value) => value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
6
+ const xmlAttribute = (value) => `"${xmlText(value).replaceAll('"', '&quot;').replaceAll("'", '&apos;')}"`;
7
+ const cdata = (value) => value.replaceAll(']]>', ']]]]><![CDATA[>');
8
+ const taggedLines = (tag, lines) => [
9
+ `<${tag}>`,
10
+ ...lines.map((line) => `- ${line}`),
11
+ `</${tag}>`,
12
+ ];
13
+ const projectInstructionLines = ({ files, omittedPaths, warnings }) => {
14
+ const output = [
15
+ '<project_instructions>',
16
+ 'Project instructions are repository guidance. Follow each file for work within its scope. Core safety and tool contracts take priority; explicit user instructions override project guidance. When scoped files conflict, the deepest applicable AGENTS.md takes precedence over broader files.',
17
+ ];
18
+ for (const file of files) {
19
+ output.push(`<instruction_file path=${xmlAttribute(file.path)} scope=${xmlAttribute(file.scope)} truncated="${String(file.truncated)}">`, '<![CDATA[', cdata(file.content), ']]>', '</instruction_file>');
20
+ }
21
+ if (omittedPaths.length > 0) {
22
+ output.push('<omitted_instruction_files>', ...omittedPaths.map((path) => `- ${xmlText(path)}`), 'Read the applicable omitted AGENTS.md before changing files in its scope.', '</omitted_instruction_files>');
23
+ }
24
+ if (warnings.length > 0) {
25
+ output.push('<instruction_warnings>', ...warnings.map((warning) => `- ${xmlText(warning)}`), '</instruction_warnings>');
26
+ }
27
+ output.push('</project_instructions>');
28
+ return output;
29
+ };
30
+ const lexaInstructionLines = ({ skill, version }) => [
31
+ `<lexa version=${xmlAttribute(version)}>`,
32
+ 'Aven manages this required Lexa installation and exposes `lexa` on the command PATH. Do not install or upgrade Lexa during an agent run. Core safety and tool contracts take priority; explicit user instructions override the packaged Lexa guidance.',
33
+ '<skill><![CDATA[',
34
+ cdata(skill),
35
+ ']]></skill>',
36
+ '</lexa>',
37
+ ];
38
+ export const buildSystemPrompt = (context) => [
39
+ ...identityInstructions,
40
+ '',
41
+ '<environment>',
42
+ `<project_root>${xmlText(context.projectRoot)}</project_root>`,
43
+ `<command_working_directory>${xmlText(context.projectRoot)}</command_working_directory>`,
44
+ `<platform>${xmlText(context.platform)}</platform>`,
45
+ `<shell>${xmlText(context.shell)}</shell>`,
46
+ '</environment>',
47
+ '',
48
+ ...taggedLines('working_principles', workflowInstructions),
49
+ '',
50
+ ...taggedLines('file_tool_rules', fileToolInstructions),
51
+ '',
52
+ ...taggedLines('command_rules', commandInstructions),
53
+ '',
54
+ ...lexaInstructionLines(context.lexa),
55
+ '',
56
+ ...projectInstructionLines(context.projectInstructions),
57
+ ].join('\n');
5
58
  //# sourceMappingURL=system.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAChE,CAAC,GAAG,oBAAoB,CAAC,WAAW,CAAC,EAAE,GAAG,oBAAoB,EAAE,GAAG,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAanD,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CACzC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAEhF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE,CAC9C,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC;AAE3E,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;AAEpF,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,KAAwB,EAAY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GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,EAA8B,EAAY,EAAE,CAAC;IACzF,iBAAiB,YAAY,CAAC,OAAO,CAAC,GAAG;IACzC,wPAAwP;IACxP,kBAAkB;IAClB,KAAK,CAAC,KAAK,CAAC;IACZ,aAAa;IACb,SAAS;CACT,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAA4B,EAAU,EAAE,CACzE;IACC,GAAG,oBAAoB;IACvB,EAAE;IACF,eAAe;IACf,iBAAiB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,iBAAiB;IAC9D,8BAA8B,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,8BAA8B;IACxF,aAAa,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa;IACnD,UAAU,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU;IAC1C,gBAAgB;IAChB,EAAE;IACF,GAAG,WAAW,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC1D,EAAE;IACF,GAAG,WAAW,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;IACvD,EAAE;IACF,GAAG,WAAW,CAAC,eAAe,EAAE,mBAAmB,CAAC;IACpD,EAAE;IACF,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC;IACrC,EAAE;IACF,GAAG,uBAAuB,CAAC,OAAO,CAAC,mBAAmB,CAAC;CACvD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const workflowInstructions: readonly string[];
2
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/workflow.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAUjD,CAAC"}
@@ -0,0 +1,12 @@
1
+ export const workflowInstructions = [
2
+ 'Ground statements about the repository in inspected files or command results.',
3
+ 'Follow the user-requested scope and preserve unrelated existing changes.',
4
+ 'For explanation, review, or status requests, inspect and report without modifying files unless the user also requests a change.',
5
+ 'For diagnosis requests, determine and explain the root cause before proposing or implementing a fix.',
6
+ 'For implementation requests, inspect the relevant code, implement the complete scoped change, and verify it proportionally.',
7
+ 'Prefer established project patterns and existing files over unnecessary abstractions or new files.',
8
+ 'When an operation fails, use the returned error and agent guidance to change the approach; do not repeat an unchanged failing operation.',
9
+ 'Do not claim success unless relevant tool and command results confirm it.',
10
+ 'Keep the final response concise and state what changed and how it was verified.',
11
+ ];
12
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../../src/modules/agent/prompts/workflow.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACtD,+EAA+E;IAC/E,0EAA0E;IAC1E,iIAAiI;IACjI,sGAAsG;IACtG,6HAA6H;IAC7H,oGAAoG;IACpG,0IAA0I;IAC1I,2EAA2E;IAC3E,iFAAiF;CACjF,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const FAILURE_WARNING_THRESHOLD = 3;
2
+ export declare const FAILURE_STOP_THRESHOLD = 5;
3
+ export declare const LOOP_WARNING_THRESHOLD = 3;
4
+ export declare const LOOP_STOP_THRESHOLD = 5;
5
+ type LoopMatch = {
6
+ patternLength: number;
7
+ repetitions: number;
8
+ };
9
+ export declare const canonicalToolSignature: (toolName: string, args: string) => string;
10
+ export declare const repeatingSuffix: (sequence: readonly string[]) => LoopMatch | undefined;
11
+ export declare const createAgentRecovery: () => {
12
+ hook: import("@anvia/core/hooks").PromptHook<unknown>;
13
+ middleware: import("@anvia/core").AgentMiddleware<unknown>;
14
+ };
15
+ export {};
16
+ //# sourceMappingURL=agent-recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-recovery.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/services/agent-recovery.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAIrC,KAAK,SAAS,GAAG;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACpB,CAAC;AA+BF,eAAO,MAAM,sBAAsB,aAAc,MAAM,QAAQ,MAAM,KAAG,MAQvE,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc,SAAS,MAAM,EAAE,KAAG,SAAS,GAAG,SAqBzE,CAAC;AA2CF,eAAO,MAAM,mBAAmB;;;CAgD/B,CAAC"}
@@ -0,0 +1,143 @@
1
+ import { createHook, createMiddleware } from '@anvia/core';
2
+ export const FAILURE_WARNING_THRESHOLD = 3;
3
+ export const FAILURE_STOP_THRESHOLD = 5;
4
+ export const LOOP_WARNING_THRESHOLD = 3;
5
+ export const LOOP_STOP_THRESHOLD = 5;
6
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
7
+ const parseRecord = (value) => {
8
+ try {
9
+ const parsed = JSON.parse(value);
10
+ return isRecord(parsed) ? parsed : undefined;
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ };
16
+ const canonicalValue = (value) => {
17
+ if (Array.isArray(value))
18
+ return value.map(canonicalValue);
19
+ if (!isRecord(value))
20
+ return value;
21
+ return Object.fromEntries(Object.keys(value)
22
+ .sort()
23
+ .map((key) => [key, canonicalValue(value[key])]));
24
+ };
25
+ export const canonicalToolSignature = (toolName, args) => {
26
+ let normalized = args.trim();
27
+ try {
28
+ normalized = canonicalValue(JSON.parse(args));
29
+ }
30
+ catch {
31
+ // Malformed arguments still need a stable signature for repetition checks.
32
+ }
33
+ return `${toolName}:${typeof normalized === 'string' ? normalized : JSON.stringify(normalized)}`;
34
+ };
35
+ export const repeatingSuffix = (sequence) => {
36
+ let best;
37
+ for (let patternLength = 1; patternLength <= Math.floor(sequence.length / LOOP_WARNING_THRESHOLD); patternLength++) {
38
+ const patternStart = sequence.length - patternLength;
39
+ const pattern = sequence.slice(patternStart);
40
+ let repetitions = 1;
41
+ for (let end = patternStart; end >= patternLength; end -= patternLength) {
42
+ const candidate = sequence.slice(end - patternLength, end);
43
+ if (!candidate.every((item, index) => item === pattern[index]))
44
+ break;
45
+ repetitions += 1;
46
+ }
47
+ if (repetitions >= LOOP_WARNING_THRESHOLD &&
48
+ (!best ||
49
+ repetitions > best.repetitions ||
50
+ (repetitions === best.repetitions && patternLength < best.patternLength))) {
51
+ best = { patternLength, repetitions };
52
+ }
53
+ }
54
+ return best;
55
+ };
56
+ const failureReason = (toolName, result) => {
57
+ const parsed = parseRecord(result);
58
+ if (!parsed)
59
+ return 'The tool returned an unstructured or malformed result.';
60
+ if (parsed.status === 'error')
61
+ return typeof parsed.error === 'string' ? parsed.error : 'The tool reported an error.';
62
+ if (toolName === 'ExecCommand') {
63
+ if (parsed.timedOut === true)
64
+ return 'The command timed out.';
65
+ if (typeof parsed.signal === 'number' && parsed.signal !== 0)
66
+ return `The command exited after signal ${parsed.signal}.`;
67
+ if (typeof parsed.exitCode !== 'number')
68
+ return 'The command result did not include a valid exit code.';
69
+ if (parsed.exitCode !== 0)
70
+ return `The command exited with code ${parsed.exitCode}.`;
71
+ return undefined;
72
+ }
73
+ if (toolName === 'Read') {
74
+ return parsed.status === 'success' || parsed.status === 'unchanged'
75
+ ? undefined
76
+ : 'Read returned an unexpected result shape.';
77
+ }
78
+ if (toolName === 'Edit' || toolName === 'Write') {
79
+ return parsed.status === 'success' ? undefined : `${toolName} returned an unexpected result shape.`;
80
+ }
81
+ return undefined;
82
+ };
83
+ const failureGuidance = (toolName, reason, failureCount) => {
84
+ const attemptsRemaining = Math.max(0, FAILURE_STOP_THRESHOLD - failureCount);
85
+ const warning = failureCount >= FAILURE_WARNING_THRESHOLD
86
+ ? 'Do not repeat the same call unchanged; inspect the error and choose a materially different approach.'
87
+ : 'Inspect the error, correct the arguments or approach, and retry only when there is a concrete reason it should succeed.';
88
+ return `${toolName} failed (${failureCount}/${FAILURE_STOP_THRESHOLD}): ${reason} ${warning} Attempts remaining before this run stops: ${attemptsRemaining}.`;
89
+ };
90
+ const loopGuidance = ({ patternLength, repetitions }) => `A repeating tool-call pattern of length ${patternLength} has occurred ${repetitions} times. The repeated call was skipped. Change tools, arguments, or strategy before continuing.`;
91
+ const guidedResult = (toolName, result, guidance) => {
92
+ const parsed = parseRecord(result);
93
+ if (parsed)
94
+ return JSON.stringify({ ...parsed, agent_guidance: guidance });
95
+ return JSON.stringify({ status: 'error', tool: toolName, error: result, agent_guidance: guidance });
96
+ };
97
+ export const createAgentRecovery = () => {
98
+ const state = {
99
+ failures: new Map(),
100
+ toolCalls: [],
101
+ loopsByCall: new Map(),
102
+ };
103
+ const middleware = createMiddleware({
104
+ onToolOutput: ({ toolName, result, internalCallId }) => {
105
+ const loop = state.loopsByCall.get(internalCallId);
106
+ state.loopsByCall.delete(internalCallId);
107
+ const reason = failureReason(toolName, result);
108
+ if (!reason && !loop) {
109
+ state.failures.delete(toolName);
110
+ return undefined;
111
+ }
112
+ const failureCount = (state.failures.get(toolName) ?? 0) + 1;
113
+ state.failures.set(toolName, failureCount);
114
+ if (failureCount >= FAILURE_STOP_THRESHOLD && !state.stopReason) {
115
+ state.stopReason = `${toolName} failed ${failureCount} consecutive times.`;
116
+ }
117
+ const guidance = [
118
+ loop ? loopGuidance(loop) : '',
119
+ failureGuidance(toolName, reason ?? 'The repeated call was skipped.', failureCount),
120
+ ]
121
+ .filter(Boolean)
122
+ .join(' ');
123
+ return guidedResult(toolName, result, guidance);
124
+ },
125
+ });
126
+ const hook = createHook({
127
+ onTurnStart: ({ run }) => (state.stopReason ? run.cancel(state.stopReason) : undefined),
128
+ onToolCall: ({ toolName, args, internalCallId, tool }) => {
129
+ const signature = canonicalToolSignature(toolName, args);
130
+ state.toolCalls.push(signature);
131
+ const loop = repeatingSuffix(state.toolCalls);
132
+ if (!loop)
133
+ return undefined;
134
+ state.loopsByCall.set(internalCallId, loop);
135
+ if (loop.repetitions >= LOOP_STOP_THRESHOLD && !state.stopReason) {
136
+ state.stopReason = `A repeating tool-call pattern occurred ${loop.repetitions} times.`;
137
+ }
138
+ return tool.skip(loopGuidance(loop));
139
+ },
140
+ });
141
+ return { hook, middleware };
142
+ };
143
+ //# sourceMappingURL=agent-recovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-recovery.js","sourceRoot":"","sources":["../../../../src/modules/agent/services/agent-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAEzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAgBrC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAuB,EAAE,CACxD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEtE,MAAM,WAAW,GAAG,CAAC,KAAa,EAA0B,EAAE;IAC7D,IAAI,CAAC;QACJ,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,KAAc,EAAW,EAAE;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,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AW,SAAS,CAAC;YACxF,CAAC;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;KACD,CAAC,CAAC;IAEH,OAAO,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC;AAC3B,CAAC,CAAC"}
@@ -3,10 +3,12 @@ import type { SqliteMemoryStore } from '@anvia/memory-sqlite';
3
3
  import type { RuntimeEvent } from '../types.js';
4
4
  import type { SubmitRequest } from '../types.js';
5
5
  import type { FileToolService } from '../tools/files/file-tool-service.js';
6
- import type { PtyRunner } from '../../../libs/pty/index.js';
6
+ import { type PtyRunner } from '../../../libs/pty/index.js';
7
+ import type { LexaRuntime } from '../../../libs/lexa/index.js';
8
+ export declare const MAX_AGENT_TURNS = 50;
7
9
  export declare class PromptTurnExecutor {
8
10
  #private;
9
- constructor(projectRoot: string, memory: SqliteMemoryStore, pty: PtyRunner, files: FileToolService);
11
+ constructor(projectRoot: string, memory: SqliteMemoryStore, pty: PtyRunner, files: FileToolService, lexa: LexaRuntime);
10
12
  run(request: SubmitRequest, signal: AbortSignal, model: CompletionModel, sessionId: string): AsyncIterable<RuntimeEvent>;
11
13
  }
12
14
  //# sourceMappingURL=prompt-turn-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-turn-executor.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/services/prompt-turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,eAAe,EAAC,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAG/C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACzE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAK1D,qBAAa,kBAAkB;;IAM9B,YAAY,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAKjG;IAEM,GAAG,CACT,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,eAAe,EACtB,SAAS,EAAE,MAAM,GACf,aAAa,CAAC,YAAY,CAAC,CA6D7B;CACD"}
1
+ {"version":3,"file":"prompt-turn-executor.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/services/prompt-turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,eAAe,EAAC,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAG/C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAMvE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAE7D,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,qBAAa,kBAAkB;;IAO9B,YACC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,WAAW,EAOjB;IAEM,GAAG,CACT,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,eAAe,EACtB,SAAS,EAAE,MAAM,GACf,aAAa,CAAC,YAAY,CAAC,CA0E7B;CACD"}
@@ -1,28 +1,46 @@
1
1
  import { AgentBuilder } from '@anvia/core';
2
2
  import { createExecCommandTool } from '../tools/exec-command.js';
3
3
  import { createFileTools } from '../tools/files/create-file-tools.js';
4
+ import { activeShell } from '../../../libs/pty/index.js';
4
5
  import { safeErrorMessage } from '../../../utils/safe-error.js';
5
6
  import { eventToRuntimeEvents } from '../events/stream-event-adapter.js';
6
7
  import { buildSystemPrompt } from '../prompts/system.js';
8
+ import { loadProjectInstructions } from '../prompts/project-instructions.js';
9
+ import { createAgentRecovery } from './agent-recovery.js';
10
+ export const MAX_AGENT_TURNS = 50;
7
11
  export class PromptTurnExecutor {
8
12
  #files;
9
13
  #memory;
10
14
  #projectRoot;
11
15
  #pty;
12
- constructor(projectRoot, memory, pty, files) {
16
+ #lexa;
17
+ constructor(projectRoot, memory, pty, files, lexa) {
13
18
  this.#projectRoot = projectRoot;
14
19
  this.#memory = memory;
15
20
  this.#pty = pty;
16
21
  this.#files = files;
22
+ this.#lexa = lexa;
17
23
  }
18
24
  async *run(request, signal, model, sessionId) {
19
25
  yield { type: 'status.changed', status: 'thinking' };
26
+ const projectInstructions = await loadProjectInstructions(this.#projectRoot);
27
+ if (signal.aborted)
28
+ throw signal.reason ?? new Error('Aborted');
29
+ const recovery = createAgentRecovery();
20
30
  const tools = [createExecCommandTool(this.#pty, signal), ...createFileTools(this.#files, signal)];
21
31
  const agent = new AgentBuilder('aven', model)
22
- .instructions(buildSystemPrompt(this.#projectRoot))
32
+ .instructions(buildSystemPrompt({
33
+ lexa: this.#lexa,
34
+ projectRoot: this.#projectRoot,
35
+ platform: process.platform,
36
+ shell: activeShell(),
37
+ projectInstructions,
38
+ }))
23
39
  .tools(tools)
40
+ .middleware(recovery.middleware)
41
+ .hook(recovery.hook)
24
42
  .memory(this.#memory, { savePolicy: 'turn' })
25
- .defaultMaxTurns(8)
43
+ .defaultMaxTurns(MAX_AGENT_TURNS)
26
44
  .build();
27
45
  const streamedTurn = agent
28
46
  .session(sessionId, { metadata: { projectRoot: this.#projectRoot } })
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-turn-executor.js","sourceRoot":"","sources":["../../../../src/modules/agent/services/prompt-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O,CAAC,EAAE,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,CAAC,MAAM,CACX,EAAE,CAAC;oBACH,IAAI,YAAY,CAAC,IAAI,KAAK,iBAAiB;wBAAE,aAAa,IAAI,YAAY,CAAC,KAAK,CAAC;oBACjF,MAAM,YAAY,CAAC;gBACpB,CAAC;gBACD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;oBAC9D,MAAM;wBACL,IAAI,EAAE,kBAAkB;wBACxB,OAAO,EAAE,EAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAC;qBACrF,CAAC;oBACF,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;gBAC9B,CAAC;YACF,CAAC;YACD,IAAI,MAAM,CAAC,OAAO;gBAAE,MAAM,MAAM,CAAC,MAAM,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,MAAM,CAAC,OAAO;gBAAE,MAAM,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC;YACjD,2EAA2E;YAC3E,iDAAiD;YACjD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;CACD"}
1
+ {"version":3,"file":"prompt-turn-executor.js","sourceRoot":"","sources":["../../../../src/modules/agent/services/prompt-turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAuB,MAAM,aAAa,CAAC;AAI/D,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAA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;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,MAAM,CAAC,OAAO;gBAAE,MAAM,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC;YACjD,2EAA2E;YAC3E,iDAAiD;YACjD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;CACD"}
@@ -9,5 +9,6 @@ export declare const createExecCommandTool: (pty: PtyRunner, signal: AbortSignal
9
9
  timedOut: boolean;
10
10
  truncated: boolean;
11
11
  output: string;
12
+ agent_guidance?: string | undefined;
12
13
  }>;
13
14
  //# sourceMappingURL=exec-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/tools/exec-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAG1D,eAAO,MAAM,qBAAqB,QAAS,SAAS,UAAU,WAAW;;;;;;;;;;EAOtE,CAAC"}
1
+ {"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../../../src/modules/agent/tools/exec-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAG1D,eAAO,MAAM,qBAAqB,QAAS,SAAS,UAAU,WAAW;;;;;;;;;;;EAOtE,CAAC"}
@@ -23,6 +23,7 @@ export declare const readResultSchema: z.ZodUnion<readonly [z.ZodObject<{
23
23
  num_lines: z.ZodNumber;
24
24
  total_lines: z.ZodNumber;
25
25
  truncated: z.ZodBoolean;
26
+ agent_guidance: z.ZodOptional<z.ZodString>;
26
27
  }, z.core.$strict>, z.ZodObject<{
27
28
  status: z.ZodLiteral<"unchanged">;
28
29
  tool: z.ZodLiteral<"Read">;
@@ -31,6 +32,7 @@ export declare const readResultSchema: z.ZodUnion<readonly [z.ZodObject<{
31
32
  num_lines: z.ZodNumber;
32
33
  total_lines: z.ZodNumber;
33
34
  message: z.ZodString;
35
+ agent_guidance: z.ZodOptional<z.ZodString>;
34
36
  }, z.core.$strict>, z.ZodObject<{
35
37
  status: z.ZodLiteral<"error">;
36
38
  tool: z.ZodEnum<{
@@ -40,6 +42,7 @@ export declare const readResultSchema: z.ZodUnion<readonly [z.ZodObject<{
40
42
  }>;
41
43
  file_path: z.ZodString;
42
44
  error: z.ZodString;
45
+ agent_guidance: z.ZodOptional<z.ZodString>;
43
46
  }, z.core.$strict>]>;
44
47
  export declare const editResultSchema: z.ZodUnion<readonly [z.ZodObject<{
45
48
  status: z.ZodLiteral<"success">;
@@ -48,6 +51,7 @@ export declare const editResultSchema: z.ZodUnion<readonly [z.ZodObject<{
48
51
  replacements: z.ZodNumber;
49
52
  operation_id: z.ZodString;
50
53
  message: z.ZodString;
54
+ agent_guidance: z.ZodOptional<z.ZodString>;
51
55
  }, z.core.$strict>, z.ZodObject<{
52
56
  status: z.ZodLiteral<"error">;
53
57
  tool: z.ZodEnum<{
@@ -57,6 +61,7 @@ export declare const editResultSchema: z.ZodUnion<readonly [z.ZodObject<{
57
61
  }>;
58
62
  file_path: z.ZodString;
59
63
  error: z.ZodString;
64
+ agent_guidance: z.ZodOptional<z.ZodString>;
60
65
  }, z.core.$strict>]>;
61
66
  export declare const writeResultSchema: z.ZodUnion<readonly [z.ZodObject<{
62
67
  status: z.ZodLiteral<"success">;
@@ -68,6 +73,7 @@ export declare const writeResultSchema: z.ZodUnion<readonly [z.ZodObject<{
68
73
  }>;
69
74
  operation_id: z.ZodString;
70
75
  message: z.ZodString;
76
+ agent_guidance: z.ZodOptional<z.ZodString>;
71
77
  }, z.core.$strict>, z.ZodObject<{
72
78
  status: z.ZodLiteral<"error">;
73
79
  tool: z.ZodEnum<{
@@ -77,6 +83,7 @@ export declare const writeResultSchema: z.ZodUnion<readonly [z.ZodObject<{
77
83
  }>;
78
84
  file_path: z.ZodString;
79
85
  error: z.ZodString;
86
+ agent_guidance: z.ZodOptional<z.ZodString>;
80
87
  }, z.core.$strict>]>;
81
88
  export declare const fileToolResultSchema: z.ZodUnion<readonly [z.ZodObject<{
82
89
  status: z.ZodLiteral<"success">;
@@ -87,6 +94,7 @@ export declare const fileToolResultSchema: z.ZodUnion<readonly [z.ZodObject<{
87
94
  num_lines: z.ZodNumber;
88
95
  total_lines: z.ZodNumber;
89
96
  truncated: z.ZodBoolean;
97
+ agent_guidance: z.ZodOptional<z.ZodString>;
90
98
  }, z.core.$strict>, z.ZodObject<{
91
99
  status: z.ZodLiteral<"unchanged">;
92
100
  tool: z.ZodLiteral<"Read">;
@@ -95,6 +103,7 @@ export declare const fileToolResultSchema: z.ZodUnion<readonly [z.ZodObject<{
95
103
  num_lines: z.ZodNumber;
96
104
  total_lines: z.ZodNumber;
97
105
  message: z.ZodString;
106
+ agent_guidance: z.ZodOptional<z.ZodString>;
98
107
  }, z.core.$strict>, z.ZodObject<{
99
108
  status: z.ZodLiteral<"success">;
100
109
  tool: z.ZodLiteral<"Edit">;
@@ -102,6 +111,7 @@ export declare const fileToolResultSchema: z.ZodUnion<readonly [z.ZodObject<{
102
111
  replacements: z.ZodNumber;
103
112
  operation_id: z.ZodString;
104
113
  message: z.ZodString;
114
+ agent_guidance: z.ZodOptional<z.ZodString>;
105
115
  }, z.core.$strict>, z.ZodObject<{
106
116
  status: z.ZodLiteral<"success">;
107
117
  tool: z.ZodLiteral<"Write">;
@@ -112,6 +122,7 @@ export declare const fileToolResultSchema: z.ZodUnion<readonly [z.ZodObject<{
112
122
  }>;
113
123
  operation_id: z.ZodString;
114
124
  message: z.ZodString;
125
+ agent_guidance: z.ZodOptional<z.ZodString>;
115
126
  }, z.core.$strict>, z.ZodObject<{
116
127
  status: z.ZodLiteral<"error">;
117
128
  tool: z.ZodEnum<{
@@ -121,6 +132,7 @@ export declare const fileToolResultSchema: z.ZodUnion<readonly [z.ZodObject<{
121
132
  }>;
122
133
  file_path: z.ZodString;
123
134
  error: z.ZodString;
135
+ agent_guidance: z.ZodOptional<z.ZodString>;
124
136
  }, z.core.$strict>]>;
125
137
  export type ReadInput = z.infer<typeof readInputSchema>;
126
138
  export type EditInput = z.infer<typeof editInputSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,eAAe;;;;kBAMlB,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;kBAOlB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;kBAKnB,CAAC;AA0DX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAqE,CAAC;AACnG,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;oBAAgD,CAAC;AAC9E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;oBAAiD,CAAC;AAChF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAM/B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iB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