aura-code 0.3.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.
- package/LICENSE +21 -0
- package/README.md +137 -0
- package/dist/agent/context.d.ts +13 -0
- package/dist/agent/context.js +183 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/loop.d.ts +60 -0
- package/dist/agent/loop.js +228 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/session-store.d.ts +30 -0
- package/dist/agent/session-store.js +178 -0
- package/dist/agent/session-store.js.map +1 -0
- package/dist/agent/spawner.d.ts +57 -0
- package/dist/agent/spawner.js +112 -0
- package/dist/agent/spawner.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +3 -0
- package/dist/agent/system-prompt.js +100 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/architect/engine.d.ts +47 -0
- package/dist/architect/engine.js +217 -0
- package/dist/architect/engine.js.map +1 -0
- package/dist/architect/types.d.ts +61 -0
- package/dist/architect/types.js +6 -0
- package/dist/architect/types.js.map +1 -0
- package/dist/cli/diamond.d.ts +1 -0
- package/dist/cli/diamond.js +23 -0
- package/dist/cli/diamond.js.map +1 -0
- package/dist/cli/display.d.ts +44 -0
- package/dist/cli/display.js +234 -0
- package/dist/cli/display.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1734 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/defaults.d.ts +46 -0
- package/dist/config/defaults.js +106 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/project-config.d.ts +90 -0
- package/dist/config/project-config.js +141 -0
- package/dist/config/project-config.js.map +1 -0
- package/dist/harness/proposer.d.ts +26 -0
- package/dist/harness/proposer.js +204 -0
- package/dist/harness/proposer.js.map +1 -0
- package/dist/harness/weakness-miner.d.ts +28 -0
- package/dist/harness/weakness-miner.js +359 -0
- package/dist/harness/weakness-miner.js.map +1 -0
- package/dist/integrations/harnesses.d.ts +23 -0
- package/dist/integrations/harnesses.js +161 -0
- package/dist/integrations/harnesses.js.map +1 -0
- package/dist/orchestration/competence.d.ts +53 -0
- package/dist/orchestration/competence.js +181 -0
- package/dist/orchestration/competence.js.map +1 -0
- package/dist/orchestration/executor.d.ts +42 -0
- package/dist/orchestration/executor.js +206 -0
- package/dist/orchestration/executor.js.map +1 -0
- package/dist/orchestration/index.d.ts +20 -0
- package/dist/orchestration/index.js +39 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/orchestrator-prompts.d.ts +11 -0
- package/dist/orchestration/orchestrator-prompts.js +153 -0
- package/dist/orchestration/orchestrator-prompts.js.map +1 -0
- package/dist/orchestration/orchestrator.d.ts +27 -0
- package/dist/orchestration/orchestrator.js +169 -0
- package/dist/orchestration/orchestrator.js.map +1 -0
- package/dist/orchestration/plan-store.d.ts +53 -0
- package/dist/orchestration/plan-store.js +176 -0
- package/dist/orchestration/plan-store.js.map +1 -0
- package/dist/orchestration/router-prompts.d.ts +6 -0
- package/dist/orchestration/router-prompts.js +55 -0
- package/dist/orchestration/router-prompts.js.map +1 -0
- package/dist/orchestration/router.d.ts +23 -0
- package/dist/orchestration/router.js +70 -0
- package/dist/orchestration/router.js.map +1 -0
- package/dist/orchestration/ruby-detect.d.ts +6 -0
- package/dist/orchestration/ruby-detect.js +130 -0
- package/dist/orchestration/ruby-detect.js.map +1 -0
- package/dist/orchestration/ruby-types.d.ts +44 -0
- package/dist/orchestration/ruby-types.js +6 -0
- package/dist/orchestration/ruby-types.js.map +1 -0
- package/dist/orchestration/specialist-prompts.d.ts +19 -0
- package/dist/orchestration/specialist-prompts.js +143 -0
- package/dist/orchestration/specialist-prompts.js.map +1 -0
- package/dist/orchestration/specialists.d.ts +66 -0
- package/dist/orchestration/specialists.js +175 -0
- package/dist/orchestration/specialists.js.map +1 -0
- package/dist/orchestration/types.d.ts +82 -0
- package/dist/orchestration/types.js +6 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/perception/extractor.d.ts +7 -0
- package/dist/perception/extractor.js +521 -0
- package/dist/perception/extractor.js.map +1 -0
- package/dist/perception/graph-store.d.ts +25 -0
- package/dist/perception/graph-store.js +117 -0
- package/dist/perception/graph-store.js.map +1 -0
- package/dist/perception/index.d.ts +4 -0
- package/dist/perception/index.js +18 -0
- package/dist/perception/index.js.map +1 -0
- package/dist/perception/queries.d.ts +29 -0
- package/dist/perception/queries.js +354 -0
- package/dist/perception/queries.js.map +1 -0
- package/dist/perception/types.d.ts +103 -0
- package/dist/perception/types.js +6 -0
- package/dist/perception/types.js.map +1 -0
- package/dist/providers/anthropic.d.ts +11 -0
- package/dist/providers/anthropic.js +172 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/factory.d.ts +58 -0
- package/dist/providers/factory.js +354 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/fallback.d.ts +24 -0
- package/dist/providers/fallback.js +72 -0
- package/dist/providers/fallback.js.map +1 -0
- package/dist/providers/google.d.ts +11 -0
- package/dist/providers/google.js +129 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +24 -0
- package/dist/providers/openai-compatible.js +216 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/providers/resilient-factory.d.ts +24 -0
- package/dist/providers/resilient-factory.js +57 -0
- package/dist/providers/resilient-factory.js.map +1 -0
- package/dist/providers/resilient.d.ts +63 -0
- package/dist/providers/resilient.js +145 -0
- package/dist/providers/resilient.js.map +1 -0
- package/dist/providers/types.d.ts +84 -0
- package/dist/providers/types.js +6 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/ruby/alternator.d.ts +40 -0
- package/dist/ruby/alternator.js +233 -0
- package/dist/ruby/alternator.js.map +1 -0
- package/dist/ruby/competence.d.ts +34 -0
- package/dist/ruby/competence.js +264 -0
- package/dist/ruby/competence.js.map +1 -0
- package/dist/ruby/episode-capture.d.ts +56 -0
- package/dist/ruby/episode-capture.js +193 -0
- package/dist/ruby/episode-capture.js.map +1 -0
- package/dist/ruby/fine-tune.d.ts +16 -0
- package/dist/ruby/fine-tune.js +253 -0
- package/dist/ruby/fine-tune.js.map +1 -0
- package/dist/ruby/index.d.ts +10 -0
- package/dist/ruby/index.js +26 -0
- package/dist/ruby/index.js.map +1 -0
- package/dist/ruby/ruby-model.d.ts +36 -0
- package/dist/ruby/ruby-model.js +81 -0
- package/dist/ruby/ruby-model.js.map +1 -0
- package/dist/ruby/training-data.d.ts +11 -0
- package/dist/ruby/training-data.js +107 -0
- package/dist/ruby/training-data.js.map +1 -0
- package/dist/ruby/types.d.ts +136 -0
- package/dist/ruby/types.js +20 -0
- package/dist/ruby/types.js.map +1 -0
- package/dist/safety/permissions.d.ts +32 -0
- package/dist/safety/permissions.js +304 -0
- package/dist/safety/permissions.js.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +342 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/session.d.ts +22 -0
- package/dist/server/session.js +16 -0
- package/dist/server/session.js.map +1 -0
- package/dist/setup/first-run.d.ts +41 -0
- package/dist/setup/first-run.js +386 -0
- package/dist/setup/first-run.js.map +1 -0
- package/dist/setup/global-config.d.ts +19 -0
- package/dist/setup/global-config.js +97 -0
- package/dist/setup/global-config.js.map +1 -0
- package/dist/tools/audio-transcribe.d.ts +8 -0
- package/dist/tools/audio-transcribe.js +156 -0
- package/dist/tools/audio-transcribe.js.map +1 -0
- package/dist/tools/browser.d.ts +15 -0
- package/dist/tools/browser.js +241 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/calendar.d.ts +12 -0
- package/dist/tools/calendar.js +196 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/clipboard.d.ts +7 -0
- package/dist/tools/clipboard.js +90 -0
- package/dist/tools/clipboard.js.map +1 -0
- package/dist/tools/cron.d.ts +10 -0
- package/dist/tools/cron.js +167 -0
- package/dist/tools/cron.js.map +1 -0
- package/dist/tools/edit-file.d.ts +6 -0
- package/dist/tools/edit-file.js +98 -0
- package/dist/tools/edit-file.js.map +1 -0
- package/dist/tools/email.d.ts +11 -0
- package/dist/tools/email.js +153 -0
- package/dist/tools/email.js.map +1 -0
- package/dist/tools/git.d.ts +1 -0
- package/dist/tools/git.js +7 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/http-request.d.ts +12 -0
- package/dist/tools/http-request.js +91 -0
- package/dist/tools/http-request.js.map +1 -0
- package/dist/tools/image-read.d.ts +7 -0
- package/dist/tools/image-read.js +125 -0
- package/dist/tools/image-read.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +201 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-dir.d.ts +1 -0
- package/dist/tools/list-dir.js +6 -0
- package/dist/tools/list-dir.js.map +1 -0
- package/dist/tools/mcp.d.ts +11 -0
- package/dist/tools/mcp.js +356 -0
- package/dist/tools/mcp.js.map +1 -0
- package/dist/tools/memory.d.ts +9 -0
- package/dist/tools/memory.js +124 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/notify.d.ts +9 -0
- package/dist/tools/notify.js +40 -0
- package/dist/tools/notify.js.map +1 -0
- package/dist/tools/read-file.d.ts +6 -0
- package/dist/tools/read-file.js +76 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/run-shell.d.ts +1 -0
- package/dist/tools/run-shell.js +6 -0
- package/dist/tools/run-shell.js.map +1 -0
- package/dist/tools/run-tests.d.ts +1 -0
- package/dist/tools/run-tests.js +6 -0
- package/dist/tools/run-tests.js.map +1 -0
- package/dist/tools/search-code.d.ts +1 -0
- package/dist/tools/search-code.js +6 -0
- package/dist/tools/search-code.js.map +1 -0
- package/dist/tools/telegram-bot.d.ts +2 -0
- package/dist/tools/telegram-bot.js +693 -0
- package/dist/tools/telegram-bot.js.map +1 -0
- package/dist/tools/telegram-safety.d.ts +52 -0
- package/dist/tools/telegram-safety.js +189 -0
- package/dist/tools/telegram-safety.js.map +1 -0
- package/dist/tools/telegram.d.ts +16 -0
- package/dist/tools/telegram.js +227 -0
- package/dist/tools/telegram.js.map +1 -0
- package/dist/tools/tools.d.ts +48 -0
- package/dist/tools/tools.js +328 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +11 -0
- package/dist/tools/web-fetch.js +119 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +8 -0
- package/dist/tools/web-search.js +81 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/whatsapp.d.ts +10 -0
- package/dist/tools/whatsapp.js +222 -0
- package/dist/tools/whatsapp.js.map +1 -0
- package/dist/tools/write-file.d.ts +1 -0
- package/dist/tools/write-file.js +6 -0
- package/dist/tools/write-file.js.map +1 -0
- package/dist/tools/youtube-transcript.d.ts +9 -0
- package/dist/tools/youtube-transcript.js +200 -0
- package/dist/tools/youtube-transcript.js.map +1 -0
- package/dist/util/circuit-breaker.d.ts +44 -0
- package/dist/util/circuit-breaker.js +78 -0
- package/dist/util/circuit-breaker.js.map +1 -0
- package/dist/util/env.d.ts +18 -0
- package/dist/util/env.js +39 -0
- package/dist/util/env.js.map +1 -0
- package/dist/util/errors.d.ts +42 -0
- package/dist/util/errors.js +121 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/rate-limiter.d.ts +71 -0
- package/dist/util/rate-limiter.js +141 -0
- package/dist/util/rate-limiter.js.map +1 -0
- package/dist/util/retry.d.ts +30 -0
- package/dist/util/retry.js +57 -0
- package/dist/util/retry.js.map +1 -0
- package/dist/util/sanitize.d.ts +16 -0
- package/dist/util/sanitize.js +255 -0
- package/dist/util/sanitize.js.map +1 -0
- package/dist/verify/checks.d.ts +21 -0
- package/dist/verify/checks.js +311 -0
- package/dist/verify/checks.js.map +1 -0
- package/dist/verify/index.d.ts +33 -0
- package/dist/verify/index.js +127 -0
- package/dist/verify/index.js.map +1 -0
- package/dist/verify/types.d.ts +20 -0
- package/dist/verify/types.js +3 -0
- package/dist/verify/types.js.map +1 -0
- package/dist/versioncheck.d.ts +22 -0
- package/dist/versioncheck.js +203 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/viz/index.d.ts +2 -0
- package/dist/viz/index.js +733 -0
- package/dist/viz/index.js.map +1 -0
- package/dist/workflows/engine.d.ts +46 -0
- package/dist/workflows/engine.js +320 -0
- package/dist/workflows/engine.js.map +1 -0
- package/dist/workflows/types.d.ts +92 -0
- package/dist/workflows/types.js +6 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProjectPerception } from '../perception/types.js';
|
|
2
|
+
import type { Episode, TrainingExample } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds instruction-tuning rows from episodes where Ruby failed and the large
|
|
5
|
+
* model produced an approved correction.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateTrainingData(episodes: Episode[], perception: ProjectPerception): Promise<TrainingExample[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Writes training examples as OpenAI-style JSONL for fine-tuning or Modelfile context.
|
|
10
|
+
*/
|
|
11
|
+
export declare function exportJSONL(examples: TrainingExample[], outputPath: string): Promise<void>;
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateTrainingData = generateTrainingData;
|
|
37
|
+
exports.exportJSONL = exportJSONL;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* Builds instruction-tuning rows from episodes where Ruby failed and the large
|
|
42
|
+
* model produced an approved correction.
|
|
43
|
+
*/
|
|
44
|
+
async function generateTrainingData(episodes, perception) {
|
|
45
|
+
try {
|
|
46
|
+
if (!Array.isArray(episodes))
|
|
47
|
+
return [];
|
|
48
|
+
const vision = perception?.trajectory?.vision ?? 'Complete coding tasks accurately.';
|
|
49
|
+
const instruction = [
|
|
50
|
+
'You are a specialized coding assistant for this project.',
|
|
51
|
+
vision,
|
|
52
|
+
perception?.constraints?.strictRules?.length
|
|
53
|
+
? `Constraints: ${perception.constraints.strictRules.join('; ')}`
|
|
54
|
+
: '',
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(' ');
|
|
58
|
+
const examples = [];
|
|
59
|
+
for (const ep of episodes) {
|
|
60
|
+
if (!ep?.rubyAttempted || ep.rubySucceeded)
|
|
61
|
+
continue;
|
|
62
|
+
if (!ep.largeModelOutput?.trim())
|
|
63
|
+
continue;
|
|
64
|
+
if (!ep.reviewerApproved)
|
|
65
|
+
continue;
|
|
66
|
+
examples.push({
|
|
67
|
+
instruction,
|
|
68
|
+
input: ep.task,
|
|
69
|
+
output: ep.largeModelOutput,
|
|
70
|
+
metadata: {
|
|
71
|
+
projectRoot: ep.projectRoot,
|
|
72
|
+
taskCategory: ep.taskCategory,
|
|
73
|
+
rubyFailureReason: ep.rubyOutput
|
|
74
|
+
? `Ruby output insufficient: ${ep.rubyOutput.slice(0, 200)}`
|
|
75
|
+
: 'Ruby did not produce an acceptable result',
|
|
76
|
+
timestamp: ep.timestamp,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return examples;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Writes training examples as OpenAI-style JSONL for fine-tuning or Modelfile context.
|
|
88
|
+
*/
|
|
89
|
+
async function exportJSONL(examples, outputPath) {
|
|
90
|
+
const dir = path.dirname(outputPath);
|
|
91
|
+
if (!fs.existsSync(dir))
|
|
92
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
93
|
+
const lines = (examples ?? []).map(ex => {
|
|
94
|
+
const userContent = `${ex.instruction}\n\n${ex.input}`;
|
|
95
|
+
const row = {
|
|
96
|
+
messages: [
|
|
97
|
+
{ role: 'user', content: userContent },
|
|
98
|
+
{ role: 'assistant', content: ex.output },
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
return JSON.stringify(row);
|
|
102
|
+
});
|
|
103
|
+
const tmp = outputPath + '.tmp';
|
|
104
|
+
await fs.promises.writeFile(tmp, lines.join('\n') + (lines.length ? '\n' : ''), 'utf8');
|
|
105
|
+
await fs.promises.rename(tmp, outputPath);
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=training-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"training-data.js","sourceRoot":"","sources":["../../src/ruby/training-data.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,oDA4CC;AAKD,kCAqBC;AA/ED,uCAAyB;AACzB,2CAA6B;AAI7B;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,QAAmB,EACnB,UAA6B;IAE7B,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,EAAE,CAAC;QAExC,MAAM,MAAM,GAAG,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,mCAAmC,CAAC;QACrF,MAAM,WAAW,GAAG;YAClB,0DAA0D;YAC1D,MAAM;YACN,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM;gBAC1C,CAAC,CAAC,gBAAgB,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACjE,CAAC,CAAC,EAAE;SACP;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,MAAM,QAAQ,GAAsB,EAAE,CAAC;QAEvC,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAC,EAAE,EAAE,aAAa,IAAI,EAAE,CAAC,aAAa;gBAAE,SAAS;YACrD,IAAI,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,EAAE;gBAAE,SAAS;YAC3C,IAAI,CAAC,EAAE,CAAC,gBAAgB;gBAAE,SAAS;YAEnC,QAAQ,CAAC,IAAI,CAAC;gBACZ,WAAW;gBACX,KAAK,EAAE,EAAE,CAAC,IAAI;gBACd,MAAM,EAAE,EAAE,CAA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C,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACxF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learned competence for a recurring task pattern.
|
|
3
|
+
* Built up over episodes where Ruby attempted the work before escalation.
|
|
4
|
+
*/
|
|
5
|
+
export interface CompetenceLevel {
|
|
6
|
+
/** Normalised pattern key used to match future tasks (e.g. category + keywords). */
|
|
7
|
+
taskPattern: string;
|
|
8
|
+
/** Fraction of Ruby attempts that succeeded, in [0, 1]. */
|
|
9
|
+
successRate: number;
|
|
10
|
+
/** Total Ruby attempts recorded for this pattern. */
|
|
11
|
+
attemptCount: number;
|
|
12
|
+
/** Unix timestamp (ms) when this level was last updated. */
|
|
13
|
+
lastUpdated: number;
|
|
14
|
+
/** Recent exemplars that informed the success rate. */
|
|
15
|
+
examples: {
|
|
16
|
+
task: string;
|
|
17
|
+
succeeded: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Runtime configuration for the Ruby small-model alternation layer.
|
|
22
|
+
* Typically loaded from `.aura/ruby.json` or CLI flags.
|
|
23
|
+
*/
|
|
24
|
+
export interface RubyConfig {
|
|
25
|
+
/** Ollama model tag (e.g. `qwen2.5-coder:1.5b`). */
|
|
26
|
+
modelName: string;
|
|
27
|
+
/** OpenAI-compatible base URL for the local Ollama server. */
|
|
28
|
+
ollamaBaseUrl: string;
|
|
29
|
+
/**
|
|
30
|
+
* Minimum success rate required before Ruby is trusted without escalation.
|
|
31
|
+
* Compared against historical episodes for similar tasks.
|
|
32
|
+
*/
|
|
33
|
+
competenceThreshold: number;
|
|
34
|
+
/**
|
|
35
|
+
* Minimum Ruby attempts on a pattern before competence gating applies.
|
|
36
|
+
* Below this count, Ruby always gets a chance to gather training data.
|
|
37
|
+
*/
|
|
38
|
+
minAttempts: number;
|
|
39
|
+
/** When false, alternation always escalates to the large model. */
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Sensible defaults for local Ollama + Qwen coder 1.5B. */
|
|
43
|
+
export declare const DEFAULT_RUBY_CONFIG: RubyConfig;
|
|
44
|
+
/** Coarse task classification for competence reports and fine-tune bucketing. */
|
|
45
|
+
export type TaskCategory = 'research' | 'implementation' | 'review' | 'refactor' | 'other';
|
|
46
|
+
/**
|
|
47
|
+
* A single alternation episode: Ruby tried (or was skipped), optionally escalated
|
|
48
|
+
* to a large model, then reviewed.
|
|
49
|
+
*/
|
|
50
|
+
export interface Episode {
|
|
51
|
+
/** Unique episode identifier. */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Unix timestamp (ms) when the episode completed. */
|
|
54
|
+
timestamp: number;
|
|
55
|
+
/** Original user task text. */
|
|
56
|
+
task: string;
|
|
57
|
+
/** Absolute path to the project root. */
|
|
58
|
+
projectRoot: string;
|
|
59
|
+
/** Whether Ruby (small model) was invoked for this episode. */
|
|
60
|
+
rubyAttempted: boolean;
|
|
61
|
+
/** Whether Ruby's output was accepted without large-model intervention. */
|
|
62
|
+
rubySucceeded: boolean;
|
|
63
|
+
/** Raw text produced by Ruby, if attempted. */
|
|
64
|
+
rubyOutput?: string;
|
|
65
|
+
/** Large-model id used when Ruby failed or was bypassed (e.g. `claude-sonnet-4-5`). */
|
|
66
|
+
largeModelUsed?: string;
|
|
67
|
+
/** Final output from the large model, if any. */
|
|
68
|
+
largeModelOutput?: string;
|
|
69
|
+
/** Whether a reviewer specialist approved the final result. */
|
|
70
|
+
reviewerApproved: boolean;
|
|
71
|
+
/** Token usage split by model tier. */
|
|
72
|
+
tokensUsed: {
|
|
73
|
+
ruby?: number;
|
|
74
|
+
largeModel?: number;
|
|
75
|
+
};
|
|
76
|
+
/** Wall-clock duration of the episode in milliseconds. */
|
|
77
|
+
durationMs: number;
|
|
78
|
+
/** Task category assigned by the router or orchestrator. */
|
|
79
|
+
taskCategory: TaskCategory;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Output of the alternator: whether to route this task to Ruby or escalate
|
|
83
|
+
* immediately to the configured large model.
|
|
84
|
+
*/
|
|
85
|
+
export interface AlternationDecision {
|
|
86
|
+
/** True when Ruby should handle the task; false when escalating. */
|
|
87
|
+
useRuby: boolean;
|
|
88
|
+
/** Human-readable explanation of the routing choice. */
|
|
89
|
+
reason: string;
|
|
90
|
+
/** Confidence in this decision, in [0, 1]. */
|
|
91
|
+
confidence: number;
|
|
92
|
+
/** Historical competence for the matched task pattern, if any. */
|
|
93
|
+
competenceLevel?: CompetenceLevel;
|
|
94
|
+
/** Large model to use when `useRuby` is false. */
|
|
95
|
+
fallbackModel: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* One instruction-tuning row derived from an episode where the large model
|
|
99
|
+
* corrected or replaced Ruby's output.
|
|
100
|
+
*/
|
|
101
|
+
export interface TrainingExample {
|
|
102
|
+
/** System or high-level directive for the small model. */
|
|
103
|
+
instruction: string;
|
|
104
|
+
/** Task context shown to the model. */
|
|
105
|
+
input: string;
|
|
106
|
+
/** Target output (typically from the large model after review). */
|
|
107
|
+
output: string;
|
|
108
|
+
metadata: {
|
|
109
|
+
projectRoot: string;
|
|
110
|
+
taskCategory: string;
|
|
111
|
+
/** Why Ruby failed, when known — used to filter low-quality rows. */
|
|
112
|
+
rubyFailureReason?: string;
|
|
113
|
+
timestamp: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Tracks an asynchronous fine-tune job against the Ruby base model.
|
|
118
|
+
*/
|
|
119
|
+
export interface FineTuneJob {
|
|
120
|
+
/** Unique job identifier. */
|
|
121
|
+
id: string;
|
|
122
|
+
/** Job lifecycle state. */
|
|
123
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
124
|
+
/** Base Ollama model before fine-tuning. */
|
|
125
|
+
baseModel: string;
|
|
126
|
+
/** Number of training examples submitted. */
|
|
127
|
+
trainingExamples: number;
|
|
128
|
+
/** Resulting model tag after a successful run. */
|
|
129
|
+
outputModel: string;
|
|
130
|
+
/** Unix timestamp (ms) when the job started. */
|
|
131
|
+
startedAt?: number;
|
|
132
|
+
/** Unix timestamp (ms) when the job reached a terminal state. */
|
|
133
|
+
completedAt?: number;
|
|
134
|
+
/** Error message when `status` is `failed`. */
|
|
135
|
+
error?: string;
|
|
136
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// Ruby Principle — core types
|
|
4
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
//
|
|
6
|
+
// The Ruby Principle: two models alternate at exactly the moment where
|
|
7
|
+
// fine-tuning is needed. Ruby is a small local model (Qwen 1B/2B via Ollama)
|
|
8
|
+
// present from the beginning; it learns from every episode where a large
|
|
9
|
+
// model had to intervene.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.DEFAULT_RUBY_CONFIG = void 0;
|
|
12
|
+
/** Sensible defaults for local Ollama + Qwen coder 1.5B. */
|
|
13
|
+
exports.DEFAULT_RUBY_CONFIG = {
|
|
14
|
+
modelName: 'qwen2.5-coder:1.5b',
|
|
15
|
+
ollamaBaseUrl: 'http://localhost:11434/v1',
|
|
16
|
+
competenceThreshold: 0.7,
|
|
17
|
+
minAttempts: 3,
|
|
18
|
+
enabled: true,
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ruby/types.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,8BAA8B;AAC9B,gFAAgF;AAChF,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,yEAAyE;AACzE,0BAA0B;;;AAkD1B,4DAA4D;AAC/C,QAAA,mBAAmB,GAAe;IAC7C,SAAS,EAAE,oBAAoB;IAC/B,aAAa,EAAE,2BAA2B;IAC1C,mBAAmB,EAAE,GAAG;IACxB,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,IAAI;CACd,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type PermissionLevel = 'read-only' | 'normal' | 'auto';
|
|
2
|
+
export interface PermissionResult {
|
|
3
|
+
allowed: boolean;
|
|
4
|
+
reason?: string;
|
|
5
|
+
needsConfirm?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface PermissionConfig {
|
|
8
|
+
allowedMountPaths?: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class ShellCommandValidator {
|
|
11
|
+
private blockedPrefixes;
|
|
12
|
+
constructor();
|
|
13
|
+
private discoverFuseMounts;
|
|
14
|
+
validateCommand(cmd: string, projectRoot: string, config?: PermissionConfig): {
|
|
15
|
+
allowed: boolean;
|
|
16
|
+
reason?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class PermissionSystem {
|
|
20
|
+
private level;
|
|
21
|
+
private sessionApprovals;
|
|
22
|
+
private validator;
|
|
23
|
+
private projectRoot;
|
|
24
|
+
private config?;
|
|
25
|
+
constructor(level?: PermissionLevel, projectRoot?: string, config?: PermissionConfig);
|
|
26
|
+
check(toolName: string, input: Record<string, unknown>): PermissionResult;
|
|
27
|
+
approveForSession(key: string): void;
|
|
28
|
+
private isDangerous;
|
|
29
|
+
private isSafe;
|
|
30
|
+
}
|
|
31
|
+
/** Ask user to confirm in the terminal. Returns true if approved. */
|
|
32
|
+
export declare function confirm(message: string): Promise<boolean>;
|
|
@@ -0,0 +1,304 @@
|
|
|
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
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PermissionSystem = exports.ShellCommandValidator = void 0;
|
|
40
|
+
exports.confirm = confirm;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const readline_1 = __importDefault(require("readline"));
|
|
44
|
+
const defaults_js_1 = require("../config/defaults.js");
|
|
45
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
46
|
+
// ShellCommandValidator — prevents recursive commands from traversing into
|
|
47
|
+
// unresponsive FUSE/network mounts where I/O can cause D-state hangs.
|
|
48
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
49
|
+
/** Extract search-path arguments from find/grep/rg command strings. */
|
|
50
|
+
function extractSearchPaths(base, args) {
|
|
51
|
+
if (base === 'find') {
|
|
52
|
+
// find [path] [expression] — first non-flag arg is the search path
|
|
53
|
+
for (const a of args) {
|
|
54
|
+
if (!a.startsWith('-') && a !== '!' && a !== '(' && a !== ')')
|
|
55
|
+
return [a];
|
|
56
|
+
}
|
|
57
|
+
return ['.'];
|
|
58
|
+
}
|
|
59
|
+
// grep / rg: look for paths after --, or the last non-flag arg that looks like a path
|
|
60
|
+
const paths = [];
|
|
61
|
+
let afterDoubleDash = false;
|
|
62
|
+
for (const a of args) {
|
|
63
|
+
if (a === '--') {
|
|
64
|
+
afterDoubleDash = true;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (afterDoubleDash && !a.startsWith('-')) {
|
|
68
|
+
paths.push(a);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Flags with values: skip the value part
|
|
72
|
+
if (a === '-e' || a === '-f' || a === '--regexp' || a === '--file')
|
|
73
|
+
continue;
|
|
74
|
+
if (a.startsWith('--max-count') || a.startsWith('--glob') || a.startsWith('--include') || a.startsWith('--exclude'))
|
|
75
|
+
continue;
|
|
76
|
+
if (a.startsWith('-') || a === '--')
|
|
77
|
+
continue;
|
|
78
|
+
// Only for -r/-R (recursive) commands — collect potential path args
|
|
79
|
+
paths.push(a);
|
|
80
|
+
}
|
|
81
|
+
return paths.length > 0 ? paths : [];
|
|
82
|
+
}
|
|
83
|
+
/** Detect whether a recursive search command targets a given path. */
|
|
84
|
+
function hasRecursiveFlag(args) {
|
|
85
|
+
return args.some(a => a === '-r' || a === '-R' || a === '--recursive' ||
|
|
86
|
+
(a.startsWith('-') && !a.startsWith('--') && (a.includes('r') || a.includes('R'))));
|
|
87
|
+
}
|
|
88
|
+
class ShellCommandValidator {
|
|
89
|
+
blockedPrefixes;
|
|
90
|
+
constructor() {
|
|
91
|
+
// Merge static blocklist with dynamically discovered FUSE mounts
|
|
92
|
+
this.blockedPrefixes = [...defaults_js_1.BLOCKED_TRAVERSAL_PATHS];
|
|
93
|
+
this.discoverFuseMounts();
|
|
94
|
+
}
|
|
95
|
+
discoverFuseMounts() {
|
|
96
|
+
try {
|
|
97
|
+
const mounts = fs.readFileSync('/proc/mounts', 'utf8');
|
|
98
|
+
for (const line of mounts.split('\n')) {
|
|
99
|
+
const parts = line.split(' ');
|
|
100
|
+
if (parts.length >= 3 && defaults_js_1.FUSE_MOUNT_PATTERN.test(parts[2])) {
|
|
101
|
+
const mountPoint = parts[1];
|
|
102
|
+
if (mountPoint && !mountPoint.endsWith('/')) {
|
|
103
|
+
this.blockedPrefixes.push(mountPoint + '/');
|
|
104
|
+
}
|
|
105
|
+
else if (mountPoint) {
|
|
106
|
+
this.blockedPrefixes.push(mountPoint);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// /proc/mounts not available (non-Linux, permissions) — static list only
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
validateCommand(cmd, projectRoot, config) {
|
|
116
|
+
const tokens = tokenize(cmd);
|
|
117
|
+
if (tokens.length === 0)
|
|
118
|
+
return { allowed: true };
|
|
119
|
+
const base = path.basename(tokens[0]);
|
|
120
|
+
if (!['find', 'grep', 'rg'].includes(base))
|
|
121
|
+
return { allowed: true };
|
|
122
|
+
// rg is recursive by default; grep/find require explicit -r flag
|
|
123
|
+
const isRecursive = base === 'find' || base === 'rg' || hasRecursiveFlag(tokens.slice(1));
|
|
124
|
+
if (!isRecursive)
|
|
125
|
+
return { allowed: true };
|
|
126
|
+
const searchPaths = extractSearchPaths(base, tokens.slice(1));
|
|
127
|
+
const normalizedRoot = projectRoot.endsWith('/') ? projectRoot : projectRoot + '/';
|
|
128
|
+
const allowed = config?.allowedMountPaths ?? [];
|
|
129
|
+
for (const raw of searchPaths) {
|
|
130
|
+
// Expand ~ to HOME
|
|
131
|
+
const expanded = raw === '~' || raw.startsWith('~/')
|
|
132
|
+
? path.join(process.env.HOME ?? '/tmp', raw.slice(1))
|
|
133
|
+
: raw;
|
|
134
|
+
const resolved = path.resolve(projectRoot, expanded);
|
|
135
|
+
const normalizedResolved = resolved.endsWith('/') ? resolved : resolved + '/';
|
|
136
|
+
// 1) Check blocked mount prefixes first — allowedMountPaths override both
|
|
137
|
+
// the mount block AND the root boundary (user explicitly opted in).
|
|
138
|
+
let whitelisted = false;
|
|
139
|
+
for (const prefix of this.blockedPrefixes) {
|
|
140
|
+
if (normalizedResolved.startsWith(prefix)) {
|
|
141
|
+
const isExplicitlyAllowed = allowed.some(a => {
|
|
142
|
+
const normAllowed = a.endsWith('/') ? a : a + '/';
|
|
143
|
+
return normalizedResolved.startsWith(normAllowed);
|
|
144
|
+
});
|
|
145
|
+
if (isExplicitlyAllowed) {
|
|
146
|
+
whitelisted = true;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
allowed: false,
|
|
151
|
+
reason: `Blocked: '${base}' would traverse into '${raw}' which matches a ` +
|
|
152
|
+
`blocked mount prefix (${prefix}). This can cause hangs on unresponsive ` +
|
|
153
|
+
`FUSE/network filesystems. Add '${raw}' to allowedMountPaths in .aura.json ` +
|
|
154
|
+
`to override.`,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// 2) Must be inside project root (skip if explicitly whitelisted above)
|
|
159
|
+
if (!whitelisted && !normalizedResolved.startsWith(normalizedRoot) && normalizedResolved !== normalizedRoot) {
|
|
160
|
+
return {
|
|
161
|
+
allowed: false,
|
|
162
|
+
reason: `Blocked: '${base}' search path '${raw}' resolves outside project root (${projectRoot}). ` +
|
|
163
|
+
`To search outside the project, run the command directly in your terminal.`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { allowed: true };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.ShellCommandValidator = ShellCommandValidator;
|
|
171
|
+
/**
|
|
172
|
+
* Minimal shell tokenizer that handles quotes and backslash escapes.
|
|
173
|
+
* Splits a command string into tokens without invoking a shell.
|
|
174
|
+
*/
|
|
175
|
+
function tokenize(cmd) {
|
|
176
|
+
const tokens = [];
|
|
177
|
+
let current = '';
|
|
178
|
+
let inSingle = false;
|
|
179
|
+
let inDouble = false;
|
|
180
|
+
let escape = false;
|
|
181
|
+
for (const ch of cmd) {
|
|
182
|
+
if (escape) {
|
|
183
|
+
current += ch;
|
|
184
|
+
escape = false;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (ch === '\\' && !inSingle) {
|
|
188
|
+
escape = true;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (ch === "'" && !inDouble) {
|
|
192
|
+
inSingle = !inSingle;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (ch === '"' && !inSingle) {
|
|
196
|
+
inDouble = !inDouble;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (/\s/.test(ch) && !inSingle && !inDouble) {
|
|
200
|
+
if (current.length > 0) {
|
|
201
|
+
tokens.push(current);
|
|
202
|
+
current = '';
|
|
203
|
+
}
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
current += ch;
|
|
207
|
+
}
|
|
208
|
+
if (current.length > 0)
|
|
209
|
+
tokens.push(current);
|
|
210
|
+
return tokens;
|
|
211
|
+
}
|
|
212
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
213
|
+
// PermissionSystem
|
|
214
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
215
|
+
class PermissionSystem {
|
|
216
|
+
level;
|
|
217
|
+
sessionApprovals = new Set();
|
|
218
|
+
validator;
|
|
219
|
+
projectRoot;
|
|
220
|
+
config;
|
|
221
|
+
constructor(level = 'normal', projectRoot, config) {
|
|
222
|
+
this.level = level;
|
|
223
|
+
this.projectRoot = projectRoot ?? process.cwd();
|
|
224
|
+
this.config = config;
|
|
225
|
+
this.validator = new ShellCommandValidator();
|
|
226
|
+
}
|
|
227
|
+
check(toolName, input) {
|
|
228
|
+
// Read-only mode: only allow read operations
|
|
229
|
+
if (this.level === 'read-only') {
|
|
230
|
+
const readOnly = ['read_file', 'list_dir', 'search_code', 'git_status', 'git_diff'];
|
|
231
|
+
if (!readOnly.includes(toolName)) {
|
|
232
|
+
return { allowed: false, reason: `Tool '${toolName}' not allowed in read-only mode` };
|
|
233
|
+
}
|
|
234
|
+
return { allowed: true };
|
|
235
|
+
}
|
|
236
|
+
// Auto mode: allow everything except explicitly dangerous
|
|
237
|
+
if (this.level === 'auto') {
|
|
238
|
+
if (toolName === 'run_shell') {
|
|
239
|
+
const cmd = String(input.command ?? '');
|
|
240
|
+
if (this.isDangerous(cmd)) {
|
|
241
|
+
return { allowed: false, reason: `Dangerous command blocked: ${cmd}` };
|
|
242
|
+
}
|
|
243
|
+
const scopeCheck = this.validator.validateCommand(cmd, this.projectRoot, this.config);
|
|
244
|
+
if (!scopeCheck.allowed)
|
|
245
|
+
return scopeCheck;
|
|
246
|
+
}
|
|
247
|
+
return { allowed: true };
|
|
248
|
+
}
|
|
249
|
+
// Normal mode: safe ops auto-approved, destructive need confirm
|
|
250
|
+
if (toolName === 'run_shell') {
|
|
251
|
+
const cmd = String(input.command ?? '');
|
|
252
|
+
if (this.isDangerous(cmd)) {
|
|
253
|
+
return { allowed: false, reason: `Dangerous command blocked: ${cmd}` };
|
|
254
|
+
}
|
|
255
|
+
const scopeCheck = this.validator.validateCommand(cmd, this.projectRoot, this.config);
|
|
256
|
+
if (!scopeCheck.allowed)
|
|
257
|
+
return scopeCheck;
|
|
258
|
+
if (!this.isSafe(cmd)) {
|
|
259
|
+
return { allowed: true, needsConfirm: true };
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (toolName === 'write_file' || toolName === 'edit_file') {
|
|
263
|
+
const path = String(input.path ?? '');
|
|
264
|
+
const key = `${toolName}:${path}`;
|
|
265
|
+
if (this.sessionApprovals.has(key))
|
|
266
|
+
return { allowed: true };
|
|
267
|
+
return { allowed: true, needsConfirm: true };
|
|
268
|
+
}
|
|
269
|
+
return { allowed: true };
|
|
270
|
+
}
|
|
271
|
+
approveForSession(key) {
|
|
272
|
+
this.sessionApprovals.add(key);
|
|
273
|
+
}
|
|
274
|
+
isDangerous(cmd) {
|
|
275
|
+
return defaults_js_1.DANGEROUS_PATTERNS.some(p => p.test(cmd));
|
|
276
|
+
}
|
|
277
|
+
isSafe(cmd) {
|
|
278
|
+
const lower = cmd.toLowerCase().trim();
|
|
279
|
+
return defaults_js_1.SAFE_SHELL_COMMANDS.some(s => lower.startsWith(s));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
exports.PermissionSystem = PermissionSystem;
|
|
283
|
+
/** Ask user to confirm in the terminal. Returns true if approved. */
|
|
284
|
+
async function confirm(message) {
|
|
285
|
+
process.stdout.write(`\n⚠️ ${message} [y/N] `);
|
|
286
|
+
// Temporarily remove existing stdin data listeners (e.g. from REPL readline)
|
|
287
|
+
// to ensure only ONE reader is active at a time — prevents input doubling.
|
|
288
|
+
const existingListeners = process.stdin.rawListeners('data');
|
|
289
|
+
for (const listener of existingListeners) {
|
|
290
|
+
process.stdin.removeListener('data', listener);
|
|
291
|
+
}
|
|
292
|
+
return new Promise(resolve => {
|
|
293
|
+
const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
294
|
+
rl.question('', (answer) => {
|
|
295
|
+
rl.close();
|
|
296
|
+
// Restore original listeners so REPL readline continues working
|
|
297
|
+
for (const listener of existingListeners) {
|
|
298
|
+
process.stdin.on('data', listener);
|
|
299
|
+
}
|
|
300
|
+
resolve(answer.trim().toLowerCase() === 'y' || answer.trim().toLowerCase() === 'yes');
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/safety/permissions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6PA,0BAmBC;AAhRD,uCAAyB;AACzB,2CAA6B;AAC7B,wDAAgC;AAChC,uDAG+B;AAc/B,gFAAgF;AAChF,2EAA2E;AAC3E,sEAAsE;AACtE,gFAAgF;AAEhF,uEAAuE;AACvE,SAAS,kBAAkB,CAAC,IAAY,EAAE,IAAc;IACtD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,mEAAmE;QACnE,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG;gBAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,sFAAsF;IACtF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAAC,eAAe,GAAG,IAAI,CAAC;YAAC,SAAS;QAAC,CAAC;QACrD,IAAI,eAAe,IAAI,CAAC,CAAC,CA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