@volter/supercode-teams 0.2.41 → 0.2.42
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/supercode-teams",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -100,7 +100,9 @@ const managerGuard=(auth,sessionId,now,{governance=false}={})=>({
|
|
|
100
100
|
params:[auth.principal_id,auth.team_id,sessionId,governance?1:0,auth.principal_id,now,auth.principal_id,auth.principal_id],
|
|
101
101
|
code:'not_found',status:404,message:'not found'
|
|
102
102
|
});
|
|
103
|
-
|
|
103
|
+
// A session is named by its id, a prefix of it (eight characters or more), or `harness:native id` (its origin on a
|
|
104
|
+
// machine). A whole id is matched exactly: the platform's LIKE refuses a pattern much longer than an id.
|
|
105
|
+
async function resolve(api,auth,ref){const head='SELECT s.*,v.descriptor_json,v.sort_at FROM sessions s JOIN session_versions v ON v.team_id=s.team_id AND v.session_id=s.id AND v.revision=s.revision WHERE s.team_id=? AND ',native=/^([a-z][a-z0-9-]*):(.+)$/.exec(ref);let rows;if(native)rows=await api.store.query(head+'s.id IN (SELECT session_id FROM origins WHERE team_id=? AND harness=? AND native_id=? AND deleted_at IS NULL)',[auth.team_id,auth.team_id,native[1],native[2]]);else if(ref.length>=36)rows=await api.store.query(head+'s.id=?',[auth.team_id,ref]);else if(ref.length>=8)rows=await api.store.query(head+'s.id LIKE ?',[auth.team_id,`${ref}%`]);else rows=[];const visible=[];for(let r of rows){r=await canonicalSession(api,auth.team_id,r);r=await api.store.one('SELECT s.*,v.descriptor_json,v.sort_at FROM sessions s JOIN session_versions v ON v.team_id=s.team_id AND v.session_id=s.id AND v.revision=s.revision WHERE s.team_id=? AND s.id=?',[auth.team_id,r.id]);if(r&&await canReadMerged(api,auth,r)&&!visible.some(x=>x.id===r.id))visible.push(r);}if(visible.length>1)fail(400,'ambiguous_reference','ambiguous session reference');if(!visible.length)fail(404,'not_found','not found');return visible[0];}
|
|
104
106
|
function qobj(url){return Object.fromEntries([...url.searchParams].map(([k,v])=>[k,['limit','since','until','tail','revision'].includes(k)?Number(v):k==='include_children'?v==='true':v]));}
|
|
105
107
|
function projection(row){return JSON.parse(row.descriptor_json);}
|
|
106
108
|
async function readerProjection(api,auth,row){
|
package/server/store-core.mjs
CHANGED
|
@@ -36,9 +36,13 @@ export function createStoreHandlers({ all, get, run, tx }) {
|
|
|
36
36
|
if(typeof ref!=='string'||ref.length<8)domainError(404,'not_found','not found');
|
|
37
37
|
const groups=all('SELECT group_id FROM group_members WHERE team_id=? AND principal_id=?',[teamId,principalId]).map(row=>row.group_id);
|
|
38
38
|
// A session is named by its id (or a prefix of it) or by the harness's own id for it (a native
|
|
39
|
-
// session id such as a Claude Code session's uuid), which its origin records.
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// session id such as a Claude Code session's uuid, bare or as `harness:id`), which its origin records. Only a
|
|
40
|
+
// ref no longer than an id is a prefix: the platform's LIKE refuses a pattern much longer than one.
|
|
41
|
+
let candidates=ref.length<=36?all('SELECT * FROM sessions WHERE team_id=? AND id LIKE ? AND deleted_at IS NULL',[teamId,`${ref}%`]):[];
|
|
42
|
+
const native=/^([a-z][a-z0-9-]*):(.+)$/.exec(ref);
|
|
43
|
+
if(!candidates.length)candidates=native
|
|
44
|
+
?all('SELECT DISTINCT s.* FROM sessions s JOIN origins o ON o.team_id=s.team_id AND o.session_id=s.id WHERE s.team_id=? AND o.harness=? AND o.native_id=? AND o.deleted_at IS NULL AND s.deleted_at IS NULL',[teamId,native[1],native[2]])
|
|
45
|
+
:all('SELECT DISTINCT s.* FROM sessions s JOIN origins o ON o.team_id=s.team_id AND o.session_id=s.id WHERE s.team_id=? AND o.native_id=? AND o.deleted_at IS NULL AND s.deleted_at IS NULL',[teamId,ref]);
|
|
42
46
|
const visible=new Map();
|
|
43
47
|
for(const candidate of candidates){
|
|
44
48
|
let root=candidate;const seen=new Set();
|