@halcyonlabs/app 0.47.0-halcyon.531 → 0.47.0-halcyon.532
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/dist/index.d.ts +2 -2
- package/package.json +2 -2
- package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/fixed-runner/linux-x64/manifest.json +4 -4
- package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/revision +1 -1
- package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/source.json +1 -1
- package/server/dist/builtin-plugins/orbit/dist/server.js +1 -1
- package/server/dist/start-server.js +100 -39
package/dist/index.d.ts
CHANGED
|
@@ -4329,8 +4329,8 @@ declare const threadTimelinePendingTodosSchema: z$1.ZodObject<{
|
|
|
4329
4329
|
type ThreadTimelinePendingTodos = z$1.infer<typeof threadTimelinePendingTodosSchema>;
|
|
4330
4330
|
|
|
4331
4331
|
declare const threadParentNotificationsSchema: z$1.ZodEnum<{
|
|
4332
|
-
off: "off";
|
|
4333
4332
|
auto: "auto";
|
|
4333
|
+
off: "off";
|
|
4334
4334
|
stuck: "stuck";
|
|
4335
4335
|
}>;
|
|
4336
4336
|
type ThreadParentNotifications = z$1.infer<typeof threadParentNotificationsSchema>;
|
|
@@ -7862,13 +7862,13 @@ declare const hostDaemonCommandRegistry: {
|
|
|
7862
7862
|
modifiedAtMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
7863
7863
|
sha256: z$1.ZodString;
|
|
7864
7864
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
7865
|
-
path: z$1.ZodString;
|
|
7866
7865
|
contentEncoding: z$1.ZodEnum<{
|
|
7867
7866
|
base64: "base64";
|
|
7868
7867
|
utf8: "utf8";
|
|
7869
7868
|
}>;
|
|
7870
7869
|
sha256: z$1.ZodString;
|
|
7871
7870
|
sizeBytes: z$1.ZodNumber;
|
|
7871
|
+
path: z$1.ZodString;
|
|
7872
7872
|
mimeType: z$1.ZodOptional<z$1.ZodString>;
|
|
7873
7873
|
modifiedAtMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
7874
7874
|
notModified: z$1.ZodLiteral<true>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halcyonlabs/app",
|
|
3
|
-
"version": "0.47.0-halcyon.
|
|
3
|
+
"version": "0.47.0-halcyon.532",
|
|
4
4
|
"description": "bb app launcher for npx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bb",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
106
106
|
},
|
|
107
107
|
"moonletRelease": {
|
|
108
|
-
"summary": "
|
|
108
|
+
"summary": "Keep Moonlet observations from resetting app update clocks (#560)"
|
|
109
109
|
},
|
|
110
110
|
"license": "SEE LICENSE IN LICENSE"
|
|
111
111
|
}
|
package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/fixed-runner/linux-x64/manifest.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "a4c6c5c831792061c8dcd985a84a3ffeb73a6fbb",
|
|
3
3
|
"file": "orbit-deploy",
|
|
4
4
|
"platform": "linux-x64",
|
|
5
5
|
"provenance": {
|
|
6
|
-
"artifactId":
|
|
7
|
-
"artifactName": "linux-bundle-
|
|
6
|
+
"artifactId": 15150232305,
|
|
7
|
+
"artifactName": "linux-bundle-a4c6c5c831792061c8dcd985a84a3ffeb73a6fbb",
|
|
8
8
|
"repository": "matt0x6F/personalassistant",
|
|
9
|
-
"runId":
|
|
9
|
+
"runId": 45884285367,
|
|
10
10
|
"workflow": ".github/workflows/moonlet-linux-bundle.yml"
|
|
11
11
|
},
|
|
12
12
|
"schema": 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a4c6c5c831792061c8dcd985a84a3ffeb73a6fbb
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"repository":"matt0x6F/personalassistant","revision":"
|
|
1
|
+
{"repository":"matt0x6F/personalassistant","revision":"a4c6c5c831792061c8dcd985a84a3ffeb73a6fbb"}
|
|
@@ -1117,7 +1117,7 @@ ${N.join(`
|
|
|
1117
1117
|
`)||"No standing decisions were used."}`}i(m,"summary");function y(E){return d(E).filter(T=>!T.revoked&&!T.expired)}i(y,"live");function w(E){return{station:E,owner:t.owner(),policyBase:Ai(t.text()),decisions:y(E).filter(T=>T.owner===t.owner()).map(T=>({rule:T.rule,expiresAt:T.expiresAt})),rulesOn:Object.fromEntries(Object.entries(sx(s,E)).filter(([T])=>T in Qm))}}i(w,"standingState");let k={family:J3,read:w,busy:i(()=>t.busy(),"busy"),write(E,T,v){if(T.once)return;let A=t.owner();if(!A)throw new ze("No owner is set in Settings.");let N=v.answer==="owner-settings"?"owner-settings":"owner-browser",x=i(B=>JSON.stringify([B.rule,B.expiresAt]),"key"),q=new Set(T.decisions.map(x)),D=y(E).filter(B=>B.owner===A),C=new Set(D.map(x));for(let B of D.filter(F=>!q.has(x(F))))l(E,"revoke",B.id,v.key??v.change,{owner:A,form:N,question:v.change,at:v.at});for(let B of T.decisions.filter(F=>!C.has(x(F)))){let F={id:Bge(16).toString("hex"),station:E,owner:A,form:N,question:v.change,request:v.key??v.change,at:v.at,expiresAt:B.expiresAt,base:T.policyBase,rule:B.rule};s.prepare("INSERT INTO standing_decisions VALUES (?,?,?)").run(F.id,E,JSON.stringify(F)),l(E,"create",F.id,F.request,F)}},async details(E,T){let v=i(N=>N===null?" (no time limit)":` (until ${new Date(N).toISOString().replace("T"," ").slice(0,16)} UTC)`,"until"),A=i(N=>N.decisions.map(x=>`- ${Ja(x.rule)}${v(x.expiresAt)}`).join(`
|
|
1118
1118
|
`)||"(none)","text");return{before:A(E),after:T.once?`${A(E)}
|
|
1119
1119
|
(approved once: nothing recorded)`:A(T),pictures:[]}},answerOptions:{apply:i((E,T,v)=>Y3(E,T,{...v,ops:v.ops}),"apply")}};a?.register("standing",k);async function _(E,T,v){try{let[A,N,...x]=E.args;if(c||!a||A!=="standing"||E.capability!=="policy"||E.rule!==""||E.deploy||E.recovery||E.protected_launch||!E.thread||await r(E.thread)!==T.hostId)return{decision:"deny",reason:"Request the original standing-decision question on this station. Work cannot answer it."};if(N==="list"&&!x.length&&E.level==="read")return{decision:"allow",reason:JSON.stringify(d(T.hostId))};if(N==="summary"&&x.length<=1&&E.level==="read")return{decision:"allow",reason:m(T.hostId,x[0])};if(E.level!=="act"||t.busy()||!t.owner())return{decision:"deny"};let q={kind:"station",station:T.hostId,job:E.thread},D=JSON.stringify({args:E.args,thread:E.thread,...v?{operation:v}:{}}),C={policy:{text:JSON.stringify({standing:"created",original:E.id}),owner:t.owner()}},B=a.status("standing",T.hostId,E.id,q);if(B&&B.intent!==D)return{decision:"deny",reason:"This request already asked for something else."};let F=[];if(!B){if(N==="start"&&!x.length)F=qD(T.hostId).map(G=>({op:"grant",rule:G}));else if(N==="propose")F=M3.parse(Qs(x)).map(G=>({op:"grant",rule:G}));else if(N==="revoke"&&x.length===1){if(F=y(T.hostId).filter(G=>x[0]==="all"||G.id===x[0]).map(G=>({op:"revoke",rule:G.rule})),!F.length)return{decision:"deny",reason:"No current standing decision has that identity."}}else return{decision:"deny",reason:"Use standing start, propose, list, summary or revoke. Only the owner's answer in Orbit can grant or revoke."};if(F.some(G=>G.rule.station!==T.hostId))return{decision:"deny",reason:"The proposed scope names another station."};if(N==="start"&&F.every(G=>y(T.hostId).some(Z=>JSON.stringify(Z.rule)===JSON.stringify(G.rule)&&Z.owner===t.owner())))return{decision:"allow",reason:"This starting set is already recorded. No new question was needed; the same cleanup setup can use it again.",policy:{text:JSON.stringify({standing:"existing",original:E.id}),owner:t.owner()}};try{await a.propose({family:"standing",scope:T.hostId,key:E.id,intent:D,ops:F,proposer:q,offer:{expiry:F.some(G=>G.op==="grant"),once:!!v}})}catch(G){if(G instanceof ze)return{decision:"deny",reason:`Nothing was asked: ${G.message}`};throw G}B=a.status("standing",T.hostId,E.id,q)}switch(B?.state==="pending"&&(await a.wait(B.id,o),B=a.status("standing",T.hostId,E.id,q)),B?.state){case"pending":return{decision:"pending",reason:"Waiting for the owner's answer on the changes form in Moonlet."};case"applied":{let G=B.applied?.after?.once===!0;return{decision:"allow",...N==="start"&&!G?C:{},reason:G?"Allowed this operation once; no standing decision was created.":N==="revoke"?"Standing permissions revoked. Future matching work asks again; work already authorized can finish.":"Standing decisions recorded. Existing operation checks still apply."}}default:return{decision:"deny",reason:`No standing decision changed: the request was ${B?.state??"not recorded"}.`}}}catch{return{decision:"deny",reason:"Unsupported standing scope or unavailable decision record. Nothing was authorized."}}}i(_,"handle");function b(){return s.prepare("SELECT DISTINCT station FROM standing_decisions").all().map(E=>E.station)}i(b,"stations");async function I(E){let T=s.prepare("SELECT receipt FROM standing_decisions WHERE id=?").get(E);if(!T||!a)return{decision:"deny",reason:"No such standing decision."};let v=t8.parse(JSON.parse(T.receipt));if(!y(v.station).some(A=>A.id===E))return{decision:"deny",reason:"That permission is already taken back or ended."};if(v.owner!==t.owner())return{decision:"deny",reason:"A previous owner gave that permission, and it isn't in effect for the current owner; there's nothing to take back."};try{return await a.applyAsOwner({family:"standing",scope:v.station,ops:[{op:"revoke",rule:v.rule}],title:`Take back: ${Ja(v.rule).slice(0,100)}`}),{decision:"allow",reason:"Taken back. Future matching work asks again; work already authorized can finish."}}catch(A){return{decision:"deny",reason:A instanceof ze?A.message:"Nothing changed."}}}i(I,"requestRevoke");function R(E,T){return E.level==="read"&&!["policy","change","deploy","work-clean"].includes(E.capability)&&!E.deploy&&!E.recovery&&!E.protected_launch?{kind:"read-status",capability:E.capability,station:T,commands:[E.args]}:qD(T).find(A=>["finished-folders","own-temp"].includes(A.kind)&&FD(A,T,E))??null}i(R,"operationRule");function P(E,T){let v=R(E,T.hostId);return v?_({...E,capability:"policy",level:"act",rule:"",args:["standing","propose",...N3([v])]},T,E):null}return i(P,"authorizeOperation"),{handle:_,list:d,latest:u,use:f,activateRules:h,revokeForRules:p,report:g,summary:m,stations:b,requestRevoke:I,authorizeOperation:P,operationRule:R}}i(r8,"setupStandingDecisions");var n8=null;function cx(e,t=Date.now()){n8?.(e,t)}i(cx,"markOwnerActive");function Uge(e){return e.initiator==="user"&&!e.senderThreadId}i(Uge,"isOwnersMessage");function qge(e){return e.reduce((t,r)=>Math.max(t,r.lastReadAt??0),0)}i(qge,"newestRead");function Fge(e,t){return{at:new Date(t).toISOString().replace(/\.\d{3}Z$/,"Z"),kind:"owner.active",key:"owner:active",source:"plugin",fields:{signal:e}}}i(Fge,"ownerActiveEvent");function Hge(e,t=6e4){let r=0;return(n,o)=>{r&&o-r<t||(r=o,e(n,o))}}i(Hge,"throttle");function i8(e,t){n8=Hge((n,o)=>{t.toEvents([Fge(n,o)]).catch(s=>e.log.warn(`owner activity: ${s.message}`))});for(let n of["message.queued","message.dispatched"])e.events.on(n,({entry:o})=>{Uge(o)&&cx("message")});let r=0;st(e,"owner-read","* * * * *",async()=>{let n=await e.sdk.threads.list({includeHidden:!0,limit:500}),o=qge(n);r&&o>r&&cx("read",o),r=Math.max(r,o)})}i(i8,"setupOwnerActivity");var o8="this conversation already has a question or question waiting in bb (an earlier request's): answer or dismiss it, then try again",nk=new Map;async function s8(e,t,r){try{let n=await e.ui.requestInput(t,r);return(n.outcome==="submitted"||n.outcome==="cancelled"&&n.reason!=="timeout")&&cx("card"),n}catch(n){if(!(await e.sdk.threads.get({threadId:t.threadId}).catch(()=>null))?.hasPendingInteraction)throw n;return{outcome:"waiting",reason:o8}}}i(s8,"open");async function nd(e,t,r){return await nk.get(t.threadId)?.(),s8(e,t,r)}i(nd,"requestCard");async function a8(e,t,r,n){if(nk.has(t.threadId))return{outcome:"waiting",reason:o8};let o=new AbortController;n?.addEventListener("abort",()=>o.abort(),{once:!0});let s,a=new Promise(l=>{s=l}),c=i(async()=>{r(),o.abort(),await a},"close");nk.set(t.threadId,c);try{return await s8(e,t,{signal:o.signal})}finally{nk.get(t.threadId)===c&&nk.delete(t.threadId),s()}}i(a8,"requestYieldingCard");import{createHash as Wge,randomBytes as zge}from"node:crypto";import{z as Hc}from"zod";var Gge=Hc.object({intent:Dp,snapshot:Lp,recovered:Hc.boolean().optional()}).strict(),c8=Hc.object({intent:Dp,snapshot:Lp}).extend({id:Hc.string().regex(/^[a-f0-9]{32}$/),deadline:Hc.number().int().positive()}).strict();function l8(e,t,r,n=Date.now,o,s=Di){let a=$e(e),c=t.ownerChanges??null,l=!1,d=i(()=>Ai(t.text()),"base"),u=i(()=>Wge("sha256").update(t.text()).digest("hex"),"legacyBase"),f=i(w=>w===d()||w===u(),"sameBase");function h(w,k){a.prepare("INSERT INTO event_rule_history(request,at,state) VALUES (?,?,?)").run(w,n(),k)}i(h,"history");function p(w,k){a.exec("SAVEPOINT rule_state");try{let _=a.prepare("UPDATE event_rule_questions SET state=? WHERE id=? AND state='waiting'").run(k,w);return _.changes===1&&h(w,k),a.exec("RELEASE rule_state"),_.changes===1}catch(_){throw a.exec("ROLLBACK TO rule_state"),a.exec("RELEASE rule_state"),_}}i(p,"finish");for(let w of a.prepare("SELECT id FROM event_rule_questions WHERE state='waiting'").all())p(w.id,"cancelled");e.onDispose(()=>{l=!0});function g(w){return{decision:"allow",reason:`Station rule request ${w.id}: approved; read its protected result to confirm application.`,policy:{text:JSON.stringify(w),owner:w.snapshot.owner}}}i(g,"allowed");async function m(w,k){try{if(l||w.capability!=="policy"||w.rule!==""||w.deploy||w.recovery||!w.thread||await r(w.thread)!==k.hostId)return{decision:"deny",reason:"Request a station rule question from a conversation on that station. Work cannot answer it."};if(w.args[0]!=="rules")return{decision:"deny"};if(w.args[1]==="result"&&w.level==="read"&&/^[a-f0-9]{32}$/.test(w.args[2]??"")){let E=Hc.object({id:Hc.string(),state:Hc.enum(["applied","restored","failed","uncertain"]),reason:Hc.string().min(1).max(1e3)}).strict().parse(Qs(w.args.slice(3))),T=a.prepare("SELECT * FROM event_rule_questions WHERE id=? AND station=?").get(w.args[2],k.hostId);if(!T||E.id!==T.id||!["approved",E.state,...E.state==="restored"?["uncertain"]:[]].includes(T.state))return{decision:"deny",reason:"No matching original rule permission."};if(T.state!==E.state){a.exec("SAVEPOINT rule_result");try{a.prepare("UPDATE event_rule_questions SET state=? WHERE id=? AND state IN ('approved','uncertain')").run(E.state,T.id),h(T.id,E.state),ax(a,k.hostId),a.exec("RELEASE rule_result")}catch(v){throw a.exec("ROLLBACK TO rule_result"),a.exec("RELEASE rule_result"),v}}return{decision:"allow",reason:`Station rule request ${T.id}: ${E.state}. ${E.reason}`}}if(w.args[1]==="status"&&w.args.length===3&&w.level==="read"){let E=a.prepare("SELECT * FROM event_rule_questions WHERE id=? AND station=?").get(w.args[2],k.hostId);return E?{decision:"allow",reason:`Station rule request ${E.id}: ${E.state}. Approval is not proof of application.`}:{decision:"deny",reason:"No such station rule request."}}if(w.args[1]!=="request"||w.level!=="act"||t.busy())return{decision:"deny",reason:"Only a new question or a status read is accepted."};let _=Gge.parse(Qs(w.args.slice(2)));if(_.snapshot.station!==k.hostId)return{decision:"deny",reason:"The protected observation belongs to another station."};if(!_.snapshot.owner||_.snapshot.owner!==t.owner())return{decision:"deny",reason:"The station owner changed or is not configured."};if(_.intent.action==="resume"&&!Jm(_.intent,_.snapshot))return{decision:"deny",reason:"Only a cleanup rule paused after repeated failures can be proposed for resumption."};_.intent.rules.sort();let b=JSON.stringify(_),I={kind:"station",station:k.hostId,job:w.thread},R=c?.status("rules",k.hostId,w.id,I)??null,P=R?void 0:a.prepare("SELECT * FROM event_rule_questions WHERE station=? AND request=?").get(k.hostId,w.id);if(P){if(P.scope!==b)return{decision:"deny",reason:"This original request names different station rules."};let E=c8.parse(JSON.parse(P.record));return P.state==="approved"&&E.deadline>n()&&f(P.base)?g(E):{decision:P.state==="waiting"?"pending":"deny",reason:`Station rule request ${P.id}: ${P.state}. Read this original request; it cannot be recreated by polling.`}}if(R&&R.intent!==b)return{decision:"deny",reason:"This original request names different station rules."};if(!R){e8(a,k.hostId,_.snapshot,n());let E={intent:_.intent,snapshot:_.snapshot,id:zge(16).toString("hex"),deadline:n()+7*864e5},T=[];if(o&&_.intent.action==="resume"){let v=o.use(k.hostId,w);v&&(T=[v.id])}if(o&&_.intent.action==="on"&&(T=o.activateRules(k.hostId,w,_.intent)),T.length){a.exec("SAVEPOINT standing_rule");try{a.prepare("INSERT INTO event_rule_questions(id,station,job,scope,base,state,created_at,record,request) VALUES (?,?,?,?,?,'approved',?,?,?)").run(E.id,k.hostId,w.thread,b,d(),n(),JSON.stringify(E),w.id),h(E.id,"approved"),a.prepare("INSERT INTO event_rule_receipts(request,at,receipt) VALUES (?,?,?)").run(E.id,n(),JSON.stringify({form:"standing-decision",decisions:T,spec:E})),ax(a,k.hostId),a.exec("RELEASE standing_rule")}catch(v){throw a.exec("ROLLBACK TO standing_rule"),a.exec("RELEASE standing_rule"),v}return g(E)}if(!c)return{decision:"deny",reason:"Owner change requests are unavailable; nothing was asked."};try{await c.propose({family:"rules",scope:k.hostId,key:w.id,intent:b,ops:[{op:"rules",action:_.intent.action,rules:_.intent.rules,observed:eo(_.snapshot)}],proposer:I})}catch(v){if(v instanceof ze)return{decision:"deny",reason:`Nothing was asked: ${v.message}`};throw v}R=c.status("rules",k.hostId,w.id,I)}if(R?.state==="pending"&&c&&(await c.wait(R.id,s),R=c.status("rules",k.hostId,w.id,I)),R?.state==="pending")return{decision:"pending",reason:"Waiting for the owner's answer on the changes form in Moonlet."};if(R?.state==="applied"){let E=a.prepare("SELECT * FROM event_rule_questions WHERE id=? AND station=?").get(R.id,k.hostId),T=E?c8.parse(JSON.parse(E.record)):null;return!E||!T?{decision:"deny",reason:"The approved rule permission is missing."}:!f(E.base)||T.deadline<=n()?{decision:"deny",reason:`Station rule request ${E.id}: its settings changed or its permission ended before the station took it. Ask again.`}:E.state!=="approved"?{decision:"deny",reason:`Station rule request ${E.id}: ${E.state}. Read its result; it isn't applied twice.`}:g(T)}return{decision:"deny",reason:`No rule permission recorded: the request was ${R?.state??"not recorded"}.`}}catch{return{decision:"deny",reason:"The station rule request has unknown or changed fields. Nothing was authorized."}}}i(m,"handle");let y={family:Z3,busy:i(()=>t.busy(),"busy"),read(w){let k=(o?.list(w)??[]).filter(_=>!_.revoked&&!_.expired&&Object.values(Qm).includes(_.rule.kind));return{station:w,owner:t.owner(),policyBase:d(),snapshot:Q3(a,w),paired:eo(k.map(_=>({id:_.id,rule:_.rule,expiresAt:_.expiresAt}))),lastApplied:sx(a,w)}},write(w,k,_){if(!k.requested||!k.snapshot)throw new ze("The request carries no rules to apply.");let b={intent:k.requested,snapshot:k.snapshot,id:_.change,deadline:_.at+7*864e5};a.prepare("INSERT INTO event_rule_questions(id,station,job,scope,base,state,created_at,record,request) VALUES (?,?,?,?,?,'approved',?,?,?)").run(b.id,w,_.proposer.kind==="station"?_.proposer.job:"",JSON.stringify({intent:b.intent,snapshot:b.snapshot}),k.policyBase,_.at,JSON.stringify(b),_.key??""),h(b.id,"approved"),ax(a,w),b.intent.action==="off"&&o?.revokeForRules(w,b.intent.rules,_.change,_.key??_.change),a.prepare("INSERT INTO event_rule_receipts(request,at,receipt) VALUES (?,?,?)").run(b.id,_.at,JSON.stringify({form:"owner-browser",station:w,question:_.change,spec:b})),e.realtime.publish("event-rules",{station:w})},undo:!1};return c?.register("rules",y),{handle:m}}i(l8,"setupRuleConsent");import{randomBytes as Xge}from"node:crypto";import{defineRpcContract as Yge}from"@get-bb/plugin-sdk";import{z as gr}from"zod";KA();import{createHash as Vge}from"node:crypto";KA();function d8(e){return Vge("sha256").update(jt(uD.parse(e))).digest("hex")}i(d8,"secretUseDigest");function VD(e){return new Map(e.map(t=>[t.id,t]))}i(VD,"normalized");function KD(e,t,r){let n=Zs(e),o=Zs(t),s=new Set([...Object.keys(n),...Object.keys(o)]);if(s.delete("secret_use"),[...s].some(f=>jt(n[f])!==jt(o[f])))throw new Kr("High risk. A secret-use proposal cannot change other station permissions or vault mappings.");let a=VD(n.secret_use??[]),c=VD(o.secret_use??[]),l=[...c.keys()].filter(f=>!a.has(f)).sort(),d=[...a.keys()].filter(f=>!c.has(f)).sort(),u=[...c.keys()].filter(f=>a.has(f)&&d8(a.get(f))!==d8(c.get(f))).sort();if(!l.length&&!d.length&&!u.length)throw new Kr("There is no change to secret use.");for(let f of[...l,...u])if(!pD(c.get(f),r))throw new Kr("High risk. This secret and destination have no installed protected connector relationship.");return{old:a,next:c,added:l,removed:d,edited:u}}i(KD,"secretUseDifference");function Kge(e,t){let r=i(n=>[n.id,n.caller,n.secret,n.purpose,n.mode,n.mode==="web"?[n.host,n.port,n.credential]:n.command],"identity");return jt(r(e))!==jt(r(t))||t.expires_at>e.expires_at||Object.keys(e.limits).some(n=>t.limits[n]>e.limits[n])?!1:e.mode==="web"&&t.mode==="web"?t.methods.every(n=>e.methods.includes(n))&&t.paths.every(n=>e.paths.includes(n)):e.mode==="runner"&&t.mode==="runner"&&t.actions.every(n=>e.actions.includes(n))}i(Kge,"narrowed");function u8(e,t){let r=`Every program running as the ${e.caller.slice(8)} account can use this permission; it is not limited to one skill.`,n=e.mode==="web"?`This lets that account use your ${e.secret.replaceAll("-"," ")} (${e.secret}) when it contacts ${e.host} over HTTPS, and nothing else under this permission. It allows ${e.methods.join(", ")} requests under these parts of the website: ${e.paths.join(", ")}.`:`This lets that account use your ${e.secret.replaceAll("-"," ")} (${e.secret}) through the protected command ${e.command}, for these operations: ${e.actions.join(", ")}. It can contact only these mail servers: ${MK(e.command).join(", ")}.`,o=new Intl.DateTimeFormat("en-US",{timeZone:t,dateStyle:"medium",timeStyle:"short"}).format(e.expires_at*1e3);return`${r} ${n} The named purpose is ${e.purpose}. Enforcement follows the listed operations. It allows up to ${e.limits.uses_per_hour} uses an hour, ${e.limits.concurrent} at a time, up to ${e.limits.input_bytes.toLocaleString("en-US")} bytes sent and ${e.limits.output_bytes.toLocaleString("en-US")} bytes returned per use, and a ${e.limits.seconds}-second time limit. It expires ${o} (${t}). The calling program never receives the secret. These connections can send data to the allowed service.`}i(u8,"grantSentence");function p8(e,t,r,n){let o=VD(Zs(e).secret_use??[]);if(!t.length||new Set(t).size!==t.length)throw new Kr("Name each secret use to approve again once.");return t.map(s=>{let a=o.get(s);if(!a)throw new Kr("A secret use to approve again isn't in the settings.");if(a.mode!=="runner")throw new Kr("High risk. Only a reviewed runner's use has a protected way to run; this use isn't available.");if(!pD(a,r))throw new Kr("High risk. This secret and destination have no installed protected connector relationship.");return{id:s,sentence:u8(a,n)}})}i(p8,"restoreChoices");function f8(e,t){let r=[[`Approves again, on this station, the secret uses you switch on below (${e.length} offered). Each is approved exactly as it is in your settings; the settings themselves don't change.`,"A use you leave off stays unapproved and is offered again the next time secret use is switched on."],["Secret use was switched on, and these uses in your settings have no approval on this station: switching it off revoked them, or they were never approved here."],["High risk. Each use you switch on lets the named account use a secret through its reviewed command. The allowed service can receive the caller's data or act on its account; limits reduce some damage but cannot prove purpose."],["Switch secret use off to revoke every approval, or propose removing a use from the settings."]];return{version:1,risk:"high",extraConfirmation:!0,details:{unchanged:["The settings, vault mappings, other station permissions and installed programs don't change. Existing action approvals still apply."],proposerWords:Np(t,2e3)},sections:qc.map((n,o)=>({heading:n,sentences:r[o]}))}}i(f8,"explainRestore");function h8(e,t,r,n,o){let s=KD(e,t,n),{old:a,next:c,added:l,removed:d,edited:u}=s,f=l.length>0||u.some(m=>!Kge(a.get(m),c.get(m))),h=[...l.map(m=>`Adds secret use called ${m}.`),...u.map(m=>`Changes secret use called ${m}.`),...d.map(m=>`Removes secret use called ${m}.`)],p=[...l,...u].map(m=>u8(c.get(m),o)),g=[[...h,...p.length?p:["Allows no new use of a secret."],"This permission cannot read or export a vault value, choose another website or command, change the connector's code, or switch the service on. Unsupported and unapproved uses are refused.","This explanation does not apply settings or restart a service. The protected application review must name any actual restarts before the owner is asked."],["The work is asking to change how a named secret can be used."],[f?"High risk. This adds or widens credential use. The allowed service can receive the caller's data, charge for requests or act on its account; limits reduce some damage but cannot prove purpose.":"Medium risk. This removes or narrows secret use, so existing work can stop."],["Propose removal of this permission, or restore its previous bounds through the same owner question. Revoking access cannot unsend a message or reverse a charge."]];return{version:1,risk:f?"high":"medium",extraConfirmation:f,details:{unchanged:["Other station permissions, vault mappings, approval rules, outbound limits and installed programs do not change. Existing action approvals still apply."],proposerWords:Np(r,2e3)},sections:qc.map((m,y)=>({heading:m,sentences:g[y]}))}}i(h8,"explainSecretUseProposal");var Jge="policy-proposal";function b8(e,t){return jt(Zs(e).secret_use??[])!==jt(Zs(t).secret_use??[])}i(b8,"secretUseDraft");function XD(e){return jK(Zs(e).connector)}i(XD,"relationships");function Zge(e,t){if(!b8(e,t)){LD(e,t);return}let{next:r,added:n,edited:o}=KD(e,t,XD(e));if([...n,...o].some(s=>r.get(s).mode!=="runner"))throw new Kr("High risk. Only a reviewed runner's use has a protected way to run; this use isn't available.")}i(Zge,"checkDraft");function Qge(e,t,r,n){return b8(e,t)?h8(e,t,r,XD(e),Intl.DateTimeFormat().resolvedOptions().timeZone):I3(e,t,r,n)}i(Qge,"explainDraft");var eye=i(()=>Intl.DateTimeFormat().resolvedOptions().timeZone,"zone");function m8(e,t){return p8(e,t,XD(e),eye())}i(m8,"restoreDraft");var k8=gr.enum(["preview","waiting","applying","applied","declined","expired","superseded","cancelled","restored","failed","uncertain"]),g8=gr.object({spec:rx,before:gr.string(),station:gr.string(),job:gr.string(),createdAt:gr.number(),state:k8,message:gr.string(),preview:nx.nullable(),explanation:x3.nullable().default(null),receipt:gr.object({form:gr.literal("owner-browser"),at:gr.number(),request:gr.string()}).strict().nullable(),result:jD.nullable()}).strict(),y8=gr.object({approve:gr.boolean(),acknowledgeRisk:gr.boolean(),restore:gr.array(gr.string()).max(64).optional()}).strict(),w8=gr.object({id:Ya,title:gr.string(),state:k8,message:gr.string(),job:gr.string(),at:gr.number()}),tye=Yge({"policy-proposals.result":{input:gr.object({id:Ya}).strict(),output:w8.nullable()},"policy-proposals.history":{input:gr.null(),output:gr.array(w8)},"policy-proposals.text":{input:gr.object({id:Ya}).strict(),output:gr.object({before:gr.string(),after:gr.string(),preview:gr.string()})}});function v8(e,t){let r=new Set(t.map(n=>n.id));return[...new Set((e??[]).filter(n=>r.has(n)))].sort()}i(v8,"chosenOf");function _8(e,t,r,n=Date.now){let o=$e(e),s=!1,a=new Map,c=new Set;function l(b){let I=o.prepare("SELECT record FROM policy_proposals WHERE id = ?").get(b);return I?g8.parse(JSON.parse(I.record)):null}i(l,"read");function d(b="1 = 1"){return o.prepare(`SELECT record FROM policy_proposals WHERE ${b}`).all().map(I=>g8.parse(JSON.parse(I.record)))}i(d,"rows");function u(b,I,R){b.state=I,b.message=R,o.exec("SAVEPOINT policy_event");try{o.prepare("UPDATE policy_proposals SET state = ?, record = ? WHERE id = ?").run(I,JSON.stringify(b),b.spec.id),o.prepare("INSERT INTO policy_proposal_log(proposal, at, state, detail) VALUES (?, ?, ?, ?)").run(b.spec.id,n(),I,R),o.exec("RELEASE policy_event")}catch(P){throw o.exec("ROLLBACK TO policy_event"),o.exec("RELEASE policy_event"),P}e.realtime.publish("policy-proposals",{id:b.spec.id,state:I})}i(u,"event");function f(){if(!s)for(let b of d("state IN ('preview', 'waiting')")){let I=n()>=b.spec.deadline;(t.busy()||I||Ai(t.text())!==b.spec.base||t.owner()!==b.spec.owner)&&(u(b,I?"expired":"superseded",t.busy()?"Another settings application started. This request changed nothing.":I?"This request expired after seven days. Nothing was changed.":"The settings this request was based on changed. Nothing was changed."),a.get(b.spec.id)?.controller.abort())}}i(f,"invalidate");for(let b of d("state IN ('preview', 'waiting')"))u(b,"cancelled","The original request stopped when the server reloaded. Nothing was changed.");let h=t.onChange(f),p=setInterval(f,1e4);p.unref(),e.onDispose(()=>{s=!0,clearInterval(p),h();for(let b of a.values())b.controller.abort();for(let b of c)clearTimeout(b)});async function g(b,I){let R=await r(b);if(s)throw new Error("The settings request service was reloaded.");return R===I.hostId}i(g,"onStation");let m=i(b=>({decision:"deny",reason:b}),"deny"),y=i(b=>({decision:"allow",policy:{text:JSON.stringify(b),owner:b.stage==="current"||b.stage==="status"?b.owner:b.spec.owner}}),"control");function w(b,I,R){if(f(),t.busy())throw new Error("A manual Settings application is running. Wait for its result before proposing another change.");if(R.base!==Ai(t.text()))throw new Error("The saved settings changed. Base the draft on the current settings.");if(R.restore?.length){if(R.text!==t.text())throw new Error("Approving secret use again changes no settings: send the current settings exactly.");m8(R.text,R.restore)}else Zge(t.text(),R.text);let P=R3(R.text),E=o.prepare("SELECT id FROM policy_proposals WHERE station = ? AND base = ? AND target = ? AND state IN ('preview', 'waiting', 'applying', 'uncertain')").get(b.hostId,R.base,P);if(E)return l(E.id);if(o.prepare("SELECT id FROM policy_proposals WHERE job = ? AND state IN ('preview', 'waiting', 'applying', 'uncertain')").get(I))throw new Error("This work already has a settings request waiting or being applied. Read its result first.");if(o.prepare("SELECT id FROM policy_proposals WHERE state IN ('applying', 'uncertain')").get())throw new Error("Another station settings change is being applied or needs its result checked.");let T={...R,title:Np(R.title,120),explanation:Np(R.explanation,2e3),id:Xge(16).toString("hex"),owner:t.owner(),deadline:n()+A3},v={spec:T,before:t.text(),station:b.hostId,job:I,createdAt:n(),state:"preview",message:"Checking the change on the station. Nothing has been applied.",preview:null,explanation:null,receipt:null,result:null};o.exec("SAVEPOINT policy_claim");try{o.prepare("INSERT INTO policy_proposals(id, station, job, base, target, state, created_at, deadline, record) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)").run(T.id,b.hostId,I,T.base,P,v.state,v.createdAt,T.deadline,JSON.stringify(v)),u(v,"preview",v.message),o.exec("RELEASE policy_claim")}catch(A){throw o.exec("ROLLBACK TO policy_claim"),o.exec("RELEASE policy_claim"),A}return v}i(w,"claim");function k(b,I,R){let P=new AbortController,E=b.spec.restore?.length?m8(b.spec.text,b.spec.restore):void 0,T=E?f8(E,b.spec.explanation):Qge(b.before,b.spec.text,b.spec.explanation,I.restarts);b.preview=I,b.explanation=T,u(b,"waiting","Waiting for your answer in Moonlet. Nothing has been applied.");let v=(async()=>{try{let A=await nd(e,{threadId:b.job,rendererId:Jge,title:E?"Approve secret use again?":"Change station permissions?",payload:{id:b.spec.id,title:b.spec.title,explanation:T,deadline:b.spec.deadline,...E?{restore:E}:{}},timeoutMs:Math.max(1,b.spec.deadline-n()),presentation:{label:{pending:"Waiting for a station settings decision",completed:"Station settings decision"}},describeSubmission(q){let D=y8.safeParse(q),C=D.success&&D.data.approve&&(!T.extraConfirmation||D.data.acknowledgeRisk);if(E){let B=C?v8(D.data.restore,E):[];return{title:B.length?`Approved ${B.length} secret use${B.length===1?"":"s"} again; checking application`:"No secret use approved again",payload:{proposal:b.spec.id,chosen:B}}}return{title:C?"Approved station settings change; checking application":"Station settings change not approved",payload:{proposal:b.spec.id}}}},{signal:P.signal});if(s)return;if(A.outcome==="waiting"){let q=l(b.spec.id);q.state==="waiting"&&u(q,"preview","Another question is already waiting on this work. Answer it, then submit this same draft again; no settings question was created.");return}f();let N=l(b.spec.id);if(N.state!=="waiting")return;let x=A.outcome==="submitted"?y8.safeParse(A.value):null;if(!x?.success||!x.data.approve||T.extraConfirmation&&!x.data.acknowledgeRisk){u(N,A.outcome==="cancelled"&&A.reason==="timeout"?"expired":"declined","This change was not approved. Nothing was changed.");return}if(E){let q=v8(x.data.restore,E);if(!q.length){u(N,"declined","You switched none of these on. No secret use was approved; they're offered again the next time secret use is switched on.");return}N.spec={...N.spec,chosen:q}}if(o.prepare("SELECT id FROM policy_proposals WHERE state IN ('applying', 'uncertain') AND id != ?").get(N.spec.id)){u(N,"superseded","Another settings change was approved first. Nothing was changed by this request.");return}N.receipt={form:"owner-browser",at:n(),request:R},u(N,"applying",N.spec.chosen?.length?`Approved by you again: ${N.spec.chosen.join(", ")}. Waiting for the station to report whether it was installed.`:"Approved by you. Waiting for the station to report whether it was applied.")}catch{if(!s){let A=l(b.spec.id);A.state==="waiting"&&u(A,"cancelled","The original question could not be completed. Nothing was changed.")}}})();a.set(b.spec.id,{controller:P,done:v}),v.finally(()=>a.delete(b.spec.id)).catch(()=>{})}i(k,"startForm");function _(b,I){if(b.result){if(jt(b.result)===jt(I)){if(!(b.state==="uncertain"&&I.status==="applied"&&Ai(t.text())===b.spec.base&&t.owner()===b.spec.owner))return}else if(b.result.status!=="uncertain"||I.status!=="restored")throw new Error("The station reported a different result for an already settled request.")}if(!b.receipt&&I.status==="failed"&&I.base===b.spec.base&&I.target===Ym(b.spec.text)&&(!b.preview||b.preview.installed===I.installed)){b.result=I;let R=["expired","declined","cancelled","superseded"].includes(b.state);u(b,R?b.state:"failed",R?b.message:I.reason),R||a.get(b.spec.id)?.controller.abort();return}if(!b.preview||I.base!==b.spec.base||I.target!==Ym(b.spec.text)||I.installed!==b.preview.installed)throw new Error("The station result does not match the checked request.");if(!["applying","uncertain"].includes(b.state)||!b.receipt)throw new Error("There is no original owner approval for this application result.");if(b.result=I,I.status==="applied"){if(Ai(t.text())!==b.spec.base||t.owner()!==b.spec.owner){u(b,"uncertain","The station reports the change applied, but the saved settings changed before its result arrived. The newer saved settings were kept. This needs inspection.");return}o.exec("BEGIN IMMEDIATE");try{t.save(b.spec.text,"Owner browser approval of station settings",b.spec.id),u(b,"applied","Applied successfully on the station and saved in Settings. No test was started."),o.exec("COMMIT")}catch(R){throw o.exec("ROLLBACK"),R}}else u(b,I.status,I.reason);e.sdk.threads.send({threadId:b.job,input:[{type:"text",text:`Station settings request ${b.spec.id}: ${b.message}`,mentions:[]}],mode:"queue-if-active"}).catch(()=>{})}return i(_,"reconcile"),e.rpc.register(tye,{"policy-proposals.result"({id:b}){f();let I=l(b);return I?{id:I.spec.id,title:I.spec.title,state:I.state,message:I.message,job:I.job,at:I.result?.at??I.createdAt}:null},"policy-proposals.history"(){return f(),d("1 = 1 ORDER BY created_at DESC LIMIT 100").sort((b,I)=>I.createdAt-b.createdAt).slice(0,100).map(b=>({id:b.spec.id,title:b.spec.title,state:b.state,message:b.message,job:b.job,at:b.result?.at??b.createdAt}))},"policy-proposals.text"({id:b}){let I=l(b);if(!I)throw new Error("This settings request was not found.");return{before:I.before,after:I.spec.text,preview:JSON.stringify(I.preview,null,2)}}}),async(b,I)=>{if(s)return m("The settings request service was reloaded.");try{if(f(),b.capability!=="policy"||b.rule||b.deploy||b.recovery)return m("Not a station settings request.");let[R,P]=b.args;if(R==="current"&&b.args.length===1&&b.level==="read")return!b.thread||!await g(b.thread,I)?m("Read current settings from a conversation on the station."):y({stage:"current",base:Ai(t.text()),text:t.text(),owner:t.owner()});if(R==="submit"||R==="undo"){if(b.level!=="act"||!b.thread||!await g(b.thread,I))return m("Submit this request from a conversation on the station.");let N;if(R==="undo"){if(b.args.length!==2||!Ya.safeParse(P).success)return m("Name one applied settings request to undo.");let q=l(P);if(!q||q.station!==I.hostId||q.state!=="applied"||Ai(t.text())!==Ai(q.spec.text))return m("Undo needs an applied request whose settings are still current. Nothing was changed.");N={base:Ai(t.text()),text:q.before,title:`Undo: ${q.spec.title}`.slice(0,120),explanation:"Return to the settings kept before this earlier change."}}else N=DD.parse(Qs(b.args.slice(1)));let x=w(I,b.thread,N);return x.state==="preview"?y({stage:"preview",spec:x.spec}):x.state==="applying"&&x.receipt&&x.preview&&n()<x.spec.deadline&&t.owner()===x.spec.owner&&Ai(t.text())===x.spec.base?y({stage:"apply",spec:x.spec,preview:x.preview}):m(`Existing request ${x.spec.id}: ${x.message}`)}if(!Ya.safeParse(P).success)return m("Name one settings request.");let E=l(P);if(!E||E.station!==I.hostId)return m("This station has no such settings request.");if(R==="preview-refused"&&b.args.length===2&&b.level==="read")return E.state==="preview"&&u(E,"failed","The station could not safely review this change. Nothing was applied."),{decision:"allow",reason:E.message};if(R==="status"&&b.args.length===2&&b.level==="read")return y({stage:"status",id:E.spec.id,state:E.state,message:E.message,owner:t.owner()});if(R==="report"&&b.level==="read"){let N=jD.parse(Qs(b.args.slice(2)));return N.id!==P?m("The station result names a different request."):(_(E,N),{decision:"allow",reason:l(P).message})}if(R!=="preview"||b.level!=="act"||b.thread!==E.job||!await g(E.job,I))return m("This request cannot answer a station settings question.");E=l(P);let T=nx.parse(Qs(b.args.slice(2)));if(T.id!==E.spec.id||T.base!==E.spec.base||T.target!==Ym(E.spec.text))return m("The station review names different settings.");if(E.preview&&jt(E.preview)!==jt(T))return E.state==="waiting"&&(u(E,"superseded","The station review changed. Nothing was applied."),a.get(E.spec.id)?.controller.abort()),m("The station review changed. Ask with a fresh draft.");E.state==="preview"&&k(E,T,b.id);let v=a.get(E.spec.id);if(v){let N;await Promise.race([v.done,new Promise(x=>{N=setTimeout(x,Di),c.add(N),N.unref()})]),N&&(clearTimeout(N),c.delete(N))}if(s)return m("The settings request service was reloaded.");let A=l(E.spec.id);return A.state==="waiting"?{decision:"pending",reason:`Settings request ${A.spec.id} is waiting for your answer in Moonlet.`}:A.state==="applying"&&A.receipt&&A.preview&&n()<A.spec.deadline&&Ai(t.text())===A.spec.base&&t.owner()===A.spec.owner?y({stage:"apply",spec:A.spec,preview:A.preview}):m(`Settings request ${A.spec.id}: ${A.message}`)}catch(R){return m(R instanceof Error?R.message:"The settings request could not be checked.")}}}i(_8,"setupPolicyProposals");import{createHash as aye}from"node:crypto";import{readFile as rye}from"node:fs/promises";import{join as nye}from"node:path";kr();var eg="orbit-back-thread";function E8(e,t){return e.replace(/\{\{(nickname|owner|front|data)\}\}/g,(r,n)=>t[n])+`
|
|
1120
|
-
`+bl.assistantLimits}i(E8,"renderBack");async function T8(e){let t=await e.storage.kv.get(eg);if(!t)return null;let r=await
|
|
1120
|
+
`+bl.assistantLimits}i(E8,"renderBack");async function T8(e){let t=await e.storage.kv.get(eg);if(!t)return null;let r=await e.sdk.threads.get({threadId:t}).catch(()=>null);return!r||r.archivedAt||r.deletedAt?null:t}i(T8,"currentBackThread");async function lx(e,t,r,n,o,s,a,c){let l=await T8(e);if(c?.protectedFront){if(l){let m=await fetch(`${e.server.loopbackBaseUrl}/api/v1/threads/${l}?include=environment`);if((m.ok?await m.json():null)?.environment?.hostId!==r.id)throw new Error("The background conversation is not on the selected work machine.")}if((await t.exec({as:"orbit",script:`mkdir -p ${Ue(`${s}/journal`)}`})).code!==0)throw new Error("The work background journal is unavailable.")}let d={nickname:hn(a.identity),owner:pr(a.identity),front:o,data:s},u=E8(await Yd(e,"plugins/orbit/back/CLAUDE.md",()=>rye(nye(wd(),"back","CLAUDE.md"),"utf8")),d),f=await ME(e,"plugins/orbit/back/CLAUDE.md",r.id,g=>E8(g,d),t,`${Ho}/CLAUDE.md`);u=f.text??u;let h=await t.exec({as:"root",script:`set -euo pipefail
|
|
1121
1121
|
install -d -o 0 -g 0 -m 755 ${Ho}
|
|
1122
1122
|
for f in CLAUDE.md AGENTS.md; do
|
|
1123
1123
|
printf %s ${Ue(u)} > ${Ho}/$f.new
|
|
@@ -204750,6 +204750,52 @@ function registerThreadActionRoutes(app, deps) {
|
|
|
204750
204750
|
});
|
|
204751
204751
|
}
|
|
204752
204752
|
|
|
204753
|
+
// src/services/threads/thread-list.ts
|
|
204754
|
+
init_src3();
|
|
204755
|
+
init_src8();
|
|
204756
|
+
init_errors4();
|
|
204757
|
+
init_entity_lookup();
|
|
204758
|
+
init_thread_runtime_display();
|
|
204759
|
+
function listThreadResponses(deps, query) {
|
|
204760
|
+
const { limit, offset } = parsePaginationQuery({
|
|
204761
|
+
limit: query.limit,
|
|
204762
|
+
offset: query.offset
|
|
204763
|
+
});
|
|
204764
|
+
if (query.projectId) {
|
|
204765
|
+
requirePublicProject(deps.db, query.projectId);
|
|
204766
|
+
}
|
|
204767
|
+
if (query.sectionId && query.unsectioned === "true") {
|
|
204768
|
+
throw new ApiError(
|
|
204769
|
+
400,
|
|
204770
|
+
"invalid_request",
|
|
204771
|
+
"sectionId and unsectioned cannot be used together"
|
|
204772
|
+
);
|
|
204773
|
+
}
|
|
204774
|
+
if (query.sectionId) {
|
|
204775
|
+
if (!getThreadSectionById(deps.db, query.sectionId)) {
|
|
204776
|
+
throw new ApiError(404, "section_not_found", "Section not found");
|
|
204777
|
+
}
|
|
204778
|
+
}
|
|
204779
|
+
const threads2 = listThreadsWithPendingInteractionState(deps.db, {
|
|
204780
|
+
...query.projectId ? { projectId: query.projectId } : {},
|
|
204781
|
+
...query.environmentId ? { environmentId: query.environmentId } : {},
|
|
204782
|
+
...query.hostId ? { hostId: query.hostId } : {},
|
|
204783
|
+
...query.parentThreadId ? { parentThreadId: query.parentThreadId } : {},
|
|
204784
|
+
...query.sourceThreadId ? { sourceThreadId: query.sourceThreadId } : {},
|
|
204785
|
+
...query.sectionId ? { sectionId: query.sectionId } : {},
|
|
204786
|
+
...query.unsectioned === "true" ? { unsectioned: true } : {},
|
|
204787
|
+
...query.originKind ? { originKind: query.originKind } : {},
|
|
204788
|
+
...query.originPluginId ? { originPluginId: query.originPluginId } : {},
|
|
204789
|
+
...query.threadIds === void 0 ? {} : { threadIds: parseThreadListThreadIds(query.threadIds) },
|
|
204790
|
+
includeHidden: query.includeHidden === "true",
|
|
204791
|
+
archived: query.archived === void 0 ? void 0 : query.archived === "true",
|
|
204792
|
+
hasParent: query.hasParent === void 0 ? void 0 : query.hasParent === "true",
|
|
204793
|
+
...limit !== void 0 ? { limit } : {},
|
|
204794
|
+
...offset !== void 0 ? { offset } : {}
|
|
204795
|
+
});
|
|
204796
|
+
return toThreadListEntryResponses(deps, { threads: threads2 });
|
|
204797
|
+
}
|
|
204798
|
+
|
|
204753
204799
|
// src/routes/threads/base.ts
|
|
204754
204800
|
init_thread_environment_providers();
|
|
204755
204801
|
init_src3();
|
|
@@ -205976,43 +206022,7 @@ function registerThreadBaseRoutes(app, deps) {
|
|
|
205976
206022
|
);
|
|
205977
206023
|
});
|
|
205978
206024
|
get(routes.list, (context, query) => {
|
|
205979
|
-
|
|
205980
|
-
limit: query.limit,
|
|
205981
|
-
offset: query.offset
|
|
205982
|
-
});
|
|
205983
|
-
if (query.projectId) {
|
|
205984
|
-
requirePublicProject(deps.db, query.projectId);
|
|
205985
|
-
}
|
|
205986
|
-
if (query.sectionId && query.unsectioned === "true") {
|
|
205987
|
-
throw new ApiError(
|
|
205988
|
-
400,
|
|
205989
|
-
"invalid_request",
|
|
205990
|
-
"sectionId and unsectioned cannot be used together"
|
|
205991
|
-
);
|
|
205992
|
-
}
|
|
205993
|
-
if (query.sectionId) {
|
|
205994
|
-
requireThreadSection(deps, query.sectionId);
|
|
205995
|
-
}
|
|
205996
|
-
const threads2 = listThreadsWithPendingInteractionState(deps.db, {
|
|
205997
|
-
...query.projectId ? { projectId: query.projectId } : {},
|
|
205998
|
-
...query.environmentId ? { environmentId: query.environmentId } : {},
|
|
205999
|
-
...query.hostId ? { hostId: query.hostId } : {},
|
|
206000
|
-
...query.parentThreadId ? { parentThreadId: query.parentThreadId } : {},
|
|
206001
|
-
...query.sourceThreadId ? { sourceThreadId: query.sourceThreadId } : {},
|
|
206002
|
-
...query.sectionId ? { sectionId: query.sectionId } : {},
|
|
206003
|
-
...query.unsectioned === "true" ? { unsectioned: true } : {},
|
|
206004
|
-
...query.originKind ? { originKind: query.originKind } : {},
|
|
206005
|
-
...query.originPluginId ? { originPluginId: query.originPluginId } : {},
|
|
206006
|
-
...query.threadIds === void 0 ? {} : { threadIds: parseThreadListThreadIds(query.threadIds) },
|
|
206007
|
-
includeHidden: query.includeHidden === "true",
|
|
206008
|
-
archived: query.archived === void 0 ? void 0 : query.archived === "true",
|
|
206009
|
-
hasParent: query.hasParent === void 0 ? void 0 : query.hasParent === "true",
|
|
206010
|
-
...limit !== void 0 ? { limit } : {},
|
|
206011
|
-
...offset !== void 0 ? { offset } : {}
|
|
206012
|
-
});
|
|
206013
|
-
return context.json(
|
|
206014
|
-
toThreadListEntryResponses(deps, { threads: threads2 })
|
|
206015
|
-
);
|
|
206025
|
+
return context.json(listThreadResponses(deps, query));
|
|
206016
206026
|
});
|
|
206017
206027
|
get(routes.search, (context, query) => {
|
|
206018
206028
|
const searchQuery2 = query.query.trim();
|
|
@@ -217384,6 +217394,9 @@ function gitRefNameForRow(row) {
|
|
|
217384
217394
|
}
|
|
217385
217395
|
|
|
217386
217396
|
// src/services/plugins/plugin-runtime.ts
|
|
217397
|
+
init_src3();
|
|
217398
|
+
init_src8();
|
|
217399
|
+
init_entity_lookup();
|
|
217387
217400
|
init_src();
|
|
217388
217401
|
init_host_policy();
|
|
217389
217402
|
var import_semver7 = __toESM(require_semver3(), 1);
|
|
@@ -217778,9 +217791,15 @@ function withPluginThreadAttribution(args, pluginId) {
|
|
|
217778
217791
|
const attribution = args.pluginMetadata !== void 0 ? { origin: "plugin", originPluginId: pluginId } : args.origin === void 0 || args.origin === "plugin" ? { origin: "plugin", originPluginId: args.originPluginId ?? pluginId } : { origin: args.origin };
|
|
217779
217792
|
return { ...args, ...attribution };
|
|
217780
217793
|
}
|
|
217781
|
-
function wrapSdkForPlugin(sdk, pluginId, rpcCallerSdk) {
|
|
217794
|
+
function wrapSdkForPlugin(sdk, pluginId, rpcCallerSdk, observations) {
|
|
217782
217795
|
return {
|
|
217783
217796
|
...sdk,
|
|
217797
|
+
...pluginId === "orbit" ? {
|
|
217798
|
+
threadSections: {
|
|
217799
|
+
...sdk.threadSections,
|
|
217800
|
+
list: observations.listSections
|
|
217801
|
+
}
|
|
217802
|
+
} : {},
|
|
217784
217803
|
hosts: {
|
|
217785
217804
|
...sdk.hosts,
|
|
217786
217805
|
list: rpcCallerSdk.hosts.list
|
|
@@ -217807,6 +217826,13 @@ function wrapSdkForPlugin(sdk, pluginId, rpcCallerSdk) {
|
|
|
217807
217826
|
},
|
|
217808
217827
|
threads: {
|
|
217809
217828
|
...sdk.threads,
|
|
217829
|
+
...pluginId === "orbit" ? {
|
|
217830
|
+
list: observations.list,
|
|
217831
|
+
interactions: {
|
|
217832
|
+
...sdk.threads.interactions,
|
|
217833
|
+
list: observations.listInteractions
|
|
217834
|
+
}
|
|
217835
|
+
} : {},
|
|
217810
217836
|
get: rpcCallerSdk.threads.get,
|
|
217811
217837
|
queue: rpcCallerSdk.threads.queue,
|
|
217812
217838
|
queuedMessages: {
|
|
@@ -218847,7 +218873,8 @@ function createPluginApi(options2) {
|
|
|
218847
218873
|
createPluginRpcCallerSdk({
|
|
218848
218874
|
baseUrl: loopbackBaseUrl,
|
|
218849
218875
|
token: rpcCaller.token
|
|
218850
|
-
})
|
|
218876
|
+
}),
|
|
218877
|
+
options2.threadObservations
|
|
218851
218878
|
);
|
|
218852
218879
|
return wrappedSdk;
|
|
218853
218880
|
},
|
|
@@ -220225,6 +220252,40 @@ function createPluginRuntime(context) {
|
|
|
220225
220252
|
db: deps.db,
|
|
220226
220253
|
dataDir: deps.dataDir,
|
|
220227
220254
|
getSdk: () => boundSdk,
|
|
220255
|
+
threadObservations: {
|
|
220256
|
+
async listSections(args) {
|
|
220257
|
+
args?.signal?.throwIfAborted();
|
|
220258
|
+
return listThreadSections(deps.db);
|
|
220259
|
+
},
|
|
220260
|
+
async list(args) {
|
|
220261
|
+
args?.signal?.throwIfAborted();
|
|
220262
|
+
if (!deps.providerRegistry)
|
|
220263
|
+
throw new Error("Provider registry is unavailable");
|
|
220264
|
+
const query = threadListQuerySchema.parse(
|
|
220265
|
+
Object.fromEntries(
|
|
220266
|
+
Object.entries(args ?? {}).filter(
|
|
220267
|
+
([key, value]) => key !== "signal" && value !== void 0
|
|
220268
|
+
).map(([key, value]) => [
|
|
220269
|
+
key,
|
|
220270
|
+
Array.isArray(value) ? value.join(",") : String(value)
|
|
220271
|
+
])
|
|
220272
|
+
)
|
|
220273
|
+
);
|
|
220274
|
+
return listThreadResponses(
|
|
220275
|
+
{ ...deps, providerRegistry: deps.providerRegistry },
|
|
220276
|
+
query
|
|
220277
|
+
);
|
|
220278
|
+
},
|
|
220279
|
+
async listInteractions({ threadId, signal }) {
|
|
220280
|
+
signal?.throwIfAborted();
|
|
220281
|
+
const thread = requirePublicThread(deps.db, threadId);
|
|
220282
|
+
if (!deps.pendingInteractions)
|
|
220283
|
+
throw new Error("Pending interactions are unavailable");
|
|
220284
|
+
return deps.pendingInteractions.listPendingThreadInteractions(
|
|
220285
|
+
thread.id
|
|
220286
|
+
);
|
|
220287
|
+
}
|
|
220288
|
+
},
|
|
220228
220289
|
getMachineEnrollments: () => {
|
|
220229
220290
|
if (!context.machineEnrollments)
|
|
220230
220291
|
throw new Error(
|