@sixb/agent 0.0.0-stage → 0.2.0

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 (240) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -2
  3. package/dist/abort.d.ts +6 -0
  4. package/dist/abort.d.ts.map +1 -0
  5. package/dist/agent-prompt.d.ts +126 -0
  6. package/dist/agent-prompt.d.ts.map +1 -0
  7. package/dist/agent-runtime/errors.d.ts +13 -0
  8. package/dist/agent-runtime/errors.d.ts.map +1 -0
  9. package/dist/agent-runtime/preflight.d.ts +18 -0
  10. package/dist/agent-runtime/preflight.d.ts.map +1 -0
  11. package/dist/agent-runtime/profile.d.ts +14 -0
  12. package/dist/agent-runtime/profile.d.ts.map +1 -0
  13. package/dist/artifacts/layout-check/layout-check.d.ts +87 -0
  14. package/dist/artifacts/layout-check/layout-check.d.ts.map +1 -0
  15. package/dist/artifacts/materialize.d.ts +115 -0
  16. package/dist/artifacts/materialize.d.ts.map +1 -0
  17. package/dist/artifacts/publish-tool.d.ts +86 -0
  18. package/dist/artifacts/publish-tool.d.ts.map +1 -0
  19. package/dist/ask-parent-tool.d.ts +36 -0
  20. package/dist/ask-parent-tool.d.ts.map +1 -0
  21. package/dist/attachments.d.ts +109 -0
  22. package/dist/attachments.d.ts.map +1 -0
  23. package/dist/child-files.d.ts +91 -0
  24. package/dist/child-files.d.ts.map +1 -0
  25. package/dist/child-questions.d.ts +24 -0
  26. package/dist/child-questions.d.ts.map +1 -0
  27. package/dist/computer-runner.d.ts +74 -0
  28. package/dist/computer-runner.d.ts.map +1 -0
  29. package/dist/context-budget.d.ts +34 -0
  30. package/dist/context-budget.d.ts.map +1 -0
  31. package/dist/context-compaction.d.ts +148 -0
  32. package/dist/context-compaction.d.ts.map +1 -0
  33. package/dist/context-guard.d.ts +69 -0
  34. package/dist/context-guard.d.ts.map +1 -0
  35. package/dist/conversation-memory.d.ts +21 -0
  36. package/dist/conversation-memory.d.ts.map +1 -0
  37. package/dist/conversation-messages.d.ts +33 -0
  38. package/dist/conversation-messages.d.ts.map +1 -0
  39. package/dist/errors.d.ts +46 -0
  40. package/dist/errors.d.ts.map +1 -0
  41. package/dist/execution-plan.d.ts +38 -0
  42. package/dist/execution-plan.d.ts.map +1 -0
  43. package/dist/failure.d.ts +14 -0
  44. package/dist/failure.d.ts.map +1 -0
  45. package/dist/family-mailbox.d.ts +60 -0
  46. package/dist/family-mailbox.d.ts.map +1 -0
  47. package/dist/file-ref.d.ts +6 -0
  48. package/dist/file-ref.d.ts.map +1 -0
  49. package/dist/image-attachments.d.ts +34 -0
  50. package/dist/image-attachments.d.ts.map +1 -0
  51. package/dist/index.d.ts +35 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +14387 -0
  54. package/dist/index.js.map +72 -0
  55. package/dist/inline-images.d.ts +28 -0
  56. package/dist/inline-images.d.ts.map +1 -0
  57. package/dist/message-authors.d.ts +34 -0
  58. package/dist/message-authors.d.ts.map +1 -0
  59. package/dist/message-times.d.ts +9 -0
  60. package/dist/message-times.d.ts.map +1 -0
  61. package/dist/model-adapters.d.ts +59 -0
  62. package/dist/model-adapters.d.ts.map +1 -0
  63. package/dist/model-lines.d.ts +16 -0
  64. package/dist/model-lines.d.ts.map +1 -0
  65. package/dist/prompt-cache.d.ts +28 -0
  66. package/dist/prompt-cache.d.ts.map +1 -0
  67. package/dist/requester.d.ts +15 -0
  68. package/dist/requester.d.ts.map +1 -0
  69. package/dist/run-agent-turn.d.ts +93 -0
  70. package/dist/run-agent-turn.d.ts.map +1 -0
  71. package/dist/run-child.d.ts +77 -0
  72. package/dist/run-child.d.ts.map +1 -0
  73. package/dist/run-conversation-turn.d.ts +42 -0
  74. package/dist/run-conversation-turn.d.ts.map +1 -0
  75. package/dist/run-credential.d.ts +22 -0
  76. package/dist/run-credential.d.ts.map +1 -0
  77. package/dist/run-environment.d.ts +145 -0
  78. package/dist/run-environment.d.ts.map +1 -0
  79. package/dist/run-fate.d.ts +15 -0
  80. package/dist/run-fate.d.ts.map +1 -0
  81. package/dist/run-files-lock.d.ts +16 -0
  82. package/dist/run-files-lock.d.ts.map +1 -0
  83. package/dist/run-sandbox.d.ts +60 -0
  84. package/dist/run-sandbox.d.ts.map +1 -0
  85. package/dist/run-subagent.d.ts +65 -0
  86. package/dist/run-subagent.d.ts.map +1 -0
  87. package/dist/run-workflow-agent-node.d.ts +46 -0
  88. package/dist/run-workflow-agent-node.d.ts.map +1 -0
  89. package/dist/sandbox-api-context.d.ts +34 -0
  90. package/dist/sandbox-api-context.d.ts.map +1 -0
  91. package/dist/sandbox-file-registry.d.ts +9 -0
  92. package/dist/sandbox-file-registry.d.ts.map +1 -0
  93. package/dist/sandbox-files.d.ts +71 -0
  94. package/dist/sandbox-files.d.ts.map +1 -0
  95. package/dist/sandbox-handle.d.ts +15 -0
  96. package/dist/sandbox-handle.d.ts.map +1 -0
  97. package/dist/sandbox-readiness.d.ts +8 -0
  98. package/dist/sandbox-readiness.d.ts.map +1 -0
  99. package/dist/skills/built-in.d.ts +15 -0
  100. package/dist/skills/built-in.d.ts.map +1 -0
  101. package/dist/subagent-context.d.ts +50 -0
  102. package/dist/subagent-context.d.ts.map +1 -0
  103. package/dist/subagent-continuation.d.ts +33 -0
  104. package/dist/subagent-continuation.d.ts.map +1 -0
  105. package/dist/subagent-inbox.d.ts +53 -0
  106. package/dist/subagent-inbox.d.ts.map +1 -0
  107. package/dist/subagent-tools.d.ts +293 -0
  108. package/dist/subagent-tools.d.ts.map +1 -0
  109. package/dist/thread-context.d.ts +17 -0
  110. package/dist/thread-context.d.ts.map +1 -0
  111. package/dist/tools/attachments.d.ts +11 -0
  112. package/dist/tools/attachments.d.ts.map +1 -0
  113. package/dist/tools/bash.d.ts +68 -0
  114. package/dist/tools/bash.d.ts.map +1 -0
  115. package/dist/tools/model-spec.d.ts +9 -0
  116. package/dist/tools/model-spec.d.ts.map +1 -0
  117. package/dist/tools/read.d.ts +43 -0
  118. package/dist/tools/read.d.ts.map +1 -0
  119. package/dist/tools/result-media.d.ts +65 -0
  120. package/dist/tools/result-media.d.ts.map +1 -0
  121. package/dist/tools/result-output.d.ts +18 -0
  122. package/dist/tools/result-output.d.ts.map +1 -0
  123. package/dist/tools/tool-files.d.ts +59 -0
  124. package/dist/tools/tool-files.d.ts.map +1 -0
  125. package/dist/tools/tool-outputs.d.ts +63 -0
  126. package/dist/tools/tool-outputs.d.ts.map +1 -0
  127. package/dist/tools/view-file.d.ts +40 -0
  128. package/dist/tools/view-file.d.ts.map +1 -0
  129. package/dist/tsconfig.json +5 -0
  130. package/dist/turn-runtime.d.ts +19 -0
  131. package/dist/turn-runtime.d.ts.map +1 -0
  132. package/dist/types.d.ts +83 -0
  133. package/dist/types.d.ts.map +1 -0
  134. package/dist/workflow-input-attachments.d.ts +18 -0
  135. package/dist/workflow-input-attachments.d.ts.map +1 -0
  136. package/package.json +59 -4
  137. package/src/abort.ts +40 -0
  138. package/src/agent-prompt.ts +860 -0
  139. package/src/agent-runtime/errors.ts +44 -0
  140. package/src/agent-runtime/preflight.ts +314 -0
  141. package/src/agent-runtime/profile.ts +23 -0
  142. package/src/artifacts/layout-check/check.cjs +478 -0
  143. package/src/artifacts/layout-check/layout-check.ts +460 -0
  144. package/src/artifacts/materialize.ts +380 -0
  145. package/src/artifacts/publish-tool.ts +700 -0
  146. package/src/ask-parent-tool.ts +100 -0
  147. package/src/attachments.ts +1041 -0
  148. package/src/child-files.ts +535 -0
  149. package/src/child-questions.ts +42 -0
  150. package/src/computer-runner.ts +336 -0
  151. package/src/context-budget.ts +177 -0
  152. package/src/context-compaction.ts +1349 -0
  153. package/src/context-guard.ts +826 -0
  154. package/src/conversation-memory.ts +45 -0
  155. package/src/conversation-messages.ts +86 -0
  156. package/src/errors.ts +85 -0
  157. package/src/execution-plan.ts +70 -0
  158. package/src/failure.ts +82 -0
  159. package/src/family-mailbox.ts +189 -0
  160. package/src/file-ref.ts +18 -0
  161. package/src/image-attachments.ts +322 -0
  162. package/src/index.ts +54 -0
  163. package/src/inline-images.ts +69 -0
  164. package/src/message-authors.ts +77 -0
  165. package/src/message-times.ts +24 -0
  166. package/src/model-adapters.ts +273 -0
  167. package/src/model-lines.ts +28 -0
  168. package/src/prompt-cache.ts +40 -0
  169. package/src/requester.ts +21 -0
  170. package/src/run-agent-turn.ts +509 -0
  171. package/src/run-child.ts +344 -0
  172. package/src/run-conversation-turn.ts +272 -0
  173. package/src/run-credential.ts +55 -0
  174. package/src/run-environment.ts +1216 -0
  175. package/src/run-fate.ts +51 -0
  176. package/src/run-files-lock.ts +118 -0
  177. package/src/run-sandbox.ts +63 -0
  178. package/src/run-subagent.ts +433 -0
  179. package/src/run-workflow-agent-node.ts +344 -0
  180. package/src/sandbox-api-context.ts +237 -0
  181. package/src/sandbox-file-registry.ts +26 -0
  182. package/src/sandbox-files.ts +326 -0
  183. package/src/sandbox-handle.ts +19 -0
  184. package/src/sandbox-readiness.ts +22 -0
  185. package/src/skills/built-in.ts +183 -0
  186. package/src/skills/sixb-artifacts/SKILL.md +95 -0
  187. package/src/skills/sixb-artifacts/canvas.md +104 -0
  188. package/src/skills/sixb-artifacts/document.md +63 -0
  189. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/first-job.html +42 -0
  190. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/region.html +29 -0
  191. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/shared.css +35 -0
  192. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/welcome.html +31 -0
  193. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/canvas.json +107 -0
  194. package/src/skills/sixb-artifacts/examples/canvas/retro/canvas.json +158 -0
  195. package/src/skills/sixb-artifacts/examples/document/incident-report/document.md +35 -0
  196. package/src/skills/sixb-artifacts/examples/document/operations-review/document.md +41 -0
  197. package/src/skills/sixb-artifacts/examples/document/operations-review/figures/restorations.svg +1 -0
  198. package/src/skills/sixb-artifacts/examples/page/collections-desk/index.html +169 -0
  199. package/src/skills/sixb-artifacts/examples/page/collections-desk/queries/overdue.json +13 -0
  200. package/src/skills/sixb-artifacts/examples/page/dispatch-board/data/dispatch.json +234 -0
  201. package/src/skills/sixb-artifacts/examples/page/dispatch-board/index.html +245 -0
  202. package/src/skills/sixb-artifacts/examples/page/fleet-planner/data/plan.json +53 -0
  203. package/src/skills/sixb-artifacts/examples/page/fleet-planner/index.html +462 -0
  204. package/src/skills/sixb-artifacts/examples/page/service-explorer/data/service.json +276 -0
  205. package/src/skills/sixb-artifacts/examples/page/service-explorer/index.html +549 -0
  206. package/src/skills/sixb-artifacts/examples/sheet/overdue-invoices/queries/overdue.json +13 -0
  207. package/src/skills/sixb-artifacts/examples/sheet/overdue-invoices/workbook.json +30 -0
  208. package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/sheets/Inventory.csv +13 -0
  209. package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/sheets/Spend.csv +6 -0
  210. package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/workbook.json +47 -0
  211. package/src/skills/sixb-artifacts/examples/sheet/service-metrics/sheets/Quarters.csv +5 -0
  212. package/src/skills/sixb-artifacts/examples/sheet/service-metrics/sheets/Regions.csv +5 -0
  213. package/src/skills/sixb-artifacts/examples/sheet/service-metrics/workbook.json +78 -0
  214. package/src/skills/sixb-artifacts/examples/slides/launch-plan/index.html +63 -0
  215. package/src/skills/sixb-artifacts/examples/slides/q3-review/index.html +133 -0
  216. package/src/skills/sixb-artifacts/file.md +17 -0
  217. package/src/skills/sixb-artifacts/page.md +215 -0
  218. package/src/skills/sixb-artifacts/queries.md +66 -0
  219. package/src/skills/sixb-artifacts/references.md +68 -0
  220. package/src/skills/sixb-artifacts/sheet.md +223 -0
  221. package/src/skills/sixb-artifacts/slides.md +137 -0
  222. package/src/skills/sixb-memory/SKILL.md +68 -0
  223. package/src/skills/text-assets.d.ts +25 -0
  224. package/src/subagent-context.ts +182 -0
  225. package/src/subagent-continuation.ts +56 -0
  226. package/src/subagent-inbox.ts +101 -0
  227. package/src/subagent-tools.ts +1671 -0
  228. package/src/thread-context.ts +31 -0
  229. package/src/tools/attachments.ts +28 -0
  230. package/src/tools/bash.ts +233 -0
  231. package/src/tools/model-spec.ts +27 -0
  232. package/src/tools/read.ts +262 -0
  233. package/src/tools/result-media.ts +351 -0
  234. package/src/tools/result-output.ts +46 -0
  235. package/src/tools/tool-files.ts +204 -0
  236. package/src/tools/tool-outputs.ts +464 -0
  237. package/src/tools/view-file.ts +155 -0
  238. package/src/turn-runtime.ts +33 -0
  239. package/src/types.ts +91 -0
  240. package/src/workflow-input-attachments.ts +140 -0
@@ -0,0 +1,169 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Collections desk</title>
6
+ <style>
7
+ :root { --late: #c2410c; }
8
+ html.dark { --late: #fb923c; }
9
+
10
+ .toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
11
+ .toolbar input[type="search"] { width: 260px; max-width: 100%; }
12
+ .chips { display: flex; flex-wrap: wrap; gap: 6px; }
13
+ .chips label { position: relative; margin: 0; }
14
+ .chips input { position: absolute; opacity: 0; pointer-events: none; }
15
+ .chips span { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 500; cursor: pointer; }
16
+ .chips input:checked + span { border-color: var(--foreground); background: var(--foreground); color: var(--background); }
17
+ .chips input:focus-visible + span { outline: 2px solid var(--foreground); outline-offset: 1px; }
18
+
19
+ .status { min-height: 20px; margin: 0 0 12px; font-size: 13px; color: var(--muted-foreground); }
20
+ .status.failed { color: var(--late); font-weight: 600; }
21
+ /* Wide enough to read on a phone, where it scrolls in its box. */
22
+ .table-scroll table { min-width: 600px; }
23
+ td { white-space: nowrap; }
24
+ td.late { color: var(--late); font-weight: 600; }
25
+ td.locked, .stat .value.locked { color: var(--muted-foreground); font-weight: 500; }
26
+ tbody tr.loading td { color: var(--muted-foreground); }
27
+ </style>
28
+ </head>
29
+ <body>
30
+ <main>
31
+ <p class="eyebrow">Accounts receivable</p>
32
+ <h1>Collections desk</h1>
33
+ <p class="lede">Overdue invoices as they stand now, oldest first, by customer.</p>
34
+
35
+ <div class="grid">
36
+ <div class="card stat"><div class="label">Overdue invoices</div><div class="value" id="count">–</div></div>
37
+ <div class="card stat"><div class="label">Outstanding</div><div class="value" id="outstanding">–</div><div class="delta" id="outstanding-locked"></div></div>
38
+ <div class="card stat"><div class="label">Over 60 days</div><div class="value" id="aged">–</div></div>
39
+ </div>
40
+
41
+ <div class="toolbar">
42
+ <div class="chips" role="radiogroup" aria-label="Days overdue">
43
+ <label><input type="radio" name="age" value="0" checked><span>All</span></label>
44
+ <label><input type="radio" name="age" value="30"><span>Over 30 days</span></label>
45
+ <label><input type="radio" name="age" value="60"><span>Over 60 days</span></label>
46
+ </div>
47
+ <input type="search" id="search" placeholder="Search customers" aria-label="Search customers">
48
+ </div>
49
+
50
+ <p class="status" id="status" role="status">Reading the overdue invoices…</p>
51
+
52
+ <div class="table-scroll">
53
+ <table>
54
+ <thead>
55
+ <tr><th>Customer</th><th>Invoice</th><th>Due</th><th class="num">Days late</th><th class="num">Outstanding</th></tr>
56
+ </thead>
57
+ <tbody id="rows">
58
+ <tr class="loading"><td colspan="5">Loading…</td></tr>
59
+ </tbody>
60
+ </table>
61
+ </div>
62
+
63
+ <p class="note">Each reader sees the invoices they may view, as they change.</p>
64
+ </main>
65
+
66
+ <script type="module">
67
+ const money = new Intl.NumberFormat(undefined, { style: "currency", currency: "USD", maximumFractionDigits: 0 })
68
+ const number = new Intl.NumberFormat()
69
+ const day = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric", year: "numeric" })
70
+ const status = document.querySelector("#status")
71
+ const rows = document.querySelector("#rows")
72
+ const search = document.querySelector("#search")
73
+
74
+ const today = new Date()
75
+ const daysLate = (due) => Math.max(0, Math.floor((today - new Date(due)) / 86_400_000))
76
+
77
+ // A value the reader isn't cleared for is left out of `properties` and listed in the row's
78
+ // `redactions`: a permission they lack. It shows as locked, never as 0, and no total reads it.
79
+ const LABELS = { amount: "Amount", paid: "Paid" }
80
+ const hiddenOf = (row, ...ids) => ids.find((id) => Object.hasOwn(row.redactions ?? {}, id))
81
+ const permission = (id) => `You don't have permission to see ${LABELS[id]}`
82
+
83
+ // One row per invoice, from the query's rows and the customer it expands.
84
+ let invoices = []
85
+ const load = async () => {
86
+ try {
87
+ const { objects, total, truncated } = await sixb.query("overdue")
88
+ invoices = objects.map((row) => {
89
+ const hidden = hiddenOf(row, "amount", "paid")
90
+ return {
91
+ number: row.properties.number ?? row.primaryId,
92
+ customer: row.links?.customer?.properties.name ?? "No customer",
93
+ due: row.properties.dueDate,
94
+ // Nothing paid yet is 0; an amount the reader can't see is not.
95
+ outstanding: hidden ? null : (row.properties.amount ?? 0) - (row.properties.paid ?? 0),
96
+ locked: hidden ? permission(hidden) : null,
97
+ }
98
+ })
99
+ status.textContent = truncated
100
+ ? `The first ${number.format(objects.length)} of ${number.format(total)} overdue invoices.`
101
+ : ""
102
+ status.classList.remove("failed")
103
+ render()
104
+ } catch (error) {
105
+ status.textContent = `The overdue invoices could not be read: ${error.message}`
106
+ status.classList.add("failed")
107
+ rows.innerHTML = ""
108
+ }
109
+ }
110
+
111
+ // The query takes no parameters: the chips and the search filter its rows here.
112
+ const render = () => {
113
+ const age = Number(document.querySelector('input[name="age"]:checked').value)
114
+ const words = search.value.trim().toLowerCase()
115
+ const shown = invoices.filter(
116
+ (invoice) => daysLate(invoice.due) > age && invoice.customer.toLowerCase().includes(words)
117
+ )
118
+
119
+ document.querySelector("#count").textContent = number.format(shown.length)
120
+
121
+ // Over a locked value, the total is locked too: never what it comes to without it.
122
+ const locked = shown.find((invoice) => invoice.locked)
123
+ const outstanding = document.querySelector("#outstanding")
124
+ outstanding.textContent = locked
125
+ ? "Locked"
126
+ : money.format(shown.reduce((sum, invoice) => sum + invoice.outstanding, 0))
127
+ outstanding.classList.toggle("locked", Boolean(locked))
128
+ document.querySelector("#outstanding-locked").textContent = locked ? locked.locked : ""
129
+
130
+ document.querySelector("#aged").textContent = number.format(
131
+ shown.filter((invoice) => daysLate(invoice.due) > 60).length
132
+ )
133
+
134
+ rows.replaceChildren(
135
+ ...shown.map((invoice) => {
136
+ const row = document.createElement("tr")
137
+ const late = daysLate(invoice.due)
138
+ for (const [text, className, title] of [
139
+ [invoice.customer, ""],
140
+ [invoice.number, ""],
141
+ [invoice.due ? day.format(new Date(invoice.due)) : "–", ""],
142
+ [number.format(late), late > 60 ? "num late" : "num"],
143
+ invoice.locked
144
+ ? ["Locked", "num locked", invoice.locked]
145
+ : [money.format(invoice.outstanding), "num"],
146
+ ]) {
147
+ const cell = document.createElement("td")
148
+ cell.textContent = text
149
+ if (className) cell.className = className
150
+ if (title) cell.title = title
151
+ row.append(cell)
152
+ }
153
+ return row
154
+ })
155
+ )
156
+ if (shown.length === 0 && !status.classList.contains("failed")) {
157
+ rows.innerHTML = '<tr><td colspan="5">No overdue invoices match.</td></tr>'
158
+ }
159
+ }
160
+
161
+ for (const chip of document.querySelectorAll('input[name="age"]')) chip.addEventListener("change", render)
162
+ search.addEventListener("input", render)
163
+
164
+ // The invoices move while the page is open: read them again when they do, filters kept.
165
+ addEventListener("sixb:query", (event) => event.detail.name === "overdue" && load())
166
+ await load()
167
+ </script>
168
+ </body>
169
+ </html>
@@ -0,0 +1,13 @@
1
+ {
2
+ "kind": "expand",
3
+ "expansions": [{ "linkId": "customer", "direction": "outgoing" }],
4
+ "input": {
5
+ "kind": "sort",
6
+ "fields": [{ "kind": "property", "propertyId": "dueDate", "direction": "asc" }],
7
+ "input": {
8
+ "kind": "filter",
9
+ "input": { "kind": "start", "objectTypeId": "Invoice" },
10
+ "predicate": { "op": "eq", "propertyId": "status", "value": "overdue" }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,234 @@
1
+ {
2
+ "region": "Harbor",
3
+ "date": "2026-10-20",
4
+ "shiftHours": 8,
5
+ "crews": [
6
+ { "id": "A", "name": "Crew A", "lead": "M. Okafor", "skills": ["Line", "Transformer"] },
7
+ { "id": "B", "name": "Crew B", "lead": "J. Lindqvist", "skills": ["Line", "Vegetation"] },
8
+ { "id": "C", "name": "Crew C", "lead": "R. Alvarez", "skills": ["Underground", "Meter"] },
9
+ { "id": "D", "name": "Crew D", "lead": "S. Tanaka", "skills": ["Transformer", "Meter"] },
10
+ { "id": "E", "name": "Crew E", "lead": "D. Mensah", "skills": ["Vegetation", "Line"] }
11
+ ],
12
+ "orders": [
13
+ {
14
+ "id": "WO-48213",
15
+ "title": "Replace pole-top transformer",
16
+ "skill": "Transformer",
17
+ "hours": 3,
18
+ "priority": "P2",
19
+ "address": "459 Dockside Way",
20
+ "due": "12:00",
21
+ "crew": "A"
22
+ },
23
+ {
24
+ "id": "WO-48220",
25
+ "title": "Restore service drop",
26
+ "skill": "Line",
27
+ "hours": 1.5,
28
+ "priority": "P1",
29
+ "address": "805 Dockside Way",
30
+ "due": "16:30",
31
+ "crew": "B"
32
+ },
33
+ {
34
+ "id": "WO-48227",
35
+ "title": "Clear limbs from primary",
36
+ "skill": "Vegetation",
37
+ "hours": 2,
38
+ "priority": "P3",
39
+ "address": "42 Cannery Row",
40
+ "due": "10:00",
41
+ "crew": "B"
42
+ },
43
+ {
44
+ "id": "WO-48234",
45
+ "title": "Investigate flickering lights",
46
+ "skill": "Line",
47
+ "hours": 1,
48
+ "priority": "P3",
49
+ "address": "538 Pier Rd",
50
+ "due": "15:30",
51
+ "crew": "A"
52
+ },
53
+ {
54
+ "id": "WO-48241",
55
+ "title": "Swap failed smart meter",
56
+ "skill": "Meter",
57
+ "hours": 0.5,
58
+ "priority": "P2",
59
+ "address": "775 Cannery Row",
60
+ "due": "11:00",
61
+ "crew": "C"
62
+ },
63
+ {
64
+ "id": "WO-48248",
65
+ "title": "Repair underground fault",
66
+ "skill": "Underground",
67
+ "hours": 4,
68
+ "priority": "P2",
69
+ "address": "717 Mariner Pl",
70
+ "due": "08:30",
71
+ "crew": "C"
72
+ },
73
+ {
74
+ "id": "WO-48255",
75
+ "title": "Re-fuse cutout",
76
+ "skill": "Line",
77
+ "hours": 1,
78
+ "priority": "P2",
79
+ "address": "437 Lighthouse Ln",
80
+ "due": "14:30",
81
+ "crew": "A"
82
+ },
83
+ {
84
+ "id": "WO-48262",
85
+ "title": "Trim right-of-way span",
86
+ "skill": "Vegetation",
87
+ "hours": 2.5,
88
+ "priority": "P3",
89
+ "address": "543 Seawall Ave",
90
+ "due": "08:30",
91
+ "crew": "E"
92
+ },
93
+ {
94
+ "id": "WO-48269",
95
+ "title": "Inspect padmount cabinet",
96
+ "skill": "Underground",
97
+ "hours": 1,
98
+ "priority": "P3",
99
+ "address": "966 Gull Ct",
100
+ "due": "13:00",
101
+ "crew": "C"
102
+ },
103
+ {
104
+ "id": "WO-48276",
105
+ "title": "Reconnect after storm damage",
106
+ "skill": "Line",
107
+ "hours": 2,
108
+ "priority": "P2",
109
+ "address": "958 Pier Rd",
110
+ "due": "16:30",
111
+ "crew": "A"
112
+ },
113
+ {
114
+ "id": "WO-48283",
115
+ "title": "Replace cracked crossarm",
116
+ "skill": "Line",
117
+ "hours": 2.5,
118
+ "priority": "P2",
119
+ "address": "797 Lighthouse Ln",
120
+ "due": "13:00",
121
+ "crew": "B"
122
+ },
123
+ {
124
+ "id": "WO-48290",
125
+ "title": "Meter base repair",
126
+ "skill": "Meter",
127
+ "hours": 1.5,
128
+ "priority": "P1",
129
+ "address": "625 Tidewater Dr",
130
+ "due": "10:30",
131
+ "crew": "D"
132
+ },
133
+ {
134
+ "id": "WO-48297",
135
+ "title": "Replace pole-top transformer",
136
+ "skill": "Transformer",
137
+ "hours": 3,
138
+ "priority": "P2",
139
+ "address": "94 Dockside Way",
140
+ "due": "12:00",
141
+ "crew": null
142
+ },
143
+ {
144
+ "id": "WO-48304",
145
+ "title": "Restore service drop",
146
+ "skill": "Line",
147
+ "hours": 1.5,
148
+ "priority": "P3",
149
+ "address": "130 Tidewater Dr",
150
+ "due": "14:00",
151
+ "crew": null
152
+ },
153
+ {
154
+ "id": "WO-48311",
155
+ "title": "Clear limbs from primary",
156
+ "skill": "Vegetation",
157
+ "hours": 2,
158
+ "priority": "P3",
159
+ "address": "978 Cannery Row",
160
+ "due": "14:30",
161
+ "crew": null
162
+ },
163
+ {
164
+ "id": "WO-48318",
165
+ "title": "Investigate flickering lights",
166
+ "skill": "Line",
167
+ "hours": 1,
168
+ "priority": "P3",
169
+ "address": "10 Pier Rd",
170
+ "due": "08:30",
171
+ "crew": null
172
+ },
173
+ {
174
+ "id": "WO-48325",
175
+ "title": "Swap failed smart meter",
176
+ "skill": "Meter",
177
+ "hours": 0.5,
178
+ "priority": "P1",
179
+ "address": "476 Breakwater Rd",
180
+ "due": "09:00",
181
+ "crew": null
182
+ },
183
+ {
184
+ "id": "WO-48332",
185
+ "title": "Repair underground fault",
186
+ "skill": "Underground",
187
+ "hours": 4,
188
+ "priority": "P3",
189
+ "address": "493 Lighthouse Ln",
190
+ "due": "08:30",
191
+ "crew": null
192
+ },
193
+ {
194
+ "id": "WO-48339",
195
+ "title": "Re-fuse cutout",
196
+ "skill": "Line",
197
+ "hours": 1,
198
+ "priority": "P3",
199
+ "address": "210 Pier Rd",
200
+ "due": "14:00",
201
+ "crew": null
202
+ },
203
+ {
204
+ "id": "WO-48346",
205
+ "title": "Trim right-of-way span",
206
+ "skill": "Vegetation",
207
+ "hours": 2.5,
208
+ "priority": "P1",
209
+ "address": "105 Pier Rd",
210
+ "due": "12:00",
211
+ "crew": null
212
+ },
213
+ {
214
+ "id": "WO-48353",
215
+ "title": "Inspect padmount cabinet",
216
+ "skill": "Underground",
217
+ "hours": 1,
218
+ "priority": "P3",
219
+ "address": "961 Mariner Pl",
220
+ "due": "08:00",
221
+ "crew": null
222
+ },
223
+ {
224
+ "id": "WO-48360",
225
+ "title": "Reconnect after storm damage",
226
+ "skill": "Line",
227
+ "hours": 2,
228
+ "priority": "P2",
229
+ "address": "526 Ferry St",
230
+ "due": "09:30",
231
+ "crew": null
232
+ }
233
+ ]
234
+ }
@@ -0,0 +1,245 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Harbor dispatch board</title>
6
+ <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.2/Sortable.min.js"></script>
7
+ <style>
8
+ :root { --over: #c2410c; --ok: #15803d; --urgent: #b91c1c; }
9
+ html.dark { --over: #fb923c; --ok: #4ade80; --urgent: #f87171; }
10
+
11
+ main { max-width: 1440px; }
12
+ .head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; margin-bottom: 20px; }
13
+ .head .lede { margin-bottom: 0; }
14
+
15
+ .toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
16
+ .toolbar input[type="search"] { width: 260px; max-width: 100%; }
17
+ .chips { display: flex; flex-wrap: wrap; gap: 6px; }
18
+ .chips label { position: relative; margin: 0; }
19
+ .chips input { position: absolute; opacity: 0; pointer-events: none; }
20
+ .chips span { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 500; cursor: pointer; }
21
+ .chips input:checked + span { border-color: var(--foreground); background: var(--foreground); color: var(--background); }
22
+ .chips input:focus-visible + span { outline: 2px solid var(--foreground); outline-offset: 1px; }
23
+
24
+ .summary { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 20px; font-size: 13px; color: var(--muted-foreground); }
25
+ .summary b { margin-right: 4px; font-size: 20px; font-weight: 650; color: var(--foreground); font-variant-numeric: tabular-nums; }
26
+ .summary .alert b { color: var(--urgent); }
27
+
28
+ /* The board: a column per crew, scrolling sideways when they don't fit. */
29
+ .board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(212px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; scroll-snap-type: x mandatory; }
30
+ .column { display: flex; flex-direction: column; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--muted); scroll-snap-align: start; }
31
+ .column.waiting { background: transparent; border-style: dashed; }
32
+ .column h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; font-size: 15px; }
33
+ .column h3 small { font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
34
+ .crew { margin: 2px 0 10px; font-size: 12px; color: var(--muted-foreground); }
35
+ .meter { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted-foreground); }
36
+ .meter .track { flex: 1; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
37
+ .meter .fill { display: block; height: 100%; border-radius: inherit; background: var(--foreground); transition: width 0.2s; }
38
+ .meter.full .fill { background: var(--ok); }
39
+ .meter.over .fill { background: var(--over); }
40
+ .meter.over { color: var(--over); font-weight: 600; }
41
+
42
+ .cards { display: grid; align-content: start; gap: 8px; flex: 1; min-height: 120px; margin: 0; padding: 0; list-style: none; }
43
+ .order { margin: 0; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); cursor: grab; transition: box-shadow 0.15s, border-color 0.15s; }
44
+ .order:hover { border-color: color-mix(in oklab, var(--foreground) 25%, var(--border)); box-shadow: 0 2px 8px rgb(0 0 0 / 0.08); }
45
+ .order.ghost { opacity: 0.35; }
46
+ .order.dragging { cursor: grabbing; box-shadow: 0 12px 28px rgb(0 0 0 / 0.18); transform: rotate(1.5deg); }
47
+ .order.hidden { display: none; }
48
+ .order-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 12px; color: var(--muted-foreground); }
49
+ .order-top code { padding: 0; background: none; font-size: 12px; }
50
+ .priority { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--foreground); }
51
+ .priority::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-foreground); }
52
+ .priority.p1 { color: var(--urgent); }
53
+ .priority.p1::before { background: var(--urgent); }
54
+ .priority.p2::before { background: var(--foreground); }
55
+ .order-title { margin: 0 0 2px; font-size: 14px; font-weight: 600; line-height: 1.35; }
56
+ .order-where { margin: 0 0 10px; font-size: 13px; color: var(--muted-foreground); }
57
+ .order-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
58
+ .order-foot .tag { margin-left: auto; font-weight: 500; }
59
+ .mismatch { margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--over); }
60
+ .empty { display: grid; place-items: center; min-height: 96px; border: 1px dashed var(--border); border-radius: var(--radius); font-size: 13px; color: var(--muted-foreground); }
61
+ </style>
62
+ </head>
63
+ <body>
64
+ <main>
65
+ <header class="head">
66
+ <div>
67
+ <p class="eyebrow" id="eyebrow">–</p>
68
+ <h1>Dispatch board</h1>
69
+ <p class="lede" id="lede">–</p>
70
+ </div>
71
+ <div class="row">
72
+ <button type="button" class="secondary" id="reset">Reset</button>
73
+ <button type="button" id="auto">Auto-assign waiting work</button>
74
+ </div>
75
+ </header>
76
+
77
+ <div class="summary" id="summary"></div>
78
+
79
+ <div class="toolbar">
80
+ <div class="chips" role="radiogroup" aria-label="Priority">
81
+ <label><input type="radio" name="priority" value="" checked><span>All</span></label>
82
+ <label><input type="radio" name="priority" value="P1"><span>P1 urgent</span></label>
83
+ <label><input type="radio" name="priority" value="P2"><span>P2</span></label>
84
+ <label><input type="radio" name="priority" value="P3"><span>P3</span></label>
85
+ </div>
86
+ <input type="search" id="search" placeholder="Find an order, job, or street" aria-label="Find an order">
87
+ </div>
88
+
89
+ <div class="board" id="board"></div>
90
+
91
+ <p class="note">Drag a work order onto a crew to assign it. A crew works an 8-hour shift; travel is in each order's hours. Assignments last while this page is open.</p>
92
+ </main>
93
+
94
+ <script>
95
+ const PRIORITY = { P1: 0, P2: 1, P3: 2 }
96
+ const hours = new Intl.NumberFormat("en-US", { maximumFractionDigits: 1 })
97
+ const field = (id) => document.getElementById(id)
98
+ let data = null
99
+ let start = null
100
+ const lists = []
101
+
102
+ const crewOf = (id) => data.crews.find((crew) => crew.id === id)
103
+ const booked = (crew) => data.orders.filter((order) => order.crew === crew.id).reduce((sum, order) => sum + order.hours, 0)
104
+ const byUrgency = (a, b) => PRIORITY[a.priority] - PRIORITY[b.priority] || a.due.localeCompare(b.due)
105
+
106
+ function card(order) {
107
+ const item = document.createElement("li")
108
+ item.className = "order"
109
+ item.dataset.id = order.id
110
+ item.innerHTML = `
111
+ <div class="order-top"><code></code><span class="priority ${order.priority.toLowerCase()}">${order.priority}</span></div>
112
+ <p class="order-title"></p>
113
+ <p class="order-where"></p>
114
+ <div class="order-foot"><span>${hours.format(order.hours)} h</span><span>Due ${order.due}</span><span class="tag"></span></div>`
115
+ item.querySelector("code").textContent = order.id
116
+ item.querySelector(".order-title").textContent = order.title
117
+ item.querySelector(".order-where").textContent = order.address
118
+ item.querySelector(".tag").textContent = order.skill
119
+ const crew = order.crew && crewOf(order.crew)
120
+ if (crew && !crew.skills.includes(order.skill)) {
121
+ const warning = document.createElement("p")
122
+ warning.className = "mismatch"
123
+ warning.textContent = `${crew.name} has no ${order.skill.toLowerCase()} skill`
124
+ item.append(warning)
125
+ }
126
+ return item
127
+ }
128
+
129
+ function column(crew) {
130
+ const section = document.createElement("section")
131
+ section.className = `column${crew ? "" : " waiting"}`
132
+ const orders = data.orders.filter((order) => order.crew === (crew?.id ?? null)).sort(byUrgency)
133
+ if (crew) {
134
+ const total = booked(crew)
135
+ const state = total > data.shiftHours ? "over" : total >= data.shiftHours - 0.5 ? "full" : ""
136
+ section.innerHTML = `
137
+ <h3><span></span><small>${orders.length} ${orders.length === 1 ? "order" : "orders"}</small></h3>
138
+ <p class="crew"></p>
139
+ <div class="meter ${state}"><span class="track"><span class="fill" style="width: ${Math.min(100, (total / data.shiftHours) * 100)}%"></span></span><span>${hours.format(total)} / ${data.shiftHours} h</span></div>`
140
+ section.querySelector("h3 span").textContent = crew.name
141
+ section.querySelector(".crew").textContent = `${crew.lead} · ${crew.skills.join(", ")}`
142
+ } else {
143
+ section.innerHTML = `<h3><span>Waiting</span><small>${orders.length} ${orders.length === 1 ? "order" : "orders"}</small></h3><p class="crew">Not yet on a crew</p><div class="meter"><span>${hours.format(orders.reduce((sum, order) => sum + order.hours, 0))} h of work</span></div>`
144
+ }
145
+ const list = document.createElement("ul")
146
+ list.className = "cards"
147
+ list.dataset.crew = crew?.id ?? ""
148
+ list.append(...orders.map(card))
149
+ if (!orders.length) {
150
+ const empty = document.createElement("li")
151
+ empty.className = "empty"
152
+ empty.textContent = crew ? "Drop work here" : "Everything is assigned"
153
+ list.append(empty)
154
+ }
155
+ section.append(list)
156
+ return section
157
+ }
158
+
159
+ function render() {
160
+ for (const list of lists.splice(0)) list.destroy()
161
+ field("board").replaceChildren(column(null), ...data.crews.map(column))
162
+ for (const list of document.querySelectorAll(".cards")) {
163
+ lists.push(
164
+ Sortable.create(list, {
165
+ group: "orders",
166
+ draggable: ".order",
167
+ animation: 160,
168
+ ghostClass: "ghost",
169
+ dragClass: "dragging",
170
+ forceFallback: true,
171
+ onEnd: (event) => {
172
+ const order = data.orders.find((item) => item.id === event.item.dataset.id)
173
+ order.crew = event.to.dataset.crew || null
174
+ render()
175
+ },
176
+ })
177
+ )
178
+ }
179
+ filter()
180
+ summarize()
181
+ }
182
+
183
+ function summarize() {
184
+ const waiting = data.orders.filter((order) => !order.crew)
185
+ const urgent = waiting.filter((order) => order.priority === "P1")
186
+ const over = data.crews.filter((crew) => booked(crew) > data.shiftHours)
187
+ const capacity = data.crews.length * data.shiftHours
188
+ const total = data.crews.reduce((sum, crew) => sum + booked(crew), 0)
189
+ field("lede").textContent = waiting.length
190
+ ? `${data.orders.length - waiting.length} of ${data.orders.length} work orders are on a crew; ${urgent.length ? `${urgent.length} urgent ${urgent.length === 1 ? "one is" : "ones are"} still waiting.` : "none of the waiting ones is urgent."}`
191
+ : `All ${data.orders.length} work orders are on a crew${over.length ? `, but ${over.map((crew) => crew.name).join(" and ")} ${over.length === 1 ? "is" : "are"} over a shift.` : ", within every shift."}`
192
+ field("summary").innerHTML = `
193
+ <span><b>${data.orders.length - waiting.length}</b>assigned</span>
194
+ <span class="${urgent.length ? "alert" : ""}"><b>${waiting.length}</b>waiting${urgent.length ? `, ${urgent.length} urgent` : ""}</span>
195
+ <span><b>${Math.round((total / capacity) * 100)}%</b>of crew hours booked</span>
196
+ <span class="${over.length ? "alert" : ""}"><b>${over.length}</b>${over.length === 1 ? "crew" : "crews"} over a shift</span>`
197
+ }
198
+
199
+ function filter() {
200
+ const priority = document.querySelector('input[name="priority"]:checked').value
201
+ const query = field("search").value.trim().toLowerCase()
202
+ for (const item of document.querySelectorAll(".order")) {
203
+ const order = data.orders.find((entry) => entry.id === item.dataset.id)
204
+ const text = `${order.id} ${order.title} ${order.address} ${order.skill}`.toLowerCase()
205
+ item.classList.toggle("hidden", (priority && order.priority !== priority) || (query && !text.includes(query)))
206
+ }
207
+ }
208
+
209
+ /** Puts each waiting order, most urgent first, on the crew with the skill and the most time left. */
210
+ function autoAssign() {
211
+ for (const order of data.orders.filter((item) => !item.crew).sort(byUrgency)) {
212
+ const crew = data.crews
213
+ .filter((candidate) => candidate.skills.includes(order.skill))
214
+ .map((candidate) => ({ candidate, left: data.shiftHours - booked(candidate) }))
215
+ .filter(({ left }) => left >= order.hours)
216
+ .sort((a, b) => b.left - a.left)[0]
217
+ if (crew) order.crew = crew.candidate.id
218
+ }
219
+ render()
220
+ }
221
+
222
+ for (const input of document.querySelectorAll('input[name="priority"]')) input.addEventListener("change", filter)
223
+ field("search").addEventListener("input", filter)
224
+ field("auto").addEventListener("click", autoAssign)
225
+ field("reset").addEventListener("click", () => {
226
+ data.orders = structuredClone(start)
227
+ render()
228
+ })
229
+
230
+ fetch("data/dispatch.json")
231
+ .then((response) => response.json())
232
+ .then((dispatch) => {
233
+ data = dispatch
234
+ start = structuredClone(dispatch.orders)
235
+ const day = new Date(`${data.date}T12:00:00Z`).toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric", timeZone: "UTC" })
236
+ field("eyebrow").textContent = `${data.region} · ${day}`
237
+ if (!window.Sortable) {
238
+ field("lede").textContent = "Dragging needs cdn.jsdelivr.net, which this page could not reach."
239
+ return
240
+ }
241
+ render()
242
+ })
243
+ </script>
244
+ </body>
245
+ </html>