@geminilight/mindos 0.5.20 → 0.5.22
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/app/app/api/ask/route.ts +343 -178
- package/app/app/api/monitoring/route.ts +95 -0
- package/app/components/SettingsModal.tsx +58 -58
- package/app/components/settings/AgentsTab.tsx +240 -0
- package/app/components/settings/AiTab.tsx +4 -25
- package/app/components/settings/AppearanceTab.tsx +31 -13
- package/app/components/settings/KnowledgeTab.tsx +13 -28
- package/app/components/settings/McpAgentInstall.tsx +227 -0
- package/app/components/settings/McpServerStatus.tsx +172 -0
- package/app/components/settings/McpSkillsSection.tsx +583 -0
- package/app/components/settings/McpTab.tsx +17 -959
- package/app/components/settings/MonitoringTab.tsx +202 -0
- package/app/components/settings/PluginsTab.tsx +4 -27
- package/app/components/settings/Primitives.tsx +69 -0
- package/app/components/settings/ShortcutsTab.tsx +2 -4
- package/app/components/settings/SyncTab.tsx +8 -24
- package/app/components/settings/types.ts +116 -2
- package/app/instrumentation.ts +7 -2
- package/app/lib/agent/context.ts +151 -87
- package/app/lib/agent/index.ts +5 -3
- package/app/lib/agent/log.ts +1 -0
- package/app/lib/agent/model.ts +76 -10
- package/app/lib/agent/skill-rules.ts +70 -0
- package/app/lib/agent/stream-consumer.ts +73 -77
- package/app/lib/agent/to-agent-messages.ts +106 -0
- package/app/lib/agent/tools.ts +260 -266
- package/app/lib/api.ts +12 -3
- package/app/lib/core/csv.ts +2 -1
- package/app/lib/core/fs-ops.ts +7 -6
- package/app/lib/core/index.ts +1 -1
- package/app/lib/core/lines.ts +7 -6
- package/app/lib/core/search-index.ts +174 -0
- package/app/lib/core/search.ts +30 -1
- package/app/lib/core/security.ts +6 -3
- package/app/lib/errors.ts +108 -0
- package/app/lib/fs.ts +6 -3
- package/app/lib/i18n-en.ts +523 -0
- package/app/lib/i18n-zh.ts +548 -0
- package/app/lib/i18n.ts +4 -963
- package/app/lib/metrics.ts +81 -0
- package/app/next-env.d.ts +1 -1
- package/app/next.config.ts +1 -1
- package/app/package-lock.json +3258 -3093
- package/app/package.json +6 -3
- package/bin/cli.js +7 -4
- package/package.json +4 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory metrics collector for MindOS runtime observability.
|
|
3
|
+
*
|
|
4
|
+
* Singleton — import { metrics } from '@/lib/metrics' in any server-side code.
|
|
5
|
+
* Data resets when the process restarts (no persistence needed).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface MetricsSnapshot {
|
|
9
|
+
processStartTime: number;
|
|
10
|
+
agentRequests: number;
|
|
11
|
+
toolExecutions: number;
|
|
12
|
+
totalTokens: { input: number; output: number };
|
|
13
|
+
avgResponseTimeMs: number;
|
|
14
|
+
errors: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const MAX_RESPONSE_TIMES = 100;
|
|
18
|
+
|
|
19
|
+
class MetricsCollector {
|
|
20
|
+
private processStartTime = Date.now();
|
|
21
|
+
private agentRequests = 0;
|
|
22
|
+
private toolExecutions = 0;
|
|
23
|
+
private totalTokens = { input: 0, output: 0 };
|
|
24
|
+
private responseTimes: number[] = [];
|
|
25
|
+
private errors = 0;
|
|
26
|
+
|
|
27
|
+
/** Record a completed agent request with its duration. */
|
|
28
|
+
recordRequest(durationMs: number): void {
|
|
29
|
+
this.agentRequests++;
|
|
30
|
+
this.responseTimes.push(durationMs);
|
|
31
|
+
if (this.responseTimes.length > MAX_RESPONSE_TIMES) {
|
|
32
|
+
this.responseTimes.shift();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Increment the tool execution counter. */
|
|
37
|
+
recordToolExecution(): void {
|
|
38
|
+
this.toolExecutions++;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Accumulate token usage. */
|
|
42
|
+
recordTokens(input: number, output: number): void {
|
|
43
|
+
this.totalTokens.input += input;
|
|
44
|
+
this.totalTokens.output += output;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Increment the error counter. */
|
|
48
|
+
recordError(): void {
|
|
49
|
+
this.errors++;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Return a read-only snapshot of all metrics. */
|
|
53
|
+
getSnapshot(): MetricsSnapshot {
|
|
54
|
+
const avg =
|
|
55
|
+
this.responseTimes.length > 0
|
|
56
|
+
? Math.round(this.responseTimes.reduce((a, b) => a + b, 0) / this.responseTimes.length)
|
|
57
|
+
: 0;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
processStartTime: this.processStartTime,
|
|
61
|
+
agentRequests: this.agentRequests,
|
|
62
|
+
toolExecutions: this.toolExecutions,
|
|
63
|
+
totalTokens: { ...this.totalTokens },
|
|
64
|
+
avgResponseTimeMs: avg,
|
|
65
|
+
errors: this.errors,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Reset all counters (useful for testing). */
|
|
70
|
+
reset(): void {
|
|
71
|
+
this.processStartTime = Date.now();
|
|
72
|
+
this.agentRequests = 0;
|
|
73
|
+
this.toolExecutions = 0;
|
|
74
|
+
this.totalTokens = { input: 0, output: 0 };
|
|
75
|
+
this.responseTimes = [];
|
|
76
|
+
this.errors = 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Global singleton — shared across all requests in the same Node process. */
|
|
81
|
+
export const metrics = new MetricsCollector();
|
package/app/next-env.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="next" />
|
|
2
2
|
/// <reference types="next/image-types/global" />
|
|
3
|
-
import "./.next/
|
|
3
|
+
import "./.next/types/routes.d.ts";
|
|
4
4
|
|
|
5
5
|
// NOTE: This file should not be edited
|
|
6
6
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
package/app/next.config.ts
CHANGED
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
|
|
4
4
|
const nextConfig: NextConfig = {
|
|
5
5
|
transpilePackages: ['github-slugger'],
|
|
6
|
-
serverExternalPackages: ['pdfjs-dist', 'pdf-parse', 'chokidar'],
|
|
6
|
+
serverExternalPackages: ['pdfjs-dist', 'pdf-parse', 'chokidar', '@mariozechner/pi-ai', '@mariozechner/pi-agent-core'],
|
|
7
7
|
outputFileTracingRoot: path.join(__dirname),
|
|
8
8
|
turbopack: {
|
|
9
9
|
root: path.join(__dirname),
|