@nokai/cli 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/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/connection-manager.d.ts +45 -0
- package/dist/connection-manager.d.ts.map +1 -0
- package/dist/connection-manager.js +262 -0
- package/dist/connection-manager.js.map +1 -0
- package/dist/crypto.d.ts +8 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +42 -0
- package/dist/crypto.js.map +1 -0
- package/dist/db.d.ts +47 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +195 -0
- package/dist/db.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/message-protocol.d.ts +9 -0
- package/dist/message-protocol.d.ts.map +1 -0
- package/dist/message-protocol.js +85 -0
- package/dist/message-protocol.js.map +1 -0
- package/dist/peer-connection.d.ts +40 -0
- package/dist/peer-connection.d.ts.map +1 -0
- package/dist/peer-connection.js +159 -0
- package/dist/peer-connection.js.map +1 -0
- package/dist/profile.d.ts +11 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +62 -0
- package/dist/profile.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +185 -0
- package/dist/server.js.map +1 -0
- package/dist/shared/constants.d.ts +20 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +23 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +19 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types.d.ts +128 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +41 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/signaling-client.d.ts +19 -0
- package/dist/signaling-client.d.ts.map +1 -0
- package/dist/signaling-client.js +83 -0
- package/dist/signaling-client.js.map +1 -0
- package/dist/tools/approve.d.ts +30 -0
- package/dist/tools/approve.d.ts.map +1 -0
- package/dist/tools/approve.js +46 -0
- package/dist/tools/approve.js.map +1 -0
- package/dist/tools/ask.d.ts +29 -0
- package/dist/tools/ask.d.ts.map +1 -0
- package/dist/tools/ask.js +43 -0
- package/dist/tools/ask.js.map +1 -0
- package/dist/tools/audit.d.ts +24 -0
- package/dist/tools/audit.d.ts.map +1 -0
- package/dist/tools/audit.js +39 -0
- package/dist/tools/audit.js.map +1 -0
- package/dist/tools/connect.d.ts +15 -0
- package/dist/tools/connect.d.ts.map +1 -0
- package/dist/tools/connect.js +62 -0
- package/dist/tools/connect.js.map +1 -0
- package/dist/tools/connections.d.ts +13 -0
- package/dist/tools/connections.d.ts.map +1 -0
- package/dist/tools/connections.js +34 -0
- package/dist/tools/connections.js.map +1 -0
- package/dist/tools/disconnect.d.ts +19 -0
- package/dist/tools/disconnect.d.ts.map +1 -0
- package/dist/tools/disconnect.js +23 -0
- package/dist/tools/disconnect.js.map +1 -0
- package/dist/tools/history.d.ts +24 -0
- package/dist/tools/history.d.ts.map +1 -0
- package/dist/tools/history.js +47 -0
- package/dist/tools/history.js.map +1 -0
- package/dist/tools/join.d.ts +22 -0
- package/dist/tools/join.d.ts.map +1 -0
- package/dist/tools/join.js +60 -0
- package/dist/tools/join.js.map +1 -0
- package/dist/tools/permissions.d.ts +24 -0
- package/dist/tools/permissions.d.ts.map +1 -0
- package/dist/tools/permissions.js +32 -0
- package/dist/tools/permissions.js.map +1 -0
- package/dist/tools/profile-tool.d.ts +29 -0
- package/dist/tools/profile-tool.d.ts.map +1 -0
- package/dist/tools/profile-tool.js +72 -0
- package/dist/tools/profile-tool.js.map +1 -0
- package/dist/tools/reconnect.d.ts +22 -0
- package/dist/tools/reconnect.d.ts.map +1 -0
- package/dist/tools/reconnect.js +88 -0
- package/dist/tools/reconnect.js.map +1 -0
- package/dist/tools/respond.d.ts +37 -0
- package/dist/tools/respond.d.ts.map +1 -0
- package/dist/tools/respond.js +31 -0
- package/dist/tools/respond.js.map +1 -0
- package/dist/tools/tell.d.ts +29 -0
- package/dist/tools/tell.d.ts.map +1 -0
- package/dist/tools/tell.js +45 -0
- package/dist/tools/tell.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.approveToolDefinition = void 0;
|
|
4
|
+
exports.handleApprove = handleApprove;
|
|
5
|
+
exports.approveToolDefinition = {
|
|
6
|
+
name: "nokai_approve",
|
|
7
|
+
description: "Toggle manual approval mode for a connection. When enabled, incoming queries are held for your review instead of being auto-responded to. Also used to approve/reject held queries.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
peer: { type: "string", description: "Name of the peer" },
|
|
12
|
+
action: { type: "string", description: "Action: 'enable' to turn on manual mode, 'disable' to turn off, 'list' to see pending queries, 'approve' to approve a held query, 'reject' to reject" },
|
|
13
|
+
message_id: { type: "string", description: "Message ID to approve/reject (only for approve/reject actions)" },
|
|
14
|
+
},
|
|
15
|
+
required: ["peer", "action"],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
async function handleApprove(args, connectionManager, db) {
|
|
19
|
+
const conn = db.getConnectionByPeerName(args.peer);
|
|
20
|
+
if (!conn) {
|
|
21
|
+
return `No connection found with "${args.peer}".`;
|
|
22
|
+
}
|
|
23
|
+
switch (args.action) {
|
|
24
|
+
case "enable":
|
|
25
|
+
db.setApprovalMode(conn.id, "manual");
|
|
26
|
+
return `Manual approval mode enabled for ${args.peer}. Incoming queries will be held for your review.`;
|
|
27
|
+
case "disable":
|
|
28
|
+
db.setApprovalMode(conn.id, "auto");
|
|
29
|
+
return `Manual approval mode disabled for ${args.peer}. Incoming queries will be auto-responded to.`;
|
|
30
|
+
case "status": {
|
|
31
|
+
const mode = db.getApprovalMode(conn.id);
|
|
32
|
+
const held = connectionManager.getHeldQueries(args.peer);
|
|
33
|
+
let result = `Approval mode for ${args.peer}: ${mode}\n`;
|
|
34
|
+
if (held.length > 0) {
|
|
35
|
+
result += `\n${held.length} held query(ies):\n`;
|
|
36
|
+
for (const q of held) {
|
|
37
|
+
result += `- [${q.id}] ${q.content.slice(0, 80)}${q.content.length > 80 ? "..." : ""}\n`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
return `Unknown action "${args.action}". Use: enable, disable, or status.`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=approve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approve.js","sourceRoot":"","sources":["../../src/tools/approve.ts"],"names":[],"mappings":";;;AAkBA,sCAmCC;AAlDY,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,qLAAqL;IACvL,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;YACzD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sJAAsJ,EAAE;YAC/L,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gEAAgE,EAAE;SAC9G;QACD,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;KAC7B;CACF,CAAC;AAEK,KAAK,UAAU,aAAa,CACjC,IAA2D,EAC3D,iBAAoC,EACpC,EAAW;IAEX,MAAM,IAAI,GAAG,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,6BAA6B,IAAI,CAAC,IA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are const askToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
peer: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
question: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
context: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function handleAsk(args: {
|
|
25
|
+
peer: string;
|
|
26
|
+
question: string;
|
|
27
|
+
context?: string;
|
|
28
|
+
}, connectionManager: ConnectionManager): Promise<string>;
|
|
29
|
+
//# sourceMappingURL=ask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../src/tools/ask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;CAa7B,CAAC;AAEF,wBAAsB,SAAS,CAC7B,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAC1D,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.askToolDefinition = void 0;
|
|
4
|
+
exports.handleAsk = handleAsk;
|
|
5
|
+
exports.askToolDefinition = {
|
|
6
|
+
name: "nokai_ask",
|
|
7
|
+
description: "Send a question to a connected peer's AI agent. The peer's Claude Code will read their codebase and respond directly.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
peer: { type: "string", description: "Name of the connected peer" },
|
|
12
|
+
question: { type: "string", description: "The question to ask" },
|
|
13
|
+
context: { type: "string", description: "Optional context about why you're asking" },
|
|
14
|
+
},
|
|
15
|
+
required: ["peer", "question"],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
async function handleAsk(args, connectionManager) {
|
|
19
|
+
try {
|
|
20
|
+
const msg = connectionManager.sendQuery(args.peer, args.question, args.context);
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
const timeout = setTimeout(() => {
|
|
23
|
+
resolve(`Question sent to ${args.peer} (message ID: ${msg.id}).\n` +
|
|
24
|
+
`Waiting for response... The peer's agent is processing your question.\n` +
|
|
25
|
+
`Note: Response is taking longer than expected. The peer may be offline.`);
|
|
26
|
+
}, 30000);
|
|
27
|
+
connectionManager.onIncomingMessage((incomingMsg, peerName) => {
|
|
28
|
+
if (peerName === args.peer && incomingMsg.type === "response" && "replyTo" in incomingMsg && incomingMsg.replyTo === msg.id) {
|
|
29
|
+
clearTimeout(timeout);
|
|
30
|
+
let result = `Response from ${args.peer}:\n\n${incomingMsg.content}`;
|
|
31
|
+
if ("sourceFiles" in incomingMsg && incomingMsg.sourceFiles) {
|
|
32
|
+
result += `\n\nSource files: ${incomingMsg.sourceFiles.join(", ")}`;
|
|
33
|
+
}
|
|
34
|
+
resolve(result);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
return `Error: ${err.message}`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=ask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask.js","sourceRoot":"","sources":["../../src/tools/ask.ts"],"names":[],"mappings":";;;AAiBA,8BA8BC;AA7CY,QAAA,iBAAiB,GAA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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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NokaiDB } from "../db.js";
|
|
2
|
+
export declare const auditToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
limit: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
peer: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function handleAudit(args: {
|
|
21
|
+
limit?: number;
|
|
22
|
+
peer?: string;
|
|
23
|
+
}, db: NokaiDB): Promise<string>;
|
|
24
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/tools/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;kBASZ,MAAM,EAAE;;CAE3B,CAAC;AAEF,wBAAsB,WAAW,CAC/B,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACvC,EAAE,EAAE,OAAO,GACV,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.auditToolDefinition = void 0;
|
|
4
|
+
exports.handleAudit = handleAudit;
|
|
5
|
+
exports.auditToolDefinition = {
|
|
6
|
+
name: "nokai_audit",
|
|
7
|
+
description: "View the audit log of all NokAI connection and message events. Useful for debugging and tracking activity.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
limit: { type: "number", description: "Number of events to show (default: 20)" },
|
|
12
|
+
peer: { type: "string", description: "Filter by peer name (optional)" },
|
|
13
|
+
},
|
|
14
|
+
required: [],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
async function handleAudit(args, db) {
|
|
18
|
+
const limit = args.limit ?? 20;
|
|
19
|
+
const events = db.getAuditLog(limit);
|
|
20
|
+
if (events.length === 0) {
|
|
21
|
+
return "No audit events recorded yet.";
|
|
22
|
+
}
|
|
23
|
+
const filtered = args.peer
|
|
24
|
+
? events.filter((e) => e.peerName === args.peer)
|
|
25
|
+
: events;
|
|
26
|
+
if (filtered.length === 0) {
|
|
27
|
+
return `No audit events found for peer "${args.peer}".`;
|
|
28
|
+
}
|
|
29
|
+
let result = "## NokAI Audit Log\n\n";
|
|
30
|
+
result += `Showing ${filtered.length} event(s):\n\n`;
|
|
31
|
+
for (const event of filtered) {
|
|
32
|
+
const time = event.timestamp.replace("T", " ").replace(/\.\d+Z$/, " UTC");
|
|
33
|
+
const peer = event.peerName ? ` [${event.peerName}]` : "";
|
|
34
|
+
const details = event.details ? ` — ${event.details}` : "";
|
|
35
|
+
result += `- **${time}**${peer} \`${event.eventType}\`${details}\n`;
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
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AG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,OAAO,IAAI,KAAK,IAAI,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,IAAI,CAAC;IACtE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConnectionManager } from "../connection-manager.js";
|
|
2
|
+
import type { SignalingClient } from "../signaling-client.js";
|
|
3
|
+
import type { AgentProfile } from "../shared/index.js";
|
|
4
|
+
import { type PeerConnectionConfig } from "../peer-connection.js";
|
|
5
|
+
export declare const connectToolDefinition: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: {};
|
|
11
|
+
required: string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function handleConnect(profile: AgentProfile, signalingClient: SignalingClient, connectionManager: ConnectionManager, pcConfig?: PeerConnectionConfig): Promise<string>;
|
|
15
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +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;;;;;;kBAOd,MAAM,EAAE;;CAE3B,CAAC;AAEF,wBAAsB,aAAa,CACjC,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectToolDefinition = void 0;
|
|
4
|
+
exports.handleConnect = handleConnect;
|
|
5
|
+
const peer_connection_js_1 = require("../peer-connection.js");
|
|
6
|
+
exports.connectToolDefinition = {
|
|
7
|
+
name: "nokai_connect",
|
|
8
|
+
description: "Generate a one-time connection code (OTP) to connect with another developer's Claude Code instance. Share the 6-digit code with your peer — they have 5 minutes to join using nokai_join.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {},
|
|
12
|
+
required: [],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
async function handleConnect(profile, signalingClient, connectionManager, pcConfig) {
|
|
16
|
+
if (!signalingClient.isConnected()) {
|
|
17
|
+
return "Error: Not connected to signaling server. Please try again.";
|
|
18
|
+
}
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
signalingClient.once("otp_created", (data) => {
|
|
21
|
+
signalingClient.once("otp_matched", async (matchData) => {
|
|
22
|
+
const pc = new peer_connection_js_1.PeerConnection(pcConfig);
|
|
23
|
+
const connectionId = `conn_${Date.now()}`;
|
|
24
|
+
pc.onIceCandidate((candidate) => {
|
|
25
|
+
signalingClient.signal(matchData.peerId, { type: "ice", ...candidate });
|
|
26
|
+
});
|
|
27
|
+
signalingClient.on("signal", (signalData) => {
|
|
28
|
+
if (signalData.from === matchData.peerId) {
|
|
29
|
+
if (signalData.data.type === "ice") {
|
|
30
|
+
pc.addIceCandidate({
|
|
31
|
+
candidate: signalData.data.candidate,
|
|
32
|
+
mid: signalData.data.mid,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else if (signalData.data.type === "answer") {
|
|
36
|
+
pc.acceptAnswer({
|
|
37
|
+
type: "answer",
|
|
38
|
+
sdp: signalData.data.sdp,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const offer = await pc.createOffer();
|
|
44
|
+
signalingClient.signal(matchData.peerId, { type: "offer", sdp: offer.sdp });
|
|
45
|
+
await pc.waitForDataChannel();
|
|
46
|
+
connectionManager.registerPeer(connectionId, matchData.peerName, matchData.peerPublicKey);
|
|
47
|
+
connectionManager.setPeerSend(connectionId, (msg) => pc.send(msg));
|
|
48
|
+
pc.onMessage((msg) => connectionManager.handleIncomingMessage(connectionId, msg));
|
|
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}.`);
|
|
53
|
+
});
|
|
54
|
+
resolve(`Connection code: ${data.otp}\n` +
|
|
55
|
+
`Expires: ${data.expiresAt}\n\n` +
|
|
56
|
+
`Share this code with your peer. They should use nokai_join with this code.\n` +
|
|
57
|
+
`Waiting for peer to connect...`);
|
|
58
|
+
});
|
|
59
|
+
signalingClient.createOTP();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/tools/connect.ts"],"names":[],"mappings":";;;AAgBA,sCA+DC;AA5ED,8DAAkF;AAErE,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,eAA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@@
|
|
|
1
|
+
import type { ConnectionManager } from "../connection-manager.js";
|
|
2
|
+
import type { NokaiDB } from "../db.js";
|
|
3
|
+
export declare const connectionsToolDefinition: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {};
|
|
9
|
+
required: string[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function handleConnections(connectionManager: ConnectionManager, db: NokaiDB): Promise<string>;
|
|
13
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/tools/connections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,yBAAyB;;;;;;kBAMlB,MAAM,EAAE;;CAE3B,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,iBAAiB,EAAE,iBAAiB,EACpC,EAAE,EAAE,OAAO,GACV,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectionsToolDefinition = void 0;
|
|
4
|
+
exports.handleConnections = handleConnections;
|
|
5
|
+
exports.connectionsToolDefinition = {
|
|
6
|
+
name: "nokai_connections",
|
|
7
|
+
description: "List all active and saved NokAI connections with their status and permission levels.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {},
|
|
11
|
+
required: [],
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
async function handleConnections(connectionManager, db) {
|
|
15
|
+
const active = connectionManager.getActiveConnections();
|
|
16
|
+
const saved = db.listConnections();
|
|
17
|
+
if (saved.length === 0) {
|
|
18
|
+
return "No connections found. Use nokai_connect to create a new connection.";
|
|
19
|
+
}
|
|
20
|
+
let result = "## NokAI Connections\n\n";
|
|
21
|
+
for (const conn of saved) {
|
|
22
|
+
const isActive = active.some((a) => a.connectionId === conn.id);
|
|
23
|
+
const status = isActive ? "ACTIVE" : "SAVED";
|
|
24
|
+
result += `- **${conn.peerName}** [${status}]\n`;
|
|
25
|
+
result += ` Permission: ${conn.permission}\n`;
|
|
26
|
+
result += ` Connected: ${conn.createdAt}\n`;
|
|
27
|
+
if (conn.lastConnected) {
|
|
28
|
+
result += ` Last active: ${conn.lastConnected}\n`;
|
|
29
|
+
}
|
|
30
|
+
result += `\n`;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/tools/connections.ts"],"names":[],"mappings":";;;AAaA,8CA0BC;AApCY,QAAA,yBAAyB,GAAG;IACvC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,sFAAsF;IACnG,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAc;KACzB;CACF,CAAC;AAEK,KAAK,UAAU,iBAAiB,CACrC,iBAAoC,EACpC,EAAW;IAEX,MAAM,MAAM,GAAG,iBAAiB,CAAC,oBAAoB,EAAE,CAAC;IACxD,MAAM,KAAK,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC;IAEnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,qEAAqE,CAAC;IAC/E,CAAC;IAED,IAAI,MAAM,GAAG,0BAA0B,CAAC;IAExC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7C,MAAM,IAAI,OAAO,IAAI,CAAC,QAAQ,OAAO,MAAM,KAAK,CAAC;QACjD,MAAM,IAAI,iBAAiB,IAAI,CAAC,UAAU,IAAI,CAAC;QAC/C,MAAM,IAAI,gBAAgB,IAAI,CAAC,SAAS,IAAI,CAAC;QAC7C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,IAAI,kBAAkB,IAAI,CAAC,aAAa,IAAI,CAAC;QACrD,CAAC;QACD,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ConnectionManager } from "../connection-manager.js";
|
|
2
|
+
export declare const disconnectToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
peer: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
required: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function handleDisconnect(args: {
|
|
17
|
+
peer: string;
|
|
18
|
+
}, connectionManager: ConnectionManager): Promise<string>;
|
|
19
|
+
//# sourceMappingURL=disconnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnect.d.ts","sourceRoot":"","sources":["../../src/tools/disconnect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;CAUpC,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACtB,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,MAAM,CAAC,CAMjB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.disconnectToolDefinition = void 0;
|
|
4
|
+
exports.handleDisconnect = handleDisconnect;
|
|
5
|
+
exports.disconnectToolDefinition = {
|
|
6
|
+
name: "nokai_disconnect",
|
|
7
|
+
description: "Disconnect from a connected peer. The connection record is kept for potential reconnection later.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
peer: { type: "string", description: "Name of the peer to disconnect from" },
|
|
12
|
+
},
|
|
13
|
+
required: ["peer"],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
async function handleDisconnect(args, connectionManager) {
|
|
17
|
+
const disconnected = connectionManager.disconnectPeer(args.peer);
|
|
18
|
+
if (disconnected) {
|
|
19
|
+
return `Disconnected from ${args.peer}. Connection saved for future reconnection.`;
|
|
20
|
+
}
|
|
21
|
+
return `No active connection with ${args.peer}.`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=disconnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnect.js","sourceRoot":"","sources":["../../src/tools/disconnect.ts"],"names":[],"mappings":";;;AAcA,4CASC;AArBY,QAAA,wBAAwB,GAAG;IACtC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mGAAmG;IAChH,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;SAC7E;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;CACF,CAAC;AAEK,KAAK,UAAU,gBAAgB,CACpC,IAAsB,EACtB,iBAAoC;IAEpC,MAAM,YAAY,GAAG,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,qBAAqB,IAAI,CAAC,IAAI,6CAA6C,CAAC;IACrF,CAAC;IACD,OAAO,6BAA6B,IAAI,CAAC,IAAI,GAAG,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NokaiDB } from "../db.js";
|
|
2
|
+
export declare const historyToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
peer: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
limit: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function handleHistory(args: {
|
|
21
|
+
peer: string;
|
|
22
|
+
limit?: number;
|
|
23
|
+
}, db: NokaiDB): Promise<string>;
|
|
24
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/tools/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;CAYjC,CAAC;AAEF,wBAAsB,aAAa,CACjC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACtC,EAAE,EAAE,OAAO,GACV,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.historyToolDefinition = void 0;
|
|
4
|
+
exports.handleHistory = handleHistory;
|
|
5
|
+
exports.historyToolDefinition = {
|
|
6
|
+
name: "nokai_history",
|
|
7
|
+
description: "View past message exchanges with a connected or previously connected peer. Shows queries, responses, and timestamps.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
peer: { type: "string", description: "Name of the peer to view history with" },
|
|
12
|
+
limit: { type: "number", description: "Maximum number of messages to show (default: 50)" },
|
|
13
|
+
},
|
|
14
|
+
required: ["peer"],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
async function handleHistory(args, db) {
|
|
18
|
+
const conn = db.getConnectionByPeerName(args.peer);
|
|
19
|
+
if (!conn) {
|
|
20
|
+
return `No connection found with peer "${args.peer}". Use nokai_connections to see available peers.`;
|
|
21
|
+
}
|
|
22
|
+
const limit = args.limit ?? 50;
|
|
23
|
+
const messages = db.getMessages(conn.id, limit);
|
|
24
|
+
if (messages.length === 0) {
|
|
25
|
+
return `No messages exchanged with ${args.peer} yet.`;
|
|
26
|
+
}
|
|
27
|
+
let result = `## Message History with ${args.peer}\n\n`;
|
|
28
|
+
result += `Showing ${messages.length} message(s):\n\n`;
|
|
29
|
+
for (const msg of messages) {
|
|
30
|
+
const arrow = msg.direction === "sent" ? "→ You" : `← ${args.peer}`;
|
|
31
|
+
const time = msg.timestamp.replace("T", " ").replace("Z", " UTC");
|
|
32
|
+
result += `**[${time}]** ${arrow} (${msg.type}):\n`;
|
|
33
|
+
result += `${msg.content}\n`;
|
|
34
|
+
if (msg.sourceFiles) {
|
|
35
|
+
try {
|
|
36
|
+
const files = JSON.parse(msg.sourceFiles);
|
|
37
|
+
result += `_Source: ${files.join(", ")}_\n`;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// ignore malformed sourceFiles
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
result += `\n`;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/tools/history.ts"],"names":[],"mappings":";;;AAgBA,sCAoCC;AAlDY,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,sHAAsH;IACxH,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uCAAuC,EAAE;YAC9E,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kDAAkD,EAAE;SAC3F;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;CACF,CAAC;AAEK,KAAK,UAAU,aAAa,CACjC,IAAsC,EACtC,EAAW;IAEX,MAAM,IAAI,GAAG,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,kCAAkC,IAAI,CAAC,IAAI,kDAAkD,CAAC;IACvG,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAEhD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,8BAA8B,IAAI,CAAC,IAAI,OAAO,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,GAAG,2BAA2B,IAAI,CAAC,IAAI,MAAM,CAAC;IACxD,MAAM,IAAI,WAAW,QAAQ,CAAC,MAAM,kBAAkB,CAAC;IAEvD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACpE,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAClE,MAAM,IAAI,MAAM,IAAI,OAAO,KAAK,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC;QACpD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC;QAC7B,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAa,CAAC;gBACtD,MAAM,IAAI,YAAY,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAC9C,CAAC;YAAC,MAAM,CAAC;gBACP,+BAA+B;YACjC,CAAC;QACH,CAAC;QACD,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ConnectionManager } from "../connection-manager.js";
|
|
2
|
+
import type { SignalingClient } from "../signaling-client.js";
|
|
3
|
+
import type { AgentProfile } from "../shared/index.js";
|
|
4
|
+
import { type PeerConnectionConfig } from "../peer-connection.js";
|
|
5
|
+
export declare const joinToolDefinition: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: {
|
|
11
|
+
otp: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
required: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function handleJoin(args: {
|
|
20
|
+
otp: string;
|
|
21
|
+
}, profile: AgentProfile, signalingClient: SignalingClient, connectionManager: ConnectionManager, pcConfig?: PeerConnectionConfig): Promise<string>;
|
|
22
|
+
//# sourceMappingURL=join.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../src/tools/join.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,kBAAkB;;;;;;;;;;;;;CAW9B,CAAC;AAEF,wBAAsB,UAAU,CAC9B,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EACrB,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAmDjB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinToolDefinition = void 0;
|
|
4
|
+
exports.handleJoin = handleJoin;
|
|
5
|
+
const peer_connection_js_1 = require("../peer-connection.js");
|
|
6
|
+
exports.joinToolDefinition = {
|
|
7
|
+
name: "nokai_join",
|
|
8
|
+
description: "Join a connection using a 6-digit OTP code shared by another developer. This establishes a peer-to-peer link between your Claude Code instances.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
otp: { type: "string", description: "The 6-digit connection code shared by your peer" },
|
|
13
|
+
},
|
|
14
|
+
required: ["otp"],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
async function handleJoin(args, profile, signalingClient, connectionManager, pcConfig) {
|
|
18
|
+
if (!signalingClient.isConnected()) {
|
|
19
|
+
return "Error: Not connected to signaling server. Please try again.";
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
signalingClient.once("otp_matched", async (matchData) => {
|
|
23
|
+
const pc = new peer_connection_js_1.PeerConnection(pcConfig);
|
|
24
|
+
const connectionId = `conn_${Date.now()}`;
|
|
25
|
+
pc.onIceCandidate((candidate) => {
|
|
26
|
+
signalingClient.signal(matchData.peerId, { type: "ice", ...candidate });
|
|
27
|
+
});
|
|
28
|
+
signalingClient.on("signal", async (signalData) => {
|
|
29
|
+
if (signalData.from === matchData.peerId) {
|
|
30
|
+
if (signalData.data.type === "ice") {
|
|
31
|
+
pc.addIceCandidate({
|
|
32
|
+
candidate: signalData.data.candidate,
|
|
33
|
+
mid: signalData.data.mid,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else if (signalData.data.type === "offer") {
|
|
37
|
+
const answer = await pc.createAnswer({
|
|
38
|
+
type: "offer",
|
|
39
|
+
sdp: signalData.data.sdp,
|
|
40
|
+
});
|
|
41
|
+
signalingClient.signal(matchData.peerId, { type: "answer", sdp: answer.sdp });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
await pc.waitForDataChannel();
|
|
46
|
+
connectionManager.registerPeer(connectionId, matchData.peerName, matchData.peerPublicKey);
|
|
47
|
+
connectionManager.setPeerSend(connectionId, (msg) => pc.send(msg));
|
|
48
|
+
pc.onMessage((msg) => connectionManager.handleIncomingMessage(connectionId, msg));
|
|
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}.`);
|
|
53
|
+
});
|
|
54
|
+
signalingClient.once("error", (data) => {
|
|
55
|
+
resolve(`Error: ${data.message}`);
|
|
56
|
+
});
|
|
57
|
+
signalingClient.joinOTP(args.otp, profile.name, profile.publicKey);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../src/tools/join.ts"],"names":[],"mappings":";;;AAkBA,gCAyDC;AAxED,8DAAkF;AAErE,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,kJAAkJ;IACpJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;SACxF;QACD,QAAQ,EAAE,CAAC,KAAK,CAAC;KAClB;CACF,CAAC;AAEK,KAAK,UAAU,UAAU,CAC9B,IAAqB,EACrB,OAAqB,EACrB,eAAgC,EAChC,iBAAoC,EACpC,QAA+B;IAE/B,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC;QACnC,OAAO,6DAA6D,CAAC;IACvE,CAAC;IAED,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QACrC,eAAe,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,SAAsE,EAAE,EAAE;YACnH,MAAM,EAAE,GAAG,IAAI,mCAAc,CAAC,QAAQ,CAAC,CAAC;YACxC,MAAM,YAAY,GAAG,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAE1C,EAAE,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC9B,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;YAEH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,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CAAC,QAAQ,GAAG,CACxE,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAyB,EAAE,EAAE;YAC1D,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NokaiDB } from "../db.js";
|
|
2
|
+
export declare const permissionsToolDefinition: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
peer: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
level: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function handlePermissions(args: {
|
|
21
|
+
peer: string;
|
|
22
|
+
level?: string;
|
|
23
|
+
}, db: NokaiDB): Promise<string>;
|
|
24
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/tools/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;CAYrC,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACtC,EAAE,EAAE,OAAO,GACV,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
|