opc-agent 4.0.4 → 4.0.6
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/dist/core/runtime.d.ts +1 -0
- package/dist/core/runtime.js +26 -0
- package/dist/providers/index.js +1 -1
- package/package.json +1 -1
- package/src/core/runtime.ts +24 -0
- package/src/providers/index.ts +1 -1
package/dist/core/runtime.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare class AgentRuntime {
|
|
|
19
19
|
private evolveScheduler;
|
|
20
20
|
loadConfig(filePath: string): Promise<OADDocument>;
|
|
21
21
|
setHistoryLimit(limit: number): void;
|
|
22
|
+
private loadDotEnv;
|
|
22
23
|
initialize(config?: OADDocument): Promise<BaseAgent>;
|
|
23
24
|
start(): Promise<void>;
|
|
24
25
|
stop(): Promise<void>;
|
package/dist/core/runtime.js
CHANGED
|
@@ -80,7 +80,33 @@ class AgentRuntime {
|
|
|
80
80
|
setHistoryLimit(limit) {
|
|
81
81
|
this.historyLimit = limit;
|
|
82
82
|
}
|
|
83
|
+
loadDotEnv() {
|
|
84
|
+
const fs = require('fs');
|
|
85
|
+
const path = require('path');
|
|
86
|
+
const envPath = path.resolve('.env');
|
|
87
|
+
if (!fs.existsSync(envPath))
|
|
88
|
+
return;
|
|
89
|
+
try {
|
|
90
|
+
const content = fs.readFileSync(envPath, 'utf-8');
|
|
91
|
+
for (const line of content.split('\n')) {
|
|
92
|
+
const trimmed = line.trim();
|
|
93
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
94
|
+
continue;
|
|
95
|
+
const eqIdx = trimmed.indexOf('=');
|
|
96
|
+
if (eqIdx === -1)
|
|
97
|
+
continue;
|
|
98
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
99
|
+
const value = trimmed.slice(eqIdx + 1).trim();
|
|
100
|
+
if (!process.env[key]) {
|
|
101
|
+
process.env[key] = value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch { /* ignore */ }
|
|
106
|
+
}
|
|
83
107
|
async initialize(config) {
|
|
108
|
+
// Auto-load .env file if present
|
|
109
|
+
this.loadDotEnv();
|
|
84
110
|
const cfg = config ?? this.config;
|
|
85
111
|
if (!cfg)
|
|
86
112
|
throw new Error('No config loaded. Call loadConfig() first.');
|
package/dist/providers/index.js
CHANGED
|
@@ -342,7 +342,7 @@ class ClaudeCLIProvider {
|
|
|
342
342
|
if (options?.tools && options.tools.length > 0) {
|
|
343
343
|
prompt += buildToolPrompt(options.tools);
|
|
344
344
|
}
|
|
345
|
-
const args = ['-p'
|
|
345
|
+
const args = ['-p'];
|
|
346
346
|
// Write system prompt to temp file to avoid shell escaping issues
|
|
347
347
|
let tmpFile;
|
|
348
348
|
if (systemPrompt) {
|
package/package.json
CHANGED
package/src/core/runtime.ts
CHANGED
|
@@ -53,7 +53,31 @@ export class AgentRuntime {
|
|
|
53
53
|
this.historyLimit = limit;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
private loadDotEnv(): void {
|
|
57
|
+
const fs = require('fs');
|
|
58
|
+
const path = require('path');
|
|
59
|
+
const envPath = path.resolve('.env');
|
|
60
|
+
if (!fs.existsSync(envPath)) return;
|
|
61
|
+
try {
|
|
62
|
+
const content = fs.readFileSync(envPath, 'utf-8');
|
|
63
|
+
for (const line of content.split('\n')) {
|
|
64
|
+
const trimmed = line.trim();
|
|
65
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
66
|
+
const eqIdx = trimmed.indexOf('=');
|
|
67
|
+
if (eqIdx === -1) continue;
|
|
68
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
69
|
+
const value = trimmed.slice(eqIdx + 1).trim();
|
|
70
|
+
if (!process.env[key]) {
|
|
71
|
+
process.env[key] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch { /* ignore */ }
|
|
75
|
+
}
|
|
76
|
+
|
|
56
77
|
async initialize(config?: OADDocument): Promise<BaseAgent> {
|
|
78
|
+
// Auto-load .env file if present
|
|
79
|
+
this.loadDotEnv();
|
|
80
|
+
|
|
57
81
|
const cfg = config ?? this.config;
|
|
58
82
|
if (!cfg) throw new Error('No config loaded. Call loadConfig() first.');
|
|
59
83
|
|
package/src/providers/index.ts
CHANGED
|
@@ -349,7 +349,7 @@ class ClaudeCLIProvider implements LLMProvider {
|
|
|
349
349
|
prompt += buildToolPrompt(options.tools);
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
const args = ['-p'
|
|
352
|
+
const args = ['-p'];
|
|
353
353
|
// Write system prompt to temp file to avoid shell escaping issues
|
|
354
354
|
let tmpFile: string | undefined;
|
|
355
355
|
if (systemPrompt) {
|