kiku-agent 1.0.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/README.md +122 -0
- package/package.json +85 -0
- package/server/agent/agentCore.js +782 -0
- package/server/agent/agentState.js +140 -0
- package/server/agent/audioPlayer.js +673 -0
- package/server/agent/cli.js +1111 -0
- package/server/agent/commandRegistry.js +58 -0
- package/server/agent/commands.js +788 -0
- package/server/agent/config.js +90 -0
- package/server/agent/errors.js +9 -0
- package/server/agent/eventBus.js +103 -0
- package/server/agent/llmClient.js +200 -0
- package/server/agent/memory.js +566 -0
- package/server/agent/sanitizer.js +314 -0
- package/server/agent/session.js +239 -0
- package/server/agent/theme.js +124 -0
- package/server/agent/tools.js +1528 -0
- package/server/agent/ui.js +469 -0
- package/server/agent/webSearch.js +719 -0
- package/server/agent/youtubeAuth.js +299 -0
- package/server/mcp/claude-desktop-config.example.json +9 -0
- package/server/mcp/data/awards.js +14 -0
- package/server/mcp/data/brands.js +9 -0
- package/server/mcp/data/discography.js +36 -0
- package/server/mcp/data/gallery.js +25 -0
- package/server/mcp/data/index.js +7 -0
- package/server/mcp/data/profile.js +44 -0
- package/server/mcp/data/timeline.js +16 -0
- package/server/mcp/data/works.js +104 -0
- package/server/mcp/handler.js +159 -0
- package/server/mcp/prompts.js +143 -0
- package/server/mcp/resources.js +54 -0
- package/server/mcp/security.js +138 -0
- package/server/mcp/server.js +100 -0
- package/server/mcp/stdio.js +33 -0
- package/server/mcp/tools.js +126 -0
- package/src/data/awardsData.js +146 -0
- package/src/data/brandsData.js +249 -0
- package/src/data/discographyData.js +874 -0
- package/src/data/galleryData.js +666 -0
- package/src/data/musicVideoData.js +406 -0
- package/src/data/profileData.js +156 -0
- package/src/data/socialUpdatesData.js +381 -0
- package/src/data/timelineData.js +172 -0
- package/src/data/worksData.js +516 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export const AgentStates = Object.freeze({
|
|
2
|
+
IDLE: 'IDLE',
|
|
3
|
+
FETCHING_TOOL: 'FETCHING_TOOL',
|
|
4
|
+
STREAMING_THOUGHTS: 'STREAMING_THOUGHTS',
|
|
5
|
+
STREAMING_ANSWER: 'STREAMING_ANSWER',
|
|
6
|
+
COMPLETE: 'COMPLETE',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const TRANSITIONS = Object.freeze({
|
|
10
|
+
[AgentStates.IDLE]: new Set([
|
|
11
|
+
AgentStates.FETCHING_TOOL,
|
|
12
|
+
AgentStates.STREAMING_THOUGHTS,
|
|
13
|
+
AgentStates.STREAMING_ANSWER,
|
|
14
|
+
]),
|
|
15
|
+
[AgentStates.FETCHING_TOOL]: new Set([
|
|
16
|
+
AgentStates.FETCHING_TOOL,
|
|
17
|
+
AgentStates.STREAMING_THOUGHTS,
|
|
18
|
+
AgentStates.STREAMING_ANSWER,
|
|
19
|
+
AgentStates.COMPLETE,
|
|
20
|
+
]),
|
|
21
|
+
[AgentStates.STREAMING_THOUGHTS]: new Set([
|
|
22
|
+
AgentStates.FETCHING_TOOL,
|
|
23
|
+
AgentStates.STREAMING_ANSWER,
|
|
24
|
+
AgentStates.COMPLETE,
|
|
25
|
+
]),
|
|
26
|
+
[AgentStates.STREAMING_ANSWER]: new Set([
|
|
27
|
+
AgentStates.COMPLETE,
|
|
28
|
+
AgentStates.FETCHING_TOOL,
|
|
29
|
+
]),
|
|
30
|
+
[AgentStates.COMPLETE]: new Set([
|
|
31
|
+
AgentStates.IDLE,
|
|
32
|
+
]),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
class MiniEmitter {
|
|
36
|
+
constructor() {
|
|
37
|
+
this._listeners = new Map();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
on(event, fn) {
|
|
41
|
+
if (!this._listeners.has(event)) this._listeners.set(event, new Set());
|
|
42
|
+
this._listeners.get(event).add(fn);
|
|
43
|
+
return () => this.off(event, fn);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
off(event, fn) {
|
|
47
|
+
const set = this._listeners.get(event);
|
|
48
|
+
if (set) set.delete(fn);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
emit(event, ...args) {
|
|
52
|
+
const set = this._listeners.get(event);
|
|
53
|
+
if (set) {
|
|
54
|
+
for (const fn of set) {
|
|
55
|
+
try { fn(...args); } catch {}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class AgentStateMachine extends MiniEmitter {
|
|
62
|
+
constructor() {
|
|
63
|
+
super();
|
|
64
|
+
this._state = AgentStates.IDLE;
|
|
65
|
+
this._enteredAt = Date.now();
|
|
66
|
+
this._toolName = null;
|
|
67
|
+
this._queryId = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get state() { return this._state; }
|
|
71
|
+
|
|
72
|
+
get elapsedMs() { return Date.now() - this._enteredAt; }
|
|
73
|
+
|
|
74
|
+
get toolName() { return this._toolName; }
|
|
75
|
+
|
|
76
|
+
get queryId() { return this._queryId; }
|
|
77
|
+
|
|
78
|
+
transition(to, meta = {}) {
|
|
79
|
+
const from = this._state;
|
|
80
|
+
|
|
81
|
+
if (from === to) {
|
|
82
|
+
if (to !== AgentStates.FETCHING_TOOL) return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const allowed = TRANSITIONS[from];
|
|
86
|
+
if (!allowed || !allowed.has(to)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.emit('leave:' + from, { to, ...meta });
|
|
91
|
+
this._state = to;
|
|
92
|
+
this._enteredAt = Date.now();
|
|
93
|
+
|
|
94
|
+
if (to === AgentStates.FETCHING_TOOL) {
|
|
95
|
+
this._toolName = meta.toolName || null;
|
|
96
|
+
} else {
|
|
97
|
+
this._toolName = null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.emit('transition', { from, to, ...meta });
|
|
101
|
+
this.emit('enter:' + to, { from, ...meta });
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
startQuery(queryId) {
|
|
106
|
+
this._queryId = queryId;
|
|
107
|
+
return this.transition(AgentStates.IDLE);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
reset() {
|
|
111
|
+
this._queryId = null;
|
|
112
|
+
this._toolName = null;
|
|
113
|
+
if (this._state !== AgentStates.IDLE) {
|
|
114
|
+
this.transition(AgentStates.IDLE);
|
|
115
|
+
}
|
|
116
|
+
if (this._state !== AgentStates.IDLE) {
|
|
117
|
+
const from = this._state;
|
|
118
|
+
this.emit('leave:' + from, { to: AgentStates.IDLE, forced: true });
|
|
119
|
+
this._state = AgentStates.IDLE;
|
|
120
|
+
this._enteredAt = Date.now();
|
|
121
|
+
this.emit('transition', { from, to: AgentStates.IDLE, forced: true });
|
|
122
|
+
this.emit('enter:' + AgentStates.IDLE, { from, forced: true });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get isProcessing() {
|
|
127
|
+
return this._state !== AgentStates.IDLE && this._state !== AgentStates.COMPLETE;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get label() {
|
|
131
|
+
switch (this._state) {
|
|
132
|
+
case AgentStates.IDLE: return 'Idle';
|
|
133
|
+
case AgentStates.FETCHING_TOOL: return `Tool: ${this._toolName || '?'}`;
|
|
134
|
+
case AgentStates.STREAMING_THOUGHTS: return 'Thinking…';
|
|
135
|
+
case AgentStates.STREAMING_ANSWER: return 'Streaming…';
|
|
136
|
+
case AgentStates.COMPLETE: return 'Done';
|
|
137
|
+
default: return this._state;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|