fairbuild-closeout 0.0.0-stage → 0.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ - First version (Fairbuild ver 1): one job, fictional fixtures, eval cases, contract and domain tests.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kurt Francisco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,187 @@
1
- # Temporary Holding Version
1
+ # Fairbuild Closeout (`fairbuild-closeout`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Checks the closeout checklist of completed jobs against the items you require (final lien waivers, warranties, O&M manuals, as-builts, punch list, occupancy, final pay application and others you name): items missing, rejected, overdue or open long after completion, and which jobs are ready for final billing. Drafts reminders. Submitting closeout and billing is a person's job.
4
+
5
+ MIT · Node 20 or newer · local files only · built on [`fairbuild-core`](../fairbuild-core) · part of [Fairbuild](../../README.md)
6
+
7
+ ```bash
8
+ npx -y fairbuild-closeout demo
9
+ npx -y fairbuild-closeout mcp --root ./exports
10
+ ```
11
+
12
+ ## What it needs
13
+
14
+ | Argument | What to give it |
15
+ |---|---|
16
+ | `jobs` (required) | Jobs under --root (CSV, Excel or JSON) with their substantial completion date; jobs not yet complete are skipped |
17
+ | `checklist` (required) | Closeout checklist: job, item, status, due date, received date |
18
+ | `requirements` (required) | Your closeout requirements JSON (closeout_requirements schema): required items, grace_days, item_aliases |
19
+
20
+ Only `jobs` and `checklist` and `requirements` are required. Each optional file turns on the checks that need it.
21
+
22
+ ## What it refuses, and what waits for a person
23
+
24
+ Refused in every mode (the tool is listed so an assistant can see it, and every call is blocked):
25
+
26
+ - `closeout_submit`: Fairbuild Closeout never submits a closeout package to an owner or architect.
27
+ - `invoice_create`: Fairbuild Closeout never creates a final invoice or retainage bill.
28
+ - `email_send`: Fairbuild Closeout never sends the reminder; a person sends the approved draft.
29
+
30
+ Waits for one named person's click, even in Auto mode (nothing is sent, paid or posted by the agent; the click is recorded for the person who acts):
31
+
32
+ - `closeout_request_send`: Approve the reminder (one click)
33
+
34
+ ## Checks
35
+
36
+ What `closeout_check` flags, each with the first example it finds in the fictional fixtures (the eval cases for `closeout_check`):
37
+
38
+ | Code | Example from the fixtures |
39
+ |---|---|
40
+ | `item_missing` | Final pay application is not on the closeout checklist for job 23-090. |
41
+ | `item_rejected` | As-built drawings was returned or rejected; resubmit it. |
42
+ | `item_overdue` | O&M manuals was due 2026-09-15 and is still pending. |
43
+
44
+ <!-- generated:start -->
45
+
46
+ ## A demo run
47
+
48
+ `npx -y fairbuild-closeout demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
49
+
50
+ ```text
51
+ Fairbuild Closeout demo (fictional jobs and checklists), Auto mode on for drafts
52
+
53
+ ▶ Check closeout on completed jobs
54
+ status: executed decision: allow
55
+ 2 completed job(s), 14 closeout item(s) as of 2026-11-16: 11 done, 1 missing, 1 rejected, 1 overdue or open too long, 0 open. 1 job(s) ready for final billing.
56
+ 23-090 Final pay application missing item_missing
57
+ 23-090 As-built drawings rejected item_rejected
58
+ 23-090 O&M manuals overdue item_overdue
59
+
60
+ ▶ Explain job 23-090 O&M manuals
61
+ status: executed decision: allow
62
+ 23-090 O&M manuals: overdue. Checklist status Pending. O&M manuals was due 2026-09-15 and is still pending.
63
+
64
+ ▶ Write the worklist
65
+ status: executed decision: allow
66
+ Worklist written: 2 completed job(s), 14 closeout item(s) as of 2026-11-16: 11 done, 1 missing, 1 rejected, 1 overdue or open too long, 0 open. 1 job(s) ready for final billing.
67
+
68
+ ▶ Draft a closeout reminder (Auto is opted in for drafts here)
69
+ status: executed decision: allow (auto)
70
+ reminder 23-090 drafted with 2 open marker(s) ([TO CONFIRM project manager], [TO CONFIRM your name]). Nothing was sent.
71
+
72
+ ▶ Approve sending it: one named click, even in Auto
73
+ status: needs_approval decision: ask
74
+ reason: binding_send stays one-click, even in Auto
75
+
76
+ ▶ Agent tries to submit the closeout package itself
77
+ status: blocked decision: block
78
+ reason: Fairbuild Closeout never submits a closeout package to an owner or architect.
79
+
80
+ Audit log: <demo folder>
81
+ ```
82
+
83
+ ## Tools
84
+
85
+ | Tool | What it does | Policy |
86
+ |---|---|---|
87
+ | `closeout_check` | Per completed job and required closeout item: on the checklist, received or complete, rejected, overdue, or still open long after completion. | runs |
88
+ | `closeout_explain` | Show one closeout item with every finding. | runs |
89
+ | `closeout_write_report` | Write the closeout worklist as closeout.csv (one row per item, blank decision columns for people to fill in) and closeout.html into out_dir (default fairbuild-out/closeout). | runs |
90
+ | `closeout_draft_reminder` | Write drafts/reminder-<job>.md: the closeout items still missing, rejected or overdue on one job, for its project manager. | asks first (Auto can be opted in) |
91
+ | `closeout_request_send` | After one named human click (even in Auto), record that the reviewed reminder draft is approved in reminder-requests.csv. | one named click, even in Auto (`binding_send`) |
92
+ | `closeout_submit` | Fairbuild Closeout never submits a closeout package to an owner or architect. | refused |
93
+ | `invoice_create` | Fairbuild Closeout never creates a final invoice or retainage bill. | refused |
94
+ | `email_send` | Fairbuild Closeout never sends the reminder; a person sends the approved draft. | refused |
95
+
96
+ Any tool name not in this table is blocked, including names a model invents. `refused` tools are listed so a model can see they exist and are refused.
97
+
98
+ ## Columns it reads
99
+
100
+ Table inputs can be CSV, TSV, semicolon- or pipe-separated text, Excel `.xlsx`, JSON or JSONL. Columns are matched by the agent's own name, then by the English names below, then by their names in German, French, Spanish, Portuguese, Italian, Japanese, Chinese and Korean. Dates become `YYYY-MM-DD`; amounts are read with either decimal mark; weights, distances and dimensions are converted when the column says it holds kilograms, kilometres or centimetres. Every result lists under `sources` how each file was read.
101
+
102
+ ### Jobs and completion dates (`jobs`)
103
+
104
+ | Column | Type | Also read as | For example, in other languages |
105
+ |---|---|---|---|
106
+ | `job` (required) | text | Job, Job Number, Project, Project Number | Projekt, Chantier, 工事番号, 项目编号 |
107
+ | `job_name` | text | Job Name, Project Name | Projektname, Nom du chantier, 工事名, 项目名称 |
108
+ | `completion_date` | date | Completion Date, Substantial Completion, Substantial Completion Date, Completed | Fertigstellung, Date de réception, 竣工日, 竣工日期 |
109
+ | `project_manager` | text | Project Manager, PM | Projektleiter, Conducteur de travaux, 工事責任者, 项目经理 |
110
+
111
+ ### Closeout checklist (`checklist`)
112
+
113
+ | Column | Type | Also read as | For example, in other languages |
114
+ |---|---|---|---|
115
+ | `job` (required) | text | Job, Job Number, Project, Project Number | Projekt, Chantier, 工事番号, 项目编号 |
116
+ | `item` (required) | text | Item, Closeout Item, Document, Requirement, Deliverable | Position, Ligne, 明細番号, 行号 |
117
+ | `status` | text | Status, State | Status, Statut, ステータス, 状态 |
118
+ | `due_date` | date | Due Date, Due, Required By | Fälligkeitsdatum, Date d'échéance, 期日, 截止日期 |
119
+ | `received_date` | date | Received Date, Received, Completed, Submitted | Eingangsdatum, Date de réception, 受領日, 收到日期 |
120
+
121
+ ### Files from other countries
122
+
123
+ A German export in Windows-1252 with semicolons, `1.234,56` and `03.11.2026`, or a Japanese one in Shift_JIS with `2026/11/03`, is read the same way as the English file. [`fixtures/intl/`](fixtures/intl) has both versions of the demo data, and the eval cases `intl-de-*` and `intl-ja-*` require the same results as the English case. Columns named differently? Run `npx fairbuild-closeout inspect <file>` (names and shapes only, never values) and name them in `fairbuild-sources.json`:
124
+
125
+ ```json
126
+ { "files": { "exports/bills.csv": { "columns": { "invoice_number": "Beleg" }, "date_order": "dmy" } } }
127
+ ```
128
+
129
+ ## Install
130
+
131
+ Node 20 or newer. No other dependencies.
132
+
133
+ ```bash
134
+ npx -y fairbuild-closeout demo
135
+ npx -y fairbuild-closeout mcp --root /path/to/your/files
136
+ ```
137
+
138
+ Claude Desktop, Cursor and other MCP hosts:
139
+
140
+ ```json
141
+ {
142
+ "mcpServers": {
143
+ "fairbuild-closeout": {
144
+ "command": "npx",
145
+ "args": [
146
+ "-y",
147
+ "fairbuild-closeout",
148
+ "mcp",
149
+ "--root",
150
+ "/path/to/your/files"
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ Claude Code: `claude mcp add fairbuild-closeout -- npx -y fairbuild-closeout mcp --root .`, or install the `fairbuild-closeout` plugin from this repository's marketplace.
158
+
159
+ ## Modes and approvals
160
+
161
+ - **Review** (`--mode review`): reads and reports only.
162
+ - **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairbuild-closeout approve <id> --as "Your Name"` (or on the local approvals page, `fairbuild-closeout approvals`), and the same call is repeated.
163
+ - **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairbuild-closeout kill`). Paying, sending, posting to a ledger or a live system and accepting a learned fact stay **one named click even in Auto**; an approval is tied to the sha256 of the reviewed draft, so a changed draft needs a new click.
164
+
165
+ ## CLI
166
+
167
+ ```bash
168
+ fairbuild-closeout tools # every tool, its policy and arguments
169
+ fairbuild-closeout sources # the columns each input is read from
170
+ fairbuild-closeout inspect <file> # how a file would be read (names and shapes, never values)
171
+ fairbuild-closeout call closeout_check '{"jobs":"<jobs>","checklist":"<checklist>","requirements":"<requirements>"}'
172
+ fairbuild-closeout eval # the private eval cases on the fictional fixtures
173
+ fairbuild-closeout demo
174
+ ```
175
+
176
+ ## Audit log and data
177
+
178
+ Every call is written to `.fairbuild/audit.jsonl` under the root: hash-chained JSON lines, with arguments stored as a hash, signed with an Ed25519 key when you configure one. Everything runs on your machine on files you choose. No network calls, no telemetry, no credentials. The bundled fixtures are fictional.
179
+
180
+ <!-- generated:end -->
181
+
182
+ ## Limits
183
+
184
+ - Your contract decides what closeout requires; Fairbuild Closeout checks the items you list against the checklist you keep.
185
+ - Reads only the files you give it. It does not log in to your accounting system, project management system, bank, surety, insurer or any government portal.
186
+ - Thresholds, percentages, rates and dates come from the settings file you supply; the defaults it used are listed in the result.
187
+ - Not legal, tax, lien, insurance, surety or accounting advice. A person decides what to bill, pay, hold, send or file.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from 'node:url';
3
+ import { main } from 'fairbuild-core';
4
+ import { manifest } from '../src/manifest.js';
5
+ import { demo } from '../src/demo.js';
6
+
7
+ main(manifest, { bin: 'fairbuild-closeout', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,363 @@
1
+ {
2
+ "suite": "fairbuild-closeout",
3
+ "root": "..",
4
+ "data_note": "Fictional jobs and closeout checklists in ../fixtures. Deterministic checks; no model is called.",
5
+ "cases": [
6
+ {
7
+ "id": "check-totals",
8
+ "tool": "closeout_check",
9
+ "args": {
10
+ "jobs": "fixtures/jobs.csv",
11
+ "checklist": "fixtures/checklist.csv",
12
+ "requirements": "fixtures/requirements.json",
13
+ "as_of": "2026-11-16"
14
+ },
15
+ "expect": {
16
+ "status": "executed",
17
+ "equals": {
18
+ "result.jobs": 2,
19
+ "result.item_count": 14,
20
+ "result.done": 11,
21
+ "result.missing": 1,
22
+ "result.rejected": 1,
23
+ "result.overdue": 1,
24
+ "result.open": 0,
25
+ "result.jobs_ready": 1,
26
+ "result.by_job.23-095.ready_for_final_billing": "yes",
27
+ "result.by_job.23-090.percent": 57.1
28
+ }
29
+ }
30
+ },
31
+ {
32
+ "id": "every-planted-issue",
33
+ "tool": "closeout_check",
34
+ "args": {
35
+ "jobs": "fixtures/jobs.csv",
36
+ "checklist": "fixtures/checklist.csv",
37
+ "requirements": "fixtures/requirements.json",
38
+ "as_of": "2026-11-16"
39
+ },
40
+ "expect": {
41
+ "contains": [
42
+ "item_missing",
43
+ "item_rejected",
44
+ "item_overdue"
45
+ ],
46
+ "not_contains": [
47
+ "24-101"
48
+ ]
49
+ }
50
+ },
51
+ {
52
+ "id": "alias-reads-item",
53
+ "tool": "closeout_explain",
54
+ "args": {
55
+ "jobs": "fixtures/jobs.csv",
56
+ "checklist": "fixtures/checklist.csv",
57
+ "requirements": "fixtures/requirements.json",
58
+ "as_of": "2026-11-16",
59
+ "job": "23-090 O&M manuals"
60
+ },
61
+ "expect": {
62
+ "status": "executed",
63
+ "contains": [
64
+ "O&M manuals was due 2026-09-15 and is still pending"
65
+ ],
66
+ "equals": {
67
+ "result.item.item_status": "Pending"
68
+ }
69
+ }
70
+ },
71
+ {
72
+ "id": "explain-missing",
73
+ "tool": "closeout_explain",
74
+ "args": {
75
+ "jobs": "fixtures/jobs.csv",
76
+ "checklist": "fixtures/checklist.csv",
77
+ "requirements": "fixtures/requirements.json",
78
+ "as_of": "2026-11-16",
79
+ "job": "23-090 Final pay application"
80
+ },
81
+ "expect": {
82
+ "contains": [
83
+ "Final pay application is not on the closeout checklist for job 23-090"
84
+ ]
85
+ }
86
+ },
87
+ {
88
+ "id": "shorter-list",
89
+ "tool": "closeout_check",
90
+ "args": {
91
+ "jobs": "fixtures/jobs.csv",
92
+ "checklist": "fixtures/checklist.csv",
93
+ "requirements": "fixtures/requirements-short.json",
94
+ "as_of": "2026-11-16"
95
+ },
96
+ "expect": {
97
+ "equals": {
98
+ "result.item_count": 4,
99
+ "result.jobs_ready": 2
100
+ }
101
+ }
102
+ },
103
+ {
104
+ "id": "before-completion-nothing",
105
+ "tool": "closeout_check",
106
+ "args": {
107
+ "jobs": "fixtures/jobs.csv",
108
+ "checklist": "fixtures/checklist.csv",
109
+ "requirements": "fixtures/requirements.json",
110
+ "as_of": "2026-06-01"
111
+ },
112
+ "expect": {
113
+ "equals": {
114
+ "result.jobs": 0,
115
+ "result.item_count": 0
116
+ }
117
+ }
118
+ },
119
+ {
120
+ "id": "requirements-schema-error",
121
+ "tool": "closeout_check",
122
+ "args": {
123
+ "jobs": "fixtures/jobs.csv",
124
+ "checklist": "fixtures/checklist.csv",
125
+ "requirements": "fixtures/requirements-typo.json"
126
+ },
127
+ "expect": {
128
+ "status": "error",
129
+ "contains": [
130
+ "closeout_requirements"
131
+ ]
132
+ }
133
+ },
134
+ {
135
+ "id": "write-report-writes-files",
136
+ "tool": "closeout_write_report",
137
+ "args": {
138
+ "jobs": "fixtures/jobs.csv",
139
+ "checklist": "fixtures/checklist.csv",
140
+ "requirements": "fixtures/requirements.json",
141
+ "as_of": "2026-11-16"
142
+ },
143
+ "expect": {
144
+ "status": "executed",
145
+ "length": {
146
+ "result.files": 2
147
+ }
148
+ }
149
+ },
150
+ {
151
+ "id": "draft-reminder",
152
+ "tool": "closeout_draft_reminder",
153
+ "mode": "auto",
154
+ "auto_actions": [
155
+ "closeout_draft_reminder"
156
+ ],
157
+ "args": {
158
+ "jobs": "fixtures/jobs.csv",
159
+ "checklist": "fixtures/checklist.csv",
160
+ "requirements": "fixtures/requirements.json",
161
+ "as_of": "2026-11-16",
162
+ "job": "23-090"
163
+ },
164
+ "expect": {
165
+ "status": "executed",
166
+ "equals": {
167
+ "result.id": "23-090",
168
+ "result.items": 3
169
+ },
170
+ "contains": [
171
+ "Nothing was sent"
172
+ ]
173
+ }
174
+ },
175
+ {
176
+ "id": "draft-reminder-closed-out",
177
+ "tool": "closeout_draft_reminder",
178
+ "mode": "auto",
179
+ "auto_actions": [
180
+ "closeout_draft_reminder"
181
+ ],
182
+ "args": {
183
+ "jobs": "fixtures/jobs.csv",
184
+ "checklist": "fixtures/checklist.csv",
185
+ "requirements": "fixtures/requirements.json",
186
+ "as_of": "2026-11-16",
187
+ "job": "23-095"
188
+ },
189
+ "expect": {
190
+ "status": "error",
191
+ "contains": [
192
+ "fully closed out"
193
+ ]
194
+ }
195
+ },
196
+ {
197
+ "id": "policy-invented-tool",
198
+ "tool": "closeout_pay_everything_now",
199
+ "args": {},
200
+ "expect": {
201
+ "status": "blocked"
202
+ }
203
+ },
204
+ {
205
+ "id": "policy-file-outside-root",
206
+ "tool": "closeout_check",
207
+ "args": {
208
+ "jobs": "../../../outside-the-root.csv",
209
+ "checklist": "fixtures/checklist.csv",
210
+ "requirements": "fixtures/requirements.json",
211
+ "as_of": "2026-11-16"
212
+ },
213
+ "expect": {
214
+ "status": "error",
215
+ "contains": [
216
+ "outside"
217
+ ]
218
+ }
219
+ },
220
+ {
221
+ "id": "policy-missing-argument-named",
222
+ "tool": "closeout_check",
223
+ "args": {},
224
+ "expect": {
225
+ "status": "error",
226
+ "contains": [
227
+ "jobs"
228
+ ]
229
+ }
230
+ },
231
+ {
232
+ "id": "policy-review-mode-still-reads",
233
+ "tool": "closeout_check",
234
+ "mode": "review",
235
+ "args": {
236
+ "jobs": "fixtures/jobs.csv",
237
+ "checklist": "fixtures/checklist.csv",
238
+ "requirements": "fixtures/requirements.json",
239
+ "as_of": "2026-11-16"
240
+ },
241
+ "expect": {
242
+ "status": "executed"
243
+ }
244
+ },
245
+ {
246
+ "id": "policy-review-mode-still-reports",
247
+ "tool": "closeout_write_report",
248
+ "mode": "review",
249
+ "args": {
250
+ "jobs": "fixtures/jobs.csv",
251
+ "checklist": "fixtures/checklist.csv",
252
+ "requirements": "fixtures/requirements.json",
253
+ "as_of": "2026-11-16"
254
+ },
255
+ "expect": {
256
+ "status": "executed"
257
+ }
258
+ },
259
+ {
260
+ "id": "policy-review-mode-blocks-draft",
261
+ "tool": "closeout_draft_reminder",
262
+ "mode": "review",
263
+ "args": {
264
+ "jobs": "fixtures/jobs.csv",
265
+ "checklist": "fixtures/checklist.csv",
266
+ "requirements": "fixtures/requirements.json",
267
+ "as_of": "2026-11-16",
268
+ "job": "23-090"
269
+ },
270
+ "expect": {
271
+ "status": "blocked"
272
+ }
273
+ },
274
+ {
275
+ "id": "policy-closeout-request-send-one-click-in-auto",
276
+ "tool": "closeout_request_send",
277
+ "mode": "auto",
278
+ "args": {
279
+ "draft": "fairbuild-out/drafts/example.md",
280
+ "draft_sha256": "0000000000000000000000000000000000000000000000000000000000000000"
281
+ },
282
+ "expect": {
283
+ "status": "needs_approval"
284
+ }
285
+ },
286
+ {
287
+ "id": "policy-refuses-closeout-submit",
288
+ "tool": "closeout_submit",
289
+ "args": {},
290
+ "expect": {
291
+ "status": "blocked"
292
+ }
293
+ },
294
+ {
295
+ "id": "policy-refuses-invoice-create",
296
+ "tool": "invoice_create",
297
+ "args": {},
298
+ "expect": {
299
+ "status": "blocked"
300
+ }
301
+ },
302
+ {
303
+ "id": "policy-refuses-email-send",
304
+ "tool": "email_send",
305
+ "args": {},
306
+ "expect": {
307
+ "status": "blocked"
308
+ }
309
+ },
310
+ {
311
+ "id": "intl-de-check-totals",
312
+ "tool": "closeout_check",
313
+ "args": {
314
+ "jobs": "fixtures/intl/de/jobs.csv",
315
+ "checklist": "fixtures/intl/de/checklist.csv",
316
+ "requirements": "fixtures/requirements.json",
317
+ "as_of": "2026-11-16"
318
+ },
319
+ "expect": {
320
+ "status": "executed",
321
+ "equals": {
322
+ "result.jobs": 2,
323
+ "result.item_count": 14,
324
+ "result.done": 11,
325
+ "result.missing": 1,
326
+ "result.rejected": 1,
327
+ "result.overdue": 1,
328
+ "result.open": 0,
329
+ "result.jobs_ready": 1,
330
+ "result.by_job.23-095.ready_for_final_billing": "yes",
331
+ "result.by_job.23-090.percent": 57.1
332
+ }
333
+ },
334
+ "note": "German export of the same data (fixtures/intl/de); must match the English case \"check-totals\"."
335
+ },
336
+ {
337
+ "id": "intl-ja-check-totals",
338
+ "tool": "closeout_check",
339
+ "args": {
340
+ "jobs": "fixtures/intl/ja/jobs.csv",
341
+ "checklist": "fixtures/intl/ja/checklist.csv",
342
+ "requirements": "fixtures/requirements.json",
343
+ "as_of": "2026-11-16"
344
+ },
345
+ "expect": {
346
+ "status": "executed",
347
+ "equals": {
348
+ "result.jobs": 2,
349
+ "result.item_count": 14,
350
+ "result.done": 11,
351
+ "result.missing": 1,
352
+ "result.rejected": 1,
353
+ "result.overdue": 1,
354
+ "result.open": 0,
355
+ "result.jobs_ready": 1,
356
+ "result.by_job.23-095.ready_for_final_billing": "yes",
357
+ "result.by_job.23-090.percent": 57.1
358
+ }
359
+ },
360
+ "note": "Japanese export of the same data (fixtures/intl/ja); must match the English case \"check-totals\"."
361
+ }
362
+ ]
363
+ }
@@ -0,0 +1,7 @@
1
+ # Fairbuild Closeout fixtures
2
+
3
+ Everything here is fictional: jobs, project managers and closeout items.
4
+
5
+ - `jobs.csv`: two completed jobs and one still running (24-101, skipped).
6
+ - `checklist.csv`: on 23-090 the O&M manuals (entered as "O and M manuals") were due on 15 September and are still pending, the as-builts were rejected, and the final pay application is not on the checklist. 23-095 is fully closed out.
7
+ - `requirements.json`: seven required items.
@@ -0,0 +1,14 @@
1
+ job,item,status,due_date,received_date
2
+ 23-090,Final lien waivers,Received,2026-09-15,2026-09-10
3
+ 23-090,Warranties,Received,2026-09-15,2026-09-12
4
+ 23-090,O and M manuals,Pending,2026-09-15,
5
+ 23-090,As-built drawings,Rejected,2026-09-30,2026-09-28
6
+ 23-090,Punch list closed,Complete,2026-10-01,2026-10-01
7
+ 23-090,Certificate of occupancy,Received,2026-08-20,2026-08-20
8
+ 23-095,Final lien waivers,Received,2026-07-31,2026-07-20
9
+ 23-095,Warranties,Received,2026-07-31,2026-07-22
10
+ 23-095,O&M manuals,Received,2026-07-31,2026-07-22
11
+ 23-095,As-built drawings,Approved,2026-07-31,2026-07-25
12
+ 23-095,Punch list closed,Complete,2026-07-15,2026-07-14
13
+ 23-095,Certificate of occupancy,Received,2026-07-01,2026-07-01
14
+ 23-095,Final pay application,Approved,2026-08-15,2026-08-10
@@ -0,0 +1,12 @@
1
+ # Fixtures from other countries
2
+
3
+ Generated by `node scripts/make-intl-fixtures.mjs` from the English fixtures one
4
+ folder up. The same fictional data, written the way a local export writes it:
5
+
6
+ - `de/`: German column names, Windows-1252 text, semicolons, comma decimals
7
+ (1.234,56), day-first dotted dates (03.11.2026), kilograms and kilometres.
8
+ - `ja/`: Japanese column names, Shift_JIS text, year-first dates (2026/11/03),
9
+ kilograms and kilometres.
10
+
11
+ Values (names, codes, charge wording) stay in English. The eval cases
12
+ `intl-de-*` and `intl-ja-*` expect exactly the same results as the English case.
@@ -0,0 +1,14 @@
1
+ Projekt;Position;Zustand;F�lligkeitsdatum;Eingangsdatum
2
+ 23-090;Final lien waivers;Received;15.09.2026;10.09.2026
3
+ 23-090;Warranties;Received;15.09.2026;12.09.2026
4
+ 23-090;O and M manuals;Pending;15.09.2026;
5
+ 23-090;As-built drawings;Rejected;30.09.2026;28.09.2026
6
+ 23-090;Punch list closed;Complete;01.10.2026;01.10.2026
7
+ 23-090;Certificate of occupancy;Received;20.08.2026;20.08.2026
8
+ 23-095;Final lien waivers;Received;31.07.2026;20.07.2026
9
+ 23-095;Warranties;Received;31.07.2026;22.07.2026
10
+ 23-095;O&M manuals;Received;31.07.2026;22.07.2026
11
+ 23-095;As-built drawings;Approved;31.07.2026;25.07.2026
12
+ 23-095;Punch list closed;Complete;15.07.2026;14.07.2026
13
+ 23-095;Certificate of occupancy;Received;01.07.2026;01.07.2026
14
+ 23-095;Final pay application;Approved;15.08.2026;10.08.2026
@@ -0,0 +1,4 @@
1
+ Projekt;Projektname;Fertigstellung;Projektleiter
2
+ 23-090;Example School gym;15.08.2026;Project manager A
3
+ 23-095;Sample Retail storefront;30.06.2026;Project manager B
4
+ 24-101;Example Clinic fit-out;;Project manager A
@@ -0,0 +1,14 @@
1
+ �H���ԍ�,���הԍ�,�X�e�[�^�X,����,��̓�
2
+ 23-090,Final lien waivers,Received,2026/09/15,2026/09/10
3
+ 23-090,Warranties,Received,2026/09/15,2026/09/12
4
+ 23-090,O and M manuals,Pending,2026/09/15,
5
+ 23-090,As-built drawings,Rejected,2026/09/30,2026/09/28
6
+ 23-090,Punch list closed,Complete,2026/10/01,2026/10/01
7
+ 23-090,Certificate of occupancy,Received,2026/08/20,2026/08/20
8
+ 23-095,Final lien waivers,Received,2026/07/31,2026/07/20
9
+ 23-095,Warranties,Received,2026/07/31,2026/07/22
10
+ 23-095,O&M manuals,Received,2026/07/31,2026/07/22
11
+ 23-095,As-built drawings,Approved,2026/07/31,2026/07/25
12
+ 23-095,Punch list closed,Complete,2026/07/15,2026/07/14
13
+ 23-095,Certificate of occupancy,Received,2026/07/01,2026/07/01
14
+ 23-095,Final pay application,Approved,2026/08/15,2026/08/10
@@ -0,0 +1,4 @@
1
+ �H���ԍ�,�H����,�v�H��,�H���ӔC��
2
+ 23-090,Example School gym,2026/08/15,Project manager A
3
+ 23-095,Sample Retail storefront,2026/06/30,Project manager B
4
+ 24-101,Example Clinic fit-out,,Project manager A
@@ -0,0 +1,4 @@
1
+ job,job_name,completion_date,project_manager
2
+ 23-090,Example School gym,2026-08-15,Project manager A
3
+ 23-095,Sample Retail storefront,2026-06-30,Project manager B
4
+ 24-101,Example Clinic fit-out,,Project manager A
@@ -0,0 +1 @@
1
+ { "required": ["Final lien waivers", "Warranties"], "grace_days": 30 }
@@ -0,0 +1 @@
1
+ { "items": ["Warranties"] }
@@ -0,0 +1,5 @@
1
+ {
2
+ "required": ["Final lien waivers", "Warranties", "O&M manuals", "As-built drawings", "Punch list closed", "Certificate of occupancy", "Final pay application"],
3
+ "grace_days": 30,
4
+ "item_aliases": { "O and M manuals": "O&M manuals" }
5
+ }
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "fairbuild-closeout",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.fpavia111-creator/fairbuild-closeout",
5
+ "description": "Fairbuild Closeout: the closeout checklist for completed jobs against the documents and steps you require (final lien waivers, warranties, O&M manuals, as-builts, punch list, occupancy, final pay application and others you name): items missing, overdue, rejected or still open long after completion, and which jobs are ready for final billing. Drafts reminders to the project manager. Never submits a closeout package or a final invoice.",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "Kurt Francisco",
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "main": "src/index.js",
13
+ "exports": {
14
+ ".": "./src/index.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "bin": {
18
+ "fairbuild-closeout": "bin/fairbuild-closeout.js"
19
+ },
20
+ "files": [
21
+ "src",
22
+ "bin",
23
+ "fixtures",
24
+ "evals",
25
+ "README.md",
26
+ "CHANGELOG.md",
27
+ "LICENSE",
28
+ "server.json"
29
+ ],
30
+ "scripts": {
31
+ "test": "node scripts/run-tests.cjs",
32
+ "demo": "node bin/fairbuild-closeout.js demo",
33
+ "eval": "node bin/fairbuild-closeout.js eval"
34
+ },
35
+ "dependencies": {
36
+ "fairbuild-core": "^0.1.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/fpavia111-creator/fairbuild-agents.git",
41
+ "directory": "packages/fairbuild-closeout"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairbuild-agents/tree/master/packages/fairbuild-closeout#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/fpavia111-creator/fairbuild-agents/issues"
46
+ },
47
+ "keywords": [
48
+ "mcp",
49
+ "mcp-server",
50
+ "construction",
51
+ "contractors",
52
+ "construction-accounting",
53
+ "fairbuild",
54
+ "closeout",
55
+ "job-closeout",
56
+ "final-billing"
57
+ ]
58
+ }
package/server.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.fpavia111-creator/fairbuild-closeout",
4
+ "title": "Fairbuild Closeout",
5
+ "description": "Fairbuild Closeout: the closeout checklist for completed jobs against the documents and steps you…",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairbuild-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairbuild-closeout"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairbuild.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairbuild-closeout",
17
+ "version": "0.1.0",
18
+ "transport": {
19
+ "type": "stdio"
20
+ },
21
+ "packageArguments": [
22
+ {
23
+ "type": "positional",
24
+ "value": "mcp"
25
+ },
26
+ {
27
+ "type": "named",
28
+ "name": "--root",
29
+ "description": "Folder holding the exports this agent may read and write (it cannot reach outside it)",
30
+ "isRequired": true,
31
+ "format": "filepath",
32
+ "valueHint": "exports_folder"
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
@@ -0,0 +1,72 @@
1
+ // Fairbuild Closeout: the closeout checklist for completed jobs. Pure functions, no I/O.
2
+ import { num, str, round2, pct, isoDate, daysBetween, statusOf, jobKey, finding, orderFindings, byFinding, sortBy } from 'fairbuild-core';
3
+
4
+ const t = (aliases, extra = {}) => ({ aliases, ...extra });
5
+ export const CLOSEOUT_JOB_FIELDS = Object.freeze({
6
+ job: t(['Job', 'Job Number', 'Project', 'Project Number'], { required: true }),
7
+ job_name: t(['Job Name', 'Project Name']),
8
+ completion_date: t(['Completion Date', 'Substantial Completion', 'Substantial Completion Date', 'Completed'], { type: 'date' }),
9
+ project_manager: t(['Project Manager', 'PM']),
10
+ });
11
+ export const CHECKLIST_FIELDS = Object.freeze({
12
+ job: t(['Job', 'Job Number', 'Project', 'Project Number'], { required: true }),
13
+ item: t(['Item', 'Closeout Item', 'Document', 'Requirement', 'Deliverable'], { required: true }),
14
+ status: t(['Status', 'State']),
15
+ due_date: t(['Due Date', 'Due', 'Required By'], { type: 'date' }),
16
+ received_date: t(['Received Date', 'Received', 'Completed', 'Submitted'], { type: 'date' }),
17
+ });
18
+ export const CLOSEOUT_REQUIREMENTS_SCHEMA = Object.freeze({
19
+ type: 'object', additionalProperties: false, required: ['required'],
20
+ properties: {
21
+ required: { type: 'array', items: { type: 'string', maxLength: 120 }, description: 'Closeout items every completed job must have' },
22
+ grace_days: { type: 'integer', minimum: 0, maximum: 365, description: 'An item still open this many days after substantial completion is flagged (default 30)' },
23
+ item_aliases: { type: 'object', additionalProperties: { type: 'string', maxLength: 120 }, description: 'Your words for an item, e.g. {"O and M": "O&M manuals"}' },
24
+ },
25
+ });
26
+ const ORDER = ['item_missing', 'item_rejected', 'item_overdue', 'item_open_too_long'];
27
+ const norm = (s) => str(s).normalize('NFKC').toLowerCase().replace(/[^\p{L}\p{N}]+/gu, '');
28
+
29
+ export function checkCloseout({ jobRows, checklistRows, requirements, asOf }) {
30
+ const grace = num(requirements.grace_days) ?? 30; const alias = Object.fromEntries(Object.entries(requirements.item_aliases || {}).map(([k, v]) => [norm(k), norm(v)]));
31
+ const ikey = (s) => alias[norm(s)] || norm(s);
32
+ const lists = new Map(); for (const c of checklistRows) { const k = jobKey(c.job); if (!k || !str(c.item)) continue; if (!lists.has(k)) lists.set(k, new Map()); lists.get(k).set(ikey(c.item), c); }
33
+ const items = []; const jobs = {};
34
+ for (const j of jobRows) {
35
+ const done = isoDate(j.completion_date); if (!str(j.job) || !done || done > asOf) continue;
36
+ const since = daysBetween(done, asOf); const list = lists.get(jobKey(j.job)) || new Map(); let complete = 0;
37
+ for (const name of requirements.required) {
38
+ const f = []; const c = list.get(ikey(name)); const st = c ? statusOf(c.status) : null; const finished = c && (st === 'closed' || st === 'approved' || /received|complete|done|approved/i.test(str(c.status)) || (!!isoDate(c.received_date) && st !== 'rejected'));
39
+ if (!c) f.push(finding('item_missing', null, `${name} is not on the closeout checklist for job ${str(j.job)}.`));
40
+ else if (st === 'rejected') f.push(finding('item_rejected', null, `${name} was returned or rejected; resubmit it.`));
41
+ else if (!finished) {
42
+ const due = isoDate(c.due_date);
43
+ if (due && due < asOf) f.push(finding('item_overdue', null, `${name} was due ${due} and is still ${str(c.status).toLowerCase() || 'open'}.`));
44
+ else if (since > grace) f.push(finding('item_open_too_long', null, `${name} is still ${str(c.status).toLowerCase() || 'open'} ${since} days after completion.`));
45
+ }
46
+ if (finished) complete++;
47
+ const code = f[0] ? f[0].code : null;
48
+ items.push({ key: `${str(j.job)} ${name}`, job: str(j.job), item: name, item_status: c ? str(c.status) : '', due_date: c ? isoDate(c.due_date) : null, received_date: c ? isoDate(c.received_date) : null, status: finished ? 'done' : code === 'item_missing' ? 'missing' : code === 'item_rejected' ? 'rejected' : code ? 'overdue' : 'open', findings: orderFindings(f, ORDER) });
49
+ }
50
+ const n = requirements.required.length;
51
+ jobs[str(j.job)] = { completed: done, days_since: since, items: n, done: complete, percent: pct(complete, n), ready_for_final_billing: complete === n ? 'yes' : 'no' };
52
+ }
53
+ const rank = { missing: 0, rejected: 1, overdue: 2, open: 3, done: 4 };
54
+ const out = sortBy(items, ['job', 1], [(i) => rank[i.status], 1], ['item', 1]);
55
+ const count = (st) => out.filter((i) => i.status === st).length;
56
+ const r = {
57
+ jobs: Object.keys(jobs).length, item_count: out.length, done: count('done'), missing: count('missing'), rejected: count('rejected'), overdue: count('overdue'), open: count('open'),
58
+ jobs_ready: Object.values(jobs).filter((j) => j.ready_for_final_billing === 'yes').length, as_of: asOf, settings_used: { required: requirements.required, grace_days: grace },
59
+ by_job: jobs, by_finding: byFinding(out), items: out,
60
+ };
61
+ r.summary = `${r.jobs} completed job(s), ${r.item_count} closeout item(s) as of ${asOf}: ${r.done} done, ${r.missing} missing, ${r.rejected} rejected, ${r.overdue} overdue or open too long, ${r.open} open. ${r.jobs_ready} job(s) ready for final billing.`;
62
+ return r;
63
+ }
64
+
65
+ /** Markdown body of a closeout reminder to one job's project manager. */
66
+ export function reminderText(items, job, { to, from }) {
67
+ const rows = items.filter((i) => i.status !== 'done');
68
+ const L = [`# Closeout: job ${job.name}`, '', `**To:** ${to || '[TO CONFIRM project manager]'}`, `**From:** ${from || '[TO CONFIRM your name]'}`, '',
69
+ `Job ${job.name} reached completion on ${job.completed} (${job.days_since} days ago); ${job.done} of ${job.items} closeout items are done. Final billing and retainage release wait for the rest:`, '',
70
+ '| Item | Status | What is needed |', '| --- | --- | --- |', ...rows.map((i) => `| ${i.item} | ${i.item_status || 'not on the checklist'} | ${i.findings.map((f) => f.detail).join(' ') || 'Finish and record it.'} |`), ''];
71
+ return { text: L.join('\n'), count: rows.length };
72
+ }
package/src/demo.js ADDED
@@ -0,0 +1,18 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { demoRuntime, printStep } from 'fairbuild-core';
3
+
4
+ export async function demo(manifest) {
5
+ const rt = demoRuntime(manifest, fileURLToPath(new URL('../fixtures', import.meta.url)), { mode: 'auto', autoActions: ['closeout_draft_reminder'] });
6
+ process.stdout.write(`Fairbuild Closeout demo (fictional jobs and checklists) in ${rt.root}, Auto mode on for drafts\n`);
7
+ const f = { jobs: 'jobs.csv', checklist: 'checklist.csv', requirements: 'requirements.json', as_of: '2026-11-16' };
8
+ const a = await rt.call('closeout_check', f);
9
+ printStep('Check closeout on completed jobs', a);
10
+ for (const i of a.result.items.filter((x) => x.status !== 'done')) process.stdout.write(` ${i.job} ${i.item.padEnd(26)} ${i.status.padEnd(9)} ${i.findings.map((x) => x.code).join(', ')}\n`);
11
+ printStep('Explain job 23-090 O&M manuals', await rt.call('closeout_explain', { ...f, job: '23-090 O&M manuals' }));
12
+ printStep('Write the worklist', await rt.call('closeout_write_report', f));
13
+ const d = await rt.call('closeout_draft_reminder', { ...f, job: '23-090' });
14
+ printStep('Draft a closeout reminder (Auto is opted in for drafts here)', d);
15
+ printStep('Approve sending it: one named click, even in Auto', await rt.call('closeout_request_send', { draft: d.result.draft, draft_sha256: d.result.draft_sha256 }));
16
+ printStep('Agent tries to submit the closeout package itself', await rt.call('closeout_submit', {}));
17
+ process.stdout.write(`\nAudit log: ${rt.stateDir}/audit.jsonl\n`);
18
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { manifest } from './manifest.js';
2
+ export * from './closeout.js';
@@ -0,0 +1,74 @@
1
+ import { defineManifest, MODEL_PIN, standardTools, draftPair, refusedTools, asOfDate, jobKey } from 'fairbuild-core';
2
+ import { readFileSync } from 'node:fs';
3
+ import { checkCloseout, reminderText, CLOSEOUT_JOB_FIELDS, CHECKLIST_FIELDS, CLOSEOUT_REQUIREMENTS_SCHEMA } from './closeout.js';
4
+
5
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
6
+ const OUT = 'fairbuild-out/closeout';
7
+ const props = {
8
+ jobs: { type: 'string', description: 'Jobs under --root (CSV, Excel or JSON) with their substantial completion date; jobs not yet complete are skipped' },
9
+ checklist: { type: 'string', description: 'Closeout checklist: job, item, status, due date, received date' },
10
+ requirements: { type: 'string', description: 'Your closeout requirements JSON (closeout_requirements schema): required items, grace_days, item_aliases' },
11
+ as_of: { type: 'string', maxLength: 30, description: 'Date the checklist is judged on, YYYY-MM-DD (default today)' },
12
+ };
13
+ const run = (a, ctx) => checkCloseout({ jobRows: ctx.records(a.jobs, 'jobs'), checklistRows: ctx.records(a.checklist, 'checklist'), requirements: ctx.readJson(a.requirements, 'closeout_requirements'), asOf: asOfDate(a.as_of) });
14
+ const std = standardTools({
15
+ prefix: 'closeout', outDir: OUT, props, required: ['jobs', 'checklist', 'requirements'], run,
16
+ check: { title: 'Check job closeout', description: 'Per completed job and required closeout item: on the checklist, received or complete, rejected, overdue, or still open long after completion. Per job: share done and whether it is ready for final billing.' },
17
+ explain: { arg: 'job', argDoc: 'Job number from closeout_check, or "job item" for one item', key: (i) => [i.key, i.job], title: 'Explain one job or item',
18
+ description: 'Show one closeout item with every finding.',
19
+ describe: (i) => `${i.job} ${i.item}: ${i.status}. ${i.item_status ? `Checklist status ${i.item_status}. ` : ''}${i.findings.map((f) => f.detail).join(' ')}`.trim() },
20
+ report: { base: 'closeout', title: 'Job closeout checklist', description: 'Write the closeout worklist',
21
+ row: (i) => ({ job: i.job, item: i.item, item_status: i.item_status, due_date: i.due_date || '', received_date: i.received_date || '', status: i.status, findings: i.findings.map((f) => f.code).join(' '), reasons: i.findings.map((f) => f.detail).join(' ') }),
22
+ columns: ['job', 'item', 'item_status', 'due_date', 'received_date', 'status', 'findings', 'reasons'],
23
+ htmlColumns: ['job', 'item', 'item_status', 'due_date', 'status', 'reasons'],
24
+ sections: (r) => [
25
+ { title: 'By job', rows: Object.entries(r.by_job).map(([job, v]) => ({ job, ...v })), columns: ['job', 'completed', 'days_since', 'items', 'done', 'percent', 'ready_for_final_billing'] },
26
+ { title: 'By finding', rows: Object.entries(r.by_finding).map(([code, v]) => ({ code, ...v })), columns: ['code', 'count'] },
27
+ ],
28
+ limits: ['files', 'settings', 'advice', 'Your contract decides what closeout requires; Fairbuild Closeout checks the items you list against the checklist you keep.'] },
29
+ });
30
+ const pair = draftPair({
31
+ prefix: 'closeout', noun: 'reminder', verb: 'send', category: 'binding_send', outDir: OUT, actor: 'a person on your team',
32
+ description: 'Write drafts/reminder-<job>.md: the closeout items still missing, rejected or overdue on one job, for its project manager. Marked DRAFT. Sending goes through closeout_request_send (one click).',
33
+ required: ['jobs', 'checklist', 'requirements', 'job'],
34
+ args: { ...props, job: { type: 'string', maxLength: 60, description: 'Job number' }, to: { type: 'string', maxLength: 200, description: 'Project manager' }, from: { type: 'string', maxLength: 200, description: 'Your name' } },
35
+ build: (a, ctx) => {
36
+ const r = run(a, ctx); const items = r.items.filter((i) => jobKey(i.job) === jobKey(a.job));
37
+ if (!items.length) throw new Error(`job "${a.job}" is not a completed job in the files`);
38
+ const j = r.by_job[items[0].job]; const t = reminderText(items, { name: items[0].job, ...j }, a);
39
+ if (!t.count) throw new Error(`job ${items[0].job} is fully closed out`);
40
+ return { id: items[0].job, to: a.to || undefined, text: t.text, extra: { items: t.count } };
41
+ },
42
+ });
43
+ const refused = refusedTools([
44
+ { name: 'closeout_submit', category: 'binding_send', description: 'Fairbuild Closeout never submits a closeout package to an owner or architect.' },
45
+ { name: 'invoice_create', category: 'binding_send', description: 'Fairbuild Closeout never creates a final invoice or retainage bill.' },
46
+ { name: 'email_send', category: 'binding_send', description: 'Fairbuild Closeout never sends the reminder; a person sends the approved draft.' },
47
+ ]);
48
+
49
+ export const manifest = defineManifest({
50
+ name: 'fairbuild-closeout', version: pkg.version,
51
+ description: 'Checks the closeout checklist of completed jobs against the items you require (final lien waivers, warranties, O&M manuals, as-builts, punch list, occupancy, final pay application and others you name): items missing, rejected, overdue or open long after completion, and which jobs are ready for final billing. Drafts reminders. Submitting closeout and billing is a person\'s job.',
52
+ model: MODEL_PIN,
53
+ caps: { maxSteps: 60, maxSpendUsd: 0 },
54
+ configSchemas: { closeout_requirements: CLOSEOUT_REQUIREMENTS_SCHEMA },
55
+ sources: {
56
+ jobs: { label: 'Jobs and completion dates', args: ['jobs'], fields: CLOSEOUT_JOB_FIELDS },
57
+ checklist: { label: 'Closeout checklist', args: ['checklist'], fields: CHECKLIST_FIELDS },
58
+ },
59
+ prompts: [{
60
+ name: 'closeout_review', title: 'Monthly closeout review',
61
+ description: 'Walks the host model through job closeout with Fairbuild Closeout.',
62
+ arguments: [{ name: 'jobs', description: 'Jobs', required: true }, { name: 'checklist', description: 'Closeout checklist', required: true }, { name: 'requirements', description: 'Requirements JSON', required: true }],
63
+ text: `You are helping a construction project coordinator close out completed jobs with fairbuild-closeout. Jobs: {{jobs}}. Checklist: {{checklist}}. Requirements: {{requirements}}.
64
+
65
+ Rules: Fairbuild Closeout never submits closeout, bills or sends; closeout_submit, invoice_create and email_send are blocked.
66
+
67
+ 1. Call closeout_check. Lead with jobs ready for final billing, then missing, rejected and overdue items per job.
68
+ 2. Call closeout_explain for jobs or items the person asks about.
69
+ 3. Call closeout_write_report and share the paths.
70
+ 4. Offer closeout_draft_reminder per job; only when the person asks, call closeout_request_send. It needs one named human click.`,
71
+ }],
72
+ tools: [...std.tools, ...pair.tools, ...refused.tools],
73
+ policy: { rules: [...std.rules, ...pair.rules, ...refused.rules, { tool: '*', decision: 'block', reason: 'Not on the Fairbuild Closeout allowlist.' }] },
74
+ });