dsh-plugin-agent-memory 0.1.1 → 0.1.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.
Files changed (3) hide show
  1. package/client.js +20 -18
  2. package/index.js +3 -1
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -5,8 +5,10 @@
5
5
  * selection back through the same origin-scoped HTTP routes, so the Host can recall that
6
6
  * expert's memories on the next turn.
7
7
  */
8
+ // The loader keys modules by their package name, so this id must stay equal to package.json's
9
+ // `name`; a mismatch leaves the module registered under an id the boot graph never mounts.
8
10
  window.__ModuleLoader__.load({
9
- id: '@local/agent-memory',
11
+ id: 'dsh-plugin-agent-memory',
10
12
  factory(require) {
11
13
  const React = require('react');
12
14
  const h = React.createElement;
@@ -227,12 +229,12 @@ window.__ModuleLoader__.load({
227
229
  .finally(() => setBusy(false));
228
230
  }, []);
229
231
 
230
- const sortedAgents = React.useMemo(() => {
231
- const owned = agents.filter((agent) => agent.owned !== false);
232
- const rest = agents.filter((agent) => agent.owned === false);
233
- return [...owned, ...rest];
234
- }, [agents]);
235
- const ownedCount = sortedAgents.filter((agent) => agent.owned !== false).length;
232
+ // Only agents this user key owns can serve as an expert; the Hub refuses cross-owner
233
+ // memory reads, so listing the rest would only offer dead entries.
234
+ const visibleAgents = React.useMemo(
235
+ () => agents.filter((agent) => agent.owned !== false),
236
+ [agents],
237
+ );
236
238
 
237
239
  const choose = React.useCallback(
238
240
  (agent) => {
@@ -454,32 +456,32 @@ window.__ModuleLoader__.load({
454
456
  ? null
455
457
  : h('div', { style: { ...mutedStyle, marginTop: '4px' } }, 'Agent / 专家'),
456
458
  busy ? h('div', { style: mutedStyle }, '加载中…') : null,
457
- ...sortedAgents.map((agent) =>
459
+ ...visibleAgents.map((agent) =>
458
460
  h(
459
461
  'button',
460
462
  {
461
463
  key: agent.agentId,
462
464
  type: 'button',
463
- disabled: agent.owned === false,
464
- title: agent.owned === false ? '这是他人的 agent,你的 userkey 无权读写其记忆' : agent.description,
465
+ title: agent.description,
465
466
  style: {
466
467
  ...rowStyle,
467
- opacity: agent.owned === false ? 0.4 : agent.status === 'active' ? 1 : 0.5,
468
- cursor: agent.owned === false ? 'not-allowed' : 'pointer',
468
+ opacity: agent.status === 'active' ? 1 : 0.5,
469
+ cursor: 'pointer',
469
470
  },
470
471
  onClick: () => choose(agent),
471
472
  },
472
- agent.owned === false ? `${agent.name} · 无权限` : agent.name,
473
+ agent.name,
473
474
  agent.description
474
475
  ? h('span', { style: { display: 'block', opacity: 0.6, fontSize: '11px' } }, agent.description)
475
476
  : null,
476
477
  ),
477
478
  ),
478
- sortedAgents.length === 0 && !busy && teams.length > 0
479
- ? h('div', { style: mutedStyle }, '该团队下没有 agent')
480
- : null,
481
- sortedAgents.length > 0 && ownedCount === 0 && !busy
482
- ? h('div', { style: mutedStyle }, '该团队下没有属于你的 agent,无法作为专家')
479
+ visibleAgents.length === 0 && !busy && teams.length > 0
480
+ ? h(
481
+ 'div',
482
+ { style: mutedStyle },
483
+ agents.length === 0 ? '该团队下没有 agent' : '该团队下没有属于你的 agent,无法作为专家',
484
+ )
483
485
  : null,
484
486
  selection
485
487
  ? h(
package/index.js CHANGED
@@ -283,7 +283,9 @@ export function apply(ctx, config) {
283
283
  debug({ at: 'skip-no-selection', sessionId });
284
284
  return decision;
285
285
  }
286
- const dedupeKey = `${sessionId}:${query}`;
286
+ // The expert is part of the key: switching experts mid-session must re-recall even
287
+ // when the user repeats the same question.
288
+ const dedupeKey = `${sessionId}:${selection.agentId}:${query}`;
287
289
  if (state.lastInjection.get(sessionId) === dedupeKey) return decision;
288
290
  const hits = await recall(selection, query);
289
291
  debug({ at: 'recall', sessionId, agent: selection.agentId, query: query.slice(0, 60), hits: hits.length });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-agent-memory",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Tencent agent-memory integration: pick a team agent as an expert at the composer and its long-term memories are recalled into each turn.",
6
6
  "license": "MIT",