oceanbus 0.5.0 → 0.5.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C,eAAO,MAAM,UAAU,EAAE,aAmDxB,CAAC"}
|
package/dist/cli/commands/add.js
CHANGED
|
@@ -5,10 +5,11 @@ const index_1 = require("../../index");
|
|
|
5
5
|
const contacts_1 = require("../contacts");
|
|
6
6
|
exports.addCommand = {
|
|
7
7
|
command: 'add <name> <openid>',
|
|
8
|
-
describe: 'Save a contact
|
|
8
|
+
describe: 'Save a contact and optionally send a greeting',
|
|
9
9
|
builder: (yargs) => yargs
|
|
10
10
|
.positional('name', { type: 'string', describe: 'Short name for this contact', demandOption: true })
|
|
11
|
-
.positional('openid', { type: 'string', describe: 'Contact OpenID', demandOption: true })
|
|
11
|
+
.positional('openid', { type: 'string', describe: 'Contact OpenID', demandOption: true })
|
|
12
|
+
.option('greet-as', { type: 'string', describe: 'Also send a greeting, signed with this name' }),
|
|
12
13
|
handler: async (argv) => {
|
|
13
14
|
try {
|
|
14
15
|
const ob = await (0, index_1.createOceanBus)();
|
|
@@ -16,19 +17,10 @@ exports.addCommand = {
|
|
|
16
17
|
console.error('No identity found. Run "oceanbus register" first.');
|
|
17
18
|
process.exit(1);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const me = await ob.identity.whoami();
|
|
23
|
-
myOpenId = me.my_openid;
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
myOpenId = ob.identity.getCachedOpenId() || '';
|
|
27
|
-
}
|
|
28
|
-
// Save to contacts.json (backward compat + CLI resolution)
|
|
20
|
+
const myOpenId = ob.identity.getCachedOpenId() || (await ob.identity.whoami()).my_openid;
|
|
21
|
+
// --- Save contact ---
|
|
29
22
|
(0, contacts_1.saveContact)(argv.name, argv.openid);
|
|
30
23
|
(0, contacts_1.setMyOpenId)(argv.name, myOpenId);
|
|
31
|
-
// Also save to Roster if available
|
|
32
24
|
try {
|
|
33
25
|
await ob.roster.add({
|
|
34
26
|
name: argv.name,
|
|
@@ -37,14 +29,21 @@ exports.addCommand = {
|
|
|
37
29
|
agents: [{ agentId: '', openId: argv.openid, purpose: '', isDefault: true }],
|
|
38
30
|
});
|
|
39
31
|
}
|
|
40
|
-
catch { /*
|
|
41
|
-
|
|
32
|
+
catch { /* may already exist */ }
|
|
33
|
+
// --- Optional greeting ---
|
|
34
|
+
if (argv.greetAs) {
|
|
35
|
+
const greeting = `Hi ${argv.name}, I'm ${argv.greetAs}. Add me to your contacts.`;
|
|
36
|
+
await ob.send(argv.openid, greeting);
|
|
37
|
+
}
|
|
38
|
+
const result = {
|
|
42
39
|
code: 0,
|
|
43
|
-
msg: 'saved',
|
|
40
|
+
msg: argv.greetAs ? 'saved + greeted' : 'saved',
|
|
44
41
|
name: argv.name,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
};
|
|
43
|
+
if (argv.greetAs) {
|
|
44
|
+
result.greeting_sent = `Hi ${argv.name}, I'm ${argv.greetAs}. Add me to your contacts.`;
|
|
45
|
+
}
|
|
46
|
+
console.log(JSON.stringify(result, null, 2));
|
|
48
47
|
}
|
|
49
48
|
catch (err) {
|
|
50
49
|
console.error('add failed:', err.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":";;;AACA,u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