@halcyonlabs/app 0.47.0-halcyon.582 → 0.47.0-halcyon.584

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 CHANGED
@@ -84,8 +84,8 @@ declare const appSettingsSchema: z$1.ZodObject<{
84
84
  providerOrder: z$1.ZodArray<z$1.ZodString>;
85
85
  defaultProviderId: z$1.ZodNullable<z$1.ZodString>;
86
86
  providerCompletedTurnDisplay: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
87
- flat: "flat";
88
87
  collapse: "collapse";
88
+ flat: "flat";
89
89
  }>>;
90
90
  streamerMode: z$1.ZodBoolean;
91
91
  allowFastServiceTier: z$1.ZodBoolean;
@@ -106,8 +106,8 @@ declare const appSettingsUpdateSchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
106
106
  providerOrder: z$1.ZodArray<z$1.ZodString>;
107
107
  defaultProviderId: z$1.ZodNullable<z$1.ZodString>;
108
108
  providerCompletedTurnDisplay: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
109
- flat: "flat";
110
109
  collapse: "collapse";
110
+ flat: "flat";
111
111
  }>>;
112
112
  streamerMode: z$1.ZodBoolean;
113
113
  managedBranchPrefix: z$1.ZodString;
@@ -145,8 +145,8 @@ declare const appSettingsUpdateSchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
145
145
  providerOrder: z$1.ZodArray<z$1.ZodString>;
146
146
  defaultProviderId: z$1.ZodNullable<z$1.ZodString>;
147
147
  providerCompletedTurnDisplay: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
148
- flat: "flat";
149
148
  collapse: "collapse";
149
+ flat: "flat";
150
150
  }>>;
151
151
  streamerMode: z$1.ZodBoolean;
152
152
  machineServerUrl: z$1.ZodNullable<z$1.ZodString>;
@@ -631,9 +631,9 @@ declare const hostSchema: z$1.ZodObject<{
631
631
  }, z$1.core.$strip>>;
632
632
  }, z$1.core.$strip>;
633
633
  maxPermissionMode: z$1.ZodEnum<{
634
+ full: "full";
634
635
  auto: "auto";
635
636
  "accept-edits": "accept-edits";
636
- full: "full";
637
637
  }>;
638
638
  delivery: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodObject<{
639
639
  oldestPendingAt: z$1.ZodNullable<z$1.ZodNumber>;
@@ -2874,9 +2874,9 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
2874
2874
  tell: "tell";
2875
2875
  }>;
2876
2876
  initiator: z$1.ZodEnum<{
2877
+ user: "user";
2877
2878
  system: "system";
2878
2879
  agent: "agent";
2879
- user: "user";
2880
2880
  }>;
2881
2881
  request: z$1.ZodObject<{
2882
2882
  method: z$1.ZodEnum<{
@@ -2897,9 +2897,9 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
2897
2897
  tell: "tell";
2898
2898
  }>;
2899
2899
  initiator: z$1.ZodEnum<{
2900
+ user: "user";
2900
2901
  system: "system";
2901
2902
  agent: "agent";
2902
- user: "user";
2903
2903
  }>;
2904
2904
  senderThreadId: z$1.ZodNullable<z$1.ZodString>;
2905
2905
  systemMessageKind: z$1.ZodOptional<z$1.ZodEnum<{
@@ -3011,12 +3011,12 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3011
3011
  }>;
3012
3012
  name: z$1.ZodString;
3013
3013
  source: z$1.ZodEnum<{
3014
- command: "command";
3015
3014
  skill: "skill";
3015
+ command: "command";
3016
3016
  }>;
3017
3017
  origin: z$1.ZodEnum<{
3018
- project: "project";
3019
3018
  user: "user";
3019
+ project: "project";
3020
3020
  builtin: "builtin";
3021
3021
  }>;
3022
3022
  label: z$1.ZodString;
@@ -3101,12 +3101,12 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3101
3101
  }>;
3102
3102
  name: z$1.ZodString;
3103
3103
  source: z$1.ZodEnum<{
3104
- command: "command";
3105
3104
  skill: "skill";
3105
+ command: "command";
3106
3106
  }>;
3107
3107
  origin: z$1.ZodEnum<{
3108
- project: "project";
3109
3108
  user: "user";
3109
+ project: "project";
3110
3110
  builtin: "builtin";
3111
3111
  }>;
3112
3112
  label: z$1.ZodString;
@@ -3179,9 +3179,9 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3179
3179
  }>;
3180
3180
  permissionMode: z$1.ZodEnum<{
3181
3181
  readonly: "readonly";
3182
+ full: "full";
3182
3183
  auto: "auto";
3183
3184
  "accept-edits": "accept-edits";
3184
- full: "full";
3185
3185
  "workspace-write": "workspace-write";
3186
3186
  }>;
3187
3187
  }, z$1.core.$strip>;
@@ -3200,9 +3200,9 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3200
3200
  tell: "tell";
3201
3201
  }>;
3202
3202
  initiator: z$1.ZodEnum<{
3203
+ user: "user";
3203
3204
  system: "system";
3204
3205
  agent: "agent";
3205
- user: "user";
3206
3206
  }>;
3207
3207
  request: z$1.ZodObject<{
3208
3208
  method: z$1.ZodEnum<{
@@ -3247,10 +3247,10 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3247
3247
  interaction: z$1.ZodUnion<readonly [z$1.ZodObject<{
3248
3248
  id: z$1.ZodString;
3249
3249
  status: z$1.ZodEnum<{
3250
+ resolved: "resolved";
3250
3251
  pending: "pending";
3251
3252
  interrupted: "interrupted";
3252
3253
  resolving: "resolving";
3253
- resolved: "resolved";
3254
3254
  }>;
3255
3255
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3256
3256
  origin: z$1.ZodObject<{
@@ -3383,10 +3383,10 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3383
3383
  }, z$1.core.$strip>, z$1.ZodObject<{
3384
3384
  id: z$1.ZodString;
3385
3385
  status: z$1.ZodEnum<{
3386
+ resolved: "resolved";
3386
3387
  pending: "pending";
3387
3388
  interrupted: "interrupted";
3388
3389
  resolving: "resolving";
3389
- resolved: "resolved";
3390
3390
  }>;
3391
3391
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3392
3392
  origin: z$1.ZodObject<{
@@ -3419,10 +3419,10 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3419
3419
  }, z$1.core.$strip>, z$1.ZodObject<{
3420
3420
  id: z$1.ZodString;
3421
3421
  status: z$1.ZodEnum<{
3422
+ resolved: "resolved";
3422
3423
  pending: "pending";
3423
3424
  interrupted: "interrupted";
3424
3425
  resolving: "resolving";
3425
- resolved: "resolved";
3426
3426
  }>;
3427
3427
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3428
3428
  origin: z$1.ZodObject<{
@@ -3470,10 +3470,10 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3470
3470
  }, z$1.core.$strip>, z$1.ZodObject<{
3471
3471
  id: z$1.ZodString;
3472
3472
  status: z$1.ZodEnum<{
3473
+ resolved: "resolved";
3473
3474
  pending: "pending";
3474
3475
  interrupted: "interrupted";
3475
3476
  resolving: "resolving";
3476
- resolved: "resolved";
3477
3477
  }>;
3478
3478
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3479
3479
  origin: z$1.ZodObject<{
@@ -3496,10 +3496,10 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3496
3496
  providerId: z$1.ZodString;
3497
3497
  providerRequestId: z$1.ZodString;
3498
3498
  status: z$1.ZodEnum<{
3499
+ resolved: "resolved";
3499
3500
  pending: "pending";
3500
3501
  interrupted: "interrupted";
3501
3502
  resolving: "resolving";
3502
- resolved: "resolved";
3503
3503
  }>;
3504
3504
  resolution: z$1.ZodDefault<z$1.ZodNullable<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
3505
3505
  decision: z$1.ZodLiteral<"allow_once">;
@@ -3548,10 +3548,10 @@ declare const threadEventSchema: z$1.ZodUnion<readonly [z$1.ZodIntersection<z$1.
3548
3548
  providerId: z$1.ZodString;
3549
3549
  providerRequestId: z$1.ZodString;
3550
3550
  status: z$1.ZodEnum<{
3551
+ resolved: "resolved";
3551
3552
  pending: "pending";
3552
3553
  interrupted: "interrupted";
3553
3554
  resolving: "resolving";
3554
- resolved: "resolved";
3555
3555
  }>;
3556
3556
  resolution: z$1.ZodDefault<z$1.ZodNullable<z$1.ZodObject<{
3557
3557
  kind: z$1.ZodLiteral<"user_answer">;
@@ -3673,10 +3673,10 @@ declare const providerPendingInteractionSchema: z$1.ZodUnion<readonly [z$1.ZodOb
3673
3673
  id: z$1.ZodString;
3674
3674
  threadId: z$1.ZodString;
3675
3675
  status: z$1.ZodEnum<{
3676
+ resolved: "resolved";
3676
3677
  pending: "pending";
3677
3678
  interrupted: "interrupted";
3678
3679
  resolving: "resolving";
3679
- resolved: "resolved";
3680
3680
  }>;
3681
3681
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3682
3682
  createdAt: z$1.ZodNumber;
@@ -3823,10 +3823,10 @@ declare const providerPendingInteractionSchema: z$1.ZodUnion<readonly [z$1.ZodOb
3823
3823
  id: z$1.ZodString;
3824
3824
  threadId: z$1.ZodString;
3825
3825
  status: z$1.ZodEnum<{
3826
+ resolved: "resolved";
3826
3827
  pending: "pending";
3827
3828
  interrupted: "interrupted";
3828
3829
  resolving: "resolving";
3829
- resolved: "resolved";
3830
3830
  }>;
3831
3831
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3832
3832
  createdAt: z$1.ZodNumber;
@@ -3868,10 +3868,10 @@ declare const providerPendingInteractionSchema: z$1.ZodUnion<readonly [z$1.ZodOb
3868
3868
  id: z$1.ZodString;
3869
3869
  threadId: z$1.ZodString;
3870
3870
  status: z$1.ZodEnum<{
3871
+ resolved: "resolved";
3871
3872
  pending: "pending";
3872
3873
  interrupted: "interrupted";
3873
3874
  resolving: "resolving";
3874
- resolved: "resolved";
3875
3875
  }>;
3876
3876
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3877
3877
  createdAt: z$1.ZodNumber;
@@ -3902,10 +3902,10 @@ declare const pluginPendingInteractionSchema: z$1.ZodObject<{
3902
3902
  id: z$1.ZodString;
3903
3903
  threadId: z$1.ZodString;
3904
3904
  status: z$1.ZodEnum<{
3905
+ resolved: "resolved";
3905
3906
  pending: "pending";
3906
3907
  interrupted: "interrupted";
3907
3908
  resolving: "resolving";
3908
- resolved: "resolved";
3909
3909
  }>;
3910
3910
  statusReason: z$1.ZodNullable<z$1.ZodString>;
3911
3911
  createdAt: z$1.ZodNumber;
@@ -3978,9 +3978,9 @@ type ReasoningLevel = z$1.infer<typeof reasoningLevelSchema>;
3978
3978
  declare const serviceTierSchema: z$1.ZodString;
3979
3979
  type ServiceTier = z$1.infer<typeof serviceTierSchema>;
3980
3980
  declare const permissionModeSchema: z$1.ZodEnum<{
3981
+ full: "full";
3981
3982
  auto: "auto";
3982
3983
  "accept-edits": "accept-edits";
3983
- full: "full";
3984
3984
  }>;
3985
3985
  type PermissionMode = z$1.infer<typeof permissionModeSchema>;
3986
3986
  declare const promptTextMentionSchema: z$1.ZodObject<{
@@ -4019,12 +4019,12 @@ declare const promptTextMentionSchema: z$1.ZodObject<{
4019
4019
  }>;
4020
4020
  name: z$1.ZodString;
4021
4021
  source: z$1.ZodEnum<{
4022
- command: "command";
4023
4022
  skill: "skill";
4023
+ command: "command";
4024
4024
  }>;
4025
4025
  origin: z$1.ZodEnum<{
4026
- project: "project";
4027
4026
  user: "user";
4027
+ project: "project";
4028
4028
  builtin: "builtin";
4029
4029
  }>;
4030
4030
  label: z$1.ZodString;
@@ -4084,12 +4084,12 @@ declare const promptInputSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
4084
4084
  }>;
4085
4085
  name: z$1.ZodString;
4086
4086
  source: z$1.ZodEnum<{
4087
- command: "command";
4088
4087
  skill: "skill";
4088
+ command: "command";
4089
4089
  }>;
4090
4090
  origin: z$1.ZodEnum<{
4091
- project: "project";
4092
4091
  user: "user";
4092
+ project: "project";
4093
4093
  builtin: "builtin";
4094
4094
  }>;
4095
4095
  label: z$1.ZodString;
@@ -4148,9 +4148,9 @@ declare const resolvedThreadExecutionOptionsSchema: z$1.ZodObject<{
4148
4148
  serviceTier: z$1.ZodString;
4149
4149
  reasoningLevel: z$1.ZodString;
4150
4150
  permissionMode: z$1.ZodEnum<{
4151
+ full: "full";
4151
4152
  auto: "auto";
4152
4153
  "accept-edits": "accept-edits";
4153
- full: "full";
4154
4154
  }>;
4155
4155
  source: z$1.ZodEnum<{
4156
4156
  "client/thread/start": "client/thread/start";
@@ -4165,9 +4165,9 @@ declare const projectExecutionDefaultsSchema: z$1.ZodObject<{
4165
4165
  serviceTier: z$1.ZodString;
4166
4166
  reasoningLevel: z$1.ZodString;
4167
4167
  permissionMode: z$1.ZodEnum<{
4168
+ full: "full";
4168
4169
  auto: "auto";
4169
4170
  "accept-edits": "accept-edits";
4170
- full: "full";
4171
4171
  }>;
4172
4172
  }, z$1.core.$strip>;
4173
4173
  type ProjectExecutionDefaults = z$1.infer<typeof projectExecutionDefaultsSchema>;
@@ -4206,9 +4206,9 @@ declare const providerInfoSchema: z$1.ZodObject<{
4206
4206
  supportsFork: z$1.ZodBoolean;
4207
4207
  supportsSessionRewind: z$1.ZodBoolean;
4208
4208
  permissionModes: z$1.ZodArray<z$1.ZodEnum<{
4209
+ full: "full";
4209
4210
  auto: "auto";
4210
4211
  "accept-edits": "accept-edits";
4211
- full: "full";
4212
4212
  }>>;
4213
4213
  modelCatalogScope: z$1.ZodEnum<{
4214
4214
  workspace: "workspace";
@@ -4243,8 +4243,8 @@ declare const providerInfoSchema: z$1.ZodObject<{
4243
4243
  }, z$1.core.$strip>;
4244
4244
  }, z$1.core.$strip>], "kind">>;
4245
4245
  completedTurnDisplay: z$1.ZodEnum<{
4246
- flat: "flat";
4247
4246
  collapse: "collapse";
4247
+ flat: "flat";
4248
4248
  }>;
4249
4249
  available: z$1.ZodBoolean;
4250
4250
  strings: z$1.ZodOptional<z$1.ZodObject<{
@@ -4348,9 +4348,9 @@ declare const threadQueuedMessageSchema: z$1.ZodObject<{
4348
4348
  }>>;
4349
4349
  originPluginId: z$1.ZodNullable<z$1.ZodString>;
4350
4350
  initiator: z$1.ZodEnum<{
4351
+ user: "user";
4351
4352
  system: "system";
4352
4353
  agent: "agent";
4353
- user: "user";
4354
4354
  }>;
4355
4355
  senderThreadId: z$1.ZodNullable<z$1.ZodString>;
4356
4356
  threadId: z$1.ZodString;
@@ -4396,12 +4396,12 @@ declare const threadQueuedMessageSchema: z$1.ZodObject<{
4396
4396
  }>;
4397
4397
  name: z$1.ZodString;
4398
4398
  source: z$1.ZodEnum<{
4399
- command: "command";
4400
4399
  skill: "skill";
4400
+ command: "command";
4401
4401
  }>;
4402
4402
  origin: z$1.ZodEnum<{
4403
- project: "project";
4404
4403
  user: "user";
4404
+ project: "project";
4405
4405
  builtin: "builtin";
4406
4406
  }>;
4407
4407
  label: z$1.ZodString;
@@ -4447,9 +4447,9 @@ declare const threadQueuedMessageSchema: z$1.ZodObject<{
4447
4447
  model: z$1.ZodString;
4448
4448
  reasoningLevel: z$1.ZodString;
4449
4449
  permissionMode: z$1.ZodEnum<{
4450
+ full: "full";
4450
4451
  auto: "auto";
4451
4452
  "accept-edits": "accept-edits";
4452
- full: "full";
4453
4453
  }>;
4454
4454
  serviceTier: z$1.ZodString;
4455
4455
  groupWithNext: z$1.ZodBoolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halcyonlabs/app",
3
- "version": "0.47.0-halcyon.582",
3
+ "version": "0.47.0-halcyon.584",
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": "Core change: a failed station update keeps outbound on instead of switching it off (#627)"
111
+ "summary": "Use Moonlet in the job-start failure message (#637)"
112
112
  },
113
113
  "license": "SEE LICENSE IN LICENSE"
114
114
  }
@@ -1,12 +1,12 @@
1
1
  {
2
- "commit": "61357130b4b93e46163a7e873acb08d7e0ce9862",
2
+ "commit": "a138158a1d47a15e6a68b789a26607e98254bda3",
3
3
  "file": "orbit-deploy",
4
4
  "platform": "linux-x64",
5
5
  "provenance": {
6
- "artifactId": 15308331469,
7
- "artifactName": "linux-bundle-61357130b4b93e46163a7e873acb08d7e0ce9862",
6
+ "artifactId": 15323631490,
7
+ "artifactName": "linux-bundle-a138158a1d47a15e6a68b789a26607e98254bda3",
8
8
  "repository": "matt0x6F/personalassistant",
9
- "runId": 46254608380,
9
+ "runId": 46292600685,
10
10
  "workflow": ".github/workflows/moonlet-linux-bundle.yml"
11
11
  },
12
12
  "schema": 1,
@@ -1 +1 @@
1
- 61357130b4b93e46163a7e873acb08d7e0ce9862
1
+ a138158a1d47a15e6a68b789a26607e98254bda3
@@ -1 +1 @@
1
- {"repository":"matt0x6F/personalassistant","revision":"61357130b4b93e46163a7e873acb08d7e0ce9862"}
1
+ {"repository":"matt0x6F/personalassistant","revision":"a138158a1d47a15e6a68b789a26607e98254bda3"}
@@ -1796,7 +1796,7 @@ ${Jy(c)}`}}),"run")}),"messages mark-read":Yg({summary:"Mark a message read (or
1796
1796
  `)}}}),"work show":gl({summary:"One station work item and its history",positionals:[{name:"key",description:"The work key",required:!0}],async run({positionals:u},f){let h=await d(f.threadId,Sf(u.key));if(!await a(f.threadId,h))throw new ga(`No accessible work item ${h.key}.`);let p=e.items.history(h.key).map(m=>` ${new Date(m.at).toISOString()} #${m.attempt} ${m.state.replaceAll("_"," ")}${m.detail?`: ${m.detail}`:""}`);return{exitCode:0,stdout:[E_(h),...p].join(`
1797
1797
  `)}}}),"work retry":gl({summary:"Start an item that needs a person again, as a new attempt",positionals:[{name:"key",description:"The work key",required:!0}],async run({positionals:u},f){let h=await d(f.threadId,Sf(u.key));if(!await a(f.threadId,h))throw new ga(`No accessible work item ${h.key}.`);try{let p=await e.answer(Sf(u.key),"retry");return{exitCode:0,stdout:E_(p)}}catch(p){throw new ga(p.message)}}}),"work first":gl({summary:"Put a queued start or waiting follow-up first in its station line",positionals:[{name:"key",description:"The work key",required:!0}],async run({positionals:u},f){await d(f.threadId,Sf(u.key));try{return{exitCode:0,stdout:E_(e.first(Sf(u.key)))}}catch(h){throw new ga(h.message)}}}),"work drop":gl({summary:"Cancel a queued start, or drop an item that needs a person",positionals:[{name:"key",description:"The work key",required:!0}],async run({positionals:u},f){let h=await d(f.threadId,Sf(u.key));if(!await a(f.threadId,h))throw new ga(`No accessible work item ${h.key}.`);try{let p=await e.answer(Sf(u.key),"drop");return{exitCode:0,stdout:E_(p)}}catch(p){throw new ga(p.message)}}})}}o(yte,"workCommands");import{cliCommand as JSe,PluginCliError as Af}from"@get-bb/plugin-sdk";var ZSe=500,QSe=new Set([yi,xt]);function eAe(e){return new Set(e.filter(t=>t.machineProviderId!==null&&QSe.has(t.machineProviderId)).map(t=>t.id))}o(eAe,"stationMachineIds");function tAe(e,t){if(e.exitCode!==0||typeof e.stdout!="string")throw new Af(`Memory ${t} failed: ${(e.stderr??e.stdout??"").trim()||`exit ${e.exitCode}`}`);let r=JSON.parse(e.stdout);if(r===null||typeof r!="object"||r.ok!==!0)throw new Af(`Memory ${t} answered in an unknown shape`);return r}o(tAe,"printed");function rAe(e){let t=e;if(t===null||typeof t!="object")throw new Af("Memory listed a record in an unknown shape");if(t.scope!=="global")return null;if(typeof t.id!="string"||typeof t.version!="number"||typeof t.name!="string"||typeof t.summary!="string"||typeof t.details!="string"||typeof t.kind!="string"||!Array.isArray(t.tags)||typeof t.importance!="number"||typeof t.pinned!="boolean"||typeof t.writeReason!="string"||t.sourceThreadId!==null&&typeof t.sourceThreadId!="string")throw new Af("Memory listed a global record in an unknown shape");return t}o(rAe,"globalMemory");async function nAe(e){let t=await e.allMemories(),r=eAe(await e.hosts()),n={checked:0,station:[],unknownThreads:[]};for(let s of t){let i=rAe(s);if(i===null)continue;n.checked+=1;let a=i.sourceThreadId;if(a===null)continue;let c=await e.threadPlace(a);if(c===null){n.unknownThreads.push({id:i.id,thread:a});continue}if(c.hostId===null||!r.has(c.hostId))continue;let l=c.projectId!==null&&await e.whollyOn(c.projectId,c.hostId)?c.projectId:null;n.station.push({memory:i,thread:a,hostId:c.hostId,target:l})}return n}o(nAe,"stationGlobals");function oAe(e){let t=`Moved from global memory by the owner. ${e.writeReason}`.slice(0,ZSe);return["add","--scope=project",`--name=${e.name}`,`--summary=${e.summary}`,`--details=${e.details}`,`--kind=${e.kind}`,...e.tags.map(r=>`--tag=${r}`),`--importance=${e.importance}`,...e.pinned?["--pinned"]:[],`--reason=${t}`,"--json"]}o(oAe,"moveArgv");async function sAe(e,t){if(t.target===null)throw new Af(`${t.memory.id}: its conversation's project isn't wholly on the station, so there's no station project to move it to`);let n=tAe(await e.memory(oAe(t.memory),t.target),"add").memory?.id;if(typeof n!="string")throw new Af(`${t.memory.id}: memory add answered without the new memory's id`);let s=await e.memory(["forget",t.memory.id,`--expected-version=${t.memory.version}`,"--reason=Moved into the station's own project by the owner","--json"]);return s.exitCode!==0?`${t.memory.id} \u2192 ${n} in ${t.target}, but the global copy is still there: ${(s.stderr??"").trim()||"forgetting it failed"}. Forget it in Memory settings.`:`${t.memory.id} \u2192 ${n} in ${t.target}`}o(sAe,"moveStationGlobal");function iAe(e){let t=e.target===null?"can't be moved: its conversation's project isn't wholly on the station":`moves to ${e.target}`;return`${e.memory.id} ${e.memory.name} (saved by ${e.thread}): ${t}`}o(iAe,"describe");function wte(e){return{"station memory":JSe({summary:"List global memories a station's conversations saved, and move them into that station's own project (owner only)",aliases:["memory station-globals"],options:{move:{type:"string",repeatable:!0,split:",",placeholder:"ID",description:"Move this memory into its station project, then forget the global copy; repeat or comma-separate"},json:{type:"boolean",description:"As JSON"}},async run({options:t},r){await e.requireUser(r.threadId);let n=await nAe(e),s=t.move??[];if(s.length===0){if(t.json)return{exitCode:0,stdout:JSON.stringify(n)};let l=[n.station.length===0?"No global memory was saved by a station's conversation.":`Saved by a station's conversation (${n.station.length}):`,...n.station.map(d=>`- ${iAe(d)}`),...n.unknownThreads.length?[`Saved by conversations that no longer exist (${n.unknownThreads.length}), so their machine is unknown:`,...n.unknownThreads.map(d=>`- ${d.id} (${d.thread})`)]:[],`Checked ${n.checked} global memories.`];return n.station.some(d=>d.target!==null)&&l.push("Move one with: moonlet station memory --move <id>"),{exitCode:0,stdout:l.join(`
1798
1798
  `)}}let i=new Map(n.station.map(l=>[l.memory.id,l])),a=s.filter(l=>!i.has(l));if(a.length)throw new Af(`Not a global memory saved by a station's conversation: ${a.join(", ")}`);let c=[];for(let l of s)c.push(await sAe(e,i.get(l)));return{exitCode:0,stdout:t.json?JSON.stringify({moved:c}):c.join(`
1799
- `)}}})}}o(wte,"memoryCommands");var Jg=4e3;function kte(e){let t=o(M=>e.projects.resolve(M).catch(z=>{throw new je(z.message)}),"resolveProject"),{bb:r,wakeCounts:n,work:s,drains:i,settings:a,stations:c,scheduler:l,upkeep:d,notices:u,orbitConfig:f,ownerChanges:h,gate:p,relay:m,messages:g,threads:y,stationHosts:w,clock:k,zone:E,backThread:v,readAvatar:x,requireUser:A,requireUserOrOrbit:$,requireOrbitThread:_,requireOrbitConversation:T,orbitStationName:b,orbitSection:S,orbitThread:O,routeTargets:C,ensureProjectAt:I,syncStations:P}=e;async function N(M){if(M&&await _(M).catch(()=>null))return{kind:"orbit"};try{await A(M)}catch{throw new je("Only the Moonlet conversation, or the owner on their own machine, follows change requests.")}return{kind:"owner"}}o(N,"changesCaller");let D=o(()=>E().catch(()=>null),"settingsZone"),B=o((M,z,G)=>u.notify([{type:M,text:z}],void 0,G),"notify"),Y=o((M,z)=>z===M?void 0:z,"askedFrom"),ee=pO(r),H=o(async M=>{let z=await xg(r,a);if(!z||M!==z)throw new je("Only the current background conversation starts background work.");return z},"requireBackground"),F=o(async M=>{M&&M===await xg(r,a)||await $(M)},"requireUpkeep");function ie(M,z,G){return{origin:"plugin",originPluginId:r.pluginId,projectId:z,environment:{type:"host",hostId:M.id,workspace:{type:"unmanaged",path:M.folder}},startedOnBehalfOf:null,originKind:null,...G}}o(ie,"stationRequest");let ve=o(M=>[{type:"text",text:M,mentions:[]}],"text"),ye=180*6e4,ke=o(()=>{let{identity:M}=f.prefs();return{owner:nr(M,"the owner"),nickname:Qr(M)}},"chatNames");async function V(M){let[z,G]=await Promise.all([r.sdk.threads.get({threadId:M}).catch(()=>null),r.sdk.threads.defaultExecutionOptions({threadId:M}).catch(()=>null)]);return z&&z.archivedAt===null&&z.deletedAt===null?{thread:z,execution:G}:null}o(V,"threadFacts");async function Q(M){let z=Date.now(),G=(await Promise.all(y.notDone(M).map(async me=>{let Ae=await V(me.thread_id);return Ae?{id:me.thread_id,title:Ae.thread.title??IR(me.root_text),model:Ae.execution?.model??null,effort:Ae.execution?.reasoningLevel??null,openedAt:me.created_at,lastAt:me.last_activity_at}:null}))).filter(me=>me!==null),te=new Set(G.map(me=>me.id)),we=new Set([M]),L=await v();L&&we.add(L);let J=new Set((await C()).filter(me=>!me.own).map(me=>me.id)),W=o(async me=>(await r.sdk.threads.get({threadId:me}).catch(()=>null))?.parentThreadId??null,"parentOf"),Z=o(async me=>{let Ae=s.items.list(me).filter(re=>re.thread!==null&&!te.has(re.thread)),Be=await Promise.all(Ae.map(re=>GB(re,we,J,W)));return Ae.filter((re,fe)=>Be[fe])},"others"),ue=(await Promise.all((await Z(["queued","admitted","running","sharing","waiting","cut_off"])).map(async me=>{let Ae=await V(me.thread);return Ae?{id:me.thread,title:Ae.thread.title??me.key,model:Ae.execution?.model??null,since:me.queuedAt}:null}))).filter(me=>me!==null),he=(await Promise.all((await Z(["parked","disposed"])).filter(me=>z-me.updatedAt<=ye).sort((me,Ae)=>Ae.updatedAt-me.updatedAt).slice(0,5).map(async me=>{let Ae=await r.sdk.threads.get({threadId:me.thread}).catch(()=>null);return{id:me.thread,title:Ae?.title??me.key,endedAt:me.updatedAt}}))).filter(me=>me!==null);return{mine:G,background:ue,finished:he}}o(Q,"chatLedger");async function se(M){if(y.taken(M.moonlet,M.seq))throw new Error(`message ${M.seq} already has a thread`);let z=await ei(r),G=(await C()).find(ue=>ue.id===z?.hostId&&!ue.own);if(!G)throw new Error("the conversation's station isn't listed");let te=await e.modelPicks.forTarget(G),we=Tu(te.provider,!1,G.codex);if(we)throw new Error(we);let L=C2({words:M.words,recent:M.recent,names:ke()}),J=await p.approveRoute({thread:M.moonlet,station:G.name,from:G.name,what:"spawn",title:M.title,brief:L,provider:te.provider,...te.model?{model:te.model}:{},wait:!1});if(J.decision!=="allow")throw new Error(J.reason??"not allowed");let W=await I(G.id,G.folder,FO(G),!0);e.modelPicks.started(G,te.provider);let Z=await s.start({key:BN(),class:"asked",station:{hostId:G.id,projectIds:new Set([W])},body:ie(G,W,{title:J.title,input:ve(J.brief),...so(te.provider,!0,"work"),...te.model?{model:te.model}:{},reasoningLevel:te.effort,parentThreadId:M.moonlet,parentNotifications:"off",visibility:"visible"})});if(!Z.thread)throw new Error("bb didn't start it");return await y.adopt(M.moonlet,M.seq,M.words,Z.thread),{id:Z.thread,lead:`${te.model??te.provider} at ${te.effort} effort`}}o(se,"startChatWork");let ne=null,j=o(()=>ne??=D2(De(r),{names:ke,zone:o(async()=>await D()??Sn,"zone"),model:o(()=>MT(f.prefs().models),"model"),recent:o(M=>b2(r,M),"recent"),ledger:Q,startWork:se,async pass(M,z){await r.sdk.threads.send({threadId:M,input:[{type:"text",text:z,mentions:[]}],mode:"steer-if-active"}),await y.replied(M).catch(G=>r.log.warn(`counting the owner's words passed on: ${G.message}`))},async stop(M,z){s.items.byThread(M).some(G=>G.state==="cut_off")?await r.sdk.threads.archive({threadId:M}):await r.sdk.threads.stop({threadId:M}),y.notDone(z).some(G=>G.thread_id===M)&&await y.done(M,z)},now:o(()=>Date.now(),"now"),warn:o(M=>r.log.warn(M),"warn")}),"router"),R=o(M=>gte(s.items,{environments:o((z,G,te)=>r.sdk.environments.list({environmentProviderId:wn,status:G,limit:100,offset:te,...z?{hostId:z}:{}}),"environments"),threads:o((z,G)=>r.sdk.threads.list({environmentId:z,archived:!1,includeHidden:!0,limit:100,offset:G}),"threads")},M),"untracked");async function U(M){let z=await e.delivery.read(M.name),G=z?.stage==="installer"&&z.endedAt===null?await i.holding(M.id).catch(()=>null):null,te=G?await T_(s,G,Date.now(),R).catch(()=>null):null,we=G&&te?{lease:G.id,startedAt:G.startedAt,proceed:te.proceed,running:te.running,threads:[...s.items.list(["admitted","running"]).filter(L=>G.host===null||L.host===G.host).flatMap(L=>L.thread?[L.thread]:[]),...te.untracked.map(L=>L.slice(7))]}:null;return{record:z,line:z7(M.name,z,we)}}o(U,"deliveryStatus");async function q(M,z,G,te,we){if(te&&we)throw new je("Name a task or a system work record, not both");!te&&!we&&/^(review|merge-reviewed):/.test(M)&&(we=(await da(r).change({action:"create",key:M,kind:"work",title:z,description:G,labels:["event-service"],parent:null},"system:review-start")).id);let L=await v();if(!L)throw new je("The background work station is unavailable.");let J=await fetch(`${r.server.loopbackBaseUrl}/api/v1/threads/${L}?include=environment`);if(!J.ok)throw new je("The background work station is unavailable.");let W=await J.json(),Z=(await C()).find(Ae=>Ae.id===W.environment?.hostId&&!Ae.own);if(!Z)throw new je("The background work station is unavailable.");let ue=await e.modelPicks.forTarget(Z),he=Tu(ue.provider,!1,Z.codex);if(he)throw new je(he);let me=await I(Z.id,Z.folder,FO(Z),!Z.own);return e.modelPicks.started(Z,ue.provider),s.start({key:M,class:"background",loop:te,record:we,station:{hostId:Z.id,projectIds:new Set([me])},body:ie(Z,me,{title:z,input:ve(G),...so(ue.provider,!0,"work"),model:ue.model,reasoningLevel:ue.effort,parentThreadId:L,visibility:"hidden"})})}o(q,"spawnBackground");let X=YJ(r,{start:q}),oe=Nee({requireUser:A,backThread:v,orbitConversationOf:e.orbitConversationOf,parentOf:o(async M=>(await r.sdk.threads.get({threadId:M}).catch(()=>null))?.parentThreadId??null,"parentOf"),onStation:o(async M=>{let z=await r.sdk.threads.get({threadId:M}).catch(()=>null),G=z?.environmentId?await r.sdk.environments.get({environmentId:z.environmentId}).catch(()=>null):null;return!!G&&(await w()).some(te=>te.id===G.hostId)},"onStation"),onListedMachine:o(async M=>{let z=await r.sdk.threads.get({threadId:M}).catch(()=>null),G=z?.environmentId?await r.sdk.environments.get({environmentId:z.environmentId}).catch(()=>null):null;return!!G&&(await C()).some(te=>te.own&&te.id===G.hostId)},"onListedMachine")});return r.cli.register(aAe({name:"orbit",summary:"Moonlet: station's credentials and status",internal_DO_NOT_USE_topLevel:MO,internal_DO_NOT_USE_pluginOnly:BO,commands:{...Iee(r),...Cee(r,oe),...qee(r,oe),...xee(r,$),...yte(s,async M=>{if(!M)return await A(M),null;if(M===await O()||M===await v())return null;let z=await r.sdk.threads.get({threadId:M}),G=z.environmentId?await r.sdk.environments.get({environmentId:z.environmentId}):null;if(G&&(await w()).some(te=>te.id===G.hostId))return G.hostId;throw new je("Work commands are called by the owner or an assistant on its own station.")},i,A,async M=>(await w()).find(z=>z.name===M)?.id??null,R,async(M,z)=>{let G=await e.orbitConversationOf(M);if(!G)return!0;if(M!==G.orbit)return!1;let te=new Set([G.orbit]),we=await v();we&&te.add(we);let L=new Set((await C()).filter(J=>!J.own).map(J=>J.id));return GB(z,te,L,async J=>(await r.sdk.threads.get({threadId:J}).catch(()=>null))?.parentThreadId??null)}),...tte(g),...ite(e),...Yee({...e.artifacts}),...wte({requireUser:A,async allMemories(){let M=await fetch(`${r.server.loopbackBaseUrl}/api/v1/plugins/memory/rpc/listMemories`,{method:"POST",headers:{"content-type":"application/json"},body:"null"});if(!M.ok)throw new je(`Moonlet memory isn't answering (HTTP ${M.status}); is the Memory plugin installed and running?`);let z=await M.json();if(z.ok!==!0||!Array.isArray(z.result?.memories))throw new je("moonlet memory listed its memories in an unknown shape");return z.result.memories},async memory(M,z){let G=await fetch(`${r.server.loopbackBaseUrl}/api/v1/plugins/memory/cli`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(z===void 0?{argv:M}:{argv:M,projectId:z})});if(!G.ok)throw new je(`Moonlet memory isn't answering (HTTP ${G.status}); is the Memory plugin installed and running?`);return await G.json()},async threadPlace(M){let z=await fetch(`${r.server.loopbackBaseUrl}/api/v1/threads/${M}?include=environment`);if(z.status===404)return null;if(!z.ok)throw new je(`Moonlet couldn't say where ${M} ran (HTTP ${z.status})`);let G=await z.json(),te=(G.thread??G).projectId,we=G.environment?.hostId;return{hostId:typeof we=="string"?we:null,projectId:typeof te=="string"?te:null}},hosts:o(async()=>(await r.sdk.hosts.list()).map(M=>({id:M.id,machineProviderId:M.machineProviderId??null})),"hosts"),async whollyOn(M,z){let G=(await r.sdk.projects.list()).find(te=>te.id===M);return!!G&&G.sources.length>0&&G.sources.every(te=>te.hostId===z)}}),...Qee({welcome:e.welcome,requireUser:A,changed:o(()=>r.realtime.publish("config",{changed:!0}),"changed")}),...v7({store:e.userland,scripts:{run:o(M=>e.scheduler.runScript(M),"run"),data:o((M,z)=>e.scheduler.readScriptData(M,z),"data"),history:o(M=>e.scheduler.scripts.history(M),"history"),digest:o(M=>e.scheduler.scripts.digestPending(M),"digest")},orbitConversationOf:e.orbitConversationOf,requireUser:A,stationThread:o(async M=>{let z=await fetch(`${r.server.loopbackBaseUrl}/api/v1/threads/${M}?include=environment`),G=z.ok?(await z.json()).environment?.hostId:void 0;return!!G&&(await w()).some(te=>te.id===G)},"stationThread")}),"station secret set":ft({summary:"Store station's credentials (values are read from stdin, never arguments)",aliases:["secret set"],options:{tailscale:{type:"string",stdin:!0,description:"Tailscale OAuth client secret (--tailscale-stdin)"},claude:{type:"string",stdin:!0,description:"Claude Code token from `claude setup-token` (--claude-stdin)"},onepassword:{type:"string",stdin:!0,description:"1Password service account token (--onepassword-stdin)"},calendar:{type:"string",stdin:!0,description:"The calendar's private https:// .ics link (--calendar-stdin); it stays on the server and every station gets only what's on the calendar"}},async run({options:M},z){await A(z.threadId);let G={};if(M.tailscale!==void 0){let J=M.tailscale.trim();if(!oz(J))throw new je("That isn't a Tailscale credential (tskey-\u2026).");G.tailscaleSecret=J}if(M.claude!==void 0){let J=M.claude.trim();if(!/^sk-ant-[A-Za-z0-9_-]+$/.test(J))throw new je("That isn't a Claude Code token (sk-ant-\u2026).");G.claudeToken=J}if(M.onepassword!==void 0){let J=M.onepassword.trim();if(!/^ops_[A-Za-z0-9_-]+$/.test(J))throw new je("That isn't a 1Password service account token (ops_\u2026).");G.onePasswordToken=J}if(M.calendar!==void 0)try{G.calendarLink=nO("calendar",M.calendar)}catch(J){throw new je(zB(J)??String(J))}let te=Object.keys(G);if(te.length===0)throw new je("Pass --tailscale-stdin, --claude-stdin, --onepassword-stdin or --calendar-stdin.");await a.experimental_set(G);let we=`Stored ${te.join(" and ")}.${G.onePasswordToken?" Stations fetch the new 1Password token on their next use of it.":""}`;if(G.calendarLink===void 0)return{exitCode:0,stdout:we};let L=await HB(e.welcome);return{exitCode:L.exitCode,stdout:`${we}
1799
+ `)}}})}}o(wte,"memoryCommands");var Jg=4e3;function kte(e){let t=o(M=>e.projects.resolve(M).catch(z=>{throw new je(z.message)}),"resolveProject"),{bb:r,wakeCounts:n,work:s,drains:i,settings:a,stations:c,scheduler:l,upkeep:d,notices:u,orbitConfig:f,ownerChanges:h,gate:p,relay:m,messages:g,threads:y,stationHosts:w,clock:k,zone:E,backThread:v,readAvatar:x,requireUser:A,requireUserOrOrbit:$,requireOrbitThread:_,requireOrbitConversation:T,orbitStationName:b,orbitSection:S,orbitThread:O,routeTargets:C,ensureProjectAt:I,syncStations:P}=e;async function N(M){if(M&&await _(M).catch(()=>null))return{kind:"orbit"};try{await A(M)}catch{throw new je("Only the Moonlet conversation, or the owner on their own machine, follows change requests.")}return{kind:"owner"}}o(N,"changesCaller");let D=o(()=>E().catch(()=>null),"settingsZone"),B=o((M,z,G)=>u.notify([{type:M,text:z}],void 0,G),"notify"),Y=o((M,z)=>z===M?void 0:z,"askedFrom"),ee=pO(r),H=o(async M=>{let z=await xg(r,a);if(!z||M!==z)throw new je("Only the current background conversation starts background work.");return z},"requireBackground"),F=o(async M=>{M&&M===await xg(r,a)||await $(M)},"requireUpkeep");function ie(M,z,G){return{origin:"plugin",originPluginId:r.pluginId,projectId:z,environment:{type:"host",hostId:M.id,workspace:{type:"unmanaged",path:M.folder}},startedOnBehalfOf:null,originKind:null,...G}}o(ie,"stationRequest");let ve=o(M=>[{type:"text",text:M,mentions:[]}],"text"),ye=180*6e4,ke=o(()=>{let{identity:M}=f.prefs();return{owner:nr(M,"the owner"),nickname:Qr(M)}},"chatNames");async function V(M){let[z,G]=await Promise.all([r.sdk.threads.get({threadId:M}).catch(()=>null),r.sdk.threads.defaultExecutionOptions({threadId:M}).catch(()=>null)]);return z&&z.archivedAt===null&&z.deletedAt===null?{thread:z,execution:G}:null}o(V,"threadFacts");async function Q(M){let z=Date.now(),G=(await Promise.all(y.notDone(M).map(async me=>{let Ae=await V(me.thread_id);return Ae?{id:me.thread_id,title:Ae.thread.title??IR(me.root_text),model:Ae.execution?.model??null,effort:Ae.execution?.reasoningLevel??null,openedAt:me.created_at,lastAt:me.last_activity_at}:null}))).filter(me=>me!==null),te=new Set(G.map(me=>me.id)),we=new Set([M]),L=await v();L&&we.add(L);let J=new Set((await C()).filter(me=>!me.own).map(me=>me.id)),W=o(async me=>(await r.sdk.threads.get({threadId:me}).catch(()=>null))?.parentThreadId??null,"parentOf"),Z=o(async me=>{let Ae=s.items.list(me).filter(re=>re.thread!==null&&!te.has(re.thread)),Be=await Promise.all(Ae.map(re=>GB(re,we,J,W)));return Ae.filter((re,fe)=>Be[fe])},"others"),ue=(await Promise.all((await Z(["queued","admitted","running","sharing","waiting","cut_off"])).map(async me=>{let Ae=await V(me.thread);return Ae?{id:me.thread,title:Ae.thread.title??me.key,model:Ae.execution?.model??null,since:me.queuedAt}:null}))).filter(me=>me!==null),he=(await Promise.all((await Z(["parked","disposed"])).filter(me=>z-me.updatedAt<=ye).sort((me,Ae)=>Ae.updatedAt-me.updatedAt).slice(0,5).map(async me=>{let Ae=await r.sdk.threads.get({threadId:me.thread}).catch(()=>null);return{id:me.thread,title:Ae?.title??me.key,endedAt:me.updatedAt}}))).filter(me=>me!==null);return{mine:G,background:ue,finished:he}}o(Q,"chatLedger");async function se(M){if(y.taken(M.moonlet,M.seq))throw new Error(`message ${M.seq} already has a thread`);let z=await ei(r),G=(await C()).find(ue=>ue.id===z?.hostId&&!ue.own);if(!G)throw new Error("the conversation's station isn't listed");let te=await e.modelPicks.forTarget(G),we=Tu(te.provider,!1,G.codex);if(we)throw new Error(we);let L=C2({words:M.words,recent:M.recent,names:ke()}),J=await p.approveRoute({thread:M.moonlet,station:G.name,from:G.name,what:"spawn",title:M.title,brief:L,provider:te.provider,...te.model?{model:te.model}:{},wait:!1});if(J.decision!=="allow")throw new Error(J.reason??"not allowed");let W=await I(G.id,G.folder,FO(G),!0);e.modelPicks.started(G,te.provider);let Z=await s.start({key:BN(),class:"asked",station:{hostId:G.id,projectIds:new Set([W])},body:ie(G,W,{title:J.title,input:ve(J.brief),...so(te.provider,!0,"work"),...te.model?{model:te.model}:{},reasoningLevel:te.effort,parentThreadId:M.moonlet,parentNotifications:"off",visibility:"visible"})});if(!Z.thread)throw new Error("Moonlet didn't start it");return await y.adopt(M.moonlet,M.seq,M.words,Z.thread),{id:Z.thread,lead:`${te.model??te.provider} at ${te.effort} effort`}}o(se,"startChatWork");let ne=null,j=o(()=>ne??=D2(De(r),{names:ke,zone:o(async()=>await D()??Sn,"zone"),model:o(()=>MT(f.prefs().models),"model"),recent:o(M=>b2(r,M),"recent"),ledger:Q,startWork:se,async pass(M,z){await r.sdk.threads.send({threadId:M,input:[{type:"text",text:z,mentions:[]}],mode:"steer-if-active"}),await y.replied(M).catch(G=>r.log.warn(`counting the owner's words passed on: ${G.message}`))},async stop(M,z){s.items.byThread(M).some(G=>G.state==="cut_off")?await r.sdk.threads.archive({threadId:M}):await r.sdk.threads.stop({threadId:M}),y.notDone(z).some(G=>G.thread_id===M)&&await y.done(M,z)},now:o(()=>Date.now(),"now"),warn:o(M=>r.log.warn(M),"warn")}),"router"),R=o(M=>gte(s.items,{environments:o((z,G,te)=>r.sdk.environments.list({environmentProviderId:wn,status:G,limit:100,offset:te,...z?{hostId:z}:{}}),"environments"),threads:o((z,G)=>r.sdk.threads.list({environmentId:z,archived:!1,includeHidden:!0,limit:100,offset:G}),"threads")},M),"untracked");async function U(M){let z=await e.delivery.read(M.name),G=z?.stage==="installer"&&z.endedAt===null?await i.holding(M.id).catch(()=>null):null,te=G?await T_(s,G,Date.now(),R).catch(()=>null):null,we=G&&te?{lease:G.id,startedAt:G.startedAt,proceed:te.proceed,running:te.running,threads:[...s.items.list(["admitted","running"]).filter(L=>G.host===null||L.host===G.host).flatMap(L=>L.thread?[L.thread]:[]),...te.untracked.map(L=>L.slice(7))]}:null;return{record:z,line:z7(M.name,z,we)}}o(U,"deliveryStatus");async function q(M,z,G,te,we){if(te&&we)throw new je("Name a task or a system work record, not both");!te&&!we&&/^(review|merge-reviewed):/.test(M)&&(we=(await da(r).change({action:"create",key:M,kind:"work",title:z,description:G,labels:["event-service"],parent:null},"system:review-start")).id);let L=await v();if(!L)throw new je("The background work station is unavailable.");let J=await fetch(`${r.server.loopbackBaseUrl}/api/v1/threads/${L}?include=environment`);if(!J.ok)throw new je("The background work station is unavailable.");let W=await J.json(),Z=(await C()).find(Ae=>Ae.id===W.environment?.hostId&&!Ae.own);if(!Z)throw new je("The background work station is unavailable.");let ue=await e.modelPicks.forTarget(Z),he=Tu(ue.provider,!1,Z.codex);if(he)throw new je(he);let me=await I(Z.id,Z.folder,FO(Z),!Z.own);return e.modelPicks.started(Z,ue.provider),s.start({key:M,class:"background",loop:te,record:we,station:{hostId:Z.id,projectIds:new Set([me])},body:ie(Z,me,{title:z,input:ve(G),...so(ue.provider,!0,"work"),model:ue.model,reasoningLevel:ue.effort,parentThreadId:L,visibility:"hidden"})})}o(q,"spawnBackground");let X=YJ(r,{start:q}),oe=Nee({requireUser:A,backThread:v,orbitConversationOf:e.orbitConversationOf,parentOf:o(async M=>(await r.sdk.threads.get({threadId:M}).catch(()=>null))?.parentThreadId??null,"parentOf"),onStation:o(async M=>{let z=await r.sdk.threads.get({threadId:M}).catch(()=>null),G=z?.environmentId?await r.sdk.environments.get({environmentId:z.environmentId}).catch(()=>null):null;return!!G&&(await w()).some(te=>te.id===G.hostId)},"onStation"),onListedMachine:o(async M=>{let z=await r.sdk.threads.get({threadId:M}).catch(()=>null),G=z?.environmentId?await r.sdk.environments.get({environmentId:z.environmentId}).catch(()=>null):null;return!!G&&(await C()).some(te=>te.own&&te.id===G.hostId)},"onListedMachine")});return r.cli.register(aAe({name:"orbit",summary:"Moonlet: station's credentials and status",internal_DO_NOT_USE_topLevel:MO,internal_DO_NOT_USE_pluginOnly:BO,commands:{...Iee(r),...Cee(r,oe),...qee(r,oe),...xee(r,$),...yte(s,async M=>{if(!M)return await A(M),null;if(M===await O()||M===await v())return null;let z=await r.sdk.threads.get({threadId:M}),G=z.environmentId?await r.sdk.environments.get({environmentId:z.environmentId}):null;if(G&&(await w()).some(te=>te.id===G.hostId))return G.hostId;throw new je("Work commands are called by the owner or an assistant on its own station.")},i,A,async M=>(await w()).find(z=>z.name===M)?.id??null,R,async(M,z)=>{let G=await e.orbitConversationOf(M);if(!G)return!0;if(M!==G.orbit)return!1;let te=new Set([G.orbit]),we=await v();we&&te.add(we);let L=new Set((await C()).filter(J=>!J.own).map(J=>J.id));return GB(z,te,L,async J=>(await r.sdk.threads.get({threadId:J}).catch(()=>null))?.parentThreadId??null)}),...tte(g),...ite(e),...Yee({...e.artifacts}),...wte({requireUser:A,async allMemories(){let M=await fetch(`${r.server.loopbackBaseUrl}/api/v1/plugins/memory/rpc/listMemories`,{method:"POST",headers:{"content-type":"application/json"},body:"null"});if(!M.ok)throw new je(`Moonlet memory isn't answering (HTTP ${M.status}); is the Memory plugin installed and running?`);let z=await M.json();if(z.ok!==!0||!Array.isArray(z.result?.memories))throw new je("moonlet memory listed its memories in an unknown shape");return z.result.memories},async memory(M,z){let G=await fetch(`${r.server.loopbackBaseUrl}/api/v1/plugins/memory/cli`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(z===void 0?{argv:M}:{argv:M,projectId:z})});if(!G.ok)throw new je(`Moonlet memory isn't answering (HTTP ${G.status}); is the Memory plugin installed and running?`);return await G.json()},async threadPlace(M){let z=await fetch(`${r.server.loopbackBaseUrl}/api/v1/threads/${M}?include=environment`);if(z.status===404)return null;if(!z.ok)throw new je(`Moonlet couldn't say where ${M} ran (HTTP ${z.status})`);let G=await z.json(),te=(G.thread??G).projectId,we=G.environment?.hostId;return{hostId:typeof we=="string"?we:null,projectId:typeof te=="string"?te:null}},hosts:o(async()=>(await r.sdk.hosts.list()).map(M=>({id:M.id,machineProviderId:M.machineProviderId??null})),"hosts"),async whollyOn(M,z){let G=(await r.sdk.projects.list()).find(te=>te.id===M);return!!G&&G.sources.length>0&&G.sources.every(te=>te.hostId===z)}}),...Qee({welcome:e.welcome,requireUser:A,changed:o(()=>r.realtime.publish("config",{changed:!0}),"changed")}),...v7({store:e.userland,scripts:{run:o(M=>e.scheduler.runScript(M),"run"),data:o((M,z)=>e.scheduler.readScriptData(M,z),"data"),history:o(M=>e.scheduler.scripts.history(M),"history"),digest:o(M=>e.scheduler.scripts.digestPending(M),"digest")},orbitConversationOf:e.orbitConversationOf,requireUser:A,stationThread:o(async M=>{let z=await fetch(`${r.server.loopbackBaseUrl}/api/v1/threads/${M}?include=environment`),G=z.ok?(await z.json()).environment?.hostId:void 0;return!!G&&(await w()).some(te=>te.id===G)},"stationThread")}),"station secret set":ft({summary:"Store station's credentials (values are read from stdin, never arguments)",aliases:["secret set"],options:{tailscale:{type:"string",stdin:!0,description:"Tailscale OAuth client secret (--tailscale-stdin)"},claude:{type:"string",stdin:!0,description:"Claude Code token from `claude setup-token` (--claude-stdin)"},onepassword:{type:"string",stdin:!0,description:"1Password service account token (--onepassword-stdin)"},calendar:{type:"string",stdin:!0,description:"The calendar's private https:// .ics link (--calendar-stdin); it stays on the server and every station gets only what's on the calendar"}},async run({options:M},z){await A(z.threadId);let G={};if(M.tailscale!==void 0){let J=M.tailscale.trim();if(!oz(J))throw new je("That isn't a Tailscale credential (tskey-\u2026).");G.tailscaleSecret=J}if(M.claude!==void 0){let J=M.claude.trim();if(!/^sk-ant-[A-Za-z0-9_-]+$/.test(J))throw new je("That isn't a Claude Code token (sk-ant-\u2026).");G.claudeToken=J}if(M.onepassword!==void 0){let J=M.onepassword.trim();if(!/^ops_[A-Za-z0-9_-]+$/.test(J))throw new je("That isn't a 1Password service account token (ops_\u2026).");G.onePasswordToken=J}if(M.calendar!==void 0)try{G.calendarLink=nO("calendar",M.calendar)}catch(J){throw new je(zB(J)??String(J))}let te=Object.keys(G);if(te.length===0)throw new je("Pass --tailscale-stdin, --claude-stdin, --onepassword-stdin or --calendar-stdin.");await a.experimental_set(G);let we=`Stored ${te.join(" and ")}.${G.onePasswordToken?" Stations fetch the new 1Password token on their next use of it.":""}`;if(G.calendarLink===void 0)return{exitCode:0,stdout:we};let L=await HB(e.welcome);return{exitCode:L.exitCode,stdout:`${we}
1800
1800
  ${L.stdout}`}}}),"welcome show":ft({summary:"Show first run's saved answers: which steps are saved, and whether it's finished (--json: the saved answers)",options:{json:{type:"boolean",description:"Print the saved answers as JSON"}},async run({options:M},z){return await A(z.threadId),dte(e.welcome,M.json===!0)}}),"welcome save":ft({summary:`Save one step's answers, as first run and Settings do (steps: ${xs.join(", ")})`,description:["The JSON names the step's part:",' you: {"you":{"name":"Sam","email":"sam@example.com","place":{\u2026}}}, where place is one of `moonlet welcome places <city>`\'s answers (it sets the time zone)',' reach: {"reach":{"inbox":true,"mail":false,"other":["Signal"]}}, optionally with quiet_from and quiet_to ("22:00")',' touchpoints: {"touchpoints":{"morning":{"on":true,"at":"07:00",\u2026},"evening":{\u2026},"weekly":{\u2026}}}',` connections: {"contacts":[{"name":"Amy","email":"amy@example.com","relation":"friend"}]}; saving it hands the contacts to every station and fails if any didn't get them`," library: no answers; documents go in with the file commands, as on the Library page","A wrong step or answer is refused with what's wrong. Only the owner's own machine runs these; a station is refused."].join(`
1801
1801
  `),positionals:[{name:"step",description:"The step",required:!0}],options:{values:{type:"string",stdin:!0,description:`The step's answers as one line of JSON, e.g. {"you":{"name":"Sam"}} (or --values-stdin)`}},async run({positionals:M,options:z},G){return await A(G.threadId),VB(()=>ute(e.welcome,String(M.step),z.values))}}),"welcome places":ft({summary:"The places a city's name could mean, best first, as JSON (for the you step's place)",positionals:[{name:"query",description:"The city",required:!0}],async run({positionals:M},z){return await A(z.threadId),VB(()=>pte(e.welcome,String(M.query)))}}),"welcome handover":ft({summary:"Hand the contacts and the calendar to every station again, and say how each went",async run(M,z){return await A(z.threadId),HB(e.welcome)}}),"welcome finish":ft({summary:"Finish first run: tell your moonlet's conversation what was saved, once (now, or when its conversation starts)",description:"It says what was saved and what was skipped, once, and only then marks first run finished. With no conversation yet it says so and leaves it open; finishing again sends nothing. `moonlet status` ends with a Welcome: line saying where it stands.",async run(M,z){await A(z.threadId);let G=await VB(()=>fte(e.welcome));return r.realtime.publish("config",{changed:!0}),G}}),"welcome reopen":ft({summary:"Set up again: open first run in Moonlet again, keeping its answers",async run(M,z){await A(z.threadId);let G=await hte(e.welcome);return r.realtime.publish("config",{changed:!0}),G}}),"station sync":ft({summary:"Give every connected station its project and its broker's credentials",async run(){let M=await P();return{exitCode:M.some(z=>z.includes("failed"))?1:0,stdout:M.join(`
1802
1802
  `)||"No connected stations."}}}),"route prepare":ft({summary:"From the Moonlet conversation's turn hook: whether the text it got is the owner's new message, and if so what to read to decide where it goes",options:{prompt:{type:"string",stdin:!0,description:"The text the hook got, on one line (\\n for a line break; or --prompt-stdin)"}},async run({options:M},z){let{orbit:G,thread:te}=await T(z.threadId);return te!==G?{exitCode:0,stdout:JSON.stringify({route:!1})}:{exitCode:0,stdout:JSON.stringify(await j().prepare(G,yn(M.prompt??"")))}}}),"route apply":ft({summary:"From the Moonlet conversation's turn hook: carry out where the owner's message <seq> goes, and say what to tell them",options:{seq:{type:"string",description:"The owner's message number, from the first step"},decision:{type:"string",stdin:!0,description:"Where it goes, as one line of JSON (or --decision-stdin)"}},async run({options:M},z){let{orbit:G,thread:te}=await T(z.threadId);if(te!==G)throw new je("Only the Moonlet conversation decides where the owner's messages go.");let we=Number(M.seq);if(!M.seq||!/^(0|[1-9][0-9]*)$/.test(M.seq)||!Number.isSafeInteger(we))throw new je("Pass the message: --seq <n>.");let L;try{L=JSON.parse(M.decision??"")}catch{L={unread:"it wasn't JSON"}}return{exitCode:0,stdout:await j().apply(G,we,L)}}}),"thread close":ft({summary:"From a work thread on the home conversation: close it with one line on how it ended, shown under its message in the main conversation",options:{outcome:{type:"string",stdin:!0,description:"How it ended, on one line ('\u2026'; or --outcome-stdin)"}},async run({options:M},z){if(!y.workThread(z.threadId))throw new je("Only a work thread on the home conversation closes itself; a thread of the Moonlet conversation says its outcome with `moonlet thread outcome`.");return{exitCode:0,stdout:`Closed. Its outcome shows under message ${(await y.close(z.threadId,M.outcome??"").catch(te=>{throw new je(te.message)})).rootSeq} in the main conversation, and ${ke().nickname} hears it.`}}}),"route spawn":ft({summary:"Start an assistant (or, with --chat, a chat) on a station, or on one of the owner's own machines they've listed: the Moonlet conversation's routing",options:{station:{type:"string",description:"The station (or listed machine of the owner's) to run on"},task:{type:"string",description:"Task key, like MOON-12; omitted for a new ask to create its task"},chat:{type:"boolean",description:"A visible chat in the Orbit section, not a hidden assistant"},title:{type:"string",description:"A short title"},model:{type:"string",description:"The model (default: the one Settings \u2192 Models has for this work); its effort comes from there too"},provider:{type:"string",description:"The provider: claude-code, or codex on a station that has it or a machine of the owner's (default: Settings \u2192 Models)"},brief:{type:"string",stdin:!0,description:"The instructions, on one line, as an argument ('\u2026'; or --brief-stdin)"}},async run({options:M},z){let{orbit:G,thread:te}=await T(z.threadId),we=await C(),L=we.find(ge=>ge.name===M.station);if(!L)throw new je(`No station or listed machine ${M.station??"(--station)"}. Targets: ${we.map(ge=>ge.name).join(", ")}`);let J=yn(M.brief??"").trim();if(!J)throw new je("Pass the instructions: --brief '<one line>' (or --brief-stdin).");let W=M.title??J.split(`