create-heresay 0.2.23 → 0.2.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-heresay",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/release/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.23
1
+ 0.2.25
@@ -22,14 +22,14 @@ export const CHAT_LIMITS = [
22
22
  { limit: 60, windowMs: 3600_000 },
23
23
  { limit: 300, windowMs: 24 * 3600_000 },
24
24
  ];
25
+ // Descriptive, not prescriptive: chat apps flag tool text that tells the model when to ask for
26
+ // approval or what counts as sensitive ("Suspicious Instruction"). Their own rules cover that.
25
27
  const INSTRUCTIONS = [
26
28
  'Heresay is this team\'s inbox for what should change in their apps: bugs, confusing parts, improvements and ideas.',
27
- 'When the person says to send, save, log or file something to Heresay (or asks you to put an idea "in Heresay"), use send_request.',
28
- 'Write `text` as the request itself, plainly, as a teammate would read it. Put what the conversation worked out in `details`:',
29
- 'why it matters, what was considered or ruled out, examples, constraints, open questions. Never put secrets, passwords or',
30
- 'personal data about other people in either. If it isn\'t clear which app, call list_apps and ask.',
31
- 'Confirm with the person before sending if they didn\'t clearly ask to send. Requests wait for a person on the team to accept',
32
- 'them; sending does not start any work. my_requests says what happened to the ones they sent.',
29
+ 'send_request files one in an app\'s inbox as the signed-in team member: `text` is the request as a teammate would read it,',
30
+ '`details` is what the conversation worked out (why it matters, what was considered or ruled out, examples, constraints,',
31
+ 'open questions). list_apps names the apps. A request stays open until someone on the team accepts it; sending does not',
32
+ 'start any work. my_requests says what happened to the ones this member sent.',
33
33
  ].join(' ');
34
34
  const TOOLS = [
35
35
  {
@@ -42,8 +42,8 @@ const TOOLS = [
42
42
  {
43
43
  name: 'send_request',
44
44
  title: 'Send to Heresay',
45
- description: 'Send a bug, a confusing part, an improvement or an idea to one app\'s Heresay inbox, as the signed-in team member, '
46
- + 'with the context from this conversation. It waits for someone on the team to accept it. Ask the person first unless they asked you to send it.',
45
+ description: 'Sends a bug, a confusing part, an improvement or an idea to one app\'s Heresay inbox, as the signed-in team member, '
46
+ + 'with context from the conversation. It stays open until someone on the team accepts it.',
47
47
  inputSchema: {
48
48
  type: 'object',
49
49
  properties: {
@@ -270,13 +270,25 @@ const onTeam = (i, email) => !!i?.members.some((m) => m.email.toLowerCase() ===
270
270
  * every call, so a revoked connection or a removed member stops at once, not in an hour.
271
271
  */
272
272
  export async function chatCaller(req, deps) {
273
- const m = /^Bearer hat_([a-f0-9]{24})_([A-Za-z0-9_-]{20,80})$/.exec(req.headers['authorization'] ?? '');
274
- if (!m)
275
- return null;
276
- const a = await deps.store.getAuth('access', m[1]);
277
- if (!a || !same(sha(m[2]), String(a.data.hash)) || Date.parse(a.expires_at ?? '') < deps.now())
273
+ const auth = req.headers['authorization'] ?? '';
274
+ let grant = null;
275
+ const m = /^Bearer hat_([a-f0-9]{24})_([A-Za-z0-9_-]{20,80})$/.exec(auth);
276
+ // A chat token (hct_), for chat apps that can't sign in with OAuth: the grant itself checks it.
277
+ const t = /^Bearer hct_([a-f0-9]{24})_([A-Za-z0-9_-]{20,80})$/.exec(auth);
278
+ if (m) {
279
+ const a = await deps.store.getAuth('access', m[1]);
280
+ if (!a || !same(sha(m[2]), String(a.data.hash)) || Date.parse(a.expires_at ?? '') < deps.now())
281
+ return null;
282
+ grant = await deps.store.getAuth('grant', String(a.data.grant_id));
283
+ }
284
+ else if (t) {
285
+ grant = await deps.store.getAuth('grant', t[1]);
286
+ if (!grant || !grant.data.token_hash || !same(sha(t[2]), String(grant.data.token_hash)))
287
+ return null;
288
+ }
289
+ else {
278
290
  return null;
279
- const grant = await deps.store.getAuth('grant', String(a.data.grant_id));
291
+ }
280
292
  if (!grant || grant.data.revoked_at)
281
293
  return null;
282
294
  const instance = await deps.store.getInstance();
@@ -298,15 +310,36 @@ export const signInFirst = (req, deps) => json(401, {
298
310
  'www-authenticate': `Bearer realm="heresay", resource_metadata="${baseUrl(req, deps)}/.well-known/oauth-protected-resource/v1/mcp", scope="${SCOPE}"`,
299
311
  });
300
312
  // ---- connections, from the dashboard -------------------------------------------------------
301
- /** GET /v1/chat-connections, DELETE /v1/chat-connections/:id. Yours, or anyone's for an owner. */
313
+ /**
314
+ * GET /v1/chat-connections, DELETE /v1/chat-connections/:id: yours, or anyone's for an owner.
315
+ * POST /v1/chat-connections { name }: a chat token, for a chat app that can't sign in with
316
+ * OAuth (a ChatGPT Sites bridge, a script). Same three tools, as you; shown once, stored hashed,
317
+ * revoked like any connection.
318
+ */
302
319
  export async function connections(p, member, req, deps) {
303
320
  const mine = (g) => String(g.data.email).toLowerCase() === member.email.toLowerCase();
321
+ if (p.length === 1 && req.method === 'POST') {
322
+ const name = str(fields(req.body).name, 80) ?? 'A chat app';
323
+ const mineNow = (await deps.store.listAuth('grant')).filter((g) => !g.data.revoked_at && mine(g) && g.data.token_hash);
324
+ if (mineNow.length >= 10)
325
+ return json(400, { error: 'You have 10 chat tokens. Disconnect one first.' });
326
+ const id = hexId(), tokenSecret = secret();
327
+ await deps.store.putAuth({
328
+ kind: 'grant', id, expires_at: null,
329
+ data: {
330
+ email: member.email, client_id: null, client_name: name, kind: 'token', token_hash: sha(tokenSecret),
331
+ created_at: new Date(deps.now()).toISOString(), last_used_at: null, revoked_at: null,
332
+ },
333
+ });
334
+ deps.log('oauth.token_created', { grant_id: id, by: member.email, name });
335
+ return json(201, { id, token: `hct_${id}_${tokenSecret}`, name, mcp_url: resourceUrl(baseUrl(req, deps)) });
336
+ }
304
337
  if (p.length === 1 && req.method === 'GET') {
305
338
  const all = (await deps.store.listAuth('grant')).filter((g) => !g.data.revoked_at && (member.role === 'owner' || mine(g)));
306
339
  all.sort((a, b) => String(a.data.created_at).localeCompare(String(b.data.created_at)));
307
340
  return json(200, {
308
341
  connections: all.map((g) => ({
309
- id: g.id, email: g.data.email, client_name: g.data.client_name,
342
+ id: g.id, email: g.data.email, client_name: g.data.client_name, kind: g.data.token_hash ? 'token' : 'oauth',
310
343
  created_at: g.data.created_at, last_used_at: g.data.last_used_at ?? null,
311
344
  })),
312
345
  });
@@ -1,3 +1,3 @@
1
1
  /** The Heresay release. Bumped by the release script; the CLI and /v1/health report it. */
2
- export const VERSION = '0.2.23';
2
+ export const VERSION = '0.2.25';
3
3
  //# sourceMappingURL=version.js.map
@@ -2006,6 +2006,27 @@
2006
2006
  ]),
2007
2007
  el('p', { class: 'hint', text: 'Claude, Cursor and other apps that take a remote MCP server use the same address.' }),
2008
2008
  ]));
2009
+ // For chat apps that can't sign in with OAuth: a ChatGPT workspace that blocks MCP plugins
2010
+ // (use a ChatGPT Sites bridge), or a script. Shown once.
2011
+ var tokenName = el('input', { name: 'token-name', value: 'ChatGPT', 'aria-label': 'What it is for', maxlength: '80' });
2012
+ var tokenOut = el('div');
2013
+ var tokenErr = el('p', { class: 'err', role: 'alert' });
2014
+ var tokenForm = el('form', { class: 'invite' }, [tokenName, el('button', { class: 'btn', text: 'Create chat token' })]);
2015
+ tokenForm.onsubmit = function (e) {
2016
+ e.preventDefault();
2017
+ tokenErr.textContent = '';
2018
+ api('POST', '/chat-connections', { name: tokenName.value }).then(function (b) {
2019
+ tokenOut.textContent = '';
2020
+ tokenOut.appendChild(el('p', { class: 'hint', text: 'Shown once. Paste it where the chat app asks for a Heresay token, with the address above. It sends requests as you; disconnect it below to stop it.' }));
2021
+ tokenOut.appendChild(el('div', { class: 'copy-prompt' }, [el('code', { class: 'url token-out', text: b.token }), copyButton(function () { return b.token; }, 'Copy token')]));
2022
+ load();
2023
+ }).catch(function (x) { tokenErr.textContent = x.message; });
2024
+ };
2025
+ view.appendChild(el('section', { class: 'card' }, [
2026
+ el('h2', { text: 'Can’t add MCP servers? Use a token' }),
2027
+ el('p', { class: 'mute', text: 'Some ChatGPT workspaces don’t allow plugins with MCPs. A ChatGPT Sites app (a bridge) can call this Heresay with a chat token instead, and works in Chat on every device. Scripts can use one too.' }),
2028
+ tokenForm, tokenErr, tokenOut,
2029
+ ]));
2009
2030
  var list = el('ul', { class: 'members' }, [loading('li')]);
2010
2031
  var err = el('p', { class: 'err', role: 'alert' });
2011
2032
  view.appendChild(el('section', { class: 'card' }, [el('h2', { text: me.role === 'owner' ? 'Connected chat apps' : 'Your connected chat apps' }), list, err]));
@@ -2016,7 +2037,7 @@
2016
2037
  list.appendChild(el('li', {}, [
2017
2038
  el('span', { class: 'avatar', text: (c.client_name || '?').charAt(0).toUpperCase() }),
2018
2039
  el('div', {}, [el('b', { text: c.client_name + (c.email === me.email ? '' : ' · ' + c.email) }),
2019
- el('span', { class: 'mute', text: 'Connected ' + new Date(c.created_at).toLocaleDateString() + (c.last_used_at ? ' · last used ' + new Date(c.last_used_at).toLocaleString() : '') })]),
2040
+ el('span', { class: 'mute', text: (c.kind === 'token' ? 'Chat token · created ' : 'Connected ') + new Date(c.created_at).toLocaleDateString() + (c.last_used_at ? ' · last used ' + new Date(c.last_used_at).toLocaleString() : '') })]),
2020
2041
  el('button', { class: 'btn ghost', type: 'button', text: 'Disconnect', onclick: function () {
2021
2042
  err.textContent = '';
2022
2043
  api('DELETE', '/chat-connections/' + c.id).then(load).catch(function (x) { err.textContent = x.message; });