@agentsignalnet/claude-plugin 0.2.75 → 0.2.76

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,7 +1,7 @@
1
1
  {
2
2
  "name": "agentsignal",
3
3
  "displayName": "AgentSignal",
4
- "version": "0.2.75",
4
+ "version": "0.2.76",
5
5
  "description": "Page a human from inside Claude Code, or become an addressable agent that other agents can reach.",
6
6
  "author": {
7
7
  "name": "Data Group AI",
package/.mcp.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "agentsignal": {
4
4
  "command": "npx",
5
- "args": ["-y", "@agentsignalnet/mcp@0.2.54"],
5
+ "args": ["-y", "@agentsignalnet/mcp@0.2.55"],
6
6
  "env": {
7
7
  "AGENTSIGNAL_API_KEY": "${user_config.api_key}",
8
8
  "AGENTSIGNAL_JOIN_TOKEN": "${user_config.join_token}",
package/commands/work.md CHANGED
@@ -18,6 +18,10 @@ not merely misfiled. It was sent to the wrong company.
18
18
  So settle it before the loop starts, not on the first message that needs it:
19
19
 
20
20
  1. Call `my_channels`. One channel is the answer, and no question is needed.
21
+ When the channels span more than one company it says so on every line and
22
+ again at the end — that listing is the check, and it exists because the rule
23
+ was unenforceable without it: until the API sent the account, an agent asked
24
+ which company it was working in had nothing to answer with.
21
25
  2. Several, and the request names one -- by channel, by company, or plainly
22
26
  enough from the work itself -- use that, and SAY which you chose, so a wrong
23
27
  guess is caught in the first line rather than three messages in.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsignalnet/claude-plugin",
3
- "version": "0.2.75",
3
+ "version": "0.2.76",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -743,6 +743,25 @@ const PAGE = `<!doctype html>
743
743
  .answer .who { color: var(--dim); font-weight: 500; }
744
744
  .answer .time { color: var(--dim); font-size: 12px; margin-left: auto; }
745
745
 
746
+ .pick { padding: 4px 2px; }
747
+ .pick-why { margin: 0 0 8px; font-size: 12px; color: var(--dim); line-height: 1.5; }
748
+ .pick-one {
749
+ display: block; width: 100%; text-align: left; margin: 0 0 6px;
750
+ padding: 8px 10px; font: inherit; font-weight: 600; cursor: pointer;
751
+ border: 1px solid var(--line); border-radius: 8px;
752
+ background: var(--surface); color: var(--fg);
753
+ }
754
+ .pick-one:hover { border-color: var(--accent); }
755
+ /* Present, and plainly not a control. No hover, no pointer, no accent: the
756
+ point is that it exists somewhere else, not that it can be opened here. */
757
+ .elsewhere { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
758
+ .elsewhere-title, .elsewhere-why {
759
+ margin: 0 0 6px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
760
+ color: var(--dim);
761
+ }
762
+ .elsewhere-why { text-transform: none; letter-spacing: 0; font-size: 12px; margin-top: 8px; }
763
+ .elsewhere-chan { margin: 0 0 2px; padding-left: 2px; font-size: 13px; color: var(--dim); }
764
+
746
765
  .chan { margin-bottom: 4px; }
747
766
  .chan-head { display: flex; align-items: center; gap: 2px; }
748
767
  .twist {
@@ -1262,6 +1281,9 @@ const PAGE = `<!doctype html>
1262
1281
 
1263
1282
  /** Every channel the server can open, from the poll. */
1264
1283
  let CHANNELS = [];
1284
+ /* The company this dashboard is for, and the ones it merely knows about. */
1285
+ let BOUND = null;
1286
+ let COMPANIES = [];
1265
1287
  /** Which of them are expanded in the rail. */
1266
1288
  const OPEN = new Set();
1267
1289
  /** The rendered agent tree per channel, so reopening one costs nothing. */
@@ -1580,17 +1602,70 @@ const PAGE = `<!doctype html>
1580
1602
  rail really is a flat list of channels and "Companies" would name a level
1581
1603
  that is not on screen.
1582
1604
  */
1583
- document.getElementById('rail-title').textContent = sectioned ? 'Companies' : 'Channels';
1584
-
1585
- nav.innerHTML = groups
1586
- .map((g) =>
1587
- sectioned
1588
- ? '<div class="company"><p class="company-name">' +
1589
- esc(g.company || 'Unnamed company') +
1590
- '</p>' + rows(g.channels) + '</div>'
1591
- : rows(g.channels),
1592
- )
1593
- .join('');
1605
+ /*
1606
+ THE TITLE IS THE SCOPE. A dashboard is for one company, so the company
1607
+ belongs at the top as its name rather than repeated as a section label
1608
+ above every row. When it is not yet known -- no poll has answered -- the
1609
+ rail says what it is showing instead of asserting a company it cannot
1610
+ name.
1611
+ */
1612
+ const boundName = (COMPANIES.find((k) => k.account === BOUND) || {}).company;
1613
+ document.getElementById('rail-title').textContent = boundName || 'Channels';
1614
+
1615
+ /*
1616
+ A CHOICE, when there is genuinely one to make.
1617
+
1618
+ Binding happens by itself when this machine holds keys to one company,
1619
+ which is the ordinary case and needs no question. With two, the question
1620
+ cannot be skipped: picking for somebody would decide whose rules the
1621
+ session works under, which is the decision this rule exists to make
1622
+ deliberate.
1623
+ */
1624
+ if (!BOUND && COMPANIES.length > 1) {
1625
+ nav.innerHTML =
1626
+ '<div class="pick"><p class="pick-why">This dashboard is for one company. ' +
1627
+ 'Which one is this session working in?</p>' +
1628
+ COMPANIES.map(
1629
+ (k) =>
1630
+ '<button type="button" class="pick-one" data-account="' + esc(k.account) + '">' +
1631
+ esc(k.company || 'Unnamed company') + '</button>',
1632
+ ).join('') +
1633
+ '<p class="pick-why">The others stay listed once you choose, and open in their own ' +
1634
+ 'dashboard rather than this one.</p></div>';
1635
+ return;
1636
+ }
1637
+
1638
+ const mine = groups.filter((g) => !g.at || g.at === BOUND);
1639
+ const others = groups.filter((g) => g.at && g.at !== BOUND);
1640
+
1641
+ nav.innerHTML =
1642
+ mine.map((g) => rows(g.channels)).join('') +
1643
+ /*
1644
+ NAMED, NOT HIDDEN. A channel that vanishes is a channel somebody hunts
1645
+ for; one that says which company it belongs to answers the question its
1646
+ absence would raise. Inert on purpose -- opening it here is what a
1647
+ dashboard for one company must not do.
1648
+ */
1649
+ (others.length
1650
+ ? '<div class="elsewhere"><p class="elsewhere-title">Other companies</p>' +
1651
+ others
1652
+ .map(
1653
+ (g) =>
1654
+ '<div class="company"><p class="company-name">' +
1655
+ esc(g.company || 'Unnamed company') +
1656
+ '</p>' +
1657
+ g.channels
1658
+ .map(
1659
+ (c) =>
1660
+ '<p class="elsewhere-chan">' + esc(c.name || c.ref || 'channel') + '</p>',
1661
+ )
1662
+ .join('') +
1663
+ '</div>',
1664
+ )
1665
+ .join('') +
1666
+ '<p class="elsewhere-why">A different company, so a different dashboard. Start one ' +
1667
+ 'with that key, on another port if this one is busy.</p></div>'
1668
+ : '');
1594
1669
 
1595
1670
  markNav();
1596
1671
  }
@@ -1621,9 +1696,11 @@ const PAGE = `<!doctype html>
1621
1696
  }
1622
1697
 
1623
1698
  /** Keep the rail in step with what the poll says exists. */
1624
- function renderChannels(list) {
1699
+ function renderChannels(list, bound, companies) {
1625
1700
  if (!list) return;
1626
1701
  CHANNELS = list;
1702
+ BOUND = bound ?? null;
1703
+ COMPANIES = companies ?? [];
1627
1704
  const active = list.find((c) => c.active);
1628
1705
  // The channel being read starts open, because its members are the ones
1629
1706
  // the log is about. The rest stay shut until asked for.
@@ -1779,7 +1856,7 @@ const PAGE = `<!doctype html>
1779
1856
  // the channel you cannot read is the one where you most need the list of
1780
1857
  // the others. Returning first left the page knowing about two channels and
1781
1858
  // showing neither.
1782
- renderChannels(data.channels);
1859
+ renderChannels(data.channels, data.bound, data.companies);
1783
1860
 
1784
1861
  if (data.error) {
1785
1862
  document.getElementById('log').className = 'empty';
@@ -2529,6 +2606,22 @@ const PAGE = `<!doctype html>
2529
2606
  document.getElementById('who-nav').addEventListener('click', (event) => {
2530
2607
  // The twisty opens and closes without going anywhere. Checked first
2531
2608
  // because it sits inside the same row as the link beside it.
2609
+ const pick = event.target.closest('.pick-one');
2610
+ if (pick) {
2611
+ event.preventDefault();
2612
+ post('/bind', { account: pick.dataset.account }).then((r) => {
2613
+ if (r.error) {
2614
+ window.alert(r.error);
2615
+ return;
2616
+ }
2617
+ // Re-poll rather than guess: the server decides the scope, and the
2618
+ // rail should redraw from what it says rather than from what was
2619
+ // clicked.
2620
+ tick();
2621
+ });
2622
+ return;
2623
+ }
2624
+
2532
2625
  const twist = event.target.closest('.twist');
2533
2626
  if (twist) {
2534
2627
  event.preventDefault();
@@ -2583,9 +2676,58 @@ const PAGE = `<!doctype html>
2583
2676
  * this machine currently is. An unknown ref falls back rather than erroring:
2584
2677
  * a stale bookmark should show something, not a stack trace.
2585
2678
  */
2679
+ /**
2680
+ * THE COMPANY THIS DASHBOARD IS FOR. One, for the whole run.
2681
+ *
2682
+ * A machine accumulates keys -- from the environment, from MCP config, from the
2683
+ * identity it holds now and from the ones it used to hold -- and nothing said
2684
+ * those had to belong to the same company. So one window could show two
2685
+ * companies' conversations side by side: two rule sets, two billing accounts,
2686
+ * two sets of people, one credential-holder straddling them. An agent working
2687
+ * out of that window has no single answer to "whose rules apply", and neither
2688
+ * does the person reading it.
2689
+ *
2690
+ * So the scope is chosen once and named at the top. Other companies are not
2691
+ * hidden -- knowing they exist is useful, and a channel that vanishes is a
2692
+ * channel somebody hunts for -- they are listed, inert, and say which company
2693
+ * they belong to and that they need their own dashboard.
2694
+ *
2695
+ * Null until chosen. It cannot be settled at startup: a channel's ref comes out
2696
+ * of its key, but the company comes from the API, so the question can only be
2697
+ * asked once something has answered.
2698
+ */
2699
+ let boundTo = null;
2700
+
2701
+ /** The name of a company by account id, for saying which one this is. */
2702
+ function nameOf(account) {
2703
+ if (!account) return null;
2704
+ return channels.find((c) => c.account === account)?.company ?? null;
2705
+ }
2706
+
2707
+ /** Companies this machine holds a key for, once the API has said. */
2708
+ function companiesKnown() {
2709
+ const byId = new Map();
2710
+ for (const c of channels) {
2711
+ if (!c.account) continue;
2712
+ if (!byId.has(c.account)) byId.set(c.account, { account: c.account, company: c.company ?? null });
2713
+ }
2714
+ return [...byId.values()];
2715
+ }
2716
+
2717
+ /** True when this channel belongs to the company this dashboard is for. */
2718
+ function inScope(c) {
2719
+ if (!boundTo) return true;
2720
+ // An account not yet known is not yet out of scope. It resolves on the poll
2721
+ // that names it, and refusing before then would hide a channel for being
2722
+ // slow rather than for being elsewhere.
2723
+ return !c.account || c.account === boundTo;
2724
+ }
2725
+
2586
2726
  function channelFor(ref) {
2587
- if (!ref) return channels[0];
2588
- return channels.find((c) => c.ref === ref) ?? channels[0];
2727
+ if (!ref) return channels.find(inScope) ?? channels[0];
2728
+ const found = channels.find((c) => c.ref === ref);
2729
+ if (found) return found;
2730
+ return channels.find(inScope) ?? channels[0];
2589
2731
  }
2590
2732
 
2591
2733
  /** One upstream call, one place that turns a non-2xx into something readable. */
@@ -3609,6 +3751,49 @@ const server = createServer(async (req, res) => {
3609
3751
  return;
3610
3752
  }
3611
3753
 
3754
+ /*
3755
+ CHOOSING THE COMPANY, once per run.
3756
+
3757
+ A POST rather than a query parameter: this changes what the whole process is
3758
+ for, and a link that silently rebinds the scope is the thing being prevented
3759
+ -- somebody following it would be reading another company under a name they
3760
+ chose earlier.
3761
+ */
3762
+ if (url.pathname === '/bind' && req.method === 'POST') {
3763
+ let payload;
3764
+ try {
3765
+ payload = await readJson(req);
3766
+ } catch {
3767
+ res.writeHead(400, { 'Content-Type': 'application/json' });
3768
+ res.end(JSON.stringify({ error: 'Unreadable request.' }));
3769
+ return;
3770
+ }
3771
+ const known = companiesKnown();
3772
+ const picked = known.find((k) => k.account === payload.account);
3773
+ if (!picked) {
3774
+ res.writeHead(400, { 'Content-Type': 'application/json' });
3775
+ res.end(JSON.stringify({ error: 'No key on this machine belongs to that company.' }));
3776
+ return;
3777
+ }
3778
+ // Once. Rebinding mid-run would leave the page showing rows read under the
3779
+ // previous scope, which is the mixture this exists to stop.
3780
+ if (boundTo && boundTo !== picked.account) {
3781
+ res.writeHead(409, { 'Content-Type': 'application/json' });
3782
+ res.end(
3783
+ JSON.stringify({
3784
+ error:
3785
+ `This dashboard is already for ${nameOf(boundTo) ?? 'a company'}. Start another one ` +
3786
+ 'for a different company rather than switching this one.',
3787
+ }),
3788
+ );
3789
+ return;
3790
+ }
3791
+ boundTo = picked.account;
3792
+ res.writeHead(200, { 'Content-Type': 'application/json' });
3793
+ res.end(JSON.stringify({ ok: true, bound: boundTo, company: picked.company }));
3794
+ return;
3795
+ }
3796
+
3612
3797
  if (url.pathname === '/messages') {
3613
3798
  /**
3614
3799
  * ASK FOR WHAT IS NEW, not for the last hundred every two seconds.
@@ -3634,6 +3819,81 @@ const server = createServer(async (req, res) => {
3634
3819
  const want = url.searchParams.get('channel');
3635
3820
  const on = channelFor(want);
3636
3821
 
3822
+ /*
3823
+ ONE COMPANY IS NOT A QUESTION. Binding automatically when only one is
3824
+ known keeps the ordinary case free of a chooser that offers a single
3825
+ answer -- and the ordinary case is one company, because most machines hold
3826
+ keys to one.
3827
+ */
3828
+ const known = companiesKnown();
3829
+ if (!boundTo && known.length === 1) boundTo = known[0].account;
3830
+
3831
+ /*
3832
+ NOTHING IS READ WHILE THE QUESTION IS OPEN.
3833
+
3834
+ The first poll has to happen -- a company is only known once the API says
3835
+ so -- but once two are known and none is chosen, reading on is showing one
3836
+ company's conversation behind a question about which company this is. That
3837
+ is the mixing this rule exists to prevent, arriving a second before the
3838
+ answer. It also costs money: a log read that returns rows is billed, and
3839
+ billing one company to decorate a chooser is the wrong account either way.
3840
+ */
3841
+ if (!boundTo && known.length > 1) {
3842
+ res.writeHead(200, { 'Content-Type': 'application/json' });
3843
+ res.end(
3844
+ JSON.stringify({
3845
+ ok: true,
3846
+ messages: [],
3847
+ channels: channels.map((c) => ({
3848
+ ref: c.ref,
3849
+ name: c.name ?? c.via,
3850
+ via: c.via,
3851
+ account: c.account ?? null,
3852
+ company: c.company ?? null,
3853
+ active: false,
3854
+ elsewhere: false,
3855
+ })),
3856
+ bound: null,
3857
+ companies: known,
3858
+ fetched: 0,
3859
+ }),
3860
+ );
3861
+ return;
3862
+ }
3863
+
3864
+ /*
3865
+ Reading a channel belonging to another company is refused HERE rather than
3866
+ being quietly redirected, because a redirect would show a different
3867
+ conversation under the name that was asked for -- which is the failure
3868
+ this whole rule exists to prevent.
3869
+ */
3870
+ if (want && on && on.ref === want && !inScope(on)) {
3871
+ res.writeHead(200, { 'Content-Type': 'application/json' });
3872
+ res.end(
3873
+ JSON.stringify({
3874
+ ok: true,
3875
+ error:
3876
+ `That channel belongs to ${on.company ?? 'another company'}, and this dashboard is ` +
3877
+ `for ${nameOf(boundTo) ?? 'one company'}. Open it in its own dashboard: ` +
3878
+ 'stop this one and start another with that company\'s key, or run a second on ' +
3879
+ 'another port with PORT.',
3880
+ channels: channels.map((c) => ({
3881
+ ref: c.ref,
3882
+ name: c.name ?? c.via,
3883
+ via: c.via,
3884
+ account: c.account ?? null,
3885
+ company: c.company ?? null,
3886
+ active: false,
3887
+ elsewhere: !inScope(c),
3888
+ })),
3889
+ bound: boundTo,
3890
+ companies: known,
3891
+ messages: [],
3892
+ }),
3893
+ );
3894
+ return;
3895
+ }
3896
+
3637
3897
  // Per channel, because history is per channel: sharing one `since` across
3638
3898
  // two would make each ask for messages newer than the other's newest and
3639
3899
  // leave a hole in whichever is quieter.
@@ -3764,8 +4024,21 @@ const server = createServer(async (req, res) => {
3764
4024
  account: c.account ?? null,
3765
4025
  company: c.company ?? null,
3766
4026
  active: c === on,
4027
+ // Listed either way, and marked. A channel that disappears is one
4028
+ // somebody hunts for; a channel that says "different company, needs its
4029
+ // own dashboard" answers the question it raises.
4030
+ elsewhere: !inScope(c),
3767
4031
  }));
3768
4032
 
4033
+ /*
4034
+ The scope, and the choice when there is one to make. Sent every poll
4035
+ rather than once, because the companies are learned as the polls answer:
4036
+ a page told "one company" at boot must be told "two, pick" when the
4037
+ second one names itself a second later.
4038
+ */
4039
+ body.bound = boundTo;
4040
+ body.companies = companiesKnown();
4041
+
3769
4042
  const agent = url.searchParams.get('agent');
3770
4043
 
3771
4044
  // Filtered here rather than in the page, so the browser never holds