@volter/teams 0.1.17 → 0.1.19

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": "@volter/teams",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
6
6
  "license": "MIT",
package/server/http.mjs CHANGED
@@ -51,7 +51,7 @@ export function createHttpHandler(api){return async(req,res)=>{const requestId=a
51
51
  if(!machineDoor&&!sourceDoor)fail(403,'forbidden','credential kind cannot use this operation');
52
52
  }
53
53
  let m;if(api.harnessRoutes&&await api.harnessRoutes.beforeIdempotency({api,req,res,auth,url,path,sub,requestId}))return;
54
- const intrinsicPart=req.method==='PUT'&&(/\/captures\/[^/]+\/parts\/\d+$/.test(sub)||/\/uploads\/[^/]+\/chunks\/\d+$/.test(sub)),intrinsicReplay=intrinsicPart||(req.method==='POST'&&(/\/captures\/[^/]+\/commit$/.test(sub)||/\/effects\/[^/]+\/(?:claim|result)$/.test(sub)));
54
+ const intrinsicPart=req.method==='PUT'&&(/\/captures\/[^/]+\/parts\/\d+$/.test(sub)||/\/uploads\/[^/]+\/chunks\/\d+$/.test(sub)),intrinsicReplay=intrinsicPart||(req.method==='POST'&&(/^\/sources\/[^/]+\/captures$/.test(sub)||/\/captures\/[^/]+\/commit$/.test(sub)||/\/effects\/[^/]+\/(?:claim|result)$/.test(sub)));
55
55
  if(['POST','PATCH','DELETE'].includes(req.method)&&!intrinsicPart){const key=req.headers['idempotency-key'];if(typeof key!=='string'||key.length<16||key.length>128||!/^[\x20-\x7e]+$/.test(key))fail(400,'invalid_request','Idempotency-Key must be 16..128 printable ASCII characters');if(!intrinsicReplay){const body=req.method==='DELETE'?null:await parseJson(req),route=`${req.method} ${path}`,requestDigest=sha256(canonicalJson({method:req.method,path,if_match:req.headers['if-match']??null,body})),old=await api.store.one('SELECT * FROM idempotency WHERE team_id=? AND principal_id=? AND route=? AND key=? AND expires_at>?',[auth.team_id,auth.principal_id,route,key,api.clock.nowMs()]);if(old){if(old.request_digest!==requestDigest)fail(409,'idempotency_conflict','idempotency key was reused with a different request');await authorizeReplay(api,auth,req.method,sub,body);return send(res,old.response_status,JSON.parse(old.response_json),requestId);}res._idempotencyRecord={teamId:auth.team_id,principalId:auth.principal_id,route,key,requestDigest,path};}}
56
56
  if(req.method==='POST'&&sub==='/invitations')return await createInvitation(api,req,res,auth,requestId);
57
57
  if(req.method==='POST'&&sub==='/credentials')return await createCredential(api,req,res,auth,requestId);
package/server/viewer.mjs CHANGED
@@ -10,6 +10,9 @@ const FILES = {
10
10
  // The same module under its own name, as a workplace console imports it (openBrowserSession, sendBrowserTurn).
11
11
  '/view/browser-channel.mjs': ['browser-channel.mjs', 'text/javascript; charset=utf-8'],
12
12
  '/view/stream-rpc.mjs': ['stream-rpc.mjs', 'text/javascript; charset=utf-8'],
13
+ // A team session's surface: supercode-ui's transcript and composer, built by scripts/build-session-view.mjs.
14
+ '/view/session-view.mjs': ['viewer/session-view.mjs', 'text/javascript; charset=utf-8'],
15
+ '/view/session-view.css': ['viewer/session-view.css', 'text/css; charset=utf-8'],
13
16
  };
14
17
  let bundled = null;
15
18
 
package/viewer/index.html CHANGED
@@ -33,6 +33,12 @@
33
33
  button.action, label.action { font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
34
34
  button.action:disabled { opacity: .5; cursor: default; }
35
35
  label.action input { display: none; }
36
+ /* supercode-ui follows this page's dark scheme; its composer spans the page instead of its 420px default. */
37
+ #session { flex: 1; min-width: 0; min-height: 0; display: flex; --scui-color-scheme: dark; }
38
+ #session .session-view { flex: 1; min-width: 0; display: flex; flex-direction: column; }
39
+ #session .session-view > section { flex: 1; min-height: 0; overflow: auto; }
40
+ #session .session-composer { border-top: 1px solid var(--line); padding: 8px; --scui-width: 100%; --scui-height: auto; }
41
+ #session .session-composer > * { flex: 1; min-width: 0; }
36
42
  [hidden] { display: none !important; }
37
43
  </style>
38
44
  </head>
@@ -41,6 +47,7 @@
41
47
  <div id="status"></div>
42
48
  <main>
43
49
  <div id="terminal" hidden></div>
50
+ <div id="session" hidden></div>
44
51
  <div id="folder">
45
52
  <nav id="entries"><div class="crumbs" id="crumbs"></div><div id="list"></div></nav>
46
53
  <section id="file">
@@ -0,0 +1,55 @@
1
+ // The hosted viewer's session surface, bundled with its dependencies into viewer/session-view.mjs
2
+ // (scripts/build-session-view.mjs): supercode-ui's team transcript and composer, mounted for one team session. The
3
+ // page (viewer.mjs) owns the token, the reads and the channel; this module only renders what it is given and hands
4
+ // back what the member typed.
5
+ import { h, render } from 'preact';
6
+ import { TeamTranscript } from '@volter/supercode-ui/preact/teams';
7
+ import { Composer } from '@volter/supercode-ui/preact/composer';
8
+ import { EMPTY_UI_STATE, normalizeUiState } from '@volter/supercode-ui';
9
+ import { projectSubagentTranscript } from '@volter/supercode-ui/controller';
10
+
11
+ const SOURCES = { 'claude-code': 'claude_code', codex: 'codex', gemini: 'gemini', goose: 'goose', grok: 'grok', opencode: 'opencode', pi: 'pi' };
12
+
13
+ /** A team session's captured messages as the harness SDK's normalized session, for supercode-ui's projection. */
14
+ function normalizedSession(descriptor, messages) {
15
+ return {
16
+ source: SOURCES[descriptor.harness] ?? 'native',
17
+ session_id: descriptor.id,
18
+ model: null,
19
+ cwd: null,
20
+ system_prompt: null,
21
+ agent_id: null,
22
+ parent_tool_use_id: null,
23
+ lineage: {},
24
+ trigger: 'human',
25
+ surface: null,
26
+ messages,
27
+ };
28
+ }
29
+
30
+ /**
31
+ * Mount one session into `element`. `update({ descriptor, messages, live, status, error, canSend, sending })` renders
32
+ * the session (messages are the captured normalized values, oldest first); `onSend(text)` is called with a turn the
33
+ * member typed, and resolves once it was delivered or refused.
34
+ */
35
+ export function mountSessionView(element, { onSend }) {
36
+ let current = { descriptor: null, messages: [], live: false, status: 'loading', error: null, canSend: false, sending: false };
37
+ const adapter = {
38
+ onIntent: async (intent) => { if (intent?.action === 'send' && intent.text?.trim()) await onSend(intent.text.trim()); },
39
+ copyText: (text) => globalThis.navigator?.clipboard?.writeText(text),
40
+ };
41
+ const draw = () => {
42
+ const { descriptor, messages, live, status, error, canSend, sending } = current;
43
+ const transcript = descriptor ? projectSubagentTranscript(normalizedSession(descriptor, messages), { prefix: descriptor.id, maxEntries: 500 }) : [];
44
+ const composerState = normalizeUiState({ ...EMPTY_UI_STATE, startup: 'ready', harness: descriptor?.harness ?? '', canSend: canSend && !sending, busy: sending, transcript });
45
+ render(h('div', { class: 'session-view' },
46
+ h(TeamTranscript, { session: descriptor, transcript, live, status, error, adapter }),
47
+ canSend ? h('div', { class: 'session-composer scui-root' }, h(Composer, { state: composerState, adapter })) : null,
48
+ ), element);
49
+ };
50
+ draw();
51
+ return {
52
+ update(next) { current = { ...current, ...next }; draw(); },
53
+ unmount() { render(null, element); },
54
+ };
55
+ }