OverviewFilesCommitsIssuesDocsReleasesPeers

ollama_semantic_function_calling commits / 0037736

Update identity to be a real identity in Keet client
003773638675f5d32f706960f074d9408db8538d
by fleeky.ashatron <fleeky@7rnx.net> · 2025-04-21T18:43:32.000Z

Changed files (3) +96 -0

ollamatools-new/second-device-keet/storage/db/identity.json +1 -0
……@@ -0,0 +1 @@
1{"id": "s3hngfgxfgs9db17jxynwxpdyieq8sesoo91wnd5mycp56t6o5ay", "name": "KeetBot", "anonymous": false}
ollamatools-new/test-keet-storage/db/identity.json +1 -0
……@@ -0,0 +1 @@
1{"id": "s3hngfgxfgs9db17jxynwxpdyieq8sesoo91wnd5mycp56t6o5ay", "name": "KeetBot", "anonymous": false}
ollamatools-new/tests/update_identity.js +94 -0
……@@ -0,0 +1,94 @@
1#!/usr/bin/env node
2/**
3 * Script to update the Keet identity to be a real identity
4 */
5
6import fs from 'fs';
7import path from 'path';
8import { fileURLToPath } from 'url';
9import { parseArgs } from 'node:util';
10
11// Get the directory name of the current module
12const __filename = fileURLToPath(import.meta.url);
13const __dirname = path.dirname(__filename);
14
15// Configure logging
16function log(level, message) {
17 const timestamp = new Date().toISOString();
18 console.log(`[${timestamp}] [${level}] ${message}`);
19}
20
21// Parse command-line arguments
22function parseArguments() {
23 const options = {
24 storage: { type: 'string' },
25 name: { type: 'string' },
26 verbose: { type: 'boolean', default: false }
27 };
28
29 const { values } = parseArgs({ options });
30 return values;
31}
32
33// Main function
34async function main() {
35 try {
36 // Parse command-line arguments
37 const args = parseArguments();
38
39 // Create a storage directory if it doesn't exist
40 const storagePath = args.storage || path.join(__dirname, '..', 'test-keet-storage');
41 if (!fs.existsSync(storagePath)) {
42 fs.mkdirSync(storagePath, { recursive: true });
43 }
44
45 // Path to the identity file
46 const identityPath = path.join(storagePath, 'identity.json');
47
48 // Check if the identity file exists
49 if (!fs.existsSync(identityPath)) {
50 log('ERROR', `Identity file not found at: ${identityPath}`);
51 return 1;
52 }
53
54 // Read the identity file
55 log('INFO', `Reading identity from: ${identityPath}`);
56 const identity = JSON.parse(fs.readFileSync(identityPath, 'utf8'));
57 log('INFO', `Current identity: ${JSON.stringify(identity)}`);
58
59 // Update the identity
60 const updatedIdentity = {
61 ...identity,
62 anonymous: false // Set to false for a real identity
63 };
64
65 // Update the display name if provided
66 if (args.name) {
67 updatedIdentity.displayName = args.name;
68 }
69
70 // Write the updated identity back to the file
71 log('INFO', `Writing updated identity to: ${identityPath}`);
72 fs.writeFileSync(identityPath, JSON.stringify(updatedIdentity));
73 log('INFO', `Updated identity: ${JSON.stringify(updatedIdentity)}`);
74
75 log('INFO', 'Identity updated successfully!');
76 return 0;
77 } catch (error) {
78 log('ERROR', `Error updating identity: ${error.message}`);
79 log('ERROR', error.stack);
80 return 1;
81 }
82}
83
84// Run the main function if this file is executed directly
85if (import.meta.url === `file://${process.argv[1]}`) {
86 try {
87 const exitCode = await main();
88 process.exit(exitCode);
89 } catch (error) {
90 log('ERROR', `Unhandled error: ${error.message}`);
91 log('ERROR', error.stack);
92 process.exit(1);
93 }
94}