symposium 0.10.8 → 0.10.9
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/Agent.js +6 -15
- package/Thread.js +4 -2
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -57,10 +57,13 @@ export default class Agent {
|
|
|
57
57
|
async doInitThread(thread) {
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
async getThread(id) {
|
|
60
|
+
async getThread(id, i) {
|
|
61
61
|
let thread = this.threads.get(id);
|
|
62
|
-
if (
|
|
63
|
-
thread
|
|
62
|
+
if (thread) {
|
|
63
|
+
if (thread.interface !== i)
|
|
64
|
+
throw new Error('Required thread is not from the same interface');
|
|
65
|
+
} else {
|
|
66
|
+
thread = new Thread(id, i, this);
|
|
64
67
|
|
|
65
68
|
if (!(await thread.loadState())) {
|
|
66
69
|
await this.resetState(thread);
|
|
@@ -73,18 +76,6 @@ export default class Agent {
|
|
|
73
76
|
return thread;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
async getThreadIfExists(id) {
|
|
77
|
-
if (this.threads.has(id))
|
|
78
|
-
return this.threads.get(id);
|
|
79
|
-
|
|
80
|
-
const thread = new Thread(id, this);
|
|
81
|
-
|
|
82
|
-
if (await thread.loadState())
|
|
83
|
-
return thread;
|
|
84
|
-
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
79
|
async message(thread, content) {
|
|
89
80
|
if (typeof thread !== 'object')
|
|
90
81
|
thread = await this.getThread(thread);
|
package/Thread.js
CHANGED
|
@@ -8,15 +8,17 @@ export default class Thread {
|
|
|
8
8
|
reply;
|
|
9
9
|
messages = [];
|
|
10
10
|
state = {};
|
|
11
|
+
interface = null;
|
|
11
12
|
|
|
12
|
-
constructor(id, agent) {
|
|
13
|
+
constructor(id, i, agent) {
|
|
13
14
|
this.id = id;
|
|
14
15
|
this.unique = agent.name + '-' + id;
|
|
15
16
|
this.agent = agent;
|
|
17
|
+
this.interface = i;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
clone(keepMessages = true) {
|
|
19
|
-
let newThread = new Thread(this.id, this.agent);
|
|
21
|
+
let newThread = new Thread(this.id, this.interface, this.agent);
|
|
20
22
|
newThread.reply = this.reply;
|
|
21
23
|
newThread.state = this.state;
|
|
22
24
|
if (keepMessages)
|