agentschat-mcp 0.36.24 → 0.36.26

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 (84) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -0
  3. package/codex/README.md +1 -1
  4. package/codex/app-server.ts +79 -22
  5. package/codex/bots-config.ts +31 -11
  6. package/codex/bridge.ts +123 -25
  7. package/codex/config.ts +128 -21
  8. package/codex/gui-channel.ts +66 -9
  9. package/codex/inbox-sync.ts +65 -12
  10. package/codex/loop-grants.ts +41 -11
  11. package/codex/manager.ts +101 -25
  12. package/codex/owner.ts +81 -9
  13. package/codex/processes.ts +51 -7
  14. package/codex/run.ts +70 -17
  15. package/codex/runtime-home.ts +41 -11
  16. package/codex/thread-history.ts +77 -30
  17. package/codex/transport.ts +122 -19
  18. package/connector/auth.ts +57 -5
  19. package/connector/backfill.ts +92 -10
  20. package/connector/descriptor.ts +27 -1
  21. package/connector/identities.ts +82 -14
  22. package/connector/ingest.ts +11 -2
  23. package/connector/normalize.ts +32 -12
  24. package/connector/run.ts +314 -67
  25. package/connector/server.ts +95 -26
  26. package/dist/codex-bots.js +410 -73
  27. package/dist/codex-bridge.js +1996 -576
  28. package/dist/connector.js +1286 -493
  29. package/dist/dsh.js +1776 -299
  30. package/dist/muse.js +967 -221
  31. package/dist/server.js +7645 -1172
  32. package/dsh/client.js +7 -5
  33. package/dsh/identity-ui/client.js +7 -5
  34. package/dsh/identity-ui/index.js +43 -8
  35. package/dsh/inbound-bridge/index.js +595 -146
  36. package/dsh/src/cli.ts +430 -91
  37. package/dsh/src/patch.ts +295 -15
  38. package/dsh/tests/dsh-hardening-127.test.ts +207 -0
  39. package/dsh/tests/dsh.test.ts +990 -3
  40. package/muse/scripts/ensure-muse-wakes.mjs +5 -3
  41. package/muse/scripts/muse-wake-receiver.mjs +4 -1
  42. package/muse/src/bridge.ts +54 -13
  43. package/muse/src/cli.ts +226 -41
  44. package/muse/src/client.ts +249 -34
  45. package/muse/src/config.ts +128 -12
  46. package/muse/src/policy.ts +28 -8
  47. package/muse/src/types.ts +1 -0
  48. package/muse/src/typing.ts +18 -1
  49. package/muse/src/wake.ts +237 -35
  50. package/muse/tests/bridge.test.mjs +131 -0
  51. package/muse/tests/client.test.mjs +327 -0
  52. package/muse/tests/config.test.mjs +78 -1
  53. package/muse/tests/hardening.test.mjs +199 -0
  54. package/muse/tests/hardening126.test.mjs +292 -0
  55. package/muse/tests/policy.test.mjs +83 -1
  56. package/muse/tests/wake.test.mjs +134 -6
  57. package/package.json +3 -3
  58. package/scripts/ensure-grok-wakes.mjs +93 -8
  59. package/scripts/example-url-wake-receiver.mjs +254 -61
  60. package/scripts/grok-bind-register.sh +38 -8
  61. package/skills/agentschat-team-lead/SKILL.md +1 -1
  62. package/skills/onboarding.md +14 -10
  63. package/src/argcheck.ts +1890 -1
  64. package/src/cli.mjs +98 -14
  65. package/src/dedup.ts +57 -8
  66. package/src/grok-bind.ts +160 -33
  67. package/src/heartbeat.ts +39 -11
  68. package/src/identity-guard.ts +93 -20
  69. package/src/identity.ts +67 -11
  70. package/src/mentions.ts +26 -5
  71. package/src/onboarding-status.ts +134 -11
  72. package/src/profile-selection.ts +269 -18
  73. package/src/profile-store.ts +222 -28
  74. package/src/read-cursor.ts +256 -9
  75. package/src/reconnect.ts +98 -2
  76. package/src/redact.ts +34 -15
  77. package/src/rest-cli.ts +713 -159
  78. package/src/server.ts +2487 -342
  79. package/src/session-bind.ts +731 -132
  80. package/src/session-route.ts +183 -12
  81. package/src/team-lead-skill.ts +3 -0
  82. package/src/timestamps.ts +56 -23
  83. package/src/tool-annotations.ts +22 -1
  84. package/src/wake.ts +524 -90
package/dsh/client.js CHANGED
@@ -103,8 +103,10 @@ window.__ModuleLoader__.load({
103
103
  }
104
104
  }, [refresh]);
105
105
 
106
- const boundName = data && sessionId ? data.binds[sessionId] : undefined;
107
- const profile = data && boundName ? data.profiles.find((p) => p.name === boundName) : undefined;
106
+ const boundName = data && data.binds && typeof data.binds === 'object' &&
107
+ Object.prototype.hasOwnProperty.call(data.binds, sessionId) ? data.binds[sessionId] : undefined;
108
+ const profiles = data && Array.isArray(data.profiles) ? data.profiles.filter((p) => p && typeof p === 'object') : [];
109
+ const profile = boundName ? profiles.find((p) => p.name === boundName) : undefined;
108
110
 
109
111
  async function call(path, payload) {
110
112
  setBusy(true);
@@ -170,7 +172,7 @@ window.__ModuleLoader__.load({
170
172
  { style: { padding: '4px 8px 6px', fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)' } },
171
173
  '这个会话用哪个 AgentsChat 身份',
172
174
  ),
173
- (data && data.profiles ? data.profiles : []).slice(0, 8).map((entry) =>
175
+ profiles.slice(0, 8).map((entry) =>
174
176
  h(
175
177
  'button',
176
178
  {
@@ -187,7 +189,7 @@ window.__ModuleLoader__.load({
187
189
  { style: { flex: '1', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
188
190
  entry.displayName || entry.name,
189
191
  ),
190
- h('span', { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: '11px' } }, entry.agentId.slice(0, 8)),
192
+ h('span', { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: '11px' } }, typeof entry.agentId === 'string' ? entry.agentId.slice(0, 8) : ''),
191
193
  ),
192
194
  ),
193
195
  sessionId
@@ -226,7 +228,7 @@ window.__ModuleLoader__.load({
226
228
  style: { color: 'var(--dsw-alias-state-business-primary)', fontSize: '12px', textDecoration: 'none' },
227
229
  href: CHAT + encodeURIComponent(profile.agentId),
228
230
  target: '_blank',
229
- rel: 'noreferrer',
231
+ rel: 'noopener noreferrer',
230
232
  },
231
233
  '打开私聊',
232
234
  ),
@@ -107,8 +107,10 @@ window.__ModuleLoader__.load({
107
107
  }
108
108
  }, [refresh]);
109
109
 
110
- const boundName = data && sessionId ? data.binds[sessionId] : undefined;
111
- const profile = data && boundName ? data.profiles.find((p) => p.name === boundName) : undefined;
110
+ const boundName = data && data.binds && typeof data.binds === 'object' &&
111
+ Object.prototype.hasOwnProperty.call(data.binds, sessionId) ? data.binds[sessionId] : undefined;
112
+ const profiles = data && Array.isArray(data.profiles) ? data.profiles.filter((p) => p && typeof p === 'object') : [];
113
+ const profile = boundName ? profiles.find((p) => p.name === boundName) : undefined;
112
114
 
113
115
  async function call(path, payload) {
114
116
  setBusy(true);
@@ -174,7 +176,7 @@ window.__ModuleLoader__.load({
174
176
  { style: { padding: '4px 8px 6px', fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)' } },
175
177
  '这个会话用哪个 AgentsChat 身份',
176
178
  ),
177
- (data && data.profiles ? data.profiles : []).slice(0, 8).map((entry) =>
179
+ profiles.slice(0, 8).map((entry) =>
178
180
  h(
179
181
  'button',
180
182
  {
@@ -191,7 +193,7 @@ window.__ModuleLoader__.load({
191
193
  { style: { flex: '1', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
192
194
  entry.displayName || entry.name,
193
195
  ),
194
- h('span', { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: '11px' } }, entry.agentId.slice(0, 8)),
196
+ h('span', { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: '11px' } }, typeof entry.agentId === 'string' ? entry.agentId.slice(0, 8) : ''),
195
197
  ),
196
198
  ),
197
199
  sessionId
@@ -230,7 +232,7 @@ window.__ModuleLoader__.load({
230
232
  style: { color: 'var(--dsw-alias-state-business-primary)', fontSize: '12px', textDecoration: 'none' },
231
233
  href: CHAT + encodeURIComponent(profile.agentId),
232
234
  target: '_blank',
233
- rel: 'noreferrer',
235
+ rel: 'noopener noreferrer',
234
236
  },
235
237
  '打开私聊',
236
238
  ),
@@ -7,15 +7,50 @@
7
7
  * very different causes — the row never loaded, or the browser module never ran
8
8
  * — and without a marker from each half there is no way to tell them apart.
9
9
  */
10
- import { appendFileSync } from 'node:fs';
10
+ import { closeSync, constants, fstatSync, lstatSync, openSync, realpathSync, writeSync } from 'node:fs';
11
11
  import { homedir } from 'node:os';
12
- import { join } from 'node:path';
12
+ import { dirname, join, resolve } from 'node:path';
13
13
 
14
- export function apply() {
14
+ const MAX_LOG_BYTES = 256 * 1024;
15
+ const DARWIN_ROOT_LINKS = new Set(['/var', '/tmp', '/etc']);
16
+
17
+ function checkDirectories(directory) {
18
+ let path = resolve(directory);
19
+ for (;;) {
20
+ const stat = lstatSync(path);
21
+ const systemLink = process.platform === 'darwin' && DARWIN_ROOT_LINKS.has(path) && stat.isSymbolicLink();
22
+ if (!systemLink && (stat.isSymbolicLink() || !stat.isDirectory())) {
23
+ throw new Error('Refusing symlinked or non-directory log ancestor');
24
+ }
25
+ const parent = dirname(path);
26
+ if (parent === path) break;
27
+ path = parent;
28
+ }
29
+ }
30
+
31
+ export function apply(_ctx, { homeDir = homedir() } = {}) {
32
+ let fd;
15
33
  try {
16
- appendFileSync(
17
- join(homedir(), '.dsh', 'agentschat-identity-host.log'),
18
- `${new Date().toISOString()} host half applied\n`,
19
- );
20
- } catch {}
34
+ const directory = resolve(homeDir, '.dsh');
35
+ checkDirectories(directory);
36
+ // Check the physical path too, including ancestors behind Darwin system links.
37
+ checkDirectories(realpathSync(directory));
38
+ const path = join(directory, 'agentschat-identity-host.log');
39
+ let target;
40
+ try { target = lstatSync(path); }
41
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
42
+ if (target && (!target.isFile() || target.isSymbolicLink() || target.size >= MAX_LOG_BYTES)) return;
43
+ const flags = constants.O_WRONLY | constants.O_APPEND | constants.O_NOFOLLOW | constants.O_NONBLOCK |
44
+ (target ? 0 : constants.O_CREAT | constants.O_EXCL);
45
+ fd = openSync(path, flags, 0o600);
46
+ const opened = fstatSync(fd);
47
+ if (!opened.isFile() || (target && (opened.dev !== target.dev || opened.ino !== target.ino))) return;
48
+ checkDirectories(directory);
49
+ checkDirectories(realpathSync(directory));
50
+ const line = `${new Date().toISOString()} host half applied\n`;
51
+ if (opened.size + Buffer.byteLength(line) > MAX_LOG_BYTES) return;
52
+ writeSync(fd, line);
53
+ } catch {} finally {
54
+ if (fd !== undefined) { try { closeSync(fd); } catch {} }
55
+ }
21
56
  }