@kubitnodes/stellaris 0.3.2 → 0.3.4

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.
Files changed (42) hide show
  1. package/dist/cli/index.js +27 -1
  2. package/dist/server/index.js +69 -21
  3. package/package.json +1 -1
  4. package/web/dist/assets/{ChannelView-CX4cPMWM.js → ChannelView-CZyYu_Zi.js} +1 -1
  5. package/web/dist/assets/{CitizenView-8ZU2hK4D.js → CitizenView-JsI89Tn3.js} +2 -2
  6. package/web/dist/assets/{CitizensView-BDenU7WD.js → CitizensView-7vHTRRIs.js} +1 -1
  7. package/web/dist/assets/KnowledgeView-eBae2Dix.js +1 -0
  8. package/web/dist/assets/Markdown-BrvfGmz7.js +31 -0
  9. package/web/dist/assets/{MessageItem-BWuFJqdk.js → MessageItem-DXU3Ovq1.js} +1 -1
  10. package/web/dist/assets/MetricsView-CxXGHRtN.js +1 -0
  11. package/web/dist/assets/NeedsYouView-R-oQddyC.js +1 -0
  12. package/web/dist/assets/{Overview-BYcIErNt.js → Overview-D76LQcxp.js} +1 -1
  13. package/web/dist/assets/{Pane-KNrdAxkc.js → Pane-JzhKR0rO.js} +1 -1
  14. package/web/dist/assets/{ProjectView-CmoGtfJ4.js → ProjectView-vYKWw1Ck.js} +1 -1
  15. package/web/dist/assets/ProposalView-dskJSjhm.js +1 -0
  16. package/web/dist/assets/{ProposalsView-DSiFdLGD.js → ProposalsView-DQW7OmOU.js} +1 -1
  17. package/web/dist/assets/{RunnersView-DfduymeY.js → RunnersView-BLwSywI7.js} +1 -1
  18. package/web/dist/assets/{SocietyView-BwfrqQiF.js → SocietyView-OCdDJqhz.js} +1 -1
  19. package/web/dist/assets/{SubjectThread-B-1_FwBN.js → SubjectThread-DQNXXY4q.js} +1 -1
  20. package/web/dist/assets/TaskFileView-Bl1vm7Op.js +4 -0
  21. package/web/dist/assets/TaskView-Bq-vXuc5.js +1 -0
  22. package/web/dist/assets/{TasksView-QpcbsOzR.js → TasksView-C1cdPYRc.js} +1 -1
  23. package/web/dist/assets/ThreadCard-CliRbP_c.js +1 -0
  24. package/web/dist/assets/{ThreadForms-B6Lv_t5p.js → ThreadForms-C4ytMMBB.js} +1 -1
  25. package/web/dist/assets/{ThreadView-5PMRCHd4.js → ThreadView-CvXd68Ml.js} +1 -1
  26. package/web/dist/assets/{citizen-B9DadtKn.js → citizen-TjyiyFqE.js} +1 -1
  27. package/web/dist/assets/{format-DbfHOiKW.js → format-8m6fdeP8.js} +1 -1
  28. package/web/dist/assets/index-CADeLxUP.js +23 -0
  29. package/web/dist/assets/index-iNICYkef.css +2 -0
  30. package/web/dist/assets/{tasks-Bw07dkQC.js → tasks-Di8iatzY.js} +1 -1
  31. package/web/dist/assets/{useStickyScroll-CRgyaBkv.js → useStickyScroll-BPuANcOs.js} +1 -1
  32. package/web/dist/index.html +4 -4
  33. package/web/dist/assets/KnowledgeView-IUzeK83J.js +0 -1
  34. package/web/dist/assets/Markdown-DH59NuID.js +0 -31
  35. package/web/dist/assets/MetricsView-RzP1J0EG.js +0 -1
  36. package/web/dist/assets/NeedsYouView-DvnPW0tZ.js +0 -1
  37. package/web/dist/assets/ProposalView-FjvrD4Fz.js +0 -1
  38. package/web/dist/assets/TaskFileView-BNR8mQRk.js +0 -1
  39. package/web/dist/assets/TaskView-qdFvjqvJ.js +0 -1
  40. package/web/dist/assets/ThreadCard-ClSg5-Lj.js +0 -1
  41. package/web/dist/assets/index-2BnqwsfR.js +0 -23
  42. package/web/dist/assets/index-C3ujZpqY.css +0 -2
package/dist/cli/index.js CHANGED
@@ -786,6 +786,8 @@ var RunnerHelloSchema = z6.object({
786
786
  stoppableClis: z6.array(CliKindSchema).default([]),
787
787
  /** Whether the runner answers file reads on its projects' branches; one from before never does. */
788
788
  branchReads: z6.boolean().default(false),
789
+ /** Whether the runner lists what a branch changed; one from before never does. */
790
+ branchChanges: z6.boolean().default(false),
789
791
  capabilities: z6.array(z6.string()).default([]),
790
792
  /** Turns the runner runs at once, or null for no limit. */
791
793
  slots: z6.number().int().positive().nullable(),
@@ -921,6 +923,24 @@ var BranchFileSchema = z6.discriminatedUnion("kind", [
921
923
  }))
922
924
  })
923
925
  ]);
926
+ var BranchChangesReadSchema = z6.object({
927
+ repo: ProjectRepoSchema,
928
+ branch: BranchNameSchema
929
+ });
930
+ var BranchFileChangeSchema = z6.object({
931
+ path: z6.string().min(1),
932
+ status: z6.enum(["added", "modified", "deleted"]),
933
+ /** Lines added and removed, or null for a binary file. */
934
+ added: z6.number().int().nonnegative().nullable(),
935
+ removed: z6.number().int().nonnegative().nullable(),
936
+ /** Absent when the file changed only through a merge of another branch. */
937
+ lastChange: z6.object({ author: z6.string(), at: IsoDateTimeSchema }).optional()
938
+ });
939
+ var BranchChangesSchema = z6.object({
940
+ head: BranchCommitSchema,
941
+ files: z6.array(BranchFileChangeSchema),
942
+ total: z6.number().int().nonnegative()
943
+ });
924
944
  var TurnSteerSchema = z6.object({ id: z6.uuid(), text: z6.string().min(1) });
925
945
  var RunnerMessageSchema = z6.discriminatedUnion("type", [
926
946
  z6.object({ type: z6.literal("turn"), job: TurnJobSchema }),
@@ -928,6 +948,12 @@ var RunnerMessageSchema = z6.discriminatedUnion("type", [
928
948
  z6.object({ type: z6.literal("models"), request: z6.string().min(1), cli: CliKindSchema }),
929
949
  /** Answered with a `BranchFile`, or null when the branch or the path does not exist. */
930
950
  z6.object({ type: z6.literal("file"), request: z6.string().min(1), read: BranchReadSchema }),
951
+ /** Answered with `BranchChanges`, or null when the repository or the branch does not exist. */
952
+ z6.object({
953
+ type: z6.literal("changes"),
954
+ request: z6.string().min(1),
955
+ read: BranchChangesReadSchema
956
+ }),
931
957
  /** Answered with whether the CLI accepted it; that it took it comes as a `steered` event. */
932
958
  z6.object({
933
959
  type: z6.literal("steer"),
@@ -1235,7 +1261,7 @@ var RunnerConfigSchema = z10.object({
1235
1261
  });
1236
1262
 
1237
1263
  // packages/shared/dist/version.js
1238
- var STELLARIS_VERSION = "0.3.2";
1264
+ var STELLARIS_VERSION = "0.3.4";
1239
1265
 
1240
1266
  // packages/board-core/dist/errors.js
1241
1267
  var BoardError = class extends Error {
@@ -818,6 +818,8 @@ var RunnerHelloSchema = z6.object({
818
818
  stoppableClis: z6.array(CliKindSchema).default([]),
819
819
  /** Whether the runner answers file reads on its projects' branches; one from before never does. */
820
820
  branchReads: z6.boolean().default(false),
821
+ /** Whether the runner lists what a branch changed; one from before never does. */
822
+ branchChanges: z6.boolean().default(false),
821
823
  capabilities: z6.array(z6.string()).default([]),
822
824
  /** Turns the runner runs at once, or null for no limit. */
823
825
  slots: z6.number().int().positive().nullable(),
@@ -953,6 +955,24 @@ var BranchFileSchema = z6.discriminatedUnion("kind", [
953
955
  }))
954
956
  })
955
957
  ]);
958
+ var BranchChangesReadSchema = z6.object({
959
+ repo: ProjectRepoSchema,
960
+ branch: BranchNameSchema
961
+ });
962
+ var BranchFileChangeSchema = z6.object({
963
+ path: z6.string().min(1),
964
+ status: z6.enum(["added", "modified", "deleted"]),
965
+ /** Lines added and removed, or null for a binary file. */
966
+ added: z6.number().int().nonnegative().nullable(),
967
+ removed: z6.number().int().nonnegative().nullable(),
968
+ /** Absent when the file changed only through a merge of another branch. */
969
+ lastChange: z6.object({ author: z6.string(), at: IsoDateTimeSchema }).optional()
970
+ });
971
+ var BranchChangesSchema = z6.object({
972
+ head: BranchCommitSchema,
973
+ files: z6.array(BranchFileChangeSchema),
974
+ total: z6.number().int().nonnegative()
975
+ });
956
976
  var TurnSteerSchema = z6.object({ id: z6.uuid(), text: z6.string().min(1) });
957
977
  var RunnerMessageSchema = z6.discriminatedUnion("type", [
958
978
  z6.object({ type: z6.literal("turn"), job: TurnJobSchema }),
@@ -960,6 +980,12 @@ var RunnerMessageSchema = z6.discriminatedUnion("type", [
960
980
  z6.object({ type: z6.literal("models"), request: z6.string().min(1), cli: CliKindSchema }),
961
981
  /** Answered with a `BranchFile`, or null when the branch or the path does not exist. */
962
982
  z6.object({ type: z6.literal("file"), request: z6.string().min(1), read: BranchReadSchema }),
983
+ /** Answered with `BranchChanges`, or null when the repository or the branch does not exist. */
984
+ z6.object({
985
+ type: z6.literal("changes"),
986
+ request: z6.string().min(1),
987
+ read: BranchChangesReadSchema
988
+ }),
963
989
  /** Answered with whether the CLI accepted it; that it took it comes as a `steered` event. */
964
990
  z6.object({
965
991
  type: z6.literal("steer"),
@@ -1315,7 +1341,7 @@ var RunnerConfigSchema = z10.object({
1315
1341
  });
1316
1342
 
1317
1343
  // packages/shared/dist/version.js
1318
- var STELLARIS_VERSION = "0.3.2";
1344
+ var STELLARIS_VERSION = "0.3.4";
1319
1345
 
1320
1346
  // packages/board-core/dist/errors.js
1321
1347
  var BoardError = class extends Error {
@@ -8678,31 +8704,25 @@ var RunnerHub = class {
8678
8704
  * `RunnerAwayError` while its runner is away.
8679
8705
  */
8680
8706
  async readBranch(project, branch, path10) {
8681
- const record = await this.board.readProject(project);
8682
- if (record.runner === void 0) {
8683
- throw new BoardError("NOT_FOUND", `${project} has no repository yet, since no turn has run there`);
8684
- }
8685
- const seat = this.seats.get(record.runner);
8686
- if (seat === void 0 || seat.send === null) {
8687
- throw new RunnerAwayError(`runner ${record.runner}, where ${project} lives, is not connected`);
8688
- }
8689
- if (!seat.hello.branchReads) {
8690
- throw new BoardError("INVALID_STATE", `runner ${seat.name}, where ${project} lives, cannot read files yet; upgrade it`);
8691
- }
8692
- const file = BranchFileSchema.nullable().parse(await this.request(seat, (request) => ({
8693
- type: "file",
8694
- request,
8695
- read: {
8696
- repo: { slug: record.slug, origin: record.repo, defaultBranch: record.defaultBranch },
8697
- branch,
8698
- path: path10
8699
- }
8700
- }), FILE_TIMEOUT_MS));
8707
+ const { seat, repo } = await this.projectSeat(project, "branchReads", "read files");
8708
+ const file = BranchFileSchema.nullable().parse(await this.request(seat, (request) => ({ type: "file", request, read: { repo, branch, path: path10 } }), FILE_TIMEOUT_MS));
8701
8709
  if (file === null) {
8702
8710
  throw new BoardError("NOT_FOUND", `${branch} has no ${path10 === "" ? "commit" : path10}`);
8703
8711
  }
8704
8712
  return file;
8705
8713
  }
8714
+ /**
8715
+ * What a branch of a project's repository changed since it left the default branch, listed on
8716
+ * the runner the project lives on, with the same refusals as `readBranch`.
8717
+ */
8718
+ async branchChanges(project, branch) {
8719
+ const { seat, repo } = await this.projectSeat(project, "branchChanges", "list changes");
8720
+ const changes = BranchChangesSchema.nullable().parse(await this.request(seat, (request) => ({ type: "changes", request, read: { repo, branch } }), FILE_TIMEOUT_MS));
8721
+ if (changes === null) {
8722
+ throw new BoardError("NOT_FOUND", `${project} has no ${branch} yet`);
8723
+ }
8724
+ return changes;
8725
+ }
8706
8726
  /** The models a CLI offers, asked of a connected runner that has it; none when no runner has it. */
8707
8727
  async models(cli) {
8708
8728
  const seat = this.byLoad().find((each) => each.send !== null && each.hello.clis.includes(cli));
@@ -8790,6 +8810,27 @@ var RunnerHub = class {
8790
8810
  isWarm: (key) => seat.warm.has(key)
8791
8811
  };
8792
8812
  }
8813
+ /**
8814
+ * The connected runner a project lives on and where its code is, for a request only runners that
8815
+ * said so at registration answer: one from before would skip it and leave the reader waiting.
8816
+ */
8817
+ async projectSeat(project, able, what) {
8818
+ const record = await this.board.readProject(project);
8819
+ if (record.runner === void 0) {
8820
+ throw new BoardError("NOT_FOUND", `${project} has no repository yet, since no turn has run there`);
8821
+ }
8822
+ const seat = this.seats.get(record.runner);
8823
+ if (seat === void 0 || seat.send === null) {
8824
+ throw new RunnerAwayError(`runner ${record.runner}, where ${project} lives, is not connected`);
8825
+ }
8826
+ if (!seat.hello[able]) {
8827
+ throw new BoardError("INVALID_STATE", `runner ${seat.name}, where ${project} lives, cannot ${what} yet; upgrade it`);
8828
+ }
8829
+ return {
8830
+ seat,
8831
+ repo: { slug: record.slug, origin: record.repo, defaultBranch: record.defaultBranch }
8832
+ };
8833
+ }
8793
8834
  assertOwns(runner, turnId) {
8794
8835
  const owner = this.host.runnerOf(turnId);
8795
8836
  if (owner !== void 0 && owner !== runner) {
@@ -9497,6 +9538,13 @@ function createApp(deps) {
9497
9538
  return c.json(await deps.runners.readBranch(task.project, `task/${task.id}`, BranchPathSchema.parse(file)));
9498
9539
  };
9499
9540
  api.get("/tasks/:id/files", (c) => taskFile(c, ""));
9541
+ api.get("/tasks/:id/changes", async (c) => {
9542
+ const { task } = await board2.findTask(UlidSchema.parse(c.req.param("id")));
9543
+ if (deps.runners === void 0) {
9544
+ throw new BoardError("NOT_FOUND", "this board has no runners to read a task's branch from");
9545
+ }
9546
+ return c.json(await deps.runners.branchChanges(task.project, `task/${task.id}`));
9547
+ });
9500
9548
  api.get("/tasks/:id/files/:path{.+}", (c) => taskFile(c, c.req.param("path")));
9501
9549
  api.get("/threads", async (c) => c.json(await board2.listThreads()));
9502
9550
  api.get("/requests", async (c) => c.json(await board2.listRequests()));
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "codex",
9
9
  "multi-agent"
10
10
  ],
11
- "version": "0.3.2",
11
+ "version": "0.3.4",
12
12
  "license": "MIT",
13
13
  "homepage": "https://github.com/kr4t0n/stellaris",
14
14
  "repository": {
@@ -1 +1 @@
1
- import{E as e,I as t,Jt as n,N as r,gn as i,hn as a,m as o,v as s,y as c,yn as l}from"./format-DbfHOiKW.js";import{I as u,N as d,a as f,t as p}from"./index-2BnqwsfR.js";import{t as m}from"./MessageItem-BWuFJqdk.js";import{n as h,t as g}from"./Pane-KNrdAxkc.js";import{n as _}from"./ThreadCard-ClSg5-Lj.js";import{i as v}from"./ThreadForms-B6Lv_t5p.js";import{t as y}from"./useStickyScroll-CRgyaBkv.js";var b=l(i(),1),x=a();function S(){let{_splat:e=`general`}=u({from:`/c/$`});return(0,x.jsx)(C,{channel:e},e)}function C({channel:i}){let{api:a}=e(),l=n({queryKey:[`channel`,i],queryFn:()=>a.channel(i)}),u=r(),S=o(),C=c(),w=s(3e4),[T,E]=(0,b.useState)(!1),D=(0,b.useMemo)(()=>{let e=(l.data??[]).map(e=>({kind:`message`,at:e.ts,id:e.id,message:e})),t=(u.data??[]).filter(e=>e.channel===i).map(e=>({kind:`thread`,at:e.openedAt,id:e.id,thread:e}));return[...e,...t].toSorted((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id))},[l.data,u.data,i]),O=l.data?.at(-1)?.id??null;(0,b.useEffect)(()=>d(i,O),[i,O]);let{ref:k,onScroll:A}=y(),[j,M]=i.split(`/`),N=M??j??i,P=M===void 0?void 0:C.data?.find(e=>e.slug===j),F=M===void 0?`society`:P?.name??j,I=P?.archived!==void 0,L=D.filter(e=>e.kind===`thread`&&e.thread.state===`open`);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(g,{title:`# ${N}`,subtitle:`${F} · ${l.data?.length??0} messages${L.length>0?` · ${L.length} open threads`:``}`,trailing:T||I?null:(0,x.jsx)(f,{onClick:()=>E(!0),children:`New thread`})}),T?(0,x.jsx)(v,{channel:i,onDone:()=>E(!1)}):null,(0,x.jsx)(`div`,{ref:k,onScroll:A,className:`flex-1 overflow-y-auto py-2`,children:l.error instanceof t&&l.error.status===404?(0,x.jsxs)(h,{children:[`There is no channel `,i,`.`]}):l.data===void 0?(0,x.jsx)(h,{children:`Reading the channel…`}):D.length===0?(0,x.jsx)(h,{children:`Nothing has been said here yet.`}):D.map(e=>e.kind===`message`?(0,x.jsx)(m,{message:e.message,members:S.data,now:w},e.id):(0,x.jsx)(_,{thread:e.thread,now:w},e.id))}),l.data===void 0?null:I?(0,x.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-meta`,children:[F,` is archived, so its channels are read-only.`]}):(0,x.jsx)(p,{target:{channel:i},placeholder:`Message #${N}`})]})}export{S as ChannelView};
1
+ import{E as e,L as t,P as n,Yt as r,_n as i,bn as a,gn as o,m as s,v as c,y as l}from"./format-8m6fdeP8.js";import{I as u,N as d,a as f,t as p}from"./index-CADeLxUP.js";import{t as m}from"./MessageItem-DXU3Ovq1.js";import{n as h,t as g}from"./Pane-JzhKR0rO.js";import{n as _}from"./ThreadCard-CliRbP_c.js";import{i as v}from"./ThreadForms-C4ytMMBB.js";import{t as y}from"./useStickyScroll-BPuANcOs.js";var b=a(i(),1),x=o();function S(){let{_splat:e=`general`}=u({from:`/c/$`});return(0,x.jsx)(C,{channel:e},e)}function C({channel:i}){let{api:a}=e(),o=r({queryKey:[`channel`,i],queryFn:()=>a.channel(i)}),u=n(),S=s(),C=l(),w=c(3e4),[T,E]=(0,b.useState)(!1),D=(0,b.useMemo)(()=>{let e=(o.data??[]).map(e=>({kind:`message`,at:e.ts,id:e.id,message:e})),t=(u.data??[]).filter(e=>e.channel===i).map(e=>({kind:`thread`,at:e.openedAt,id:e.id,thread:e}));return[...e,...t].toSorted((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id))},[o.data,u.data,i]),O=o.data?.at(-1)?.id??null;(0,b.useEffect)(()=>d(i,O),[i,O]);let{ref:k,onScroll:A}=y(),[j,M]=i.split(`/`),N=M??j??i,P=M===void 0?void 0:C.data?.find(e=>e.slug===j),F=M===void 0?`society`:P?.name??j,I=P?.archived!==void 0,L=D.filter(e=>e.kind===`thread`&&e.thread.state===`open`);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(g,{title:`# ${N}`,subtitle:`${F} · ${o.data?.length??0} messages${L.length>0?` · ${L.length} open threads`:``}`,trailing:T||I?null:(0,x.jsx)(f,{onClick:()=>E(!0),children:`New thread`})}),T?(0,x.jsx)(v,{channel:i,onDone:()=>E(!1)}):null,(0,x.jsx)(`div`,{ref:k,onScroll:A,className:`flex-1 overflow-y-auto py-2`,children:o.error instanceof t&&o.error.status===404?(0,x.jsxs)(h,{children:[`There is no channel `,i,`.`]}):o.data===void 0?(0,x.jsx)(h,{children:`Reading the channel…`}):D.length===0?(0,x.jsx)(h,{children:`Nothing has been said here yet.`}):D.map(e=>e.kind===`message`?(0,x.jsx)(m,{message:e.message,members:S.data,now:w},e.id):(0,x.jsx)(_,{thread:e.thread,now:w},e.id))}),o.data===void 0?null:I?(0,x.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-meta`,children:[F,` is archived, so its channels are read-only.`]}):(0,x.jsx)(p,{target:{channel:i},placeholder:`Message #${N}`})]})}export{S as ChannelView};
@@ -1,2 +1,2 @@
1
- import{B as e,C as t,E as n,F as r,I as i,M as a,P as o,T as s,_ as c,a as l,at as u,bt as d,d as f,f as p,gn as m,h,hn as g,m as _,mn as v,t as y,u as b,v as x,w as S,yn as C}from"./format-DbfHOiKW.js";import{F as w,I as T,L as E,S as ee,a as D,d as O,f as k,g as A,h as j,l as M,m as te,p as ne,t as re,u as N,v as P,y as F}from"./index-2BnqwsfR.js";import{t as I}from"./Markdown-DH59NuID.js";import{n as L,t as ie}from"./Pane-KNrdAxkc.js";import{n as ae,r as R}from"./ThreadForms-B6Lv_t5p.js";import{t as oe}from"./useStickyScroll-CRgyaBkv.js";import{a as z,c as B,n as se,o as ce,r as le,s as ue,t as de}from"./citizen-B9DadtKn.js";var V=C(m(),1),H=g(),fe={completed:`completed`,timeout:`timed out`,error:`failed`,interrupted:`was interrupted`,blocked:`was blocked`,stopped:`was stopped by you`};function U(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function W({label:e,tone:t,children:n}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`px-0.5 pb-0.5 text-[10px] tracking-wider text-fg-muted uppercase`,children:e}),(0,H.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-surface-0/60 p-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words ${t}`,children:n})]})}function pe({step:e,open:t}){if(e.kind===`say`)return(0,H.jsx)(`li`,{className:`py-1.5 text-sm`,title:U(e.at),children:(0,H.jsx)(I,{text:e.text})});if(e.kind===`error`)return(0,H.jsx)(`li`,{className:`py-1 font-mono text-xs break-words text-red-400`,title:U(e.at),children:e.message});if(e.kind===`steer`)return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:t,className:`group rounded-md open:bg-surface-2/30`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md px-1.5 py-1 text-xs hover:bg-surface-2/40`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`grid w-3 shrink-0 place-items-center text-sky-300`,children:`↳`}),(0,H.jsxs)(`span`,{className:`shrink-0 text-fg-tertiary`,children:[`Took `,k(e.posts.length)]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:e.from.length===0?``:`from ${e.from.join(`, `)}, delivered mid-turn`}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-muted`,children:U(e.at)})]}),(0,H.jsx)(`ul`,{className:`space-y-1.5 px-1.5 pb-1.5`,children:e.posts.map(e=>(0,H.jsxs)(`li`,{className:`rounded-md bg-surface-0/40 px-2.5 py-2`,children:[(0,H.jsxs)(`p`,{className:`flex gap-1.5 text-meta`,children:[(0,H.jsx)(`span`,{className:`text-fg-secondary`,children:e.author}),(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`in `,e.where]}),e.at===``?null:(0,H.jsx)(`span`,{className:`ml-auto shrink-0 font-mono`,children:U(e.at)})]}),(0,H.jsx)(`div`,{className:`mt-1 text-sm`,children:(0,H.jsx)(I,{text:e.body})})]},`${e.at}-${e.author}`))})]})});let n=e.ok===null?(0,H.jsx)(`span`,{"aria-label":`running`,className:`size-1.5 animate-pulse rounded-full bg-amber-300`}):e.ok?(0,H.jsx)(`span`,{"aria-label":`succeeded`,className:`text-[11px] text-emerald-400`,children:`✓`}):(0,H.jsx)(`span`,{"aria-label":`failed`,className:`text-[11px] text-red-400`,children:`✕`});return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:t,className:`group rounded-md open:bg-surface-2/30`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md px-1.5 py-1 text-xs hover:bg-surface-2/40`,children:[(0,H.jsx)(`span`,{className:`grid w-3 shrink-0 place-items-center`,children:n}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-fg-tertiary`,children:ne(e.name)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-fg-secondary`,children:e.summary}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-muted`,children:U(e.at)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5 px-1.5 pb-1.5`,children:[(0,H.jsx)(W,{label:`Input`,tone:`text-fg-secondary`,children:e.detail}),e.output===null?null:(0,H.jsx)(W,{label:e.ok===!1?`Returned an error`:`Returned`,tone:e.ok===!1?`text-red-300`:`text-fg-tertiary`,children:e.output})]})]})})}function G({steps:e}){let[t,n]=(0,V.useState)(!1),r=e.filter(e=>e.kind===`tool`).length;return e.length===0?(0,H.jsx)(`p`,{className:`mt-2 text-meta`,children:`No steps yet.`}):(0,H.jsxs)(H.Fragment,{children:[r===0?null:(0,H.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-meta`,children:[r===1?`1 tool call`:`${r} tool calls`,(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(!t),className:`rounded-md px-1.5 py-0.5 text-fg-tertiary transition-colors hover:bg-surface-2/60 hover:text-fg-primary`,children:t?`Collapse all`:`Expand all`})]}),(0,H.jsx)(`ol`,{className:`mt-1 space-y-0.5`,children:e.map(e=>(0,H.jsx)(pe,{step:e,open:t},e.seq))})]})}function me({turn:e,running:t,now:n}){if(e.end!==null){let t=e.end.costUsd>0?` · $${e.end.costUsd.toFixed(2)}`:``;return(0,H.jsxs)(`section`,{className:`mt-3 rounded-xl bg-surface-2/40 px-3.5 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]`,children:[(0,H.jsxs)(`p`,{className:`text-caps`,children:[`The turn `,fe[e.end.exitReason],` `,y(e.end.at,n),t,e.fromStart?` · ${N(e.startedAt,Date.parse(e.end.at))}`:``]}),e.end.summary===null?null:(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:e.end.summary})]})}return t?(0,H.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-meta`,"aria-live":`polite`,children:[(0,H.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-400`}),`Working · last step `,y(e.lastAt,n)]}):(0,H.jsx)(`p`,{className:`mt-3 text-meta`,children:`The turn ended without a report.`})}var K=30,he={turn:`turn`,board:`board`,merge:`both kept`},ge={turn:`Changed by a turn`,board:`Written by the board`,merge:`Both versions kept`};function _e(e){return e.status===`added`?`new`:e.status===`deleted`?`deleted`:e.added===null||e.removed===null?`binary`:`+${e.added} −${e.removed}`}function ve(e){return e.files.map(e=>`${e.path} ${_e(e)}`).join(`, `)}function ye(e){return e.startsWith(`@@`)||e.startsWith(`\\`)?`text-fg-muted`:e.startsWith(`+`)?`text-emerald-300`:e.startsWith(`-`)?`text-red-300`:`text-fg-tertiary`}function be({file:e}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[e.path,e.status===`modified`?``:(0,H.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,e.status]})]}),e.patch===null?(0,H.jsx)(`p`,{className:`mt-1 text-meta`,children:`A binary file; its contents are not shown.`}):e.patch===``?(0,H.jsx)(`p`,{className:`mt-1 text-meta`,children:`Empty.`}):(0,H.jsx)(`pre`,{className:`mt-1 max-h-96 overflow-auto rounded-md bg-surface-0/60 p-2 font-mono text-[11px] leading-relaxed`,children:e.patch.split(`
2
- `).map((e,t)=>(0,H.jsx)(`span`,{className:`block whitespace-pre-wrap break-words ${ye(e)}`,children:e===``?` `:e},t))}),e.truncated?(0,H.jsx)(`p`,{className:`mt-1 text-meta`,children:`The rest of this file's change is cut.`}):null]})}function xe({name:e,change:t}){let n=b(e,t.commit,!0);return(0,H.jsxs)(`div`,{className:`space-y-3 px-4 pt-1 pb-3`,children:[(0,H.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[t.kind===`merge`?`Two turns on different runners changed the same lines at once. The file kept one turn's version, and this copy holds the other's until the citizen reconciles them.`:t.kind===`board`?`Written by the board: ${t.subject.replace(/^home: /,``)}.`:t.turnId===void 0?t.subject:(0,H.jsx)(d,{to:`/citizen/$name`,params:{name:e},search:{tab:`turns`,turn:t.turnId},className:`text-fg-secondary underline decoration-line underline-offset-2 hover:text-fg-primary`,children:`Open the turn that made it`}),(0,H.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,U(t.at)]})]}),n.data===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:n.isError?`Could not read the change.`:`Reading the change…`}):n.data.map(e=>(0,H.jsx)(be,{file:e},e.path))]})}function Se({name:e,change:t,now:n}){let[r,i]=(0,V.useState)(!1),a=t.files.length===0?t.subject:ve(t);return(0,H.jsx)(`li`,{className:`border-b border-line/60 last:border-b-0`,children:(0,H.jsxs)(`details`,{className:`group`,onToggle:e=>i(e.currentTarget.open),children:[(0,H.jsx)(`summary`,{"aria-label":`${ge[t.kind]} ${y(t.at,n)}: ${a}`,className:`block cursor-pointer list-none px-4 py-2.5 transition-colors hover:bg-surface-2/30 group-open:bg-surface-2/20`,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:he[t.kind]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:a}),(0,H.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:y(t.at,n)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[10px] text-fg-muted transition-transform group-open:rotate-90`,children:`▸`})]})}),r?(0,H.jsx)(xe,{name:e,change:t}):null]})})}function Ce({name:e}){let[t,n]=(0,V.useState)(K),r=p(e,t),i=x(3e4);if(r.data===void 0)return(0,H.jsx)(L,{children:r.isError?`Could not read the home's history.`:`Reading the history…`});let{changes:a,more:o}=r.data;return a.length===0?(0,H.jsxs)(L,{children:[e,`'s home has no history yet; it starts with the citizen's first turn.`]}):(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,H.jsxs)(`p`,{className:`px-4 pt-3 pb-1 text-meta`,children:[`What `,e,`'s turns changed in its memory, skills, and profile, newest first.`]}),(0,H.jsx)(`ol`,{children:a.map(t=>(0,H.jsx)(Se,{name:e,change:t,now:i},t.commit))}),o?(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(t+K),className:`px-4 py-3 text-xs text-fg-tertiary hover:text-fg-primary`,children:`Show earlier changes`}):null]})}function q({title:e,children:t}){return(0,H.jsxs)(`section`,{className:`border-t border-line pt-4 first:border-t-0 first:pt-0`,children:[(0,H.jsx)(`h3`,{className:`text-section`,children:e}),(0,H.jsx)(`div`,{className:`mt-2`,children:t})]})}function we({member:e,charter:t}){let n=h(e.name),r=l(e.name),i=f(e.name),a=x(3e4);return(0,H.jsxs)(`div`,{className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[i.data===void 0||i.data.length===0?null:(0,H.jsxs)(q,{title:`Edits to reconcile`,children:[(0,H.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`Two turns on different runners changed these files at once. Each file kept one version; the other waits beside it until `,e.name,` merges it in and deletes the copy.`]}),(0,H.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:i.data.map(e=>(0,H.jsxs)(`li`,{className:`text-sm`,children:[(0,H.jsx)(`span`,{className:`text-fg-primary`,children:e.file}),(0,H.jsxs)(`span`,{className:`text-meta`,children:[` `,`· `,e.path.slice(e.path.lastIndexOf(`/`)+1),` · left`,` `,y(e.since,a)]})]},e.path))})]}),(0,H.jsx)(q,{title:`Profile`,children:e.profile.trim()===``?(0,H.jsx)(`p`,{className:`text-meta`,children:`No profile yet. The citizen writes its own profile.md.`}):(0,H.jsx)(I,{text:B(e.profile,`Profile`)})}),(0,H.jsx)(q,{title:`Core memory`,children:n.data===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`Reading…`}):n.data.body.trim()===``?(0,H.jsx)(`p`,{className:`text-meta`,children:`Empty. Every turn loads this file in full.`}):(0,H.jsx)(I,{text:B(n.data.body,`Core memory`)})}),(0,H.jsx)(q,{title:`Own skills`,children:r.data===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`Reading…`}):r.data.length===0?(0,H.jsx)(`p`,{className:`text-meta`,children:`None yet.`}):(0,H.jsx)(`ul`,{className:`space-y-1.5`,children:r.data.map(e=>(0,H.jsxs)(`li`,{className:`text-sm`,children:[(0,H.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),e.summary===``?null:(0,H.jsxs)(`span`,{className:`text-fg-secondary`,children:[` · `,e.summary]})]},e.name))})}),t===void 0?null:(0,H.jsxs)(q,{title:`Charter of ${t.name}`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:t.purpose}),(0,H.jsxs)(`p`,{className:`mt-2 text-meta`,children:[`Wakes on mentions, stages, and `,t.wakeTriggers.join(`, `)||`nothing else`,t.resident?` · keeps a warm session`:``,t.reflects?` · reflects`:``]}),(0,H.jsx)(`p`,{className:`mt-2 flex flex-wrap gap-1`,children:t.verbs.map(e=>(0,H.jsx)(`span`,{className:`rounded-md bg-surface-2/70 px-1.5 py-px font-mono text-[11px] text-fg-tertiary`,children:e},e))})]})]})}function J(e,t){let n=o(e,t?.turnId??null);return{turn:(0,V.useMemo)(()=>t===void 0||n.data===void 0?void 0:te(n.data,e,t.project,t.thread),[t,n.data,e]),loading:t?.turnId!==void 0&&n.isPending,missing:t!==void 0&&(t.turnId===void 0||n.isError)}}var Y=50;function Te({name:e,entry:t,cli:n,now:r,opened:i}){let[a,o]=(0,V.useState)(i),s=(0,V.useRef)(null);(0,V.useEffect)(()=>{i&&s.current?.scrollIntoView({block:`start`})},[i]);let c=F(),l=ce(t),u=t.thread===void 0?null:c.get(t.thread)?.title??`a thread`,d=t.error??t.summary??``,f=t.error===null?`text-fg-secondary`:`text-red-300`;return(0,H.jsx)(`li`,{ref:s,className:`border-b border-line/60 last:border-b-0`,children:(0,H.jsxs)(`details`,{className:`group`,open:a,onToggle:e=>o(e.currentTarget.open),children:[(0,H.jsxs)(`summary`,{className:`block cursor-pointer list-none px-4 py-2.5 transition-colors hover:bg-surface-2/30 group-open:bg-surface-2/20`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 truncate text-fg-secondary`,children:[z(t.project),u===null?``:` · ${u}`]}),(0,H.jsx)(`span`,{className:`text-fg-muted`,children:t.trigger}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-fg-muted`,children:[se(t),` `,y(t.ts,r)]}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-tertiary`,children:[l,t.toolCalls===void 0?null:`${t.toolCalls} tools`,de(t,n)].filter(e=>e!==null).join(` · `)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[10px] text-fg-muted transition-transform group-open:rotate-90`,children:`▸`})]}),d.trim()===``?null:(0,H.jsx)(`span`,{className:`mt-1 line-clamp-2 block text-xs leading-relaxed group-open:hidden ${f}`,children:(0,H.jsx)(P,{text:d,links:!1})})]}),a?(0,H.jsx)(Ee,{name:e,entry:t,text:d,tone:f}):null]})})}function Ee({name:e,entry:t,text:n,tone:r}){let i=J(e,t);return(0,H.jsxs)(`div`,{className:`px-4 pt-1 pb-3`,children:[n.trim()===``?null:(0,H.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap ${r}`,children:(0,H.jsx)(P,{text:n})}),(0,H.jsx)(`div`,{className:`mt-2`,children:t.turnId===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`This turn ran before turns kept their steps.`}):i.loading?(0,H.jsx)(`p`,{className:`text-meta`,children:`Reading the steps…`}):i.turn===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`No steps were kept for this turn.`}):(0,H.jsxs)(H.Fragment,{children:[t.startedAt===void 0?null:(0,H.jsxs)(`p`,{className:`text-caps`,children:[`Started `,U(t.startedAt)]}),(0,H.jsx)(G,{steps:i.turn.steps})]})})]})}function De({name:e,cli:t,opened:n}){let[i,a]=(0,V.useState)(Y),o=r(e,i),s=x(3e4);if(o.data===void 0)return(0,H.jsx)(L,{children:`Reading the turns…`});let c=o.data.toReversed();if(c.length===0)return(0,H.jsxs)(L,{children:[e,` has not finished a turn yet.`]});let l=le(c),u=t===`codex`?`unmetered`:`$${l.costUsd.toFixed(2)}`;return(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,H.jsxs)(`p`,{className:`px-4 pt-3 pb-1 text-meta`,children:[l.turns===1?`1 turn`:`${l.turns} turns`,l.failed===0?``:`, ${l.failed} not completed`,` · `,u]}),n!==null&&!c.some(e=>e.turnId===n)?(0,H.jsx)(`p`,{className:`px-4 pb-1 text-meta`,children:o.data.length===i?`The turn this address opens is further back; show earlier turns to reach it.`:`The turn this address opens is not in this citizen's history.`}):null,(0,H.jsx)(`ol`,{children:c.map(r=>(0,H.jsx)(Te,{name:e,entry:r,cli:t,now:s,opened:n!==null&&r.turnId===n},r.id))}),o.data.length===i?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>a(i+Y),className:`px-4 py-3 text-xs text-fg-tertiary hover:text-fg-primary`,children:[`Show `,Y,` earlier turns`]}):null]})}function Oe(e){return e===void 0?``:`${e.name}${e.id===null?``:` · ${e.id}`}`}function X({label:e,choices:t,value:n,onChange:r}){let[i,a]=(0,V.useState)(!1),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)([]),l=t.findIndex(e=>e.value===n);(0,V.useEffect)(()=>{if(!i)return;c.current[Math.max(l,0)]?.focus();let e=e=>{e.target instanceof Node&&o.current?.contains(e.target)===!0||a(!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[i,l]);let u=e=>{if(e.key===`Escape`){e.stopPropagation(),a(!1),s.current?.focus();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let n=(c.current.findIndex(e=>e===document.activeElement)+(e.key===`ArrowDown`?1:-1)+t.length)%t.length;c.current[n]?.focus()},d=t[l];return(0,H.jsxs)(`div`,{ref:o,className:`relative min-w-0 flex-1`,children:[(0,H.jsxs)(`button`,{ref:s,type:`button`,"aria-label":`${e}: ${Oe(d)}`,"aria-expanded":i,onClick:()=>a(!i),onKeyDown:i?u:void 0,className:`flex h-7 w-full items-center gap-1.5 rounded-md bg-surface-2/60 px-2.5 text-xs text-fg-secondary transition-colors hover:bg-surface-2 focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:[d?.name,d?.id===null||d===void 0?null:(0,H.jsxs)(`span`,{className:`text-fg-tertiary`,children:[` · `,d.id]})]}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-[10px] text-fg-muted transition-transform ${i?`rotate-180`:``}`,children:`▾`})]}),i?(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-full z-20 mt-1 max-h-80 overflow-y-auto rounded-xl bg-surface-1/95 p-1 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.08),0_16px_32px_-12px_rgba(0,0,0,0.8)] backdrop-blur-xl`,children:t.map((e,t)=>{let i=e.value===n;return(0,H.jsxs)(`button`,{ref:e=>{c.current[t]=e},type:`button`,"aria-current":i?`true`:void 0,onKeyDown:u,onClick:()=>{r(e.value),a(!1),s.current?.focus()},className:`flex w-full items-start gap-2 rounded-lg px-2.5 py-1.5 text-left transition-colors focus-visible:outline-none ${i?`bg-surface-2/80`:`hover:bg-surface-2/50 focus-visible:bg-surface-2/50`}`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`block truncate text-xs text-fg-secondary`,children:[e.name,e.id===null?null:(0,H.jsxs)(`span`,{className:`text-fg-tertiary`,children:[` · `,e.id]})]}),e.description===``?null:(0,H.jsx)(`span`,{className:`block truncate text-[11px] text-fg-muted`,children:e.description})]}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0 pt-px text-[11px] text-fg-primary`,children:i?`✓`:``})]},e.value)})}):null]})}var Z=``;function ke(e,t){return[{value:Z,name:`CLI default`,id:e.find(e=>e.isDefault)?.name??null,description:`Whatever the CLI runs when no model is set.`},...e.map(e=>({value:e.id,name:e.name,id:e.name===e.id?null:e.id,description:e.description})),...t===null?[]:[{value:t,name:t,id:null,description:`Not in the CLI's list.`}]]}function Ae({member:e,onDone:t}){let{api:r}=n(),a=v(),o=c(e.cli),s=e.model??Z,[l,u]=(0,V.useState)(s),d=E({mutationFn:()=>r.setModel(e.name,l===Z?null:l),onSuccess:()=>{a.invalidateQueries({queryKey:[`members`]}),t()}}),f=o.data??[],p=e.model!==void 0&&!f.some(t=>t.id===e.model)?e.model:null;return(0,H.jsxs)(`form`,{"aria-label":`Model of ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),d.mutate()},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o.isPending?(0,H.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:[`Asking `,e.cli,` for its models…`]}):o.error===null?(0,H.jsx)(X,{label:`Model`,choices:ke(f,p),value:l,onChange:u}):(0,H.jsxs)(`p`,{role:`alert`,className:`min-w-0 flex-1 truncate text-xs text-red-400`,children:[e.cli,` did not list its models:`,` `,o.error instanceof i?o.error.message:`the board server did not answer`]}),(0,H.jsx)(D,{onClick:t,children:`Cancel`}),(0,H.jsx)(D,{variant:`primary`,type:`submit`,disabled:d.isPending||l===s||o.error!==null,children:d.isPending?`Saving…`:`Use this model`})]}),(0,H.jsx)(R,{error:d.error})]})}var Q=``;function je(e,t){let n=t.cli;return[e.status,e.clis.length===0?`offers no CLI yet`:e.clis.join(`, `),n!==null&&e.clis.length>0&&!e.clis.includes(n)?`has no ${n}`:``,e.capabilities.length===0?``:e.capabilities.join(`, `)].filter(e=>e!==``).join(` · `)}function Me(e,t){return[{value:Q,name:`Any runner`,id:null,description:`Pinned to the least busy runner on its next turn outside a project.`},...e.map(e=>({value:e.name,name:e.name,id:e.os,description:je(e,t)}))]}function Ne({member:e,onDone:t}){let{api:r}=n(),i=v(),a=S(),o=e.homeRunner??Q,[s,c]=(0,V.useState)(o),l=E({mutationFn:()=>r.setRunner(e.name,s===Q?null:s),onSuccess:()=>{i.invalidateQueries({queryKey:[`members`]}),t()}});return(0,H.jsxs)(`form`,{"aria-label":`Runner of ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),l.mutate()},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a.data===void 0?(0,H.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:`Reading the runners…`}):(0,H.jsx)(X,{label:`Runner`,choices:Me(a.data,e),value:s,onChange:c}),(0,H.jsx)(D,{onClick:t,children:`Cancel`}),(0,H.jsx)(D,{variant:`primary`,type:`submit`,disabled:l.isPending||s===o,children:l.isPending?`Saving…`:`Run here`})]}),(0,H.jsx)(`p`,{className:`text-meta`,children:`Its conversations outside projects start afresh there from its next turn; its memory and skills follow it. Project work runs where each project lives.`}),(0,H.jsx)(R,{error:l.error})]})}function Pe(e){return e.thread===void 0?{channel:e.channel??(e.scope===`society`?`general`:`${e.scope}/general`)}:{threadId:e.thread}}function Fe({name:e,turn:t}){let{api:r}=n(),i=v(),[a,o]=(0,V.useState)(!1),s=E({mutationFn:()=>r.stopTurn(t.turnId),onSuccess:()=>{o(!1),i.invalidateQueries({queryKey:[`scheduler`]})}});return(0,H.jsxs)(`div`,{className:`border-t border-line`,children:[(0,H.jsx)(re,{target:Pe(t),initialText:`@${e} `,placeholder:t.steerable?`Message ${e} while it works`:`Message ${e} for its next turn`,className:`px-3 pt-3 pb-2`},t.turnId),t.stoppable?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-3`,children:[(0,H.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-fg-muted`,children:a?`Ends the turn now. What it was shown counts as read; its stages stay held.`:t.steerable?`Posts reach the turn at its next step.`:`This runner delivers posts after the turn ends.`}),a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(D,{onClick:()=>{o(!1),s.reset()},children:`Keep it running`}),(0,H.jsx)(D,{variant:`primary`,disabled:s.isPending,onClick:()=>{s.mutate()},children:s.isPending?`Stopping…`:`Stop the turn`})]}):(0,H.jsx)(D,{onClick:()=>o(!0),children:`Stop…`})]}):null,s.error===null?null:(0,H.jsx)(`div`,{className:`px-3 pb-3`,children:(0,H.jsx)(R,{error:s.error})})]})}function Ie({member:e,scopes:t,preferred:r,running:i,paused:a,onDone:o}){let{api:s}=n(),c=v(),[l,u]=(0,V.useState)(`manual`),[d,f]=(0,V.useState)(r!==null&&t.includes(r)?r:t[0]??``),[p,m]=(0,V.useState)(``),h=(0,V.useRef)(null);(0,V.useEffect)(()=>h.current?.focus(),[]);let g=E({mutationFn:()=>s.wake({agent:e.name,project:d,kind:l,...p.trim()===``?{}:{reason:p.trim()}}),onSuccess:()=>{c.invalidateQueries({queryKey:[`scheduler`]}),o()}}),_=z(d),y=l===`reflection`?`Asks ${e.name} to reflect at ${_}: consolidate its memory, skills, and profile, and take no new work. It restarts the reflection clock.`:`Starts a turn for ${e.name} at ${_} as soon as the scheduler takes it.`,b=a?` The society is paused, so it waits until you resume.`:i.includes(d)?` ${e.name} is in a turn there now; this one follows it.`:``;return(0,H.jsxs)(`form`,{"aria-label":`Wake ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),g.mutate()},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`fieldset`,{className:`flex gap-1`,children:[(0,H.jsx)(`legend`,{className:`sr-only`,children:`Kind of turn`}),[`manual`,`reflection`].map(e=>(0,H.jsxs)(`label`,{className:`cursor-pointer rounded-md px-2.5 py-1 text-xs transition-colors has-focus-visible:ring-2 has-focus-visible:ring-fg-primary/30 ${l===e?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`kind`,value:e,checked:l===e,onChange:()=>u(e),className:`sr-only`}),e===`manual`?`A turn`:`A reflection`]},e))]}),(0,H.jsxs)(`label`,{className:`ml-auto flex items-center gap-2 text-xs text-fg-tertiary`,children:[`at`,(0,H.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),"aria-label":`Where`,className:`rounded-md bg-surface-2/60 px-2 py-1 text-xs text-fg-primary outline-none`,children:t.map(e=>(0,H.jsx)(`option`,{value:e,children:z(e)},e))})]})]}),(0,H.jsx)(`textarea`,{ref:h,value:p,rows:2,placeholder:l===`reflection`?`Anything to reflect on in particular? Optional.`:`What should it look at? It reads this as the reason it was woken.`,"aria-label":`Reason`,onChange:e=>m(e.target.value),className:`${ae} resize-none`}),(0,H.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-fg-muted`,children:[y,b,` Each turn costs money.`]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(D,{onClick:o,children:`Cancel`}),(0,H.jsx)(D,{variant:`primary`,type:`submit`,disabled:g.isPending||d===``,children:g.isPending?`Waking…`:l===`reflection`?`Ask for a reflection`:`Wake ${e.name}`})]}),(0,H.jsx)(R,{error:g.error})]})}var Le={working:`bg-emerald-500/15 text-emerald-300`,queued:`bg-amber-500/15 text-amber-300`,idle:`bg-surface-2 text-fg-tertiary`};function Re({project:e,name:t}){let n=(a(e).data??[]).filter(e=>e.status===`claimed`&&e.claimedBy===t);return n.length===0?null:(0,H.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:n.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(d,{to:`/task/$taskId`,params:{taskId:e.id},className:`flex items-center gap-2 rounded-md text-xs text-fg-secondary hover:text-fg-primary`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◇`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,H.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate font-mono text-[11px] text-fg-muted`,children:u(e)?.name??e.stage})]})},e.id))})}function ze(){let{name:e}=T({from:`/citizen/$name`}),{scope:t,tab:n,turn:r}=w({from:`/citizen/$name`});return(0,H.jsx)(Ve,{name:e,chosen:t??null,tab:n??`now`,turn:r??null},e)}var Be=[{tab:`now`,label:`Now`},{tab:`turns`,label:`Turns`},{tab:`memory`,label:`Memory`},{tab:`history`,label:`History`}];function Ve({name:n,chosen:r,tab:i,turn:a}){let o=_(),c=t(),l=s(),u=A(),[f,p]=(0,V.useState)(null),m=o.data?.find(e=>e.name===n);if(m===void 0)return(0,H.jsx)(L,{children:o.data===void 0?`Reading the roster…`:`There is no citizen ${n}.`});let h=e(l.data?.running??[]).filter(e=>e.agent===n),g=[...new Set(h.map(e=>e.scope))],v=h.map(e=>O(e.agent,e.scope,e.thread)),y=e(l.data?.pending??[]).find(e=>e.agent===n),b=g.length>0?`working`:y===void 0?`idle`:`queued`,x=j(u,n)[0],S=x?.model??m.lastModel,C=S??m.model??`CLI default`,w=m.model!==void 0&&m.model!==S?m.model:null,T=c.data?.find(e=>e.name===m.role),E=ue(m),k=m.status===`active`&&m.cli!==null;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ie,{leading:m.cli===null?null:(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-2/70`,children:(0,H.jsx)(ee,{cli:m.cli,size:20})}),title:n,subtitle:(0,H.jsxs)(H.Fragment,{children:[m.role,` · `,C,w===null?``:` · set to ${w}`,m.homeRunner===void 0?``:` · on ${m.homeRunner}`,m.status===`retired`?` · retired`:``]}),trailing:(0,H.jsxs)(H.Fragment,{children:[k&&f===null?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(D,{onClick:()=>p(`model`),children:`Model…`}),(0,H.jsx)(D,{onClick:()=>p(`runner`),children:`Runner…`}),(0,H.jsx)(D,{onClick:()=>p(`wake`),children:`Wake…`})]}):null,(0,H.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${Le[b]}`,children:b})]})}),f===`wake`?(0,H.jsx)(Ie,{member:m,scopes:E,preferred:r?.split(`/`)[0]??x?.scope??null,running:g,paused:l.data?.paused??!1,onDone:()=>p(null)}):f===`model`?(0,H.jsx)(Ae,{member:m,onDone:()=>p(null)}):f===`runner`?(0,H.jsx)(Ne,{member:m,onDone:()=>p(null)}):null,(0,H.jsx)(`nav`,{"aria-label":`Citizen views`,className:`flex gap-1 border-b border-line px-3 py-2`,children:Be.map(e=>(0,H.jsx)(d,{to:`/citizen/$name`,params:{name:n},search:{...r===null?{}:{scope:r},...e.tab===`now`?{}:{tab:e.tab}},replace:!0,"aria-current":e.tab===i?`page`:void 0,className:`rounded-md px-2.5 py-1 text-xs transition-colors ${e.tab===i?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:e.label},e.tab))}),i===`turns`?(0,H.jsx)(De,{name:n,cli:m.cli,opened:a},a):i===`memory`?(0,H.jsx)(we,{member:m,charter:T}):i===`history`?(0,H.jsx)(Ce,{name:n}):(0,H.jsx)(He,{name:n,chosen:r,lastTurnAt:m.lastTurnAt,state:b,runningScopes:g,runningKeys:v,runningTurns:(l.data?.turns??[]).filter(e=>e.agent===n),queuedScope:y?.scope??null})]})}function $(e){return e.toSorted((e,t)=>e.startedAt.localeCompare(t.startedAt))[0]}function He({name:e,chosen:t,lastTurnAt:n,state:i,runningScopes:a,runningKeys:o,runningTurns:s,queuedScope:c}){let l=A(),u=x(5e3),{ref:f,onScroll:p}=oe(),m=j(l,e),h=r(e,1),g=J(e,m.length===0?h.data?.at(-1):void 0),_=F(),v=e=>e.end===null&&o.includes(O(e.agent,e.scope,e.thread)),b=t?.split(`/`)[0]??null,S=(t?.includes(`/`)===!0?m.find(e=>M(e)===t):void 0)??$(m.filter(e=>e.scope===b&&v(e)))??m.find(e=>M(e)===t)??$(m.filter(v))??m[0]??g.turn,C=e=>e.thread===void 0?z(e.scope):`${z(e.scope)} · ${_.get(e.thread)?.title??`a thread`}`,w=S!==void 0&&v(S),T=S?.scope??a[0]??c,E=(S===void 0?void 0:s.find(e=>e.scope===S.scope&&e.thread===S.thread))??(w?void 0:s[0]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`border-b border-line px-4 py-3 text-xs text-fg-tertiary`,children:[(0,H.jsx)(`p`,{children:w?`In a turn at ${z(S.scope)} for ${S.fromStart?``:`at least `}${N(S.startedAt,u)}`:a.length>0?`In a turn at ${a.map(z).join(` and `)}`:c===null?n===void 0?`No turns yet`:`Last turn ${y(n,u)}`:`Queued for a turn at ${z(c)}`}),T===null||T===`society`?null:(0,H.jsx)(Re,{project:T,name:e})]}),(0,H.jsx)(`div`,{ref:f,onScroll:p,className:`flex-1 overflow-y-auto px-4 py-3`,children:S===void 0?(0,H.jsx)(L,{children:i===`working`?`The turn has not reported a step yet.`:g.loading?`Reading the last turn…`:n===void 0?`${e} has not taken a turn yet.`:`${e}'s last turn kept no steps; Turns lists every finished one.`}):(0,H.jsxs)(H.Fragment,{children:[m.length>1?(0,H.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,"aria-label":`Turns by conversation`,children:m.toSorted((e,t)=>M(e).localeCompare(M(t))).map(t=>(0,H.jsxs)(d,{to:`/citizen/$name`,params:{name:e},search:{scope:M(t)},replace:!0,"aria-current":t===S?`true`:void 0,className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[11px] transition-colors ${t===S?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[v(t)?(0,H.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-400`}):null,C(t)]},M(t)))}):null,(0,H.jsxs)(`p`,{className:`text-caps`,children:[w?`This turn`:`Last turn`,` · `,C(S),` · started`,` `,S.fromStart?U(S.startedAt):`before the earliest step shown`]}),S.fromStart?null:(0,H.jsxs)(`p`,{className:`mt-1 text-meta`,children:[`Earlier steps of this turn are no longer in the server's live buffer`,w?``:`; Turns has the whole turn`,`.`]}),(0,H.jsx)(G,{steps:S.steps}),(0,H.jsx)(me,{turn:S,running:w,now:u})]})}),E===void 0?null:(0,H.jsx)(Fe,{name:e,turn:E})]})}export{ze as CitizenView};
1
+ import{C as e,E as t,F as n,I as r,L as i,N as a,T as o,V as s,_ as c,_n as l,a as u,bn as d,d as f,f as p,gn as m,h,hn as g,m as _,ot as v,t as y,u as b,v as x,w as S,xt as C}from"./format-8m6fdeP8.js";import{F as w,I as T,L as E,S as ee,a as D,d as O,f as k,g as A,h as j,l as M,m as te,p as ne,t as re,u as N,v as P,y as F}from"./index-CADeLxUP.js";import{t as I}from"./Markdown-BrvfGmz7.js";import{n as L,t as ie}from"./Pane-JzhKR0rO.js";import{n as ae,r as R}from"./ThreadForms-C4ytMMBB.js";import{t as oe}from"./useStickyScroll-BPuANcOs.js";import{a as z,c as B,n as se,o as ce,r as le,s as ue,t as de}from"./citizen-TjyiyFqE.js";var V=d(l(),1),H=m(),fe={completed:`completed`,timeout:`timed out`,error:`failed`,interrupted:`was interrupted`,blocked:`was blocked`,stopped:`was stopped by you`};function U(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function W({label:e,tone:t,children:n}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`px-0.5 pb-0.5 text-[10px] tracking-wider text-fg-muted uppercase`,children:e}),(0,H.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-surface-0/60 p-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words ${t}`,children:n})]})}function pe({step:e,open:t}){if(e.kind===`say`)return(0,H.jsx)(`li`,{className:`py-1.5 text-sm`,title:U(e.at),children:(0,H.jsx)(I,{text:e.text})});if(e.kind===`error`)return(0,H.jsx)(`li`,{className:`py-1 font-mono text-xs break-words text-red-400`,title:U(e.at),children:e.message});if(e.kind===`steer`)return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:t,className:`group rounded-md open:bg-surface-2/30`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md px-1.5 py-1 text-xs hover:bg-surface-2/40`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`grid w-3 shrink-0 place-items-center text-sky-300`,children:`↳`}),(0,H.jsxs)(`span`,{className:`shrink-0 text-fg-tertiary`,children:[`Took `,k(e.posts.length)]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:e.from.length===0?``:`from ${e.from.join(`, `)}, delivered mid-turn`}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-muted`,children:U(e.at)})]}),(0,H.jsx)(`ul`,{className:`space-y-1.5 px-1.5 pb-1.5`,children:e.posts.map(e=>(0,H.jsxs)(`li`,{className:`rounded-md bg-surface-0/40 px-2.5 py-2`,children:[(0,H.jsxs)(`p`,{className:`flex gap-1.5 text-meta`,children:[(0,H.jsx)(`span`,{className:`text-fg-secondary`,children:e.author}),(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`in `,e.where]}),e.at===``?null:(0,H.jsx)(`span`,{className:`ml-auto shrink-0 font-mono`,children:U(e.at)})]}),(0,H.jsx)(`div`,{className:`mt-1 text-sm`,children:(0,H.jsx)(I,{text:e.body})})]},`${e.at}-${e.author}`))})]})});let n=e.ok===null?(0,H.jsx)(`span`,{"aria-label":`running`,className:`size-1.5 animate-pulse rounded-full bg-amber-300`}):e.ok?(0,H.jsx)(`span`,{"aria-label":`succeeded`,className:`text-[11px] text-emerald-400`,children:`✓`}):(0,H.jsx)(`span`,{"aria-label":`failed`,className:`text-[11px] text-red-400`,children:`✕`});return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:t,className:`group rounded-md open:bg-surface-2/30`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md px-1.5 py-1 text-xs hover:bg-surface-2/40`,children:[(0,H.jsx)(`span`,{className:`grid w-3 shrink-0 place-items-center`,children:n}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-fg-tertiary`,children:ne(e.name)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-fg-secondary`,children:e.summary}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-muted`,children:U(e.at)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5 px-1.5 pb-1.5`,children:[(0,H.jsx)(W,{label:`Input`,tone:`text-fg-secondary`,children:e.detail}),e.output===null?null:(0,H.jsx)(W,{label:e.ok===!1?`Returned an error`:`Returned`,tone:e.ok===!1?`text-red-300`:`text-fg-tertiary`,children:e.output})]})]})})}function G({steps:e}){let[t,n]=(0,V.useState)(!1),r=e.filter(e=>e.kind===`tool`).length;return e.length===0?(0,H.jsx)(`p`,{className:`mt-2 text-meta`,children:`No steps yet.`}):(0,H.jsxs)(H.Fragment,{children:[r===0?null:(0,H.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-meta`,children:[r===1?`1 tool call`:`${r} tool calls`,(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(!t),className:`rounded-md px-1.5 py-0.5 text-fg-tertiary transition-colors hover:bg-surface-2/60 hover:text-fg-primary`,children:t?`Collapse all`:`Expand all`})]}),(0,H.jsx)(`ol`,{className:`mt-1 space-y-0.5`,children:e.map(e=>(0,H.jsx)(pe,{step:e,open:t},e.seq))})]})}function me({turn:e,running:t,now:n}){if(e.end!==null){let t=e.end.costUsd>0?` · $${e.end.costUsd.toFixed(2)}`:``;return(0,H.jsxs)(`section`,{className:`mt-3 rounded-xl bg-surface-2/40 px-3.5 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]`,children:[(0,H.jsxs)(`p`,{className:`text-caps`,children:[`The turn `,fe[e.end.exitReason],` `,y(e.end.at,n),t,e.fromStart?` · ${N(e.startedAt,Date.parse(e.end.at))}`:``]}),e.end.summary===null?null:(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:e.end.summary})]})}return t?(0,H.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-meta`,"aria-live":`polite`,children:[(0,H.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-400`}),`Working · last step `,y(e.lastAt,n)]}):(0,H.jsx)(`p`,{className:`mt-3 text-meta`,children:`The turn ended without a report.`})}var K=30,he={turn:`turn`,board:`board`,merge:`both kept`},ge={turn:`Changed by a turn`,board:`Written by the board`,merge:`Both versions kept`};function _e(e){return e.status===`added`?`new`:e.status===`deleted`?`deleted`:e.added===null||e.removed===null?`binary`:`+${e.added} −${e.removed}`}function ve(e){return e.files.map(e=>`${e.path} ${_e(e)}`).join(`, `)}function ye(e){return e.startsWith(`@@`)||e.startsWith(`\\`)?`text-fg-muted`:e.startsWith(`+`)?`text-emerald-300`:e.startsWith(`-`)?`text-red-300`:`text-fg-tertiary`}function be({file:e}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[e.path,e.status===`modified`?``:(0,H.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,e.status]})]}),e.patch===null?(0,H.jsx)(`p`,{className:`mt-1 text-meta`,children:`A binary file; its contents are not shown.`}):e.patch===``?(0,H.jsx)(`p`,{className:`mt-1 text-meta`,children:`Empty.`}):(0,H.jsx)(`pre`,{className:`mt-1 max-h-96 overflow-auto rounded-md bg-surface-0/60 p-2 font-mono text-[11px] leading-relaxed`,children:e.patch.split(`
2
+ `).map((e,t)=>(0,H.jsx)(`span`,{className:`block whitespace-pre-wrap break-words ${ye(e)}`,children:e===``?` `:e},t))}),e.truncated?(0,H.jsx)(`p`,{className:`mt-1 text-meta`,children:`The rest of this file's change is cut.`}):null]})}function xe({name:e,change:t}){let n=b(e,t.commit,!0);return(0,H.jsxs)(`div`,{className:`space-y-3 px-4 pt-1 pb-3`,children:[(0,H.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[t.kind===`merge`?`Two turns on different runners changed the same lines at once. The file kept one turn's version, and this copy holds the other's until the citizen reconciles them.`:t.kind===`board`?`Written by the board: ${t.subject.replace(/^home: /,``)}.`:t.turnId===void 0?t.subject:(0,H.jsx)(C,{to:`/citizen/$name`,params:{name:e},search:{tab:`turns`,turn:t.turnId},className:`text-fg-secondary underline decoration-line underline-offset-2 hover:text-fg-primary`,children:`Open the turn that made it`}),(0,H.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,U(t.at)]})]}),n.data===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:n.isError?`Could not read the change.`:`Reading the change…`}):n.data.map(e=>(0,H.jsx)(be,{file:e},e.path))]})}function Se({name:e,change:t,now:n}){let[r,i]=(0,V.useState)(!1),a=t.files.length===0?t.subject:ve(t);return(0,H.jsx)(`li`,{className:`border-b border-line/60 last:border-b-0`,children:(0,H.jsxs)(`details`,{className:`group`,onToggle:e=>i(e.currentTarget.open),children:[(0,H.jsx)(`summary`,{"aria-label":`${ge[t.kind]} ${y(t.at,n)}: ${a}`,className:`block cursor-pointer list-none px-4 py-2.5 transition-colors hover:bg-surface-2/30 group-open:bg-surface-2/20`,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:he[t.kind]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:a}),(0,H.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:y(t.at,n)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[10px] text-fg-muted transition-transform group-open:rotate-90`,children:`▸`})]})}),r?(0,H.jsx)(xe,{name:e,change:t}):null]})})}function Ce({name:e}){let[t,n]=(0,V.useState)(K),r=p(e,t),i=x(3e4);if(r.data===void 0)return(0,H.jsx)(L,{children:r.isError?`Could not read the home's history.`:`Reading the history…`});let{changes:a,more:o}=r.data;return a.length===0?(0,H.jsxs)(L,{children:[e,`'s home has no history yet; it starts with the citizen's first turn.`]}):(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,H.jsxs)(`p`,{className:`px-4 pt-3 pb-1 text-meta`,children:[`What `,e,`'s turns changed in its memory, skills, and profile, newest first.`]}),(0,H.jsx)(`ol`,{children:a.map(t=>(0,H.jsx)(Se,{name:e,change:t,now:i},t.commit))}),o?(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(t+K),className:`px-4 py-3 text-xs text-fg-tertiary hover:text-fg-primary`,children:`Show earlier changes`}):null]})}function q({title:e,children:t}){return(0,H.jsxs)(`section`,{className:`border-t border-line pt-4 first:border-t-0 first:pt-0`,children:[(0,H.jsx)(`h3`,{className:`text-section`,children:e}),(0,H.jsx)(`div`,{className:`mt-2`,children:t})]})}function we({member:e,charter:t}){let n=h(e.name),r=u(e.name),i=f(e.name),a=x(3e4);return(0,H.jsxs)(`div`,{className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[i.data===void 0||i.data.length===0?null:(0,H.jsxs)(q,{title:`Edits to reconcile`,children:[(0,H.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`Two turns on different runners changed these files at once. Each file kept one version; the other waits beside it until `,e.name,` merges it in and deletes the copy.`]}),(0,H.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:i.data.map(e=>(0,H.jsxs)(`li`,{className:`text-sm`,children:[(0,H.jsx)(`span`,{className:`text-fg-primary`,children:e.file}),(0,H.jsxs)(`span`,{className:`text-meta`,children:[` `,`· `,e.path.slice(e.path.lastIndexOf(`/`)+1),` · left`,` `,y(e.since,a)]})]},e.path))})]}),(0,H.jsx)(q,{title:`Profile`,children:e.profile.trim()===``?(0,H.jsx)(`p`,{className:`text-meta`,children:`No profile yet. The citizen writes its own profile.md.`}):(0,H.jsx)(I,{text:B(e.profile,`Profile`)})}),(0,H.jsx)(q,{title:`Core memory`,children:n.data===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`Reading…`}):n.data.body.trim()===``?(0,H.jsx)(`p`,{className:`text-meta`,children:`Empty. Every turn loads this file in full.`}):(0,H.jsx)(I,{text:B(n.data.body,`Core memory`)})}),(0,H.jsx)(q,{title:`Own skills`,children:r.data===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`Reading…`}):r.data.length===0?(0,H.jsx)(`p`,{className:`text-meta`,children:`None yet.`}):(0,H.jsx)(`ul`,{className:`space-y-1.5`,children:r.data.map(e=>(0,H.jsxs)(`li`,{className:`text-sm`,children:[(0,H.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),e.summary===``?null:(0,H.jsxs)(`span`,{className:`text-fg-secondary`,children:[` · `,e.summary]})]},e.name))})}),t===void 0?null:(0,H.jsxs)(q,{title:`Charter of ${t.name}`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:t.purpose}),(0,H.jsxs)(`p`,{className:`mt-2 text-meta`,children:[`Wakes on mentions, stages, and `,t.wakeTriggers.join(`, `)||`nothing else`,t.resident?` · keeps a warm session`:``,t.reflects?` · reflects`:``]}),(0,H.jsx)(`p`,{className:`mt-2 flex flex-wrap gap-1`,children:t.verbs.map(e=>(0,H.jsx)(`span`,{className:`rounded-md bg-surface-2/70 px-1.5 py-px font-mono text-[11px] text-fg-tertiary`,children:e},e))})]})]})}function J(e,t){let r=n(e,t?.turnId??null);return{turn:(0,V.useMemo)(()=>t===void 0||r.data===void 0?void 0:te(r.data,e,t.project,t.thread),[t,r.data,e]),loading:t?.turnId!==void 0&&r.isPending,missing:t!==void 0&&(t.turnId===void 0||r.isError)}}var Y=50;function Te({name:e,entry:t,cli:n,now:r,opened:i}){let[a,o]=(0,V.useState)(i),s=(0,V.useRef)(null);(0,V.useEffect)(()=>{i&&s.current?.scrollIntoView({block:`start`})},[i]);let c=F(),l=ce(t),u=t.thread===void 0?null:c.get(t.thread)?.title??`a thread`,d=t.error??t.summary??``,f=t.error===null?`text-fg-secondary`:`text-red-300`;return(0,H.jsx)(`li`,{ref:s,className:`border-b border-line/60 last:border-b-0`,children:(0,H.jsxs)(`details`,{className:`group`,open:a,onToggle:e=>o(e.currentTarget.open),children:[(0,H.jsxs)(`summary`,{className:`block cursor-pointer list-none px-4 py-2.5 transition-colors hover:bg-surface-2/30 group-open:bg-surface-2/20`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 truncate text-fg-secondary`,children:[z(t.project),u===null?``:` · ${u}`]}),(0,H.jsx)(`span`,{className:`text-fg-muted`,children:t.trigger}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-fg-muted`,children:[se(t),` `,y(t.ts,r)]}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-tertiary`,children:[l,t.toolCalls===void 0?null:`${t.toolCalls} tools`,de(t,n)].filter(e=>e!==null).join(` · `)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[10px] text-fg-muted transition-transform group-open:rotate-90`,children:`▸`})]}),d.trim()===``?null:(0,H.jsx)(`span`,{className:`mt-1 line-clamp-2 block text-xs leading-relaxed group-open:hidden ${f}`,children:(0,H.jsx)(P,{text:d,links:!1})})]}),a?(0,H.jsx)(Ee,{name:e,entry:t,text:d,tone:f}):null]})})}function Ee({name:e,entry:t,text:n,tone:r}){let i=J(e,t);return(0,H.jsxs)(`div`,{className:`px-4 pt-1 pb-3`,children:[n.trim()===``?null:(0,H.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap ${r}`,children:(0,H.jsx)(P,{text:n})}),(0,H.jsx)(`div`,{className:`mt-2`,children:t.turnId===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`This turn ran before turns kept their steps.`}):i.loading?(0,H.jsx)(`p`,{className:`text-meta`,children:`Reading the steps…`}):i.turn===void 0?(0,H.jsx)(`p`,{className:`text-meta`,children:`No steps were kept for this turn.`}):(0,H.jsxs)(H.Fragment,{children:[t.startedAt===void 0?null:(0,H.jsxs)(`p`,{className:`text-caps`,children:[`Started `,U(t.startedAt)]}),(0,H.jsx)(G,{steps:i.turn.steps})]})})]})}function De({name:e,cli:t,opened:n}){let[i,a]=(0,V.useState)(Y),o=r(e,i),s=x(3e4);if(o.data===void 0)return(0,H.jsx)(L,{children:`Reading the turns…`});let c=o.data.toReversed();if(c.length===0)return(0,H.jsxs)(L,{children:[e,` has not finished a turn yet.`]});let l=le(c),u=t===`codex`?`unmetered`:`$${l.costUsd.toFixed(2)}`;return(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,H.jsxs)(`p`,{className:`px-4 pt-3 pb-1 text-meta`,children:[l.turns===1?`1 turn`:`${l.turns} turns`,l.failed===0?``:`, ${l.failed} not completed`,` · `,u]}),n!==null&&!c.some(e=>e.turnId===n)?(0,H.jsx)(`p`,{className:`px-4 pb-1 text-meta`,children:o.data.length===i?`The turn this address opens is further back; show earlier turns to reach it.`:`The turn this address opens is not in this citizen's history.`}):null,(0,H.jsx)(`ol`,{children:c.map(r=>(0,H.jsx)(Te,{name:e,entry:r,cli:t,now:s,opened:n!==null&&r.turnId===n},r.id))}),o.data.length===i?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>a(i+Y),className:`px-4 py-3 text-xs text-fg-tertiary hover:text-fg-primary`,children:[`Show `,Y,` earlier turns`]}):null]})}function Oe(e){return e===void 0?``:`${e.name}${e.id===null?``:` · ${e.id}`}`}function X({label:e,choices:t,value:n,onChange:r}){let[i,a]=(0,V.useState)(!1),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)([]),l=t.findIndex(e=>e.value===n);(0,V.useEffect)(()=>{if(!i)return;c.current[Math.max(l,0)]?.focus();let e=e=>{e.target instanceof Node&&o.current?.contains(e.target)===!0||a(!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[i,l]);let u=e=>{if(e.key===`Escape`){e.stopPropagation(),a(!1),s.current?.focus();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let n=(c.current.findIndex(e=>e===document.activeElement)+(e.key===`ArrowDown`?1:-1)+t.length)%t.length;c.current[n]?.focus()},d=t[l];return(0,H.jsxs)(`div`,{ref:o,className:`relative min-w-0 flex-1`,children:[(0,H.jsxs)(`button`,{ref:s,type:`button`,"aria-label":`${e}: ${Oe(d)}`,"aria-expanded":i,onClick:()=>a(!i),onKeyDown:i?u:void 0,className:`flex h-7 w-full items-center gap-1.5 rounded-md bg-surface-2/60 px-2.5 text-xs text-fg-secondary transition-colors hover:bg-surface-2 focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:[d?.name,d?.id===null||d===void 0?null:(0,H.jsxs)(`span`,{className:`text-fg-tertiary`,children:[` · `,d.id]})]}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-[10px] text-fg-muted transition-transform ${i?`rotate-180`:``}`,children:`▾`})]}),i?(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-full z-20 mt-1 max-h-80 overflow-y-auto rounded-xl bg-surface-1/95 p-1 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.08),0_16px_32px_-12px_rgba(0,0,0,0.8)] backdrop-blur-xl`,children:t.map((e,t)=>{let i=e.value===n;return(0,H.jsxs)(`button`,{ref:e=>{c.current[t]=e},type:`button`,"aria-current":i?`true`:void 0,onKeyDown:u,onClick:()=>{r(e.value),a(!1),s.current?.focus()},className:`flex w-full items-start gap-2 rounded-lg px-2.5 py-1.5 text-left transition-colors focus-visible:outline-none ${i?`bg-surface-2/80`:`hover:bg-surface-2/50 focus-visible:bg-surface-2/50`}`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`block truncate text-xs text-fg-secondary`,children:[e.name,e.id===null?null:(0,H.jsxs)(`span`,{className:`text-fg-tertiary`,children:[` · `,e.id]})]}),e.description===``?null:(0,H.jsx)(`span`,{className:`block truncate text-[11px] text-fg-muted`,children:e.description})]}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0 pt-px text-[11px] text-fg-primary`,children:i?`✓`:``})]},e.value)})}):null]})}var Z=``;function ke(e,t){return[{value:Z,name:`CLI default`,id:e.find(e=>e.isDefault)?.name??null,description:`Whatever the CLI runs when no model is set.`},...e.map(e=>({value:e.id,name:e.name,id:e.name===e.id?null:e.id,description:e.description})),...t===null?[]:[{value:t,name:t,id:null,description:`Not in the CLI's list.`}]]}function Ae({member:e,onDone:n}){let{api:r}=t(),a=g(),o=c(e.cli),s=e.model??Z,[l,u]=(0,V.useState)(s),d=E({mutationFn:()=>r.setModel(e.name,l===Z?null:l),onSuccess:()=>{a.invalidateQueries({queryKey:[`members`]}),n()}}),f=o.data??[],p=e.model!==void 0&&!f.some(t=>t.id===e.model)?e.model:null;return(0,H.jsxs)(`form`,{"aria-label":`Model of ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),d.mutate()},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o.isPending?(0,H.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:[`Asking `,e.cli,` for its models…`]}):o.error===null?(0,H.jsx)(X,{label:`Model`,choices:ke(f,p),value:l,onChange:u}):(0,H.jsxs)(`p`,{role:`alert`,className:`min-w-0 flex-1 truncate text-xs text-red-400`,children:[e.cli,` did not list its models:`,` `,o.error instanceof i?o.error.message:`the board server did not answer`]}),(0,H.jsx)(D,{onClick:n,children:`Cancel`}),(0,H.jsx)(D,{variant:`primary`,type:`submit`,disabled:d.isPending||l===s||o.error!==null,children:d.isPending?`Saving…`:`Use this model`})]}),(0,H.jsx)(R,{error:d.error})]})}var Q=``;function je(e,t){let n=t.cli;return[e.status,e.clis.length===0?`offers no CLI yet`:e.clis.join(`, `),n!==null&&e.clis.length>0&&!e.clis.includes(n)?`has no ${n}`:``,e.capabilities.length===0?``:e.capabilities.join(`, `)].filter(e=>e!==``).join(` · `)}function Me(e,t){return[{value:Q,name:`Any runner`,id:null,description:`Pinned to the least busy runner on its next turn outside a project.`},...e.map(e=>({value:e.name,name:e.name,id:e.os,description:je(e,t)}))]}function Ne({member:e,onDone:n}){let{api:r}=t(),i=g(),a=S(),o=e.homeRunner??Q,[s,c]=(0,V.useState)(o),l=E({mutationFn:()=>r.setRunner(e.name,s===Q?null:s),onSuccess:()=>{i.invalidateQueries({queryKey:[`members`]}),n()}});return(0,H.jsxs)(`form`,{"aria-label":`Runner of ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),l.mutate()},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a.data===void 0?(0,H.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:`Reading the runners…`}):(0,H.jsx)(X,{label:`Runner`,choices:Me(a.data,e),value:s,onChange:c}),(0,H.jsx)(D,{onClick:n,children:`Cancel`}),(0,H.jsx)(D,{variant:`primary`,type:`submit`,disabled:l.isPending||s===o,children:l.isPending?`Saving…`:`Run here`})]}),(0,H.jsx)(`p`,{className:`text-meta`,children:`Its conversations outside projects start afresh there from its next turn; its memory and skills follow it. Project work runs where each project lives.`}),(0,H.jsx)(R,{error:l.error})]})}function Pe(e){return e.thread===void 0?{channel:e.channel??(e.scope===`society`?`general`:`${e.scope}/general`)}:{threadId:e.thread}}function Fe({name:e,turn:n}){let{api:r}=t(),i=g(),[a,o]=(0,V.useState)(!1),s=E({mutationFn:()=>r.stopTurn(n.turnId),onSuccess:()=>{o(!1),i.invalidateQueries({queryKey:[`scheduler`]})}});return(0,H.jsxs)(`div`,{className:`border-t border-line`,children:[(0,H.jsx)(re,{target:Pe(n),initialText:`@${e} `,placeholder:n.steerable?`Message ${e} while it works`:`Message ${e} for its next turn`,className:`px-3 pt-3 pb-2`},n.turnId),n.stoppable?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-3`,children:[(0,H.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-fg-muted`,children:a?`Ends the turn now. What it was shown counts as read; its stages stay held.`:n.steerable?`Posts reach the turn at its next step.`:`This runner delivers posts after the turn ends.`}),a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(D,{onClick:()=>{o(!1),s.reset()},children:`Keep it running`}),(0,H.jsx)(D,{variant:`primary`,disabled:s.isPending,onClick:()=>{s.mutate()},children:s.isPending?`Stopping…`:`Stop the turn`})]}):(0,H.jsx)(D,{onClick:()=>o(!0),children:`Stop…`})]}):null,s.error===null?null:(0,H.jsx)(`div`,{className:`px-3 pb-3`,children:(0,H.jsx)(R,{error:s.error})})]})}function Ie({member:e,scopes:n,preferred:r,running:i,paused:a,onDone:o}){let{api:s}=t(),c=g(),[l,u]=(0,V.useState)(`manual`),[d,f]=(0,V.useState)(r!==null&&n.includes(r)?r:n[0]??``),[p,m]=(0,V.useState)(``),h=(0,V.useRef)(null);(0,V.useEffect)(()=>h.current?.focus(),[]);let _=E({mutationFn:()=>s.wake({agent:e.name,project:d,kind:l,...p.trim()===``?{}:{reason:p.trim()}}),onSuccess:()=>{c.invalidateQueries({queryKey:[`scheduler`]}),o()}}),v=z(d),y=l===`reflection`?`Asks ${e.name} to reflect at ${v}: consolidate its memory, skills, and profile, and take no new work. It restarts the reflection clock.`:`Starts a turn for ${e.name} at ${v} as soon as the scheduler takes it.`,b=a?` The society is paused, so it waits until you resume.`:i.includes(d)?` ${e.name} is in a turn there now; this one follows it.`:``;return(0,H.jsxs)(`form`,{"aria-label":`Wake ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),_.mutate()},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`fieldset`,{className:`flex gap-1`,children:[(0,H.jsx)(`legend`,{className:`sr-only`,children:`Kind of turn`}),[`manual`,`reflection`].map(e=>(0,H.jsxs)(`label`,{className:`cursor-pointer rounded-md px-2.5 py-1 text-xs transition-colors has-focus-visible:ring-2 has-focus-visible:ring-fg-primary/30 ${l===e?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`kind`,value:e,checked:l===e,onChange:()=>u(e),className:`sr-only`}),e===`manual`?`A turn`:`A reflection`]},e))]}),(0,H.jsxs)(`label`,{className:`ml-auto flex items-center gap-2 text-xs text-fg-tertiary`,children:[`at`,(0,H.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),"aria-label":`Where`,className:`rounded-md bg-surface-2/60 px-2 py-1 text-xs text-fg-primary outline-none`,children:n.map(e=>(0,H.jsx)(`option`,{value:e,children:z(e)},e))})]})]}),(0,H.jsx)(`textarea`,{ref:h,value:p,rows:2,placeholder:l===`reflection`?`Anything to reflect on in particular? Optional.`:`What should it look at? It reads this as the reason it was woken.`,"aria-label":`Reason`,onChange:e=>m(e.target.value),className:`${ae} resize-none`}),(0,H.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-fg-muted`,children:[y,b,` Each turn costs money.`]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(D,{onClick:o,children:`Cancel`}),(0,H.jsx)(D,{variant:`primary`,type:`submit`,disabled:_.isPending||d===``,children:_.isPending?`Waking…`:l===`reflection`?`Ask for a reflection`:`Wake ${e.name}`})]}),(0,H.jsx)(R,{error:_.error})]})}var Le={working:`bg-emerald-500/15 text-emerald-300`,queued:`bg-amber-500/15 text-amber-300`,idle:`bg-surface-2 text-fg-tertiary`};function Re({project:e,name:t}){let n=(a(e).data??[]).filter(e=>e.status===`claimed`&&e.claimedBy===t);return n.length===0?null:(0,H.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:n.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(C,{to:`/task/$taskId`,params:{taskId:e.id},className:`flex items-center gap-2 rounded-md text-xs text-fg-secondary hover:text-fg-primary`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◇`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,H.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate font-mono text-[11px] text-fg-muted`,children:v(e)?.name??e.stage})]})},e.id))})}function ze(){let{name:e}=T({from:`/citizen/$name`}),{scope:t,tab:n,turn:r}=w({from:`/citizen/$name`});return(0,H.jsx)(Ve,{name:e,chosen:t??null,tab:n??`now`,turn:r??null},e)}var Be=[{tab:`now`,label:`Now`},{tab:`turns`,label:`Turns`},{tab:`memory`,label:`Memory`},{tab:`history`,label:`History`}];function Ve({name:t,chosen:n,tab:r,turn:i}){let a=_(),c=e(),l=o(),u=A(),[d,f]=(0,V.useState)(null),p=a.data?.find(e=>e.name===t);if(p===void 0)return(0,H.jsx)(L,{children:a.data===void 0?`Reading the roster…`:`There is no citizen ${t}.`});let m=s(l.data?.running??[]).filter(e=>e.agent===t),h=[...new Set(m.map(e=>e.scope))],g=m.map(e=>O(e.agent,e.scope,e.thread)),v=s(l.data?.pending??[]).find(e=>e.agent===t),y=h.length>0?`working`:v===void 0?`idle`:`queued`,b=j(u,t)[0],x=b?.model??p.lastModel,S=x??p.model??`CLI default`,w=p.model!==void 0&&p.model!==x?p.model:null,T=c.data?.find(e=>e.name===p.role),E=ue(p),k=p.status===`active`&&p.cli!==null;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ie,{leading:p.cli===null?null:(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-2/70`,children:(0,H.jsx)(ee,{cli:p.cli,size:20})}),title:t,subtitle:(0,H.jsxs)(H.Fragment,{children:[p.role,` · `,S,w===null?``:` · set to ${w}`,p.homeRunner===void 0?``:` · on ${p.homeRunner}`,p.status===`retired`?` · retired`:``]}),trailing:(0,H.jsxs)(H.Fragment,{children:[k&&d===null?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(D,{onClick:()=>f(`model`),children:`Model…`}),(0,H.jsx)(D,{onClick:()=>f(`runner`),children:`Runner…`}),(0,H.jsx)(D,{onClick:()=>f(`wake`),children:`Wake…`})]}):null,(0,H.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${Le[y]}`,children:y})]})}),d===`wake`?(0,H.jsx)(Ie,{member:p,scopes:E,preferred:n?.split(`/`)[0]??b?.scope??null,running:h,paused:l.data?.paused??!1,onDone:()=>f(null)}):d===`model`?(0,H.jsx)(Ae,{member:p,onDone:()=>f(null)}):d===`runner`?(0,H.jsx)(Ne,{member:p,onDone:()=>f(null)}):null,(0,H.jsx)(`nav`,{"aria-label":`Citizen views`,className:`flex gap-1 border-b border-line px-3 py-2`,children:Be.map(e=>(0,H.jsx)(C,{to:`/citizen/$name`,params:{name:t},search:{...n===null?{}:{scope:n},...e.tab===`now`?{}:{tab:e.tab}},replace:!0,"aria-current":e.tab===r?`page`:void 0,className:`rounded-md px-2.5 py-1 text-xs transition-colors ${e.tab===r?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:e.label},e.tab))}),r===`turns`?(0,H.jsx)(De,{name:t,cli:p.cli,opened:i},i):r===`memory`?(0,H.jsx)(we,{member:p,charter:T}):r===`history`?(0,H.jsx)(Ce,{name:t}):(0,H.jsx)(He,{name:t,chosen:n,lastTurnAt:p.lastTurnAt,state:y,runningScopes:h,runningKeys:g,runningTurns:(l.data?.turns??[]).filter(e=>e.agent===t),queuedScope:v?.scope??null})]})}function $(e){return e.toSorted((e,t)=>e.startedAt.localeCompare(t.startedAt))[0]}function He({name:e,chosen:t,lastTurnAt:n,state:i,runningScopes:a,runningKeys:o,runningTurns:s,queuedScope:c}){let l=A(),u=x(5e3),{ref:d,onScroll:f}=oe(),p=j(l,e),m=r(e,1),h=J(e,p.length===0?m.data?.at(-1):void 0),g=F(),_=e=>e.end===null&&o.includes(O(e.agent,e.scope,e.thread)),v=t?.split(`/`)[0]??null,b=(t?.includes(`/`)===!0?p.find(e=>M(e)===t):void 0)??$(p.filter(e=>e.scope===v&&_(e)))??p.find(e=>M(e)===t)??$(p.filter(_))??p[0]??h.turn,S=e=>e.thread===void 0?z(e.scope):`${z(e.scope)} · ${g.get(e.thread)?.title??`a thread`}`,w=b!==void 0&&_(b),T=b?.scope??a[0]??c,E=(b===void 0?void 0:s.find(e=>e.scope===b.scope&&e.thread===b.thread))??(w?void 0:s[0]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`border-b border-line px-4 py-3 text-xs text-fg-tertiary`,children:[(0,H.jsx)(`p`,{children:w?`In a turn at ${z(b.scope)} for ${b.fromStart?``:`at least `}${N(b.startedAt,u)}`:a.length>0?`In a turn at ${a.map(z).join(` and `)}`:c===null?n===void 0?`No turns yet`:`Last turn ${y(n,u)}`:`Queued for a turn at ${z(c)}`}),T===null||T===`society`?null:(0,H.jsx)(Re,{project:T,name:e})]}),(0,H.jsx)(`div`,{ref:d,onScroll:f,className:`flex-1 overflow-y-auto px-4 py-3`,children:b===void 0?(0,H.jsx)(L,{children:i===`working`?`The turn has not reported a step yet.`:h.loading?`Reading the last turn…`:n===void 0?`${e} has not taken a turn yet.`:`${e}'s last turn kept no steps; Turns lists every finished one.`}):(0,H.jsxs)(H.Fragment,{children:[p.length>1?(0,H.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,"aria-label":`Turns by conversation`,children:p.toSorted((e,t)=>M(e).localeCompare(M(t))).map(t=>(0,H.jsxs)(C,{to:`/citizen/$name`,params:{name:e},search:{scope:M(t)},replace:!0,"aria-current":t===b?`true`:void 0,className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[11px] transition-colors ${t===b?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[_(t)?(0,H.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-400`}):null,S(t)]},M(t)))}):null,(0,H.jsxs)(`p`,{className:`text-caps`,children:[w?`This turn`:`Last turn`,` · `,S(b),` · started`,` `,b.fromStart?U(b.startedAt):`before the earliest step shown`]}),b.fromStart?null:(0,H.jsxs)(`p`,{className:`mt-1 text-meta`,children:[`Earlier steps of this turn are no longer in the server's live buffer`,w?``:`; Turns has the whole turn`,`.`]}),(0,H.jsx)(G,{steps:b.steps}),(0,H.jsx)(me,{turn:b,running:w,now:u})]})}),E===void 0?null:(0,H.jsx)(Fe,{name:e,turn:E})]})}export{ze as CitizenView};
@@ -1 +1 @@
1
- import{B as e,T as t,bt as n,hn as r,m as i,y as a}from"./format-DbfHOiKW.js";import{S as o}from"./index-2BnqwsfR.js";import{n as s,t as c}from"./Pane-KNrdAxkc.js";import{a as l,i as u}from"./citizen-B9DadtKn.js";var d=r();function f(e){let t=e.lastModel??e.model??`CLI default`;return e.model!==void 0&&e.model!==t?`${t} · set to ${e.model}`:t}function p(e,t){return e.name.localeCompare(t.name)}function m(e,t){return e.role.localeCompare(t.role)||p(e,t)}function h(){let r=i(),h=t(),g=a();if(r.data===void 0)return(0,d.jsx)(s,{children:`Reading the roster…`});let _=r.data.filter(e=>e.cli!==null),v=_.filter(e=>e.status===`active`).toSorted(m),y=_.filter(e=>e.status!==`active`).toSorted(p),b=new Set(v.map(e=>e.role)).size,x=e(h.data?.running??[]),S=e(h.data?.pending??[]),C=new Map((g.data??[]).flatMap(e=>e.runner===void 0?[]:[[e.slug,e.runner]])),w=e=>{let t=[...new Set(x.filter(t=>t.agent===e.name).map(e=>e.scope))];return t.length>0?{label:`working`,detail:`in a turn at ${t.map(l).join(` and `)}`,tone:`text-emerald-300`}:S.some(t=>t.agent===e.name)?{label:`queued`,detail:`queued for a turn`,tone:`text-amber-300`}:{label:`resting`,detail:`resting`,tone:`text-fg-muted`}};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{title:`Citizens`,subtitle:`${v.length} active in ${b===1?`1 role`:`${b} roles`}${y.length===0?``:` · ${y.length} retired`}`}),(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[v.length===0?(0,d.jsx)(`p`,{className:`px-2 py-2 text-meta`,children:`No citizens yet. Ask the concierge for one.`}):null,(0,d.jsx)(`ul`,{className:`grid grid-cols-[auto_auto_auto_minmax(0,max-content)_auto_minmax(3rem,1fr)_auto] gap-x-3`,children:v.map(e=>{let t=w(e),r=f(e),i=e.memberships.length===0?`no projects`:e.memberships.join(`, `),a=u(e,C);return(0,d.jsx)(`li`,{className:`col-span-full grid grid-cols-subgrid`,children:(0,d.jsxs)(n,{to:`/citizen/$name`,params:{name:e.name},className:`col-span-full grid grid-cols-subgrid items-center rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-surface-2/50`,children:[(0,d.jsx)(`span`,{className:`grid size-4 place-items-center`,children:e.cli===null?null:(0,d.jsx)(o,{cli:e.cli,size:13})}),(0,d.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),(0,d.jsx)(`span`,{className:`text-fg-secondary`,children:e.role}),(0,d.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:r,children:r}),(0,d.jsx)(`span`,{className:`text-xs text-fg-muted`,title:a.detail,children:a.label}),(0,d.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:i,children:i}),(0,d.jsx)(`span`,{className:`text-right text-xs ${t.tone}`,title:t.detail,children:t.label})]})},e.name)})}),y.length===0?null:(0,d.jsxs)(`p`,{className:`mt-2 border-t border-line px-2 pt-2 text-meta`,children:[`Retired: `,y.map(e=>`${e.name} (${e.role})`).join(`, `)]})]})]})}export{h as CitizensView};
1
+ import{T as e,V as t,gn as n,m as r,xt as i,y as a}from"./format-8m6fdeP8.js";import{S as o}from"./index-CADeLxUP.js";import{n as s,t as c}from"./Pane-JzhKR0rO.js";import{a as l,i as u}from"./citizen-TjyiyFqE.js";var d=n();function f(e){let t=e.lastModel??e.model??`CLI default`;return e.model!==void 0&&e.model!==t?`${t} · set to ${e.model}`:t}function p(e,t){return e.name.localeCompare(t.name)}function m(e,t){return e.role.localeCompare(t.role)||p(e,t)}function h(){let n=r(),h=e(),g=a();if(n.data===void 0)return(0,d.jsx)(s,{children:`Reading the roster…`});let _=n.data.filter(e=>e.cli!==null),v=_.filter(e=>e.status===`active`).toSorted(m),y=_.filter(e=>e.status!==`active`).toSorted(p),b=new Set(v.map(e=>e.role)).size,x=t(h.data?.running??[]),S=t(h.data?.pending??[]),C=new Map((g.data??[]).flatMap(e=>e.runner===void 0?[]:[[e.slug,e.runner]])),w=e=>{let t=[...new Set(x.filter(t=>t.agent===e.name).map(e=>e.scope))];return t.length>0?{label:`working`,detail:`in a turn at ${t.map(l).join(` and `)}`,tone:`text-emerald-300`}:S.some(t=>t.agent===e.name)?{label:`queued`,detail:`queued for a turn`,tone:`text-amber-300`}:{label:`resting`,detail:`resting`,tone:`text-fg-muted`}};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{title:`Citizens`,subtitle:`${v.length} active in ${b===1?`1 role`:`${b} roles`}${y.length===0?``:` · ${y.length} retired`}`}),(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[v.length===0?(0,d.jsx)(`p`,{className:`px-2 py-2 text-meta`,children:`No citizens yet. Ask the concierge for one.`}):null,(0,d.jsx)(`ul`,{className:`grid grid-cols-[auto_auto_auto_minmax(0,max-content)_auto_minmax(3rem,1fr)_auto] gap-x-3`,children:v.map(e=>{let t=w(e),n=f(e),r=e.memberships.length===0?`no projects`:e.memberships.join(`, `),a=u(e,C);return(0,d.jsx)(`li`,{className:`col-span-full grid grid-cols-subgrid`,children:(0,d.jsxs)(i,{to:`/citizen/$name`,params:{name:e.name},className:`col-span-full grid grid-cols-subgrid items-center rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-surface-2/50`,children:[(0,d.jsx)(`span`,{className:`grid size-4 place-items-center`,children:e.cli===null?null:(0,d.jsx)(o,{cli:e.cli,size:13})}),(0,d.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),(0,d.jsx)(`span`,{className:`text-fg-secondary`,children:e.role}),(0,d.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:n,children:n}),(0,d.jsx)(`span`,{className:`text-xs text-fg-muted`,title:a.detail,children:a.label}),(0,d.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:r,children:r}),(0,d.jsx)(`span`,{className:`text-right text-xs ${t.tone}`,title:t.detail,children:t.label})]})},e.name)})}),y.length===0?null:(0,d.jsxs)(`p`,{className:`mt-2 border-t border-line px-2 pt-2 text-meta`,children:[`Retired: `,y.map(e=>`${e.name} (${e.role})`).join(`, `)]})]})]})}export{h as CitizensView};
@@ -0,0 +1 @@
1
+ import{gn as e,it as t,p as n,t as r,v as i,xt as a,y as o}from"./format-8m6fdeP8.js";import{I as s}from"./index-CADeLxUP.js";import{t as c}from"./Markdown-BrvfGmz7.js";import{n as l,t as u}from"./Pane-JzhKR0rO.js";var d=e(),f=`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`;function p(){let{scope:e,topic:p}=s({from:`/knowledge/$scope/$topic`}),m=n(e),h=o(),g=i(3e4),_=e===t,v=_?`the society`:h.data?.find(t=>t.slug===e)?.name??e,y=m.data?.find(e=>e.topic===p),b=_?(0,d.jsx)(a,{to:`/society`,"aria-label":`Back to the society`,className:f,children:`←`}):(0,d.jsx)(a,{to:`/p/$slug`,params:{slug:e},"aria-label":`Back to ${v}`,className:f,children:`←`});return y===void 0?(0,d.jsx)(l,{children:m.data===void 0?`Reading…`:`${v} has no topic ${p}.`}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u,{leading:b,title:y.topic,subtitle:`Knowledge of ${v} · written by ${y.updatedBy} ${r(y.updatedAt,g)}`}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:(0,d.jsx)(c,{text:y.body})})]})}export{p as KnowledgeView};