@halcyonlabs/app 0.47.0-halcyon.538 → 0.47.0-halcyon.539
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 +10 -10
- 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/builtin-plugins/tasks/dist/app.js +37 -37
- package/server/dist/builtin-plugins/tasks/dist/server.js +1 -1
- package/server/dist/builtin-plugins/tasks/skills/tasks/SKILL.md +9 -0
package/dist/index.d.ts
CHANGED
|
@@ -191,10 +191,10 @@ declare const uiPreferenceDefinitions: {
|
|
|
191
191
|
}>>;
|
|
192
192
|
readonly "sidebar.threadGrouping.environment": UiPreferenceDefinition<z$1.ZodUnion<readonly [z$1.ZodLiteral<"auto">, z$1.ZodBoolean]>>;
|
|
193
193
|
readonly "sidebar.chronologicalSort": UiPreferenceDefinition<z$1.ZodEnum<{
|
|
194
|
+
none: "none";
|
|
194
195
|
updated: "updated";
|
|
195
196
|
created: "created";
|
|
196
197
|
alpha: "alpha";
|
|
197
|
-
none: "none";
|
|
198
198
|
}>>;
|
|
199
199
|
readonly "sidebar.sortDirection": UiPreferenceDefinition<z$1.ZodEnum<{
|
|
200
200
|
default: "default";
|
|
@@ -488,8 +488,8 @@ type ChangedMessage = z$1.infer<typeof changedMessageSchema>;
|
|
|
488
488
|
|
|
489
489
|
declare const environmentStatusSchema: z$1.ZodEnum<{
|
|
490
490
|
error: "error";
|
|
491
|
-
ready: "ready";
|
|
492
491
|
provisioning: "provisioning";
|
|
492
|
+
ready: "ready";
|
|
493
493
|
creating: "creating";
|
|
494
494
|
destroyed: "destroyed";
|
|
495
495
|
}>;
|
|
@@ -508,8 +508,8 @@ declare const environmentSchema: z$1.ZodObject<{
|
|
|
508
508
|
mergeBaseBranch: z$1.ZodNullable<z$1.ZodString>;
|
|
509
509
|
status: z$1.ZodEnum<{
|
|
510
510
|
error: "error";
|
|
511
|
-
ready: "ready";
|
|
512
511
|
provisioning: "provisioning";
|
|
512
|
+
ready: "ready";
|
|
513
513
|
creating: "creating";
|
|
514
514
|
destroyed: "destroyed";
|
|
515
515
|
}>;
|
|
@@ -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>;
|
|
@@ -6131,8 +6131,8 @@ declare const hostDaemonCommandRegistry: {
|
|
|
6131
6131
|
skillFilePath: z$1.ZodString;
|
|
6132
6132
|
}, z$1.core.$strict>], "kind">>;
|
|
6133
6133
|
instructionMode: z$1.ZodEnum<{
|
|
6134
|
-
replace: "replace";
|
|
6135
6134
|
append: "append";
|
|
6135
|
+
replace: "replace";
|
|
6136
6136
|
}>;
|
|
6137
6137
|
type: z$1.ZodLiteral<"thread.rewind.prepare">;
|
|
6138
6138
|
leaseId: z$1.ZodString;
|
|
@@ -6280,8 +6280,8 @@ declare const hostDaemonCommandRegistry: {
|
|
|
6280
6280
|
skillFilePath: z$1.ZodString;
|
|
6281
6281
|
}, z$1.core.$strict>], "kind">>;
|
|
6282
6282
|
instructionMode: z$1.ZodEnum<{
|
|
6283
|
-
replace: "replace";
|
|
6284
6283
|
append: "append";
|
|
6284
|
+
replace: "replace";
|
|
6285
6285
|
}>;
|
|
6286
6286
|
type: z$1.ZodLiteral<"thread.start">;
|
|
6287
6287
|
requestId: z$1.ZodString;
|
|
@@ -6744,8 +6744,8 @@ declare const hostDaemonCommandRegistry: {
|
|
|
6744
6744
|
envPassthrough: z$1.ZodArray<z$1.ZodString>;
|
|
6745
6745
|
}, z$1.core.$strict>;
|
|
6746
6746
|
instructionMode: z$1.ZodEnum<{
|
|
6747
|
-
replace: "replace";
|
|
6748
6747
|
append: "append";
|
|
6748
|
+
replace: "replace";
|
|
6749
6749
|
}>;
|
|
6750
6750
|
projectId: z$1.ZodString;
|
|
6751
6751
|
providerId: z$1.ZodString;
|
|
@@ -6960,8 +6960,8 @@ declare const hostDaemonCommandRegistry: {
|
|
|
6960
6960
|
envPassthrough: z$1.ZodArray<z$1.ZodString>;
|
|
6961
6961
|
}, z$1.core.$strict>;
|
|
6962
6962
|
instructionMode: z$1.ZodEnum<{
|
|
6963
|
-
replace: "replace";
|
|
6964
6963
|
append: "append";
|
|
6964
|
+
replace: "replace";
|
|
6965
6965
|
}>;
|
|
6966
6966
|
projectId: z$1.ZodString;
|
|
6967
6967
|
providerId: z$1.ZodString;
|
|
@@ -8185,9 +8185,9 @@ declare const hostDaemonCommandRegistry: {
|
|
|
8185
8185
|
executablePath: z$1.ZodNullable<z$1.ZodString>;
|
|
8186
8186
|
installed: z$1.ZodBoolean;
|
|
8187
8187
|
installSource: z$1.ZodEnum<{
|
|
8188
|
+
external: "external";
|
|
8188
8189
|
notInstalled: "notInstalled";
|
|
8189
8190
|
npmGlobal: "npmGlobal";
|
|
8190
|
-
external: "external";
|
|
8191
8191
|
}>;
|
|
8192
8192
|
currentVersion: z$1.ZodNullable<z$1.ZodString>;
|
|
8193
8193
|
latestVersion: z$1.ZodNullable<z$1.ZodString>;
|
|
@@ -8736,9 +8736,9 @@ declare const providerCliStatusResponseSchema: z$1.ZodRecord<z$1.ZodString, z$1.
|
|
|
8736
8736
|
executablePath: z$1.ZodNullable<z$1.ZodString>;
|
|
8737
8737
|
installed: z$1.ZodBoolean;
|
|
8738
8738
|
installSource: z$1.ZodEnum<{
|
|
8739
|
+
external: "external";
|
|
8739
8740
|
notInstalled: "notInstalled";
|
|
8740
8741
|
npmGlobal: "npmGlobal";
|
|
8741
|
-
external: "external";
|
|
8742
8742
|
}>;
|
|
8743
8743
|
currentVersion: z$1.ZodNullable<z$1.ZodString>;
|
|
8744
8744
|
latestVersion: z$1.ZodNullable<z$1.ZodString>;
|
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.539",
|
|
4
4
|
"description": "bb app launcher for npx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bb",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
109
109
|
},
|
|
110
110
|
"moonletRelease": {
|
|
111
|
-
"summary": "
|
|
111
|
+
"summary": "fix(tasks): retire the old sidebar entry after task cutover (#564)"
|
|
112
112
|
},
|
|
113
113
|
"license": "SEE LICENSE IN LICENSE"
|
|
114
114
|
}
|
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": "5d3691c1d8f35c0b12d9fddf3109a2d2c92362fd",
|
|
3
3
|
"file": "orbit-deploy",
|
|
4
4
|
"platform": "linux-x64",
|
|
5
5
|
"provenance": {
|
|
6
|
-
"artifactId":
|
|
7
|
-
"artifactName": "linux-bundle-
|
|
6
|
+
"artifactId": 15215253717,
|
|
7
|
+
"artifactName": "linux-bundle-5d3691c1d8f35c0b12d9fddf3109a2d2c92362fd",
|
|
8
8
|
"repository": "matt0x6F/personalassistant",
|
|
9
|
-
"runId":
|
|
9
|
+
"runId": 46030382987,
|
|
10
10
|
"workflow": ".github/workflows/moonlet-linux-bundle.yml"
|
|
11
11
|
},
|
|
12
12
|
"schema": 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
5d3691c1d8f35c0b12d9fddf3109a2d2c92362fd
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"repository":"matt0x6F/personalassistant","revision":"
|
|
1
|
+
{"repository":"matt0x6F/personalassistant","revision":"5d3691c1d8f35c0b12d9fddf3109a2d2c92362fd"}
|
|
@@ -1832,7 +1832,7 @@ rm -f "$f.pid" "$f.out" "$f.code"
|
|
|
1832
1832
|
BB_THREAD_ID=${He(t)} setsid -f sh -c 'echo $$ > "$1.pid"; ${FEe} deploy ${r?"activate":"undo"} events > "$1.out" 2>&1; echo $? > "$1.code"' sh "$f" < /dev/null > /dev/null 2>&1
|
|
1833
1833
|
for _ in $(seq 50); do [ -s "$f.pid" ] && break; sleep 0.1; done
|
|
1834
1834
|
[ -s "$f.pid" ] && echo asked`}o(GEe,"askScript");function WM(e){return(e.trim().split(`
|
|
1835
|
-
`).map(t=>t.replace(/^orbit-cap: /,"").trim()).filter(Boolean).pop()??"no reason given").slice(0,300)}o(WM,"lastLine");function VEe(e){return[!e.installed&&"the event service's program (orbit station policy installs it)",!e.options&&"its settings for the station runner (orbit station policy saves them)",!e.runner&&"the station runner's socket (activation.md, Switching the station runner on)"].filter(t=>!!t)}o(VEe,"missing");function VM(e,t,r){let{now:n,ownerAsked:s}=r,i=e??{state:r.fresh?"due":"untouched",at:n},a=null;if(i.state==="asked"){let d=t.request,u=i.target??!0;if(d?.code===null&&d.running)return{record:i,ask:!1,report:s?"event service: a switch question is already waiting":null};d?.code===0&&t.active===u?(i={state:u?"on":"stopped",at:n},a=`event service: switched ${u?"on":"off"} after your approval`):d?d.code===77?i={state:"declined",at:n,reason:WM(d.output)}:i={state:"failed",at:n,reason:d.code===null?"the request ended before an answer":WM(d.output)}:i={state:"failed",at:n,reason:"the request's record on the station is gone"},i.state==="declined"&&(a=`event service: not switched ${u?"on":"off"} (${i.reason}). It stays ${t.active?"on":"off"}, and you won't be asked again unless you ask: ${sO}.`),i.state==="failed"&&(a=`event service: switching didn't complete and it stays ${t.active?"on":"off"} (${i.reason}). To try again: ${sO}.`)}else t.active&&i.state!=="on"?(i={state:"on",at:n},a=e?"event service: on":null):!t.active&&i.state==="on"&&(i={state:"stopped",at:n},a=`event service: off now. Orbit won't switch it on or ask again; to be asked: ${sO}.`);let c=!1,l=r.target??!0;if(s&&t.active===l)a=`event service: already ${l?"on":"off"}`;else if((s||i.state==="due")&&!r.canAsk)s&&(a=zEe);else if(s||i.state==="due"&&!t.active){let d=l?VEe(t):t.runner?[]:["the station runner's socket"];d.length?(s&&(a=`event service: you'll be asked once the station has ${d.join(", ")}`),s||(i={state:"due",at:i.at})):(c=!0,i={state:"asked",target:l,at:n},a=`event service: asked you in your Moonlet window whether to switch it ${l?"on":"off"}`)}return{record:i,ask:c,report:a}}o(VM,"decide");var oO=new Map;function kg(e){return KM(e.dataDir,()=>KEe(e))}o(kg,"reconcileEvents");function KM(e,t){let r=(oO.get(e)??Promise.resolve()).catch(()=>{}).then(t);return oO.set(e,r),r.finally(()=>{oO.get(e)===r&&oO.delete(e)}).catch(()=>{}),r}o(KM,"withEventsLock");async function KEe(e){let t=await e.station.exec({as:"orbit",script:zM(e.dataDir)}),r=t.code===0?GM(t.stdout):null;if(!r)return"event service: its state on the station couldn't be read, so nothing was changed or asked";let n=e.ownerTarget!==void 0,s=VM(await e.load(),r,{fresh:e.fresh,ownerAsked:n,target:e.ownerTarget,canAsk:e.canAsk,now:e.now()});if(!s.ask)return await e.save(s.record),s.report;let i=typeof e.front=="string"?e.front:await e.front();try{await e.save({...s.record,thread:i})}catch(c){return`event service: the question couldn't be recorded, so it wasn't asked (${c.message})`}let a=await e.station.exec({as:"orbit",script:GEe(e.dataDir,i,s.record.target)}).catch(c=>({code:1,stdout:"",stderr:c.message}));if(a.code!==0||a.stdout.trim()!=="asked"){let c=WM(a.stderr||a.stdout);return await e.save({state:"failed",at:e.now(),reason:`the question couldn't be requested: ${c}`}),`event service: the question couldn't be requested (${c}), so its state is unchanged. To try again: ${sO}.`}return s.report}o(KEe,"reconcileNow");var HZ=wd.object({active:wd.boolean(),pending:wd.boolean(),thread:wd.string().nullable(),message:wd.string().nullable()}),WZ=JEe({"events.state":{input:wd.null(),output:HZ},"events.switch":{input:wd.object({active:wd.boolean()}).strict(),output:HZ}});async function zZ(e){await e.get("events-switch-migrated")||(await e.delete("events-offer-owner-ask"),await e.set("events-switch-migrated",!0))}o(zZ,"migrateEventService");function GZ(e){async function t(){let n=await e.target();return KM(n.dataDir,async()=>{let s=await n.station.exec({as:"orbit",script:zM(n.dataDir)}),i=s.code===0?GM(s.stdout):null;if(!i)throw new Error("The event service's state couldn't be read. Reconnect the station and try again.");let a=VM(await n.load(),i,{fresh:!1,ownerAsked:!1,canAsk:!1,now:n.now()});return await n.save(a.record),{active:i.active,pending:a.record.state==="asked",thread:a.record.state==="asked"?a.record.thread??null:null,message:a.record.reason??a.report}})}o(t,"state");async function r(n){let s=await e.target(),i=await kg({...s,front:s.questionThread,ownerTarget:n});return{...await t(),message:i}}return o(r,"switchTo"),{state:t,switchTo:r}}o(GZ,"eventService");import{PluginCliError as VZ}from"@get-bb/plugin-sdk";async function KZ(e,t){let r=await e.sdk.threads.internal_DO_NOT_USE_visibleReplyEvidence({threadId:t,body:{}});if(r.status!=="visible")throw new VZ("No current visible reply can satisfy this reminder. Review the conversation and send any answer that is due.");let n=await e.sdk.threads.internal_DO_NOT_USE_visibleReplyEvidence({threadId:t,body:{revision:r.revision}});if(n.status!=="visible"||n.revision!==r.revision||n.messageSeq!==r.messageSeq)throw new VZ("Visible reply evidence changed. Review the current conversation and send any answer that is due.");return n.messageSeq}o(KZ,"acknowledgeVisibleMessage");import{cliCommand as XZ,defineRpcContract as n0e}from"@get-bb/plugin-sdk";import{z as Qc}from"zod";import{createHash as XEe}from"node:crypto";import{z as rs}from"zod";var YEe=rs.string().regex(vn),ZEe=rs.object({version:rs.literal(1),phase:rs.enum(["snapshot","tasks","history","index","complete"]),pending:rs.array(YEe),checked:rs.number().int().nonnegative(),waiting:rs.string().nullable()}),qk="task-reconciliation-v1",QEe="meaning-needed",e0e=/^(?:review:|worker:|ci:|prompt:|approve:|unread:|rule:|schedule:|output-clean:|archive-output:|fixture-expiry:|retention:work)/i,t0e=/https:\/\/github\.com\/[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]{0,8}\b/g;function r0e(e,t){if(e.project.id===Co)return!1;let r=[...e.description.matchAll(/^Work start: ([^\n]+)$/gm)].at(-1)?.[1];if(r)return t.some(i=>i.key===r&&i.key.startsWith("review:")&&i.class==="background")&&!t.some(i=>!i.key.startsWith("review:")&&!i.key.startsWith("event:"));let n=/^Key: ([^\n]+)(?:\n|$)/.exec(e.description)?.[1];if(!n)return!1;let s=/^Labels: ([^\n]*)$/m.exec(e.description)?.[1]?.split(",").map(i=>i.trim())??[];return[...e.labels,...s].includes("event-service")||e0e.test(n)}o(r0e,"systemRecord");function JZ(e,t){let r=Le(e),n=t.tasks??(()=>Kt(e)),s=null,i=c$(e,n),a=o(()=>e.realtime.publish("tasks",{changed:!0}),"changed");async function c(){let h=await e.storage.kv.get(qk);return h==null?null:ZEe.parse(h)}o(c,"status");function l(h,p){let g=n().store;g.update(h.id,{addLabels:[QEe]},"system"),g.note(h.id,"system",`Needs your decision: ${p}`,"note",`meaning-needed:${XEe("sha256").update(p).digest("hex").slice(0,32)}`),a()}o(l,"hold");async function d(){let h=n(),p=await h.moveOrb();if(!await h.orbMoved())throw new Error(p?.failed.length?`The old task board is partly moved; ${p.failed.length} tasks are still to come over`:"The old task board hasn't moved into Moonlet's tasks yet");let g=new Set;for(let m of rs.array(rs.object({orb:rs.string()})).parse(r.prepare("SELECT orb FROM task_orb_mirror ORDER BY orb").all())){let y=h.store.find(m.orb);y&&g.add(y.key)}return[...g]}o(d,"snapshot");async function u(h){let p=n().store,g=p.find(h);if(!g||g.status==="dropped")return;let m=_k(p,g),y=rs.array(rs.object({key:rs.string(),class:rs.string()})).parse(r.prepare(`SELECT key, class FROM work_items WHERE loop IN (${m.map(()=>"?").join(",")})`).all(...m));if(r0e(g,y))return;let w=p.links(g.id).filter(b=>b.kind==="conversation"&&/^thr_[a-z0-9]+$/.test(b.ref)).map(b=>b.ref),k=await t.workers(m,g.description,w),_=!1;for(let b of k){let A=await e.sdk.threads.get({threadId:b}),N=await e.sdk.threads.timeline({threadId:b,summaryOnly:"true",segmentLimit:"1"});_||=["active","starting","pending"].includes(A.status)||!!N.goal&&N.goal.status!=="complete"||N.activeWorkflows.length>0||N.activeBackgroundCommands.length>0||!!N.pendingTodos?.items.some(x=>x.status!=="completed"),_||=(await e.sdk.threads.interactions.list({threadId:b})).some(x=>x.status==="pending")}let v=y.length>0;if(g.status==="done"&&!_&&!v)return;v||await e.storage.kv.set(Mj(g.key),!0);for(let b of k)await i.attach({loop:g.key,thread:b});let R=Sx(g.description);if(R&&!t.repos().includes(new URL(R).pathname.split("/").slice(1,3).join("/"))){l(g,"the named repository is not available for independent completion evidence");return}let S=[...g.description.matchAll(t0e)].map(b=>b[0]);if((!R||S.some(b=>b!==R))&&(S.length>0||Bj(g)==="in_review")&&!_&&!v){l(g,"the completion condition needs a decision; a pull request reference alone does not finish this promise");return}let E=o(b=>JSON.stringify([b.title,b.description,b.doneWhen,b.priority,b.status]),"meaning");if(R&&S.every(b=>b===R)&&!p.list({parent:g.id,status:"open",limit:1}).tasks.length){if(E(p.get(g.id))!==E(g))return;p.links(g.id).some(b=>b.kind==="pull_request"&&b.ref===R)||(p.link(g.id,{kind:"pull_request",ref:R,label:null}),a())}await t.update(g.key);let T=p.get(g.id);if(T.status!=="done"&&(T.description!==g.description||T.title!==g.title||T.priority!==g.priority||T.doneWhen!==g.doneWhen))throw new Error("Task meaning changed during reconciliation; its current condition will be read again")}o(u,"reconcile");async function f(){let h=await c();if(h?.phase!=="complete"){h||(h={version:1,phase:"snapshot",pending:[],checked:0,waiting:null},await e.storage.kv.set(qk,h)),h.waiting=null;try{if(h.phase==="snapshot"&&(h.pending=await d(),h.phase="tasks",await e.storage.kv.set(qk,h)),h.phase==="tasks"){let p=h.pending.slice(0,12),g=null;for(let m of p){try{await u(m),h.pending=h.pending.filter(y=>y!==m),h.checked++}catch(y){h.pending=[...h.pending.filter(w=>w!==m),m],h.waiting=y instanceof Error?y.message:String(y),g=y}await e.storage.kv.set(qk,h)}if(g)throw g;h.pending.length||(h.phase="history")}if(h.phase==="history"){let p=await t.historyStep();p.waiting?h.waiting=p.waiting:h.phase="index"}h.phase==="index"&&(h.waiting=await t.index(),h.waiting===null&&(h.phase="complete"))}catch(p){throw h.waiting=p instanceof Error?p.message:String(p),p}finally{await e.storage.kv.set(qk,h)}}}return o(f,"pass"),{status:c,tick(){return s??=f().finally(()=>{s=null}),s}}}o(JZ,"taskReconciliation");var YZ=Qc.object({version:Qc.literal(1),phase:Qc.enum(["snapshot","tasks","history","index","complete"]),pending:Qc.array(Qc.string()),checked:Qc.number(),waiting:Qc.string().nullable()}).nullable(),o0e=n0e({"tasks.reconciliation":{input:Qc.null(),output:YZ},"tasks.reconcile":{input:Qc.null(),output:YZ}}),JM=new WeakMap;function ZZ(e,t){let r=JZ(e,t);return JM.set(e,r),e.rpc.register(o0e,{"tasks.reconciliation":o(()=>r.status(),"tasks.reconciliation"),"tasks.reconcile":o(async()=>(await r.tick(),r.status()),"tasks.reconcile")}),ct(e,"task-reconciliation","* * * * *",r.tick),r.tick().catch(n=>e.log.warn(`Task reconciliation: ${String(n)}`)),r}o(ZZ,"setupTaskReconciliation");function QZ(e,t){return{"loops reconciliation":XZ({summary:"Read the automatic board reconciliation progress",aliases:["tasks reconciliation"],async run(r,n){await t(n.threadId);let s=JM.get(e);if(!s)throw new Error("Task reconciliation is not ready");return{exitCode:0,stdout:JSON.stringify(await s.status())}}}),"loops reconcile":XZ({summary:"Retry the automatic board reconciliation without changing task meaning",aliases:["tasks reconcile"],async run(r,n){await t(n.threadId);let s=JM.get(e);if(!s)throw new Error("Task reconciliation is not ready");return await s.tick(),{exitCode:0,stdout:JSON.stringify(await s.status())}}})}}o(QZ,"taskReconciliationCommands");import{cliCommand as _g,PluginCliError as eQ}from"@get-bb/plugin-sdk";var tQ={name:"id",description:"System record identity, including a historical ORB alias",required:!0},Eg={type:"boolean",description:"Emit JSON"},Tg=o(e=>({exitCode:0,stdout:JSON.stringify(e)}),"output");function rQ(e){return{"records ready":_g({summary:"Prepare durable system records without changing task history",options:{json:Eg},async run(){return await sa(e).ready(),Tg({ready:!0,version:1})}}),"records show":_g({summary:"Read one work record, notice or watch",positionals:[tQ],options:{json:Eg},async run(t){let r=await sa(e).query({action:"get",id:t.positionals.id});if(!r.records.length&&!t.options.json)throw new eQ("System record not found");return Tg(r)}}),"records find":_g({summary:"Find a system record by its exact event key",options:{key:{type:"string",required:!0,description:"Exact event key"},json:Eg},async run(t){return Tg(await sa(e).query({action:"find",key:t.options.key}))}}),"records list":_g({summary:"List work, notices and watches with bounded pages",options:{all:{type:"boolean",description:"Include resolved work and notice history"},label:{type:"string",description:"Filter by label"},parent:{type:"string",description:"Parent record or task identity"},after:{type:"integer",min:0,max:Number.MAX_SAFE_INTEGER,default:0,description:"Continue after this sequence"},limit:{type:"integer",min:1,max:200,default:100,description:"Maximum records in a page"},json:Eg},async run(t){return Tg(await sa(e).query({action:"list",active:!t.options.all,label:t.options.label??"",parent:t.options.parent??null,after:t.options.after,limit:t.options.limit}))}}),"records change":_g({summary:"Record system work, notice or watch state",options:{data:{type:"string",required:!0,description:"JSON create, update or comment operation; never changes a task's meaning"},json:Eg},async run(t,r){let n;try{n=JSON.parse(t.options.data)}catch{throw new eQ("Record data must be JSON")}let s=x_["records.change"].input.parse(n);return Tg(await sa(e).change(s,r.threadId?`conversation:${r.threadId}`:"cli:records"))}}),"records comments":_g({summary:"Read system record comments",positionals:[tQ],options:{after:{type:"integer",min:0,max:Number.MAX_SAFE_INTEGER,default:0,description:"Continue after this comment sequence"},limit:{type:"integer",min:1,max:200,default:100,description:"Maximum comments"},json:Eg},async run(t){let r=sa(e);return await r.ready(),Tg(r.store.comments(t.positionals.id,t.options.after,t.options.limit))}})}}o(rQ,"eventRecordCommands");import{PluginCliError as s0e}from"@get-bb/plugin-sdk";function nQ(e){async function t(n,s){return n===s||!!await e.orbitConversationOf(n)}o(t,"moonletConversation");async function r(n){let s=await e.backThread().catch(()=>null),i=await e.parentOf(n);for(let a=0;i&&a<16;a++){if(await t(i,s))return!0;i=await e.parentOf(i)}return!1}return o(r,"startedByMoonlet"),async n=>{if(!n)return await e.requireUser(n),"owner";if(await t(n,await e.backThread().catch(()=>null))||await e.onStation(n)||await e.onListedMachine(n)&&await r(n))return"assistant";if(await e.requireUser(n).then(()=>!0,()=>!1))return"owner";throw new s0e("Tasks are read and changed by the owner, the Moonlet conversation, and work on its stations or the owner's machines.")}}o(nQ,"taskCaller");import{cliCommand as Zn,PluginCliError as Qp}from"@get-bb/plugin-sdk";import{z as sQ}from"zod";var Qn={type:"boolean",description:"Print JSON"},el={name:"task",description:"A task key (ME-3, MOON-1308), an old key (ORB-12, L-0042) or its id",required:!0},iO=["todo","followup","scheduled"],XM=["owner","assistant","others"],oQ=["urgent","high","medium","low","none"],i0e=["owner","assistant"],a0e={urgent:"!!",high:"! ",medium:" ",low:"\xB7 ",none:" "},c0e=sQ.enum(["chat","mail","message","calendar","conversation","cli"]),l0e={owner:"your move",assistant:"assistant\u2019s move",others:"waiting"};function aO(e){let t=e.whenText?` \xB7 ${e.whenText}`:"",r=e.move==="others"&&e.waitingOn?` on ${e.waitingOn}`:"",n=e.status==="open"?`${l0e[e.move]}${r}`:e.status,s=e.origin==="assistant"?" \xB7 added by the assistant":"";return`${e.key.padEnd(10)} ${a0e[e.priority]} ${e.title}${t} \xB7 ${n}${s}`}o(aO,"line");var Fk=o((e,t)=>t.length?[`${e} (${t.length})`,...t.map(r=>` ${aO(r)}`)]:[],"section");async function bd(e){try{return await e()}catch(t){throw t instanceof on?new Qp(t.message):t instanceof sQ.ZodError?new Qp(t.issues.map(r=>`${r.path.join(".")||"input"}: ${r.message}`).join("; ")):t}}o(bd,"run");var ic=o((e,t,r)=>({exitCode:0,stdout:r?JSON.stringify(e):Array.isArray(t)?t.join(`
|
|
1835
|
+
`).map(t=>t.replace(/^orbit-cap: /,"").trim()).filter(Boolean).pop()??"no reason given").slice(0,300)}o(WM,"lastLine");function VEe(e){return[!e.installed&&"the event service's program (orbit station policy installs it)",!e.options&&"its settings for the station runner (orbit station policy saves them)",!e.runner&&"the station runner's socket (activation.md, Switching the station runner on)"].filter(t=>!!t)}o(VEe,"missing");function VM(e,t,r){let{now:n,ownerAsked:s}=r,i=e??{state:r.fresh?"due":"untouched",at:n},a=null;if(i.state==="asked"){let d=t.request,u=i.target??!0;if(d?.code===null&&d.running)return{record:i,ask:!1,report:s?"event service: a switch question is already waiting":null};d?.code===0&&t.active===u?(i={state:u?"on":"stopped",at:n},a=`event service: switched ${u?"on":"off"} after your approval`):d?d.code===77?i={state:"declined",at:n,reason:WM(d.output)}:i={state:"failed",at:n,reason:d.code===null?"the request ended before an answer":WM(d.output)}:i={state:"failed",at:n,reason:"the request's record on the station is gone"},i.state==="declined"&&(a=`event service: not switched ${u?"on":"off"} (${i.reason}). It stays ${t.active?"on":"off"}, and you won't be asked again unless you ask: ${sO}.`),i.state==="failed"&&(a=`event service: switching didn't complete and it stays ${t.active?"on":"off"} (${i.reason}). To try again: ${sO}.`)}else t.active&&i.state!=="on"?(i={state:"on",at:n},a=e?"event service: on":null):!t.active&&i.state==="on"&&(i={state:"stopped",at:n},a=`event service: off now. Orbit won't switch it on or ask again; to be asked: ${sO}.`);let c=!1,l=r.target??!0;if(s&&t.active===l)a=`event service: already ${l?"on":"off"}`;else if((s||i.state==="due")&&!r.canAsk)s&&(a=zEe);else if(s||i.state==="due"&&!t.active){let d=l?VEe(t):t.runner?[]:["the station runner's socket"];d.length?(s&&(a=`event service: you'll be asked once the station has ${d.join(", ")}`),s||(i={state:"due",at:i.at})):(c=!0,i={state:"asked",target:l,at:n},a=`event service: asked you in your Moonlet window whether to switch it ${l?"on":"off"}`)}return{record:i,ask:c,report:a}}o(VM,"decide");var oO=new Map;function kg(e){return KM(e.dataDir,()=>KEe(e))}o(kg,"reconcileEvents");function KM(e,t){let r=(oO.get(e)??Promise.resolve()).catch(()=>{}).then(t);return oO.set(e,r),r.finally(()=>{oO.get(e)===r&&oO.delete(e)}).catch(()=>{}),r}o(KM,"withEventsLock");async function KEe(e){let t=await e.station.exec({as:"orbit",script:zM(e.dataDir)}),r=t.code===0?GM(t.stdout):null;if(!r)return"event service: its state on the station couldn't be read, so nothing was changed or asked";let n=e.ownerTarget!==void 0,s=VM(await e.load(),r,{fresh:e.fresh,ownerAsked:n,target:e.ownerTarget,canAsk:e.canAsk,now:e.now()});if(!s.ask)return await e.save(s.record),s.report;let i=typeof e.front=="string"?e.front:await e.front();try{await e.save({...s.record,thread:i})}catch(c){return`event service: the question couldn't be recorded, so it wasn't asked (${c.message})`}let a=await e.station.exec({as:"orbit",script:GEe(e.dataDir,i,s.record.target)}).catch(c=>({code:1,stdout:"",stderr:c.message}));if(a.code!==0||a.stdout.trim()!=="asked"){let c=WM(a.stderr||a.stdout);return await e.save({state:"failed",at:e.now(),reason:`the question couldn't be requested: ${c}`}),`event service: the question couldn't be requested (${c}), so its state is unchanged. To try again: ${sO}.`}return s.report}o(KEe,"reconcileNow");var HZ=wd.object({active:wd.boolean(),pending:wd.boolean(),thread:wd.string().nullable(),message:wd.string().nullable()}),WZ=JEe({"events.state":{input:wd.null(),output:HZ},"events.switch":{input:wd.object({active:wd.boolean()}).strict(),output:HZ}});async function zZ(e){await e.get("events-switch-migrated")||(await e.delete("events-offer-owner-ask"),await e.set("events-switch-migrated",!0))}o(zZ,"migrateEventService");function GZ(e){async function t(){let n=await e.target();return KM(n.dataDir,async()=>{let s=await n.station.exec({as:"orbit",script:zM(n.dataDir)}),i=s.code===0?GM(s.stdout):null;if(!i)throw new Error("The event service's state couldn't be read. Reconnect the station and try again.");let a=VM(await n.load(),i,{fresh:!1,ownerAsked:!1,canAsk:!1,now:n.now()});return await n.save(a.record),{active:i.active,pending:a.record.state==="asked",thread:a.record.state==="asked"?a.record.thread??null:null,message:a.record.reason??a.report}})}o(t,"state");async function r(n){let s=await e.target(),i=await kg({...s,front:s.questionThread,ownerTarget:n});return{...await t(),message:i}}return o(r,"switchTo"),{state:t,switchTo:r}}o(GZ,"eventService");import{PluginCliError as VZ}from"@get-bb/plugin-sdk";async function KZ(e,t){let r=await e.sdk.threads.internal_DO_NOT_USE_visibleReplyEvidence({threadId:t,body:{}});if(r.status!=="visible")throw new VZ("No current visible reply can satisfy this reminder. Review the conversation and send any answer that is due.");let n=await e.sdk.threads.internal_DO_NOT_USE_visibleReplyEvidence({threadId:t,body:{revision:r.revision}});if(n.status!=="visible"||n.revision!==r.revision||n.messageSeq!==r.messageSeq)throw new VZ("Visible reply evidence changed. Review the current conversation and send any answer that is due.");return n.messageSeq}o(KZ,"acknowledgeVisibleMessage");import{cliCommand as XZ,defineRpcContract as n0e}from"@get-bb/plugin-sdk";import{z as Qc}from"zod";import{createHash as XEe}from"node:crypto";import{z as rs}from"zod";var YEe=rs.string().regex(vn),ZEe=rs.object({version:rs.literal(1),phase:rs.enum(["snapshot","tasks","history","index","complete"]),pending:rs.array(YEe),checked:rs.number().int().nonnegative(),waiting:rs.string().nullable()}),qk="task-reconciliation-v1",QEe="meaning-needed",e0e=/^(?:review:|worker:|ci:|prompt:|approve:|unread:|rule:|schedule:|output-clean:|archive-output:|fixture-expiry:|retention:work)/i,t0e=/https:\/\/github\.com\/[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]{0,8}\b/g;function r0e(e,t){if(e.project.id===Co)return!1;let r=[...e.description.matchAll(/^Work start: ([^\n]+)$/gm)].at(-1)?.[1];if(r)return t.some(i=>i.key===r&&i.key.startsWith("review:")&&i.class==="background")&&!t.some(i=>!i.key.startsWith("review:")&&!i.key.startsWith("event:"));let n=/^Key: ([^\n]+)(?:\n|$)/.exec(e.description)?.[1];if(!n)return!1;let s=/^Labels: ([^\n]*)$/m.exec(e.description)?.[1]?.split(",").map(i=>i.trim())??[];return[...e.labels,...s].includes("event-service")||e0e.test(n)}o(r0e,"systemRecord");function JZ(e,t){let r=Le(e),n=t.tasks??(()=>Kt(e)),s=null,i=c$(e,n),a=o(()=>e.realtime.publish("tasks",{changed:!0}),"changed");async function c(){let h=await e.storage.kv.get(qk);return h==null?null:ZEe.parse(h)}o(c,"status");function l(h,p){let g=n().store;g.update(h.id,{addLabels:[QEe]},"system"),g.note(h.id,"system",`Needs your decision: ${p}`,"note",`meaning-needed:${XEe("sha256").update(p).digest("hex").slice(0,32)}`),a()}o(l,"hold");async function d(){let h=n(),p=await h.moveOrb();if(!await h.orbMoved())throw new Error(p?.failed.length?`The old task board is partly moved; ${p.failed.length} tasks are still to come over`:"The old task board hasn't moved into Moonlet's tasks yet");let g=new Set;for(let m of rs.array(rs.object({orb:rs.string()})).parse(r.prepare("SELECT orb FROM task_orb_mirror ORDER BY orb").all())){let y=h.store.find(m.orb);y&&g.add(y.key)}return[...g]}o(d,"snapshot");async function u(h){let p=n().store,g=p.find(h);if(!g||g.status==="dropped")return;let m=_k(p,g),y=rs.array(rs.object({key:rs.string(),class:rs.string()})).parse(r.prepare(`SELECT key, class FROM work_items WHERE loop IN (${m.map(()=>"?").join(",")})`).all(...m));if(r0e(g,y))return;let w=p.links(g.id).filter(b=>b.kind==="conversation"&&/^thr_[a-z0-9]+$/.test(b.ref)).map(b=>b.ref),k=await t.workers(m,g.description,w),_=!1;for(let b of k){let A=await e.sdk.threads.get({threadId:b}),N=await e.sdk.threads.timeline({threadId:b,summaryOnly:"true",segmentLimit:"1"});_||=["active","starting","pending"].includes(A.status)||!!N.goal&&N.goal.status!=="complete"||N.activeWorkflows.length>0||N.activeBackgroundCommands.length>0||!!N.pendingTodos?.items.some(x=>x.status!=="completed"),_||=(await e.sdk.threads.interactions.list({threadId:b})).some(x=>x.status==="pending")}let v=y.length>0;if(g.status==="done"&&!_&&!v)return;v||await e.storage.kv.set(Mj(g.key),!0);for(let b of k)await i.attach({loop:g.key,thread:b});let R=Sx(g.description);if(R&&!t.repos().includes(new URL(R).pathname.split("/").slice(1,3).join("/"))){l(g,"the named repository is not available for independent completion evidence");return}let S=[...g.description.matchAll(t0e)].map(b=>b[0]);if((!R||S.some(b=>b!==R))&&(S.length>0||Bj(g)==="in_review")&&!_&&!v){l(g,"the completion condition needs a decision; a pull request reference alone does not finish this promise");return}let E=o(b=>JSON.stringify([b.title,b.description,b.doneWhen,b.priority,b.status]),"meaning");if(R&&S.every(b=>b===R)&&!p.list({parent:g.id,status:"open",limit:1}).tasks.length){if(E(p.get(g.id))!==E(g))return;p.links(g.id).some(b=>b.kind==="pull_request"&&b.ref===R)||(p.link(g.id,{kind:"pull_request",ref:R,label:null}),a())}await t.update(g.key);let T=p.get(g.id);if(T.status!=="done"&&(T.description!==g.description||T.title!==g.title||T.priority!==g.priority||T.doneWhen!==g.doneWhen))throw new Error("Task meaning changed during reconciliation; its current condition will be read again")}o(u,"reconcile");async function f(){let h=await c();if(h?.phase!=="complete"){h||(h={version:1,phase:"snapshot",pending:[],checked:0,waiting:null},await e.storage.kv.set(qk,h)),h.waiting=null;try{if(h.phase==="snapshot"&&(h.pending=await d(),h.phase="tasks",await e.storage.kv.set(qk,h)),h.phase==="tasks"){let p=h.pending.slice(0,12),g=null;for(let m of p){try{await u(m),h.pending=h.pending.filter(y=>y!==m),h.checked++}catch(y){h.pending=[...h.pending.filter(w=>w!==m),m],h.waiting=y instanceof Error?y.message:String(y),g=y}await e.storage.kv.set(qk,h)}if(g)throw g;h.pending.length||(h.phase="history")}if(h.phase==="history"){let p=await t.historyStep();p.waiting?h.waiting=p.waiting:h.phase="index"}h.phase==="index"&&(h.waiting=await t.index(),h.waiting===null&&(h.phase="complete"))}catch(p){throw h.waiting=p instanceof Error?p.message:String(p),p}finally{await e.storage.kv.set(qk,h)}}}return o(f,"pass"),{status:c,tick(){return s??=f().finally(()=>{s=null}),s}}}o(JZ,"taskReconciliation");var YZ=Qc.object({version:Qc.literal(1),phase:Qc.enum(["snapshot","tasks","history","index","complete"]),pending:Qc.array(Qc.string()),checked:Qc.number(),waiting:Qc.string().nullable()}).nullable(),o0e=n0e({"tasks.reconciliation":{input:Qc.null(),output:YZ},"tasks.reconcile":{input:Qc.null(),output:YZ}}),JM=new WeakMap;function ZZ(e,t){let r=JZ(e,t),n=null,s={status:r.status,tick(){return n??=(async()=>{if(await r.tick(),(await r.status())?.phase!=="complete")return;let i="task-navigation-retired-v1";await e.storage.kv.get(i)===!0||(await e.sdk.plugins.getSettings({pluginId:"tasks"})).schema.showNavigation?.type!=="boolean"||(await e.sdk.plugins.updateSettings({pluginId:"tasks",values:{showNavigation:!1}}),await e.storage.kv.set(i,!0))})().finally(()=>{n=null}),n}};return JM.set(e,s),e.rpc.register(o0e,{"tasks.reconciliation":o(()=>s.status(),"tasks.reconciliation"),"tasks.reconcile":o(async()=>(await s.tick(),s.status()),"tasks.reconcile")}),ct(e,"task-reconciliation","* * * * *",s.tick),s.tick().catch(i=>e.log.warn(`Task reconciliation: ${String(i)}`)),s}o(ZZ,"setupTaskReconciliation");function QZ(e,t){return{"loops reconciliation":XZ({summary:"Read the automatic board reconciliation progress",aliases:["tasks reconciliation"],async run(r,n){await t(n.threadId);let s=JM.get(e);if(!s)throw new Error("Task reconciliation is not ready");return{exitCode:0,stdout:JSON.stringify(await s.status())}}}),"loops reconcile":XZ({summary:"Retry the automatic board reconciliation without changing task meaning",aliases:["tasks reconcile"],async run(r,n){await t(n.threadId);let s=JM.get(e);if(!s)throw new Error("Task reconciliation is not ready");return await s.tick(),{exitCode:0,stdout:JSON.stringify(await s.status())}}})}}o(QZ,"taskReconciliationCommands");import{cliCommand as _g,PluginCliError as eQ}from"@get-bb/plugin-sdk";var tQ={name:"id",description:"System record identity, including a historical ORB alias",required:!0},Eg={type:"boolean",description:"Emit JSON"},Tg=o(e=>({exitCode:0,stdout:JSON.stringify(e)}),"output");function rQ(e){return{"records ready":_g({summary:"Prepare durable system records without changing task history",options:{json:Eg},async run(){return await sa(e).ready(),Tg({ready:!0,version:1})}}),"records show":_g({summary:"Read one work record, notice or watch",positionals:[tQ],options:{json:Eg},async run(t){let r=await sa(e).query({action:"get",id:t.positionals.id});if(!r.records.length&&!t.options.json)throw new eQ("System record not found");return Tg(r)}}),"records find":_g({summary:"Find a system record by its exact event key",options:{key:{type:"string",required:!0,description:"Exact event key"},json:Eg},async run(t){return Tg(await sa(e).query({action:"find",key:t.options.key}))}}),"records list":_g({summary:"List work, notices and watches with bounded pages",options:{all:{type:"boolean",description:"Include resolved work and notice history"},label:{type:"string",description:"Filter by label"},parent:{type:"string",description:"Parent record or task identity"},after:{type:"integer",min:0,max:Number.MAX_SAFE_INTEGER,default:0,description:"Continue after this sequence"},limit:{type:"integer",min:1,max:200,default:100,description:"Maximum records in a page"},json:Eg},async run(t){return Tg(await sa(e).query({action:"list",active:!t.options.all,label:t.options.label??"",parent:t.options.parent??null,after:t.options.after,limit:t.options.limit}))}}),"records change":_g({summary:"Record system work, notice or watch state",options:{data:{type:"string",required:!0,description:"JSON create, update or comment operation; never changes a task's meaning"},json:Eg},async run(t,r){let n;try{n=JSON.parse(t.options.data)}catch{throw new eQ("Record data must be JSON")}let s=x_["records.change"].input.parse(n);return Tg(await sa(e).change(s,r.threadId?`conversation:${r.threadId}`:"cli:records"))}}),"records comments":_g({summary:"Read system record comments",positionals:[tQ],options:{after:{type:"integer",min:0,max:Number.MAX_SAFE_INTEGER,default:0,description:"Continue after this comment sequence"},limit:{type:"integer",min:1,max:200,default:100,description:"Maximum comments"},json:Eg},async run(t){let r=sa(e);return await r.ready(),Tg(r.store.comments(t.positionals.id,t.options.after,t.options.limit))}})}}o(rQ,"eventRecordCommands");import{PluginCliError as s0e}from"@get-bb/plugin-sdk";function nQ(e){async function t(n,s){return n===s||!!await e.orbitConversationOf(n)}o(t,"moonletConversation");async function r(n){let s=await e.backThread().catch(()=>null),i=await e.parentOf(n);for(let a=0;i&&a<16;a++){if(await t(i,s))return!0;i=await e.parentOf(i)}return!1}return o(r,"startedByMoonlet"),async n=>{if(!n)return await e.requireUser(n),"owner";if(await t(n,await e.backThread().catch(()=>null))||await e.onStation(n)||await e.onListedMachine(n)&&await r(n))return"assistant";if(await e.requireUser(n).then(()=>!0,()=>!1))return"owner";throw new s0e("Tasks are read and changed by the owner, the Moonlet conversation, and work on its stations or the owner's machines.")}}o(nQ,"taskCaller");import{cliCommand as Zn,PluginCliError as Qp}from"@get-bb/plugin-sdk";import{z as sQ}from"zod";var Qn={type:"boolean",description:"Print JSON"},el={name:"task",description:"A task key (ME-3, MOON-1308), an old key (ORB-12, L-0042) or its id",required:!0},iO=["todo","followup","scheduled"],XM=["owner","assistant","others"],oQ=["urgent","high","medium","low","none"],i0e=["owner","assistant"],a0e={urgent:"!!",high:"! ",medium:" ",low:"\xB7 ",none:" "},c0e=sQ.enum(["chat","mail","message","calendar","conversation","cli"]),l0e={owner:"your move",assistant:"assistant\u2019s move",others:"waiting"};function aO(e){let t=e.whenText?` \xB7 ${e.whenText}`:"",r=e.move==="others"&&e.waitingOn?` on ${e.waitingOn}`:"",n=e.status==="open"?`${l0e[e.move]}${r}`:e.status,s=e.origin==="assistant"?" \xB7 added by the assistant":"";return`${e.key.padEnd(10)} ${a0e[e.priority]} ${e.title}${t} \xB7 ${n}${s}`}o(aO,"line");var Fk=o((e,t)=>t.length?[`${e} (${t.length})`,...t.map(r=>` ${aO(r)}`)]:[],"section");async function bd(e){try{return await e()}catch(t){throw t instanceof on?new Qp(t.message):t instanceof sQ.ZodError?new Qp(t.issues.map(r=>`${r.path.join(".")||"input"}: ${r.message}`).join("; ")):t}}o(bd,"run");var ic=o((e,t,r)=>({exitCode:0,stdout:r?JSON.stringify(e):Array.isArray(t)?t.join(`
|
|
1836
1836
|
`):t}),"out"),d0e=768*1024,YM=200,ZM=o(e=>({key:e.key,title:e.title,project:e.project.key,kind:e.kind,priority:e.priority,move:e.move,waitingOn:e.waitingOn,dueAt:e.dueAt,whenText:e.whenText}),"brief");function QM(e,t){let r=t==="newest"?[...e].reverse():e,n=[],s=0;for(let i of r){if(s+=Buffer.byteLength(JSON.stringify(i))+1,s>d0e&&n.length)break;n.push(i)}return t==="newest"?n.reverse():n}o(QM,"fitOutput");function iQ(e,t){let r=o(()=>Kt(e),"service");async function n(i,a){if(i===void 0)return;await r().fresh();let c=r().parse(i,a);if(!c.ok)throw new Qp(c.error);return c.when}o(n,"when");async function s(i,a,c){let l=await t(a),d=await bd(()=>r().apply(i,l,l==="owner"?"owner":"assistant"));return ic(d,aO(d),c)}return o(s,"change"),{"tasks today":Zn({summary:"What needs the owner, what the assistant is on, what's waiting, and today's times",options:{project:{type:"string",description:"Only this project (key, name or id)"},json:Qn},async run(i,a){await t(a.threadId);let c=await bd(()=>r().today({project:i.options.project})),l=[{name:"yours",title:"Your move",more:"--move owner",tasks:c.yours},{name:"onIt",title:"Assistant\u2019s move",more:"--move assistant",tasks:c.onIt},{name:"waiting",title:"Waiting on others",more:"--move others --sort due",tasks:c.waiting},{name:"overdue",title:"Overdue",more:"--sort due",tasks:c.overdue}].map(p=>({...p,shown:p.tasks.slice(0,YM)})),d=c.schedule.slice(0,YM),u=d.map(p=>` ${Ad(mi(p.at,c.zone)).padEnd(9)} ${p.task.key} ${p.task.title}`),f=o(p=>p.tasks.length>p.shown.length?[` ${p.tasks.length-p.shown.length} more: moonlet orbit tasks list ${p.more}`]:[],"more"),h=o(p=>l.find(g=>g.name===p),"sectionOf");return ic({day:c.day,zone:c.zone,...Object.fromEntries(l.map(p=>[p.name,p.shown.map(ZM)])),schedule:d.map(p=>({at:p.at,timed:p.timed,task:ZM(p.task)})),more:{...Object.fromEntries(l.map(p=>[p.name,p.tasks.length-p.shown.length])),schedule:c.schedule.length-d.length}},[`Today, ${c.day}`,...Fk("Your move",h("yours").shown),...f(h("yours")),...Fk("Assistant\u2019s move",h("onIt").shown),...f(h("onIt")),...Fk("Waiting on others",h("waiting").shown),...f(h("waiting")),...u.length?["Today\u2019s times",...u]:[],...Fk("Overdue",h("overdue").shown),...f(h("overdue"))],i.options.json)}}),"tasks now":Zn({summary:"For the assistant at the start of a turn: its move, what's due within a day, and check-backs that have come",options:{json:Qn},async run(i,a){await t(a.threadId);let c=r();await c.fresh();let l=c.store.attention(),d=[{name:"mine",title:"Your move (the assistant\u2019s)",more:"--move assistant",tasks:l.mine},{name:"due",title:"Due within a day",more:"--sort due",tasks:l.due},{name:"checks",title:"Check-backs that have come",more:"--move others --sort due",tasks:l.checks},{name:"unwatched",title:"Waiting with nothing watching",more:"--move others",tasks:l.unwatched}].map(u=>({...u,shown:u.tasks.slice(0,YM).map(f=>c.decorate(f))}));return ic({...Object.fromEntries(d.map(u=>[u.name,u.shown.map(ZM)])),more:Object.fromEntries(d.map(u=>[u.name,u.tasks.length-u.shown.length]))},d.flatMap(u=>[...Fk(u.title,u.shown),...u.tasks.length>u.shown.length?[` ${u.tasks.length-u.shown.length} more: moonlet orbit tasks list ${u.more}`]:[]]).join(`
|
|
1837
1837
|
`)||"Nothing is due and nothing is waiting on you.",i.options.json)}}),"tasks list":Zn({summary:"List tasks, ordered by priority then when",options:{project:{type:"string",description:"Project key, name or id"},origin:{type:"enum",values:i0e,description:"Who added it"},move:{type:"enum",values:XM,description:"Whose move it is"},kind:{type:"enum",values:iO,description:"Kind of task"},status:{type:"enum",values:["open","done","dropped","all"],default:"open",description:"Which tasks"},label:{type:"string",description:"Only tasks with this label"},search:{type:"string",description:"Words in the title or description"},sort:{type:"enum",values:["priority","due","closed"],default:"priority",description:"By priority then when, by when then priority, or most recently closed first"},offset:{type:"integer",min:0,max:1e6,default:0,description:"Skip this many"},limit:{type:"integer",min:1,max:500,default:100,description:"At most this many"},json:Qn},async run(i,a){await t(a.threadId);let c=r();await c.fresh();let l=i.options,d=await bd(async()=>c.store.list({project:l.project,origin:l.origin,move:l.move,kind:l.kind,status:l.status,label:l.label,search:l.search,sort:l.sort,offset:l.offset,limit:l.limit})),u=QM(d.tasks.map(h=>c.decorate(h)),"oldest"),f=u.length<d.tasks.length?l.offset+u.length:d.next;return ic({tasks:u,next:f,total:d.total},u.length?[...u.map(aO),...f!==null?[`${d.total-f} more: --offset ${f}`]:[]]:"No tasks match.",i.options.json)}}),"tasks show":Zn({summary:"One task with its steps, links, old keys and its newest journal lines",positionals:[el],options:{recent:{type:"integer",min:1,max:500,default:200,description:"How many of the newest journal lines to show"},json:Qn},async run(i,a){await t(a.threadId);let c=r();await c.fresh();let l=await bd(async()=>c.store.show(i.positionals.task,i.options.recent)),d=QM(l.journal,"newest"),u={...l,journal:d,earlier:d.length<l.journal.length?d[0]?.seq??l.earlier:l.earlier},f=c.decorate(u.task),h=c.zone();return ic({...u,task:f},[aO(f),`Project: ${f.project.name} (${f.project.key})${u.aliases.length?` \xB7 also ${u.aliases.join(", ")}`:""}`,...f.why?[`Why: ${f.why}`]:[],...f.doneWhen?[`Done when: ${f.doneWhen}`]:[],...f.description?["",f.description]:[],...u.steps.length?["","Steps",...u.steps.map(p=>` ${p.doneAt?"[x]":"[ ]"} ${p.position}. ${p.title}`)]:[],...u.links.length?["","Links",...u.links.map(p=>` ${p.kind}: ${p.ref}${p.label?` (${p.label})`:""}`)]:[],"","Journal",...u.earlier!==null?[` Earlier lines: moonlet orbit tasks journal --task ${f.key} --before ${u.earlier}`]:[],...u.journal.map(p=>` ${nn(p.at,h)} ${mi(p.at,h)} ${p.actor}: ${p.body}`)],i.options.json)}}),"tasks add":Zn({summary:"Add a task. The assistant says --why; a waiting task names --waiting-on",options:{title:{type:"string",required:!0,description:"What the task is"},project:{type:"string",default:"personal",description:"Project key, name or id (personal, internal, MOON, \u2026)"},description:{type:"string",description:"Background"},"done-when":{type:"string",description:"What finishing means"},kind:{type:"enum",values:iO,default:"todo",description:"to-do, follow-up or scheduled"},when:{type:"string",description:"In plain words: \u201Ctoday 5pm\u201D, \u201Cby friday\u201D, \u201Cevery weekday at 7:30\u201D, \u201Ccheck back fri 9am\u201D"},priority:{type:"enum",values:oQ,default:"medium",description:"Priority"},move:{type:"enum",values:XM,default:"assistant",description:"Whose move it is"},"waiting-on":{type:"string",description:"Who a waiting task waits on"},why:{type:"string",description:"Why the assistant added it, in one line"},source:{type:"string",description:"Where it came from, as kind:ref (mail:<id>, chat:<seq>, message:<id>)"},label:{type:"string",repeatable:!0,split:",",description:"Labels"},parent:{type:"string",description:"Parent task"},step:{type:"string",repeatable:!0,description:"A step, in order"},json:Qn},async run(i,a){let c=i.options,l=c.source?/^(chat|mail|message|calendar|conversation|cli):(.+)$/.exec(c.source):null;if(c.source&&!l)throw new Qp("--source is kind:ref, with kind one of chat, mail, message, calendar, conversation, cli");let d=l?{kind:c0e.parse(l[1]),ref:l[2]??""}:null;return s({action:"create",task:{project:c.project,title:c.title,description:c.description??"",doneWhen:c["done-when"]??"",kind:c.kind,move:c.move,waitingOn:c["waiting-on"]??null,priority:c.priority,why:c.why??null,when:await n(c.when,c.kind)??null,source:d,labels:c.label??[],parent:c.parent??null,steps:c.step??[]}},a.threadId,c.json)}}),"tasks update":Zn({summary:"Change a task. Re-ranks and hand-overs are journaled with --why",positionals:[el],options:{title:{type:"string",description:"New title"},description:{type:"string",description:"New description"},"done-when":{type:"string",description:"What finishing means"},kind:{type:"enum",values:iO,description:"Kind"},when:{type:"string",description:"New when, in plain words"},"no-when":{type:"boolean",description:"Clear the when"},priority:{type:"enum",values:oQ,description:"Priority"},move:{type:"enum",values:XM,description:"Whose move it is"},"waiting-on":{type:"string",description:"Who it waits on"},label:{type:"string",repeatable:!0,split:",",description:"Add labels"},"remove-label":{type:"string",repeatable:!0,split:",",description:"Remove labels"},parent:{type:"string",description:"New parent"},"no-parent":{type:"boolean",description:"No longer a subtask"},why:{type:"string",description:"Why, for the journal"},json:Qn},async run(i,a){let c=i.options,l=r(),d=await bd(async()=>l.store.get(i.positionals.task));return s({action:"update",ref:d.id,patch:{title:c.title,description:c.description,doneWhen:c["done-when"],kind:c.kind,priority:c.priority,move:c.move,waitingOn:c["waiting-on"],when:c["no-when"]?null:await n(c.when,c.kind??d.kind),addLabels:c.label,removeLabels:c["remove-label"],parent:c["no-parent"]?null:c.parent,why:c.why}},a.threadId,c.json)}}),"tasks done":Zn({summary:"Mark a task done",positionals:[el],options:{note:{type:"string",description:"How it ended"},json:Qn},run:o((i,a)=>s({action:"done",ref:i.positionals.task,note:i.options.note??null},a.threadId,i.options.json),"run")}),"tasks drop":Zn({summary:"Drop a task, with the reason. The assistant can undo a drop for 7 days",positionals:[el],options:{reason:{type:"string",required:!0,description:"Why it no longer matters"},json:Qn},run:o((i,a)=>s({action:"drop",ref:i.positionals.task,reason:i.options.reason},a.threadId,i.options.json),"run")}),"tasks reopen":Zn({summary:"Reopen a done or dropped task",positionals:[el],options:{why:{type:"string",description:"Why"},json:Qn},run:o((i,a)=>s({action:"reopen",ref:i.positionals.task,why:i.options.why??null},a.threadId,i.options.json),"run")}),"tasks move":Zn({summary:"Move a task to another project; its old key keeps working",positionals:[el],options:{project:{type:"string",required:!0,description:"Destination project"},json:Qn},run:o((i,a)=>s({action:"move",ref:i.positionals.task,project:i.options.project},a.threadId,i.options.json),"run")}),"tasks note":Zn({summary:"Add a line to a task's journal",positionals:[el],options:{body:{type:"string",required:!0,stdin:!0,description:"What happened, or what to remember"},json:Qn},run:o((i,a)=>s({action:"note",ref:i.positionals.task,body:i.options.body},a.threadId,i.options.json),"run")}),"tasks step":Zn({summary:"Add a step, or mark one done or not done",positionals:[el],options:{add:{type:"string",description:"A new step's title"},check:{type:"integer",min:1,max:1e3,description:"Mark this step done"},uncheck:{type:"integer",min:1,max:1e3,description:"Mark this step not done"},json:Qn},async run(i,a){let c=i.options;if([c.add!==void 0,c.check!==void 0,c.uncheck!==void 0].filter(Boolean).length!==1)throw new Qp("Give one of --add, --check or --uncheck");return c.add!==void 0?s({action:"addStep",ref:i.positionals.task,title:c.add},a.threadId,c.json):s({action:"checkStep",ref:i.positionals.task,position:c.check??c.uncheck??0,done:c.check!==void 0},a.threadId,c.json)}}),"tasks link":Zn({summary:"Link a conversation, page, pull request, mail, schedule or address to a task",positionals:[el],options:{kind:{type:"enum",values:["conversation","artifact","pull_request","mail","task","schedule","url"],required:!0,description:"What it is"},ref:{type:"string",required:!0,description:"Its id or address"},label:{type:"string",description:"A short label"},json:Qn},run:o((i,a)=>s({action:"link",ref:i.positionals.task,link:{kind:i.options.kind,ref:i.options.ref,label:i.options.label??null}},a.threadId,i.options.json),"run")}),"tasks journal":Zn({summary:"Read the journal: one task's, one project's or one day's",options:{task:{type:"string",description:"One task"},project:{type:"string",description:"One project"},actor:{type:"enum",values:["owner","assistant","system"],description:"Whose lines"},day:{type:"string",description:"One day, YYYY-MM-DD in the owner's zone"},after:{type:"integer",min:0,max:Number.MAX_SAFE_INTEGER,default:0,description:"Continue after this line"},before:{type:"integer",min:1,max:Number.MAX_SAFE_INTEGER,description:"Read back from this line: the newest lines before it"},limit:{type:"integer",min:1,max:500,default:200,description:"At most this many lines"},json:Qn},async run(i,a){await t(a.threadId);let c=r(),l=i.options,d=l.before!==void 0,u=await bd(()=>c.journalDay({task:l.task,project:l.project,actor:l.actor,day:l.day,after:l.after,before:l.before,newest:d,limit:l.limit})),f=QM(u.entries,d?"newest":"oldest"),h=f.length<u.entries.length,p={...u,entries:f,next:h?(d?f[0]?.seq:f.at(-1)?.seq)??u.next:u.next},g=c.zone();return ic(p,[...p.notes.map(m=>`Note from ${m.actor}: ${m.body}`),...p.entries.map(m=>`${nn(m.at,g)} ${mi(m.at,g)} ${m.key} ${m.actor}: ${m.body}`),...p.next!==null?[`More: ${d?"--before":"--after"} ${p.next}`]:[]].join(`
|
|
1838
1838
|
`)||"Nothing in the journal for that.",l.json)}}),"tasks day-note":Zn({summary:"Write a day's note: the owner's own, or the assistant's summary of the day",options:{body:{type:"string",required:!0,stdin:!0,description:"The note; an empty one clears it"},day:{type:"string",description:"The day, YYYY-MM-DD in the owner's zone (today if left out)"},json:Qn},async run(i,a){let c=await t(a.threadId),l=r();await l.fresh();let d=i.options.day??nn(Date.now(),l.zone());if(!/^\d{4}-\d{2}-\d{2}$/.test(d))throw new Qp("--day is YYYY-MM-DD");return await bd(async()=>l.writeDayNote(d,c,i.options.body)),ic({day:d,actor:c},`Saved the ${c==="owner"?"owner\u2019s":"assistant\u2019s"} note for ${d}.`,i.options.json)}}),"tasks projects":Zn({summary:"The projects tasks belong to, with their keys",options:{json:Qn},async run(i,a){await t(a.threadId);let c=r().store.projects();return ic(c,c.map(l=>`${l.key.padEnd(8)} ${l.name} (${l.id})`),i.options.json)}}),"tasks when":Zn({summary:"Read a when in plain words, and show the next five times",positionals:[{name:"text",description:"For example \u201Cevery other friday at 4pm starting next week\u201D",required:!0}],options:{kind:{type:"enum",values:iO,default:"todo",description:"The task's kind, which decides what a bare time means"},json:Qn},async run(i,a){await t(a.threadId);let c=r();await c.fresh();let l=c.parse(i.positionals.text,i.options.kind);if(!l.ok)throw new Qp(l.error);let d=c.zone();return ic(l,[l.reading,...l.next.map(u=>` ${nn(u,d)} ${Ad(mi(u,d))}`)],i.options.json)}}),"tasks move-orb":Zn({summary:"Move ORB's tasks into Moonlet, once; after that ORB is retired and never read again",options:{json:Qn},async run(i,a){await t(a.threadId);let c=await bd(()=>r().moveOrb()),l=o((u,f)=>f.length?`
|