opencode-claw 0.2.2 → 0.2.3

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.
@@ -45,7 +45,6 @@ function peerKey(channel, peerId) {
45
45
  }
46
46
  async function handleCommand(cmd, msg, deps, activeStreams) {
47
47
  const key = buildSessionKey(msg.channel, msg.peerId, msg.threadId);
48
- const prefix = `${msg.channel}:${msg.peerId}`;
49
48
  switch (cmd.name) {
50
49
  case "new": {
51
50
  const id = await deps.sessions.newSession(key, cmd.args || undefined);
@@ -58,7 +57,7 @@ async function handleCommand(cmd, msg, deps, activeStreams) {
58
57
  return `Switched to session: ${cmd.args}`;
59
58
  }
60
59
  case "sessions": {
61
- const list = await deps.sessions.listSessions(prefix);
60
+ const list = await deps.sessions.listSessions(key);
62
61
  if (list.length === 0)
63
62
  return "No sessions found.";
64
63
  return list
@@ -13,7 +13,7 @@ export declare function createSessionManager(client: OpencodeClient, config: Ses
13
13
  resolveSession: (key: string, title?: string) => Promise<string>;
14
14
  switchSession: (key: string, targetId: string) => Promise<void>;
15
15
  newSession: (key: string, title?: string) => Promise<string>;
16
- listSessions: (channelPeerPrefix: string) => Promise<SessionInfo[]>;
16
+ listSessions: (key: string) => Promise<SessionInfo[]>;
17
17
  currentSession: (key: string) => string | undefined;
18
18
  persist: () => Promise<void>;
19
19
  };
@@ -39,20 +39,17 @@ export function createSessionManager(client, config, map, logger) {
39
39
  logger.info("sessions: created and switched to new session", { key, id: session.data.id });
40
40
  return session.data.id;
41
41
  }
42
- async function listSessions(channelPeerPrefix) {
42
+ async function listSessions(key) {
43
43
  const all = await client.session.list();
44
44
  const sessions = all.data ?? [];
45
- const entries = [...map.entries()].filter(([key]) => key.includes(channelPeerPrefix));
46
- return entries.map(([key, id]) => {
47
- const session = sessions.find((s) => s.id === id);
48
- return {
49
- id,
50
- key,
51
- title: session?.title ?? "(deleted)",
52
- active: map.get(key) === id,
53
- createdAt: session?.time.created,
54
- };
55
- });
45
+ const activeId = map.get(key);
46
+ return sessions.map((s) => ({
47
+ id: s.id,
48
+ key: [...map.entries()].find(([, id]) => id === s.id)?.[0] ?? "(external)",
49
+ title: s.title ?? s.id,
50
+ active: s.id === activeId,
51
+ createdAt: s.time.created,
52
+ }));
56
53
  }
57
54
  function currentSession(key) {
58
55
  return map.get(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-claw",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Wrap OpenCode with persistent memory, messaging channels, and cron jobs",
5
5
  "license": "MIT",
6
6
  "type": "module",