@nokai/cli 1.0.0 → 1.1.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 +35 -169
- package/dist/connection-manager.d.ts +9 -1
- package/dist/connection-manager.d.ts.map +1 -1
- package/dist/connection-manager.js +85 -1
- package/dist/connection-manager.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/message-protocol.d.ts +3 -1
- package/dist/message-protocol.d.ts.map +1 -1
- package/dist/message-protocol.js +25 -1
- package/dist/message-protocol.js.map +1 -1
- package/dist/profile.d.ts +9 -0
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +31 -2
- package/dist/profile.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +111 -5
- package/dist/server.js.map +1 -1
- package/dist/shared/constants.d.ts +12 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +13 -1
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/types.d.ts +19 -1
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +7 -0
- package/dist/shared/types.js.map +1 -1
- package/dist/signaling-client.d.ts +18 -3
- package/dist/signaling-client.d.ts.map +1 -1
- package/dist/signaling-client.js +83 -7
- package/dist/signaling-client.js.map +1 -1
- package/dist/tools/ask.d.ts.map +1 -1
- package/dist/tools/ask.js +2 -1
- package/dist/tools/ask.js.map +1 -1
- package/dist/tools/connect.d.ts +19 -2
- package/dist/tools/connect.d.ts.map +1 -1
- package/dist/tools/connect.js +187 -43
- package/dist/tools/connect.js.map +1 -1
- package/dist/tools/discover.d.ts +12 -0
- package/dist/tools/discover.d.ts.map +1 -0
- package/dist/tools/discover.js +67 -0
- package/dist/tools/discover.js.map +1 -0
- package/dist/tools/id.d.ts +12 -0
- package/dist/tools/id.d.ts.map +1 -0
- package/dist/tools/id.js +24 -0
- package/dist/tools/id.js.map +1 -0
- package/dist/tools/invite.d.ts +32 -0
- package/dist/tools/invite.d.ts.map +1 -0
- package/dist/tools/invite.js +144 -0
- package/dist/tools/invite.js.map +1 -0
- package/dist/tools/reconnect.d.ts.map +1 -1
- package/dist/tools/reconnect.js +6 -2
- package/dist/tools/reconnect.js.map +1 -1
- package/dist/tools/share.d.ts +37 -0
- package/dist/tools/share.d.ts.map +1 -0
- package/dist/tools/share.js +153 -0
- package/dist/tools/share.js.map +1 -0
- package/dist/tools/tell.d.ts.map +1 -1
- package/dist/tools/tell.js +2 -1
- package/dist/tools/tell.js.map +1 -1
- package/package.json +2 -1
package/dist/tools/ask.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.askToolDefinition = void 0;
|
|
4
4
|
exports.handleAsk = handleAsk;
|
|
5
|
+
const index_js_1 = require("../shared/index.js");
|
|
5
6
|
exports.askToolDefinition = {
|
|
6
7
|
name: "nokai_ask",
|
|
7
8
|
description: "Send a question to a connected peer's AI agent. The peer's Claude Code will read their codebase and respond directly.",
|
|
@@ -23,7 +24,7 @@ async function handleAsk(args, connectionManager) {
|
|
|
23
24
|
resolve(`Question sent to ${args.peer} (message ID: ${msg.id}).\n` +
|
|
24
25
|
`Waiting for response... The peer's agent is processing your question.\n` +
|
|
25
26
|
`Note: Response is taking longer than expected. The peer may be offline.`);
|
|
26
|
-
},
|
|
27
|
+
}, index_js_1.ASK_TIMEOUT_MS);
|
|
27
28
|
connectionManager.onIncomingMessage((incomingMsg, peerName) => {
|
|
28
29
|
if (peerName === args.peer && incomingMsg.type === "response" && "replyTo" in incomingMsg && incomingMsg.replyTo === msg.id) {
|
|
29
30
|
clearTimeout(timeout);
|
package/dist/tools/ask.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask.js","sourceRoot":"","sources":["../../src/tools/ask.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ask.js","sourceRoot":"","sources":["../../src/tools/ask.ts"],"names":[],"mappings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MAAM,GAAG,iBAAiB,IAAI,CAAC,IAAI,QAAQ,WAAW,CAAC,OAAO,EAAE,CAAC;oBACrE,IAAI,aAAa,IAAI,WAAW,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;wBAC5D,MAAM,IAAI,qBAAqB,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtE,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,UAAW,GAAa,CAAC,OAAO,EAAE,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
package/dist/tools/connect.d.ts
CHANGED
|
@@ -7,9 +7,26 @@ export declare const connectToolDefinition: {
|
|
|
7
7
|
description: string;
|
|
8
8
|
inputSchema: {
|
|
9
9
|
type: "object";
|
|
10
|
-
properties: {
|
|
10
|
+
properties: {
|
|
11
|
+
mode: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
id: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
session: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
11
24
|
required: string[];
|
|
12
25
|
};
|
|
13
26
|
};
|
|
14
|
-
export declare function handleConnect(
|
|
27
|
+
export declare function handleConnect(args: {
|
|
28
|
+
mode: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
session?: string;
|
|
31
|
+
}, profile: AgentProfile, signalingClient: SignalingClient, connectionManager: ConnectionManager, signalingUrl: string, currentSessionId: string, currentSessionName: string, pcConfig?: PeerConnectionConfig): Promise<string>;
|
|
15
32
|
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/tools/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElF,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/tools/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAsBjC,CAAC;AAwMF,wBAAsB,aAAa,CACjC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,MAAM,EAC1B,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
|
package/dist/tools/connect.js
CHANGED
|
@@ -5,58 +5,202 @@ exports.handleConnect = handleConnect;
|
|
|
5
5
|
const peer_connection_js_1 = require("../peer-connection.js");
|
|
6
6
|
exports.connectToolDefinition = {
|
|
7
7
|
name: "nokai_connect",
|
|
8
|
-
description: "
|
|
8
|
+
description: "Connect to another NokAI session. Use mode='teammate' with their NokAI ID to connect to a teammate. Use mode='self' to connect to your own other project session on this machine.",
|
|
9
9
|
inputSchema: {
|
|
10
10
|
type: "object",
|
|
11
|
-
properties: {
|
|
12
|
-
|
|
11
|
+
properties: {
|
|
12
|
+
mode: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "Connection mode: 'teammate' (connect to another person's NokAI ID) or 'self' (connect to your own other session)",
|
|
15
|
+
},
|
|
16
|
+
id: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "For mode='teammate': the teammate's NokAI ID (e.g., NKI-8A3F-K2M9)",
|
|
19
|
+
},
|
|
20
|
+
session: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "For mode='self': the session name to connect to (e.g., 'web-frontend')",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
required: ["mode"],
|
|
13
26
|
},
|
|
14
27
|
};
|
|
15
|
-
async function
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
async function fetchSessions(signalingUrl, nokaiId) {
|
|
29
|
+
try {
|
|
30
|
+
const httpUrl = signalingUrl.replace("wss://", "https://").replace("ws://", "http://");
|
|
31
|
+
const presenceUrl = `${httpUrl}/presence`;
|
|
32
|
+
// Use the presence DO's /sessions endpoint
|
|
33
|
+
const res = await fetch(`${presenceUrl}/sessions?nokaiId=${encodeURIComponent(nokaiId)}`);
|
|
34
|
+
if (res.ok) {
|
|
35
|
+
const data = await res.json();
|
|
36
|
+
return data.sessions;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// ignore
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
async function handleSelfConnect(sessionName, profile, signalingClient, connectionManager, signalingUrl, currentSessionId, currentSessionName, pcConfig) {
|
|
45
|
+
// Find the target session
|
|
46
|
+
const sessions = await fetchSessions(signalingUrl, profile.nokaiId);
|
|
47
|
+
const otherSessions = sessions.filter((s) => s.sessionId !== currentSessionId);
|
|
48
|
+
if (otherSessions.length === 0) {
|
|
49
|
+
return (`No other active sessions found for your NokAI ID (${profile.nokaiId}).\n\n` +
|
|
50
|
+
`Open another project with NokAI running, then try again.\n` +
|
|
51
|
+
`Each Claude Code / Cursor instance on a different project is a separate session.`);
|
|
52
|
+
}
|
|
53
|
+
// Find matching session by name
|
|
54
|
+
const target = otherSessions.find((s) => s.sessionName.toLowerCase() === sessionName.toLowerCase());
|
|
55
|
+
if (!target) {
|
|
56
|
+
let result = `Session "${sessionName}" not found. Available sessions:\n\n`;
|
|
57
|
+
for (const s of otherSessions) {
|
|
58
|
+
result += `- **${s.sessionName}**\n`;
|
|
59
|
+
}
|
|
60
|
+
result += `\nUse one of these names with \`nokai_connect mode=self session=<name>\``;
|
|
61
|
+
return result;
|
|
18
62
|
}
|
|
19
63
|
return new Promise((resolve) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: "answer",
|
|
38
|
-
sdp: signalData.data.sdp,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
64
|
+
const timeout = setTimeout(() => {
|
|
65
|
+
resolve(`Error: Self-connect to "${target.sessionName}" timed out.`);
|
|
66
|
+
}, 30000);
|
|
67
|
+
signalingClient.once("otp_matched", async (matchData) => {
|
|
68
|
+
clearTimeout(timeout);
|
|
69
|
+
const pc = new peer_connection_js_1.PeerConnection(pcConfig);
|
|
70
|
+
const connectionId = `conn_${Date.now()}`;
|
|
71
|
+
pc.onIceCandidate((candidate) => {
|
|
72
|
+
signalingClient.signal(matchData.peerId, { type: "ice", ...candidate });
|
|
73
|
+
});
|
|
74
|
+
signalingClient.on("signal", (signalData) => {
|
|
75
|
+
if (signalData.from === matchData.peerId) {
|
|
76
|
+
if (signalData.data.type === "ice") {
|
|
77
|
+
pc.addIceCandidate({
|
|
78
|
+
candidate: signalData.data.candidate,
|
|
79
|
+
mid: signalData.data.mid,
|
|
80
|
+
});
|
|
41
81
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
resolve(`Connected with ${matchData.peerName}!\n` +
|
|
50
|
-
`Connection ID: ${connectionId}\n` +
|
|
51
|
-
`Permission: read-only\n` +
|
|
52
|
-
`You can now use nokai_ask to send questions to ${matchData.peerName}.`);
|
|
82
|
+
else if (signalData.data.type === "answer") {
|
|
83
|
+
pc.acceptAnswer({
|
|
84
|
+
type: "answer",
|
|
85
|
+
sdp: signalData.data.sdp,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
53
89
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
90
|
+
const offer = await pc.createOffer();
|
|
91
|
+
signalingClient.signal(matchData.peerId, { type: "offer", sdp: offer.sdp });
|
|
92
|
+
await pc.waitForDataChannel();
|
|
93
|
+
connectionManager.registerPeer(connectionId, matchData.peerName, matchData.peerPublicKey);
|
|
94
|
+
connectionManager.setPeerSend(connectionId, (msg) => pc.send(msg));
|
|
95
|
+
connectionManager.setPeerClose(connectionId, () => pc.close());
|
|
96
|
+
pc.onMessage((msg) => connectionManager.handleIncomingMessage(connectionId, msg));
|
|
97
|
+
resolve(`Connected to your session: ${target.sessionName}!\n` +
|
|
98
|
+
`Connection ID: ${connectionId}\n` +
|
|
99
|
+
`Permission: read-only\n\n` +
|
|
100
|
+
`You can now use nokai_ask to query your other project's codebase.`);
|
|
58
101
|
});
|
|
59
|
-
signalingClient.
|
|
102
|
+
signalingClient.selfConnect(target.sessionId, profile.name, profile.publicKey, currentSessionId, currentSessionName);
|
|
60
103
|
});
|
|
61
104
|
}
|
|
105
|
+
async function handleTeammateConnect(targetId, profile, signalingClient, connectionManager, pcConfig) {
|
|
106
|
+
const id = targetId.toUpperCase().trim();
|
|
107
|
+
if (!/^NKI-[A-Z0-9]{4}-[A-Z0-9]{4}$/.test(id)) {
|
|
108
|
+
return `Error: Invalid NokAI ID format. Expected format: NKI-XXXX-XXXX`;
|
|
109
|
+
}
|
|
110
|
+
if (id === profile.nokaiId) {
|
|
111
|
+
return `That's your own NokAI ID. Use \`mode=self\` to connect to your other sessions.`;
|
|
112
|
+
}
|
|
113
|
+
return new Promise((resolve) => {
|
|
114
|
+
const timeout = setTimeout(() => {
|
|
115
|
+
resolve(`Connection request sent to ${id}.\n` +
|
|
116
|
+
`The peer hasn't responded yet — they may be offline.`);
|
|
117
|
+
}, 60000);
|
|
118
|
+
signalingClient.once("error", (data) => {
|
|
119
|
+
clearTimeout(timeout);
|
|
120
|
+
if (data.code === "PEER_NOT_FOUND" || data.code === "PEER_OFFLINE") {
|
|
121
|
+
resolve(`Error: Peer ${id} is not online. Ask them to start NokAI first.`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
resolve(`Error: ${data.message}`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
signalingClient.once("otp_matched", async (matchData) => {
|
|
128
|
+
clearTimeout(timeout);
|
|
129
|
+
const pc = new peer_connection_js_1.PeerConnection(pcConfig);
|
|
130
|
+
const connectionId = `conn_${Date.now()}`;
|
|
131
|
+
pc.onIceCandidate((candidate) => {
|
|
132
|
+
signalingClient.signal(matchData.peerId, { type: "ice", ...candidate });
|
|
133
|
+
});
|
|
134
|
+
signalingClient.on("signal", (signalData) => {
|
|
135
|
+
if (signalData.from === matchData.peerId) {
|
|
136
|
+
if (signalData.data.type === "ice") {
|
|
137
|
+
pc.addIceCandidate({
|
|
138
|
+
candidate: signalData.data.candidate,
|
|
139
|
+
mid: signalData.data.mid,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else if (signalData.data.type === "answer") {
|
|
143
|
+
pc.acceptAnswer({
|
|
144
|
+
type: "answer",
|
|
145
|
+
sdp: signalData.data.sdp,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const offer = await pc.createOffer();
|
|
151
|
+
signalingClient.signal(matchData.peerId, { type: "offer", sdp: offer.sdp });
|
|
152
|
+
await pc.waitForDataChannel();
|
|
153
|
+
connectionManager.registerPeer(connectionId, matchData.peerName, matchData.peerPublicKey);
|
|
154
|
+
connectionManager.setPeerSend(connectionId, (msg) => pc.send(msg));
|
|
155
|
+
connectionManager.setPeerClose(connectionId, () => pc.close());
|
|
156
|
+
pc.onMessage((msg) => connectionManager.handleIncomingMessage(connectionId, msg));
|
|
157
|
+
resolve(`Connected with ${matchData.peerName}!\n` +
|
|
158
|
+
`Connection ID: ${connectionId}\n` +
|
|
159
|
+
`Permission: read-only\n` +
|
|
160
|
+
`You can now use nokai_ask to send questions to ${matchData.peerName}.`);
|
|
161
|
+
});
|
|
162
|
+
signalingClient.connectByNokaiId(id, profile.name, profile.publicKey, profile.deviceId, profile.nokaiId);
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
resolve(`Connection request sent to ${id}.\n\n` +
|
|
165
|
+
`The peer will see a connection request with an approval code.\n` +
|
|
166
|
+
`Ask them for the 4-digit code to approve.\n\n` +
|
|
167
|
+
`Waiting for approval...`);
|
|
168
|
+
}, 2000);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async function handleConnect(args, profile, signalingClient, connectionManager, signalingUrl, currentSessionId, currentSessionName, pcConfig) {
|
|
172
|
+
if (!signalingClient.isConnected()) {
|
|
173
|
+
return "Error: Not connected to signaling server. Please try again.";
|
|
174
|
+
}
|
|
175
|
+
if (args.mode === "self") {
|
|
176
|
+
if (!args.session) {
|
|
177
|
+
// List available sessions
|
|
178
|
+
const sessions = await fetchSessions(signalingUrl, profile.nokaiId);
|
|
179
|
+
const otherSessions = sessions.filter((s) => s.sessionId !== currentSessionId);
|
|
180
|
+
if (otherSessions.length === 0) {
|
|
181
|
+
return (`No other active sessions found.\n\n` +
|
|
182
|
+
`Your current session: **${currentSessionName}**\n\n` +
|
|
183
|
+
`Open another project with NokAI running, then try again.`);
|
|
184
|
+
}
|
|
185
|
+
let result = `## Your Active Sessions\n\n`;
|
|
186
|
+
result += `Current: **${currentSessionName}** (this session)\n\n`;
|
|
187
|
+
result += `Available to connect:\n`;
|
|
188
|
+
for (const s of otherSessions) {
|
|
189
|
+
result += `- **${s.sessionName}**\n`;
|
|
190
|
+
}
|
|
191
|
+
result += `\nUse \`nokai_connect mode=self session=<name>\` to connect.`;
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
return handleSelfConnect(args.session, profile, signalingClient, connectionManager, signalingUrl, currentSessionId, currentSessionName, pcConfig);
|
|
195
|
+
}
|
|
196
|
+
if (args.mode === "teammate") {
|
|
197
|
+
if (!args.id) {
|
|
198
|
+
return "Error: Please provide the teammate's NokAI ID. Use `nokai_connect mode=teammate id=NKI-XXXX-XXXX`";
|
|
199
|
+
}
|
|
200
|
+
return handleTeammateConnect(args.id, profile, signalingClient, connectionManager, pcConfig);
|
|
201
|
+
}
|
|
202
|
+
return (`Invalid mode. Choose one:\n\n` +
|
|
203
|
+
`- \`mode=teammate\` — Connect to another person using their NokAI ID\n` +
|
|
204
|
+
`- \`mode=self\` — Connect to your own other project session`);
|
|
205
|
+
}
|
|
62
206
|
//# sourceMappingURL=connect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/tools/connect.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/tools/connect.ts"],"names":[],"mappings":";;;AAmOA,sCAwDC;AAxRD,8DAAkF;AAErE,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,mLAAmL;IACrL,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACv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QACD,OAAO,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAC/F,CAAC;IAED,OAAO,CACL,+BAA+B;QAC/B,wEAAwE;QACxE,6DAA6D,CAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NokaiDB } from "../db.js";
|
|
2
|
+
export declare const discoverToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: never[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function handleDiscover(db: NokaiDB, signalingUrl: string): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/tools/discover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,sBAAsB;;;;;;;;CASlC,CAAC;AAEF,wBAAsB,cAAc,CAClC,EAAE,EAAE,OAAO,EACX,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CA4DjB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.discoverToolDefinition = void 0;
|
|
4
|
+
exports.handleDiscover = handleDiscover;
|
|
5
|
+
exports.discoverToolDefinition = {
|
|
6
|
+
name: "nokai_discover",
|
|
7
|
+
description: "Discover which of your previously connected peers are currently online. Shows saved connections with their online/offline status.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {},
|
|
11
|
+
required: [],
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
async function handleDiscover(db, signalingUrl) {
|
|
15
|
+
const allConnections = db.listConnections();
|
|
16
|
+
if (allConnections.length === 0) {
|
|
17
|
+
return "No saved connections. Use nokai_connect or nokai_join_invite to connect with a peer first.";
|
|
18
|
+
}
|
|
19
|
+
// Check presence for each saved peer
|
|
20
|
+
const httpUrl = signalingUrl.replace("wss://", "https://").replace("ws://", "http://");
|
|
21
|
+
const results = [];
|
|
22
|
+
for (const conn of allConnections) {
|
|
23
|
+
let online = false;
|
|
24
|
+
try {
|
|
25
|
+
const res = await fetch(`${httpUrl}/presence/status?deviceId=${encodeURIComponent(conn.peerPublicKey)}`);
|
|
26
|
+
if (res.ok) {
|
|
27
|
+
const data = await res.json();
|
|
28
|
+
online = data.online;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Assume offline if presence check fails
|
|
33
|
+
}
|
|
34
|
+
results.push({
|
|
35
|
+
name: conn.peerName,
|
|
36
|
+
online,
|
|
37
|
+
lastConnected: conn.lastConnected,
|
|
38
|
+
permission: conn.permission,
|
|
39
|
+
status: conn.status,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const onlinePeers = results.filter((r) => r.online);
|
|
43
|
+
const offlinePeers = results.filter((r) => !r.online);
|
|
44
|
+
let output = "## Discovered Peers\n\n";
|
|
45
|
+
if (onlinePeers.length > 0) {
|
|
46
|
+
output += "### Online\n";
|
|
47
|
+
for (const peer of onlinePeers) {
|
|
48
|
+
output += `- **${peer.name}** (${peer.permission}) — last connected: ${peer.lastConnected || "never"}\n`;
|
|
49
|
+
}
|
|
50
|
+
output += "\n";
|
|
51
|
+
}
|
|
52
|
+
if (offlinePeers.length > 0) {
|
|
53
|
+
output += "### Offline\n";
|
|
54
|
+
for (const peer of offlinePeers) {
|
|
55
|
+
output += `- ${peer.name} (${peer.permission}) — last connected: ${peer.lastConnected || "never"}\n`;
|
|
56
|
+
}
|
|
57
|
+
output += "\n";
|
|
58
|
+
}
|
|
59
|
+
if (onlinePeers.length > 0) {
|
|
60
|
+
output += `Use \`nokai_reconnect\` to reconnect with online peers.`;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
output += `No peers are currently online. Use \`nokai_invite\` to create an invite link for new teammates.`;
|
|
64
|
+
}
|
|
65
|
+
return output;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../src/tools/discover.ts"],"names":[],"mappings":";;;AAaA,wCA+DC;AA1EY,QAAA,sBAAsB,GAAG;IACpC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,mIAAmI;IACrI,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;CACF,CAAC;AAEK,KAAK,UAAU,cAAc,CAClC,EAAW,EACX,YAAoB;IAEpB,MAAM,cAAc,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC;IAE5C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,4FAA4F,CAAC;IACtG,CAAC;IAED,qCAAqC;IACrC,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACvF,MAAM,OAAO,GAA+G,EAAE,CAAC;IAE/H,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,6BAA6B,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YACzG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;gBACX,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAyB,CAAC;g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AC,EAAE,CAAC;QAC3B,MAAM,IAAI,yDAAyD,CAAC;IACtE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,iGAAiG,CAAC;IAC9G,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentProfile } from "../shared/index.js";
|
|
2
|
+
export declare const idToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function handleId(profile: AgentProfile, sessionId: string, sessionName: string): string;
|
|
12
|
+
//# sourceMappingURL=id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/tools/id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,gBAAgB;;;;;;kBAOT,MAAM,EAAE;;CAE3B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAW9F"}
|
package/dist/tools/id.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.idToolDefinition = void 0;
|
|
4
|
+
exports.handleId = handleId;
|
|
5
|
+
exports.idToolDefinition = {
|
|
6
|
+
name: "nokai_id",
|
|
7
|
+
description: "Show your NokAI ID and current session. Share your ID with teammates so they can connect to you.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {},
|
|
11
|
+
required: [],
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
function handleId(profile, sessionId, sessionName) {
|
|
15
|
+
return (`## Your NokAI Identity\n\n` +
|
|
16
|
+
`**NokAI ID:** ${profile.nokaiId}\n` +
|
|
17
|
+
`**Agent Name:** ${profile.name}\n` +
|
|
18
|
+
`**Session:** ${sessionName} (${sessionId})\n\n` +
|
|
19
|
+
`### Connect with a teammate\n` +
|
|
20
|
+
`Share your NokAI ID. They use: \`nokai_connect mode=teammate id=${profile.nokaiId}\`\n\n` +
|
|
21
|
+
`### Connect to your own other project\n` +
|
|
22
|
+
`Use: \`nokai_connect mode=self\` to see your other active sessions.`);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/tools/id.ts"],"names":[],"mappings":";;;AAaA,4BAWC;AAtBY,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,kGAAkG;IACpG,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAc;KACzB;CACF,CAAC;AAEF,SAAgB,QAAQ,CAAC,OAAqB,EAAE,SAAiB,EAAE,WAAmB;IACpF,OAAO,CACL,4BAA4B;QAC5B,iBAAiB,OAAO,CAAC,OAAO,IAAI;QACpC,mBAAmB,OAAO,CAAC,IAAI,IAAI;QACnC,gBAAgB,WAAW,KAAK,SAAS,OAAO;QAChD,+BAA+B;QAC/B,mEAAmE,OAAO,CAAC,OAAO,QAAQ;QAC1F,yCAAyC;QACzC,qEAAqE,CACtE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentProfile } from "../shared/index.js";
|
|
2
|
+
import type { ConnectionManager } from "../connection-manager.js";
|
|
3
|
+
import type { SignalingClient } from "../signaling-client.js";
|
|
4
|
+
import { type PeerConnectionConfig } from "../peer-connection.js";
|
|
5
|
+
export declare const inviteToolDefinition: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: {};
|
|
11
|
+
required: never[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const joinInviteToolDefinition: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object";
|
|
19
|
+
properties: {
|
|
20
|
+
invite: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function handleInvite(profile: AgentProfile, signalingUrl: string): Promise<string>;
|
|
29
|
+
export declare function handleJoinInvite(args: {
|
|
30
|
+
invite: string;
|
|
31
|
+
}, profile: AgentProfile, signalingClient: SignalingClient, connectionManager: ConnectionManager, signalingUrl: string, pcConfig?: PeerConnectionConfig): Promise<string>;
|
|
32
|
+
//# sourceMappingURL=invite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invite.d.ts","sourceRoot":"","sources":["../../src/tools/invite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElF,eAAO,MAAM,oBAAoB;;;;;;;;CAShC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;CAWpC,CAAC;AAUF,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAgCjB;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EACxB,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAoHjB"}
|