bernard-agent 0.8.1 → 0.9.0

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 (174) hide show
  1. package/README.md +80 -44
  2. package/dist/agent.d.ts +14 -3
  3. package/dist/agent.js +228 -38
  4. package/dist/agent.js.map +1 -1
  5. package/dist/builtin-specialists/correction-agent.json +32 -0
  6. package/dist/builtin-specialists/file-wrapper.json +43 -0
  7. package/dist/builtin-specialists/shell-wrapper.json +50 -0
  8. package/dist/builtin-specialists/specialist-creator.json +32 -0
  9. package/dist/builtin-specialists/web-wrapper.json +38 -0
  10. package/dist/candidate-bootstrap.d.ts +18 -0
  11. package/dist/candidate-bootstrap.js +61 -0
  12. package/dist/candidate-bootstrap.js.map +1 -0
  13. package/dist/config.d.ts +126 -10
  14. package/dist/config.js +222 -45
  15. package/dist/config.js.map +1 -1
  16. package/dist/context.js +23 -6
  17. package/dist/context.js.map +1 -1
  18. package/dist/correction-candidates.d.ts +54 -0
  19. package/dist/correction-candidates.js +138 -0
  20. package/dist/correction-candidates.js.map +1 -0
  21. package/dist/correction.d.ts +67 -0
  22. package/dist/correction.js +138 -0
  23. package/dist/correction.js.map +1 -0
  24. package/dist/critic.js +2 -1
  25. package/dist/critic.js.map +1 -1
  26. package/dist/cron/notes-store.d.ts +41 -0
  27. package/dist/cron/notes-store.js +134 -0
  28. package/dist/cron/notes-store.js.map +1 -0
  29. package/dist/cron/runner.js +25 -3
  30. package/dist/cron/runner.js.map +1 -1
  31. package/dist/cron/scoped-notes-tools.d.ts +24 -0
  32. package/dist/cron/scoped-notes-tools.js +50 -0
  33. package/dist/cron/scoped-notes-tools.js.map +1 -0
  34. package/dist/custom-providers.d.ts +80 -0
  35. package/dist/custom-providers.js +238 -0
  36. package/dist/custom-providers.js.map +1 -0
  37. package/dist/fs-utils.d.ts +2 -0
  38. package/dist/fs-utils.js +44 -0
  39. package/dist/fs-utils.js.map +1 -0
  40. package/dist/history.js +3 -1
  41. package/dist/history.js.map +1 -1
  42. package/dist/image.d.ts +59 -0
  43. package/dist/image.js +228 -0
  44. package/dist/image.js.map +1 -0
  45. package/dist/index.js +72 -4
  46. package/dist/index.js.map +1 -1
  47. package/dist/mcp.js +1 -1
  48. package/dist/mcp.js.map +1 -1
  49. package/dist/memory.d.ts +13 -0
  50. package/dist/memory.js +45 -4
  51. package/dist/memory.js.map +1 -1
  52. package/dist/menu.d.ts +97 -0
  53. package/dist/menu.js +338 -0
  54. package/dist/menu.js.map +1 -0
  55. package/dist/os-info.d.ts +22 -0
  56. package/dist/os-info.js +111 -0
  57. package/dist/os-info.js.map +1 -0
  58. package/dist/output.d.ts +35 -1
  59. package/dist/output.js +256 -45
  60. package/dist/output.js.map +1 -1
  61. package/dist/pac.d.ts +14 -2
  62. package/dist/pac.js +5 -5
  63. package/dist/pac.js.map +1 -1
  64. package/dist/paths.d.ts +5 -0
  65. package/dist/paths.js +6 -1
  66. package/dist/paths.js.map +1 -1
  67. package/dist/plan-store.d.ts +47 -0
  68. package/dist/plan-store.js +94 -0
  69. package/dist/plan-store.js.map +1 -0
  70. package/dist/prompt-rewriter.d.ts +29 -0
  71. package/dist/prompt-rewriter.js +155 -0
  72. package/dist/prompt-rewriter.js.map +1 -0
  73. package/dist/providers/index.d.ts +56 -4
  74. package/dist/providers/index.js +86 -5
  75. package/dist/providers/index.js.map +1 -1
  76. package/dist/providers/profiles.d.ts +37 -0
  77. package/dist/providers/profiles.js +110 -0
  78. package/dist/providers/profiles.js.map +1 -0
  79. package/dist/providers/types.d.ts +11 -2
  80. package/dist/providers/types.js +3 -0
  81. package/dist/providers/types.js.map +1 -1
  82. package/dist/rag-query.js +15 -1
  83. package/dist/rag-query.js.map +1 -1
  84. package/dist/react.d.ts +38 -0
  85. package/dist/react.js +116 -0
  86. package/dist/react.js.map +1 -0
  87. package/dist/reasoning-log.d.ts +30 -0
  88. package/dist/reasoning-log.js +102 -0
  89. package/dist/reasoning-log.js.map +1 -0
  90. package/dist/reference-resolver.d.ts +47 -0
  91. package/dist/reference-resolver.js +316 -0
  92. package/dist/reference-resolver.js.map +1 -0
  93. package/dist/reference-tool-lookup.d.ts +37 -0
  94. package/dist/reference-tool-lookup.js +318 -0
  95. package/dist/reference-tool-lookup.js.map +1 -0
  96. package/dist/repl.js +1038 -371
  97. package/dist/repl.js.map +1 -1
  98. package/dist/setup.js +2 -1
  99. package/dist/setup.js.map +1 -1
  100. package/dist/specialist-detector.js +2 -1
  101. package/dist/specialist-detector.js.map +1 -1
  102. package/dist/specialists.d.ts +74 -3
  103. package/dist/specialists.js +152 -20
  104. package/dist/specialists.js.map +1 -1
  105. package/dist/structured-output.d.ts +58 -0
  106. package/dist/structured-output.js +138 -0
  107. package/dist/structured-output.js.map +1 -0
  108. package/dist/theme.d.ts +2 -0
  109. package/dist/theme.js +18 -12
  110. package/dist/theme.js.map +1 -1
  111. package/dist/tool-call-repair.d.ts +29 -0
  112. package/dist/tool-call-repair.js +99 -0
  113. package/dist/tool-call-repair.js.map +1 -0
  114. package/dist/tool-profiles.d.ts +70 -0
  115. package/dist/tool-profiles.js +385 -0
  116. package/dist/tool-profiles.js.map +1 -0
  117. package/dist/tools/activity-summary.d.ts +15 -0
  118. package/dist/tools/activity-summary.js +44 -0
  119. package/dist/tools/activity-summary.js.map +1 -0
  120. package/dist/tools/ask-user.d.ts +49 -0
  121. package/dist/tools/ask-user.js +52 -0
  122. package/dist/tools/ask-user.js.map +1 -0
  123. package/dist/tools/augment.d.ts +17 -0
  124. package/dist/tools/augment.js +102 -0
  125. package/dist/tools/augment.js.map +1 -0
  126. package/dist/tools/cron-logs.js +7 -0
  127. package/dist/tools/cron-logs.js.map +1 -1
  128. package/dist/tools/cron-notes.d.ts +52 -0
  129. package/dist/tools/cron-notes.js +105 -0
  130. package/dist/tools/cron-notes.js.map +1 -0
  131. package/dist/tools/datetime.d.ts +7 -0
  132. package/dist/tools/datetime.js +29 -3
  133. package/dist/tools/datetime.js.map +1 -1
  134. package/dist/tools/evaluate.d.ts +20 -0
  135. package/dist/tools/evaluate.js +29 -0
  136. package/dist/tools/evaluate.js.map +1 -0
  137. package/dist/tools/index.js +4 -0
  138. package/dist/tools/index.js.map +1 -1
  139. package/dist/tools/mcp.d.ts +3 -3
  140. package/dist/tools/plan.d.ts +81 -0
  141. package/dist/tools/plan.js +108 -0
  142. package/dist/tools/plan.js.map +1 -0
  143. package/dist/tools/result-cap.d.ts +24 -0
  144. package/dist/tools/result-cap.js +44 -0
  145. package/dist/tools/result-cap.js.map +1 -0
  146. package/dist/tools/routine.d.ts +3 -3
  147. package/dist/tools/shell.d.ts +14 -1
  148. package/dist/tools/shell.js +86 -4
  149. package/dist/tools/shell.js.map +1 -1
  150. package/dist/tools/specialist-run.d.ts +5 -3
  151. package/dist/tools/specialist-run.js +115 -24
  152. package/dist/tools/specialist-run.js.map +1 -1
  153. package/dist/tools/specialist.d.ts +83 -3
  154. package/dist/tools/specialist.js +83 -3
  155. package/dist/tools/specialist.js.map +1 -1
  156. package/dist/tools/subagent.js +32 -14
  157. package/dist/tools/subagent.js.map +1 -1
  158. package/dist/tools/task.d.ts +5 -5
  159. package/dist/tools/task.js +9 -42
  160. package/dist/tools/task.js.map +1 -1
  161. package/dist/tools/think.d.ts +18 -0
  162. package/dist/tools/think.js +25 -0
  163. package/dist/tools/think.js.map +1 -0
  164. package/dist/tools/tool-wrapper-run.d.ts +121 -0
  165. package/dist/tools/tool-wrapper-run.js +382 -0
  166. package/dist/tools/tool-wrapper-run.js.map +1 -0
  167. package/dist/tools/types.d.ts +28 -2
  168. package/dist/tools/web-search.d.ts +31 -0
  169. package/dist/tools/web-search.js +172 -0
  170. package/dist/tools/web-search.js.map +1 -0
  171. package/dist/tools/wrap-with-specialist.d.ts +55 -0
  172. package/dist/tools/wrap-with-specialist.js +137 -0
  173. package/dist/tools/wrap-with-specialist.js.map +1 -0
  174. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools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AC/C,6CAAmD;AACnD,qCAA6C;AAC7C,mDAAsD;AACtD,uCAA2C;AAC3C,uCAA4C;AAC5C,6CAAiD;AACjD,mDAAuD;AAUvD;;;;;;;;GAQG;AACH,SAAgB,WAAW,CACzB,OAAoB,EACpB,WAAwB,EACxB,QAA8B,EAC9B,YAA2B,EAC3B,eAAiC,EACjC,cAAqC,EACrC,MAAsB;IAEtB,OAAO;QACL,KAAK,EAAE,IAAA,0BAAe,EAAC,OAAO,CAAC;QAC/B,MAAM,EAAE,IAAA,4BAAgB,EAAC,WAAW,CAAC;QACrC,OAAO,EAAE,IAAA,6BAAiB,EAAC,WAAW,CAAC;QACvC,OAAO,EAAE,IAAA,8BAAiB,EAAC,YAAY,CAAC;QACxC,UAAU,EAAE,IAAA,oCAAoB,EAAC,eAAe,EAAE,cAAc,EAAE,MAAM,CAAC;QACzE,QAAQ,EAAE,IAAA,gCAAkB,GAAE;QAC9B,GAAG,IAAA,yBAAe,GAAE;QACpB,GAAG,IAAA,iCAAkB,GAAE;QACvB,GAAG,IAAA,oCAAoB,GAAE;QACzB,GAAG,IAAA,yBAAe,GAAE;QACpB,UAAU,EAAE,IAAA,4BAAmB,GAAE;QACjC,WAAW,EAAE,IAAA,gCAAmB,GAAE;QAClC,QAAQ,EAAE,IAAA,0BAAiB,GAAE;QAC7B,UAAU,EAAE,IAAA,mCAAmB,GAAE;QACjC,IAAI,EAAE,IAAA,wBAAc,GAAE;QACtB,GAAG,IAAA,yBAAe,GAAE;QACpB,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC"}
@@ -13,21 +13,21 @@ export declare function createMCPConfigTool(): import("ai").Tool<z.ZodObject<{
13
13
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
14
14
  }, "strip", z.ZodTypeAny, {
15
15
  action: "list" | "add" | "remove" | "get";
16
- command?: string | undefined;
17
16
  key?: string | undefined;
17
+ command?: string | undefined;
18
18
  env?: Record<string, string> | undefined;
19
19
  args?: string[] | undefined;
20
20
  }, {
21
21
  action: "list" | "add" | "remove" | "get";
22
- command?: string | undefined;
23
22
  key?: string | undefined;
23
+ command?: string | undefined;
24
24
  env?: Record<string, string> | undefined;
25
25
  args?: string[] | undefined;
26
26
  }>, string> & {
27
27
  execute: (args: {
28
28
  action: "list" | "add" | "remove" | "get";
29
- command?: string | undefined;
30
29
  key?: string | undefined;
30
+ command?: string | undefined;
31
31
  env?: Record<string, string> | undefined;
32
32
  args?: string[] | undefined;
33
33
  }, options: import("ai").ToolExecutionOptions) => PromiseLike<string>;
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ import type { PlanStore } from '../plan-store.js';
3
+ /**
4
+ * Creates the `plan` tool for coordinator (ReAct) mode.
5
+ *
6
+ * Each step carries a verification criterion at creation time. Marking a step
7
+ * `done` requires a `signoff` attesting that the verification was actually
8
+ * performed. `cancelled`/`error` require `note` (no sign-off, since the step
9
+ * did not succeed).
10
+ */
11
+ export declare function createPlanTool(planStore: PlanStore): import("ai").Tool<z.ZodObject<{
12
+ action: z.ZodEnum<["create", "update", "add", "view"]>;
13
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
14
+ description: z.ZodString;
15
+ verification: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ description: string;
18
+ verification: string;
19
+ }, {
20
+ description: string;
21
+ verification: string;
22
+ }>, "many">>;
23
+ step: z.ZodOptional<z.ZodObject<{
24
+ description: z.ZodString;
25
+ verification: z.ZodString;
26
+ }, "strip", z.ZodTypeAny, {
27
+ description: string;
28
+ verification: string;
29
+ }, {
30
+ description: string;
31
+ verification: string;
32
+ }>>;
33
+ id: z.ZodOptional<z.ZodNumber>;
34
+ status: z.ZodOptional<z.ZodEnum<["pending", "in_progress", "done", "cancelled", "error"]>>;
35
+ note: z.ZodOptional<z.ZodString>;
36
+ signoff: z.ZodOptional<z.ZodString>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ action: "add" | "update" | "create" | "view";
39
+ status?: "error" | "done" | "pending" | "in_progress" | "cancelled" | undefined;
40
+ id?: number | undefined;
41
+ note?: string | undefined;
42
+ signoff?: string | undefined;
43
+ steps?: {
44
+ description: string;
45
+ verification: string;
46
+ }[] | undefined;
47
+ step?: {
48
+ description: string;
49
+ verification: string;
50
+ } | undefined;
51
+ }, {
52
+ action: "add" | "update" | "create" | "view";
53
+ status?: "error" | "done" | "pending" | "in_progress" | "cancelled" | undefined;
54
+ id?: number | undefined;
55
+ note?: string | undefined;
56
+ signoff?: string | undefined;
57
+ steps?: {
58
+ description: string;
59
+ verification: string;
60
+ }[] | undefined;
61
+ step?: {
62
+ description: string;
63
+ verification: string;
64
+ } | undefined;
65
+ }>, string> & {
66
+ execute: (args: {
67
+ action: "add" | "update" | "create" | "view";
68
+ status?: "error" | "done" | "pending" | "in_progress" | "cancelled" | undefined;
69
+ id?: number | undefined;
70
+ note?: string | undefined;
71
+ signoff?: string | undefined;
72
+ steps?: {
73
+ description: string;
74
+ verification: string;
75
+ }[] | undefined;
76
+ step?: {
77
+ description: string;
78
+ verification: string;
79
+ } | undefined;
80
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<string>;
81
+ };
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPlanTool = createPlanTool;
4
+ const ai_1 = require("ai");
5
+ const zod_1 = require("zod");
6
+ const output_js_1 = require("../output.js");
7
+ const stepInputSchema = zod_1.z.object({
8
+ description: zod_1.z
9
+ .string()
10
+ .min(1, 'description must not be empty')
11
+ .describe('What this step accomplishes.'),
12
+ verification: zod_1.z
13
+ .string()
14
+ .min(1, 'verification must not be empty')
15
+ .describe('Concrete check that proves the step succeeded — a command to run, a file to read, a URL to GET, an output substring to look for. Must be observable, not subjective.'),
16
+ });
17
+ /**
18
+ * Creates the `plan` tool for coordinator (ReAct) mode.
19
+ *
20
+ * Each step carries a verification criterion at creation time. Marking a step
21
+ * `done` requires a `signoff` attesting that the verification was actually
22
+ * performed. `cancelled`/`error` require `note` (no sign-off, since the step
23
+ * did not succeed).
24
+ */
25
+ function createPlanTool(planStore) {
26
+ // Suppress redundant re-renders: the model often calls `view` repeatedly
27
+ // (and may also re-issue an `update` that produces no visible change).
28
+ // Compare against the last rendered string and skip printing when identical.
29
+ let lastRendered = null;
30
+ const printIfChanged = () => {
31
+ const rendered = planStore.render();
32
+ if (rendered === lastRendered)
33
+ return;
34
+ lastRendered = rendered;
35
+ (0, output_js_1.printPlan)(planStore.view());
36
+ };
37
+ return (0, ai_1.tool)({
38
+ description: "Track and manage a structured plan for the current turn. Required in coordinator mode. Each step has a `verification` criterion (set at creation) describing how you'll prove it succeeded. Actions: 'create' seeds a plan with step objects {description, verification}; 'add' appends one such step; 'update' transitions a step's status; 'view' shows the plan. Marking 'done' requires `signoff` (attesting verification was performed). Marking 'cancelled' or 'error' requires `note` (the reason). The plan is visible to the user.",
39
+ parameters: zod_1.z.object({
40
+ action: zod_1.z.enum(['create', 'update', 'add', 'view']).describe('The action to perform'),
41
+ steps: zod_1.z
42
+ .array(stepInputSchema)
43
+ .optional()
44
+ .describe('Required for create: ordered list of {description, verification} objects.'),
45
+ step: stepInputSchema
46
+ .optional()
47
+ .describe('Required for add: a {description, verification} object.'),
48
+ id: zod_1.z.number().optional().describe('Required for update: step id'),
49
+ status: zod_1.z
50
+ .enum(['pending', 'in_progress', 'done', 'cancelled', 'error'])
51
+ .optional()
52
+ .describe('Required for update: new status'),
53
+ note: zod_1.z
54
+ .string()
55
+ .optional()
56
+ .describe('Required when transitioning to cancelled or error: 1-2 sentences explaining why the step did not complete.'),
57
+ signoff: zod_1.z
58
+ .string()
59
+ .optional()
60
+ .describe('Required when transitioning to done: a brief statement (1-2 sentences) attesting that the verification criterion was checked and passed. Cite the concrete evidence (command output, file contents, status code) — do not just restate the description.'),
61
+ }),
62
+ execute: async ({ action, steps, step, id, status, note, signoff }) => {
63
+ switch (action) {
64
+ case 'create': {
65
+ if (!steps || steps.length === 0) {
66
+ return 'Error: steps is required for create action and must be non-empty.';
67
+ }
68
+ const created = planStore.create(steps);
69
+ printIfChanged();
70
+ return `Plan created with ${created.length} step${created.length === 1 ? '' : 's'}.`;
71
+ }
72
+ case 'add': {
73
+ if (!step)
74
+ return 'Error: step is required for add action ({description, verification}).';
75
+ const added = planStore.add(step);
76
+ printIfChanged();
77
+ return `Step ${added.id} added.`;
78
+ }
79
+ case 'update': {
80
+ if (id === undefined || !status) {
81
+ return 'Error: id and status are required for update action.';
82
+ }
83
+ if (status === 'done' && !signoff) {
84
+ return 'Error: signoff is required when marking a step done. Cite the verification evidence (command output, file contents, status code) — do not just restate the step description.';
85
+ }
86
+ if ((status === 'cancelled' || status === 'error') && !note) {
87
+ return `Error: note is required when marking a step ${status}. Explain why the step did not complete in 1-2 sentences.`;
88
+ }
89
+ const updated = planStore.update(id, status, { note, signoff });
90
+ if (!updated)
91
+ return `Error: no step found with id ${id}.`;
92
+ printIfChanged();
93
+ return `Step ${id} -> ${status}.`;
94
+ }
95
+ case 'view': {
96
+ const current = planStore.view();
97
+ if (current.length === 0)
98
+ return 'No plan in progress. Use create to start one.';
99
+ printIfChanged();
100
+ return `Plan: ${current.length} step${current.length === 1 ? '' : 's'}, ${planStore.unresolvedCount()} unresolved.`;
101
+ }
102
+ default:
103
+ return `Unknown action: ${action}`;
104
+ }
105
+ },
106
+ });
107
+ }
108
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/tools/plan.ts"],"names":[],"mappings":";;AA0BA,wCAoFC;AA9GD,2BAA0B;AAC1B,6BAAwB;AAExB,4CAAyC;AAEzC,MAAM,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/B,WAAW,EAAE,OAAC;SACX,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,+BAA+B,CAAC;SACvC,QAAQ,CAAC,8BAA8B,CAAC;IAC3C,YAAY,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,G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CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;wBAC5D,OAAO,+CAA+C,MAAM,2DAA2D,CAAC;oBAC1H,CAAC;oBACD,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;oBAChE,IAAI,CAAC,OAAO;wBAAE,OAAO,gCAAgC,EAAE,GAAG,CAAC;oBAC3D,cAAc,EAAE,CAAC;oBACjB,OAAO,QAAQ,EAAE,OAAO,MAAM,GAAG,CAAC;gBACpC,CAAC;gBACD,KAAK,MAAM,CAAC,CAAC,CAAC;oBACZ,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;oBACjC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;wBAAE,OAAO,+CAA+C,CAAC;oBACjF,cAAc,EAAE,CAAC;oBACjB,OAAO,SAAS,OAAO,CAAC,MAAM,QAAQ,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,eAAe,EAAE,cAAc,CAAC;gBACtH,CAAC;gBACD;oBACE,OAAO,mBAAmB,MAAM,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Default cap on characters returned from a sub-agent or specialist to the
3
+ * parent agent's context. The user still sees full output via printToolResult
4
+ * in onStepFinish.
5
+ */
6
+ export declare const DEFAULT_SUBAGENT_RESULT_MAX_CHARS = 4000;
7
+ /**
8
+ * Parses a raw env-var value into a positive integer cap.
9
+ * Falls back to {@link DEFAULT_SUBAGENT_RESULT_MAX_CHARS} when the input is
10
+ * missing, non-numeric, or below 1.
11
+ */
12
+ export declare function parseSubagentResultMaxChars(raw: string | undefined): number;
13
+ /**
14
+ * Resolved cap, honoring the BERNARD_SUBAGENT_RESULT_MAX_CHARS env var.
15
+ * Read once at module load. Set the env var before launching Bernard to override.
16
+ */
17
+ export declare const SUBAGENT_RESULT_MAX_CHARS: number;
18
+ /**
19
+ * Caps a sub-agent or specialist result string to prevent context bloat in
20
+ * the parent agent. The total returned length is guaranteed to be `<= maxChars`
21
+ * — the truncation marker is included in the budget. When `maxChars` is
22
+ * smaller than the marker itself, a truncated marker is returned.
23
+ */
24
+ export declare function capSubagentResult(text: string, maxChars?: number): string;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUBAGENT_RESULT_MAX_CHARS = exports.DEFAULT_SUBAGENT_RESULT_MAX_CHARS = void 0;
4
+ exports.parseSubagentResultMaxChars = parseSubagentResultMaxChars;
5
+ exports.capSubagentResult = capSubagentResult;
6
+ /**
7
+ * Default cap on characters returned from a sub-agent or specialist to the
8
+ * parent agent's context. The user still sees full output via printToolResult
9
+ * in onStepFinish.
10
+ */
11
+ exports.DEFAULT_SUBAGENT_RESULT_MAX_CHARS = 4000;
12
+ /**
13
+ * Parses a raw env-var value into a positive integer cap.
14
+ * Falls back to {@link DEFAULT_SUBAGENT_RESULT_MAX_CHARS} when the input is
15
+ * missing, non-numeric, or below 1.
16
+ */
17
+ function parseSubagentResultMaxChars(raw) {
18
+ if (!raw)
19
+ return exports.DEFAULT_SUBAGENT_RESULT_MAX_CHARS;
20
+ const parsed = parseInt(raw, 10);
21
+ if (!Number.isFinite(parsed) || parsed < 1)
22
+ return exports.DEFAULT_SUBAGENT_RESULT_MAX_CHARS;
23
+ return Math.floor(parsed);
24
+ }
25
+ /**
26
+ * Resolved cap, honoring the BERNARD_SUBAGENT_RESULT_MAX_CHARS env var.
27
+ * Read once at module load. Set the env var before launching Bernard to override.
28
+ */
29
+ exports.SUBAGENT_RESULT_MAX_CHARS = parseSubagentResultMaxChars(process.env.BERNARD_SUBAGENT_RESULT_MAX_CHARS);
30
+ /**
31
+ * Caps a sub-agent or specialist result string to prevent context bloat in
32
+ * the parent agent. The total returned length is guaranteed to be `<= maxChars`
33
+ * — the truncation marker is included in the budget. When `maxChars` is
34
+ * smaller than the marker itself, a truncated marker is returned.
35
+ */
36
+ function capSubagentResult(text, maxChars = exports.SUBAGENT_RESULT_MAX_CHARS) {
37
+ if (text.length <= maxChars)
38
+ return text;
39
+ const marker = `\n...[output truncated at ${maxChars} chars]`;
40
+ if (marker.length >= maxChars)
41
+ return marker.slice(0, maxChars);
42
+ return text.slice(0, maxChars - marker.length) + marker;
43
+ }
44
+ //# sourceMappingURL=result-cap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-cap.js","sourceRoot":"","sources":["../../src/tools/result-cap.ts"],"names":[],"mappings":";;;AAYA,kEAKC;AAgBD,8CAQC;AAzCD;;;;GAIG;AACU,QAAA,iCAAiC,GAAG,IAAI,CAAC;AAEtD;;;;GAIG;AACH,SAAgB,2BAA2B,CAAC,GAAuB;IACjE,IAAI,CAAC,GAAG;QAAE,OAAO,yCAAiC,CAAC;IACnD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;QAAE,OAAO,yCAAiC,CAAC;IACrF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACU,QAAA,yBAAyB,GAAG,2BAA2B,CAClE,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAC9C,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,IAAY,EACZ,WAAmB,iCAAyB;IAE5C,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,MAAM,GAAG,6BAA6B,QAAQ,SAAS,CAAC;IAC9D,IAAI,MAAM,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAChE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC1D,CAAC"}
@@ -14,21 +14,21 @@ export declare function createRoutineTool(routineStore?: RoutineStore): import("
14
14
  content: z.ZodOptional<z.ZodString>;
15
15
  }, "strip", z.ZodTypeAny, {
16
16
  action: "list" | "read" | "delete" | "update" | "create";
17
- content?: string | undefined;
18
17
  name?: string | undefined;
18
+ content?: string | undefined;
19
19
  id?: string | undefined;
20
20
  description?: string | undefined;
21
21
  }, {
22
22
  action: "list" | "read" | "delete" | "update" | "create";
23
- content?: string | undefined;
24
23
  name?: string | undefined;
24
+ content?: string | undefined;
25
25
  id?: string | undefined;
26
26
  description?: string | undefined;
27
27
  }>, string> & {
28
28
  execute: (args: {
29
29
  action: "list" | "read" | "delete" | "update" | "create";
30
- content?: string | undefined;
31
30
  name?: string | undefined;
31
+ content?: string | undefined;
32
32
  id?: string | undefined;
33
33
  description?: string | undefined;
34
34
  }, options: import("ai").ToolExecutionOptions) => PromiseLike<string>;
@@ -8,11 +8,24 @@ import type { ToolOptions, ShellResult } from './types.js';
8
8
  * @returns `true` if the command matches a dangerous pattern.
9
9
  */
10
10
  export declare function isDangerous(command: string): boolean;
11
+ /**
12
+ * The agent's system prompt instructs the model to write temp scripts under
13
+ * this prefix and clean them up afterward, so the cleanup must not require
14
+ * confirmation.
15
+ */
16
+ export declare const BERNARD_TMP_PREFIX: string;
17
+ /**
18
+ * Commands that match a dangerous pattern but should bypass the confirmation
19
+ * prompt because they operate exclusively on Bernard's own workspace.
20
+ *
21
+ * @internal Exported for testing only.
22
+ */
23
+ export declare function isSafelisted(command: string): boolean;
11
24
  /**
12
25
  * Creates the shell execution tool that runs commands in the user's terminal.
13
26
  *
14
27
  * Dangerous commands are intercepted and require explicit user confirmation
15
- * before execution.
28
+ * before execution, unless they match a safelist of Bernard-owned operations.
16
29
  *
17
30
  * @param options - Shell timeout and dangerous-command confirmation callback.
18
31
  */
@@ -1,10 +1,47 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BERNARD_TMP_PREFIX = void 0;
3
37
  exports.isDangerous = isDangerous;
38
+ exports.isSafelisted = isSafelisted;
4
39
  exports.createShellTool = createShellTool;
5
40
  const ai_1 = require("ai");
6
41
  const zod_1 = require("zod");
7
42
  const node_child_process_1 = require("node:child_process");
43
+ const os = __importStar(require("node:os"));
44
+ const path = __importStar(require("node:path"));
8
45
  const DANGEROUS_PATTERNS = [
9
46
  /\brm\s+(-[^\s]*\s+)*-[^\s]*r/, // rm with -r flag
10
47
  /\brm\s+(-[^\s]*\s+)*-[^\s]*f/, // rm with -f flag
@@ -31,11 +68,56 @@ const DANGEROUS_PATTERNS = [
31
68
  function isDangerous(command) {
32
69
  return DANGEROUS_PATTERNS.some((pattern) => pattern.test(command));
33
70
  }
71
+ // Reject commands containing these so the safelist can't be tricked into
72
+ // composing additional shell work outside its narrow scope.
73
+ const META_RE = /[;&|`>]|\$\(/;
74
+ // Glob characters would let the shell expand the path past the prefix check.
75
+ const GLOB_RE = /[*?[\]{}!]/;
76
+ // Quotes or expansion sigils inside a token signal an attempt to inject more
77
+ // shell work — the safelist only handles literal paths.
78
+ const UNSAFE_TOKEN_CHARS = /['"`$\\]/;
79
+ /**
80
+ * The agent's system prompt instructs the model to write temp scripts under
81
+ * this prefix and clean them up afterward, so the cleanup must not require
82
+ * confirmation.
83
+ */
84
+ exports.BERNARD_TMP_PREFIX = path.join(os.tmpdir(), 'bernard-');
85
+ /**
86
+ * Commands that match a dangerous pattern but should bypass the confirmation
87
+ * prompt because they operate exclusively on Bernard's own workspace.
88
+ *
89
+ * @internal Exported for testing only.
90
+ */
91
+ function isSafelisted(command) {
92
+ const trimmed = command.trim();
93
+ if (!/^rm(\s|$)/.test(trimmed))
94
+ return false;
95
+ if (META_RE.test(trimmed))
96
+ return false;
97
+ const paths = trimmed
98
+ .split(/\s+/)
99
+ .slice(1)
100
+ .filter((t) => !t.startsWith('-'));
101
+ if (paths.length === 0)
102
+ return false;
103
+ return paths.every((t) => {
104
+ if (GLOB_RE.test(t))
105
+ return false;
106
+ if (UNSAFE_TOKEN_CHARS.test(t))
107
+ return false;
108
+ if (t.split('/').includes('..'))
109
+ return false;
110
+ // Resolve against cwd to catch `bernard-x/../..` traversal that would
111
+ // escape the tmp prefix once the shell evaluates it.
112
+ const resolved = path.resolve(t);
113
+ return resolved.startsWith(exports.BERNARD_TMP_PREFIX);
114
+ });
115
+ }
34
116
  /**
35
117
  * Creates the shell execution tool that runs commands in the user's terminal.
36
118
  *
37
119
  * Dangerous commands are intercepted and require explicit user confirmation
38
- * before execution.
120
+ * before execution, unless they match a safelist of Bernard-owned operations.
39
121
  *
40
122
  * @param options - Shell timeout and dangerous-command confirmation callback.
41
123
  */
@@ -45,9 +127,9 @@ function createShellTool(options) {
45
127
  parameters: zod_1.z.object({
46
128
  command: zod_1.z.string().describe('The shell command to execute'),
47
129
  }),
48
- execute: async ({ command }) => {
49
- if (isDangerous(command)) {
50
- const confirmed = await options.confirmDangerous(command);
130
+ execute: async ({ command }, execOptions) => {
131
+ if (isDangerous(command) && !isSafelisted(command)) {
132
+ const confirmed = await options.confirmDangerous(command, execOptions?.abortSignal);
51
133
  if (!confirmed) {
52
134
  return { output: 'Command cancelled by user.', is_error: false };
53
135
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/tools/shell.ts"],"names":[],"mappings":";;AA6BA,kCAEC;AAUD,0CAiCC;AA1ED,2BAA0B;AAC1B,6BAAwB;AACxB,2DAA8C;AAG9C,MAAM,kBAAkB,GAAG;IACzB,8BAA8B,EAAE,kBAAkB;IAClD,8BAA8B,EAAE,kBAAkB;IAClD,UAAU;IACV,UAAU;IACV,SAAS;IACT,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,qCAAqC;IACrC,eAAe;IACf,WAAW;IACX,aAAa;CACd,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,OAAe;IACzC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,OAAoB;IAClD,OAAO,IAAA,SAAI,EAAC;QACV,WAAW,EACT,+NAA+N;QACjO,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,OAAO,EAAE,OAAC,CAAC,MAA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CAAC,SAAS,EAAE,CAAC;oBACf,OAAO,EAAE,MAAM,EAAE,4BAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;gBACnE,CAAC;YACH,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,IAAA,6BAAQ,EAAC,OAAO,EAAE;oBAC/B,QAAQ,EAAE,OAAO;oBACjB,OAAO,EAAE,OAAO,CAAC,YAAY;oBAC7B,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE,EAAE,OAAO;oBACpC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;iBAChC,CAAC,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;YAC9D,CAAC;YAAC,OAAO,GAAY,EAAE,CAAC;gBACtB,MAAM,SAAS,GAAG,GAA6D,CAAC;gBAChF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;gBACtC,MAAM,MAAM,GACV,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,IAAI,gBAAgB,CAAC;gBACvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACpC,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -7,9 +7,11 @@ import type { SpecialistStore } from '../specialists.js';
7
7
  /**
8
8
  * Creates the specialist execution tool for running tasks through a saved specialist profile.
9
9
  *
10
- * Each specialist run receives its own `generateText` loop with a 10-step budget
11
- * and no conversation history. The specialist's system prompt and guidelines are
12
- * used as the persona. Shares the concurrency pool with sub-agents and tasks.
10
+ * Each specialist run receives its own `generateText` loop with a step budget of
11
+ * `ceil(config.maxSteps * SPECIALIST_STEP_RATIO)` (tripled and clamped via
12
+ * `computeEffectiveMaxSteps` when ReAct mode is on) and no conversation history.
13
+ * The specialist's system prompt and guidelines are used as the persona. Shares
14
+ * the concurrency pool with sub-agents and tasks.
13
15
  *
14
16
  * @param config - Bernard configuration (provider, model, token limits).
15
17
  * @param options - Shell execution options forwarded to child tool sets.