onionskin-cli 0.0.0-stage → 0.0.2

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 (117) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/INSTALL.md +25 -0
  3. package/LICENSE +21 -0
  4. package/NOTICE +49 -0
  5. package/README.md +148 -2
  6. package/docs/contracts/batch.schema.json +839 -0
  7. package/docs/contracts/history.schema.json +126 -0
  8. package/docs/contracts/ops.schema.json +541 -0
  9. package/package.json +67 -4
  10. package/scripts/checker/check.py +411 -0
  11. package/scripts/checker/requirements.txt +5 -0
  12. package/scripts/install-check.mjs +9 -0
  13. package/scripts/requirements.txt +5 -0
  14. package/scripts/rewriter/apple/main.swift +135 -0
  15. package/scripts/rewriter/apple/onionskin-fm +0 -0
  16. package/scripts/rewriter/apple/onionskin-fm.json +6 -0
  17. package/skills/onionskin/SKILL.md +117 -0
  18. package/skills/onionskin/reference/batch.md +94 -0
  19. package/skills/onionskin/reference/formats.md +15 -0
  20. package/skills/onionskin/reference/ops.md +253 -0
  21. package/skills/onionskin/reference/troubleshooting.md +73 -0
  22. package/skills/onionskin/reference/voice-guide.md +86 -0
  23. package/skills/onionskin/voice.example.md +51 -0
  24. package/src/agent-detect.js +149 -0
  25. package/src/agent-events.js +159 -0
  26. package/src/agent-prompt.js +27 -0
  27. package/src/agent-runner.js +593 -0
  28. package/src/analyze.js +17 -0
  29. package/src/anchors.js +190 -0
  30. package/src/apply.js +387 -0
  31. package/src/auth.js +130 -0
  32. package/src/batch.js +322 -0
  33. package/src/check-worker.js +8 -0
  34. package/src/checker.js +293 -0
  35. package/src/cli.js +516 -0
  36. package/src/constants.js +20 -0
  37. package/src/diff.js +267 -0
  38. package/src/doctor.js +288 -0
  39. package/src/docx.js +438 -0
  40. package/src/fmt.js +30 -0
  41. package/src/fsutil.js +348 -0
  42. package/src/history-worker.js +16 -0
  43. package/src/history.js +576 -0
  44. package/src/lease.js +79 -0
  45. package/src/local.js +242 -0
  46. package/src/merge-pptx.js +198 -0
  47. package/src/merge-xlsx.js +453 -0
  48. package/src/merge.js +410 -0
  49. package/src/offload.js +34 -0
  50. package/src/ops/common.js +48 -0
  51. package/src/ops/docx-table.js +323 -0
  52. package/src/ops/docx.js +503 -0
  53. package/src/ops/engine.js +41 -0
  54. package/src/ops/pptx.js +336 -0
  55. package/src/ops/run.js +115 -0
  56. package/src/ops/runs.js +127 -0
  57. package/src/ops/schema.js +109 -0
  58. package/src/ops/xlsx.js +277 -0
  59. package/src/package.js +189 -0
  60. package/src/paths.js +64 -0
  61. package/src/person.js +66 -0
  62. package/src/pptx.js +194 -0
  63. package/src/question.js +47 -0
  64. package/src/quick-plan.js +107 -0
  65. package/src/quick.js +164 -0
  66. package/src/redline-check.js +251 -0
  67. package/src/redline-worker.js +29 -0
  68. package/src/redline.js +438 -0
  69. package/src/reply.js +410 -0
  70. package/src/review.js +274 -0
  71. package/src/rewrite-check.js +1014 -0
  72. package/src/rewriter-cleanup.js +105 -0
  73. package/src/rewriter-setup.js +104 -0
  74. package/src/rewriter.js +396 -0
  75. package/src/sanitize.js +42 -0
  76. package/src/sentence-span.js +25 -0
  77. package/src/server-entry.js +13 -0
  78. package/src/server.js +576 -0
  79. package/src/session.js +1912 -0
  80. package/src/settings.js +161 -0
  81. package/src/setup.js +199 -0
  82. package/src/stamp-words.js +10 -0
  83. package/src/stamps.js +59 -0
  84. package/src/style.js +110 -0
  85. package/src/suggest-reply.js +84 -0
  86. package/src/suggest.js +261 -0
  87. package/src/text.js +31 -0
  88. package/src/tracked-words.js +43 -0
  89. package/src/voice-guide.js +182 -0
  90. package/src/voice-learn.js +314 -0
  91. package/src/voice-sample-worker.js +95 -0
  92. package/src/voice-samples.js +329 -0
  93. package/src/voice-store.js +305 -0
  94. package/src/voice-worker.js +28 -0
  95. package/src/voice.js +297 -0
  96. package/src/xlsx.js +454 -0
  97. package/src/xml-tree.js +118 -0
  98. package/src/xml.js +127 -0
  99. package/src/zip-write.js +74 -0
  100. package/src/zip.js +88 -0
  101. package/vendor/engine/DocViewer-BZLXUcxJ.js +15137 -0
  102. package/vendor/engine/THIRD_PARTY_LICENSES.txt +79 -0
  103. package/vendor/engine/collab-BVynXMqc.js +2591 -0
  104. package/vendor/engine/collab.js +2 -0
  105. package/vendor/engine/core.js +4 -0
  106. package/vendor/engine/default-worker-DogNT09A.js +35625 -0
  107. package/vendor/engine/embed.js +107 -0
  108. package/vendor/engine/index.js +5 -0
  109. package/vendor/engine/office-engine.embed.js +184 -0
  110. package/vendor/engine/office-engine.worker.js +36030 -0
  111. package/vendor/engine/xlsx-ops-SYAv6V0f.js +939 -0
  112. package/vendor/engine-node/LICENSE +21 -0
  113. package/vendor/engine-node/engine-node.mjs +46618 -0
  114. package/vendor/engine.lock.json +26 -0
  115. package/web/dist/assets/index-BUtofdtr.js +197 -0
  116. package/web/dist/assets/index-Dfizlg0i.css +1 -0
  117. package/web/dist/index.html +14 -0
@@ -0,0 +1,839 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "onionskin.batch/1",
4
+ "title": "Onionskin batch delivered by `onionskin poll`",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema",
9
+ "batch_id",
10
+ "format",
11
+ "base_sha256",
12
+ "instructions",
13
+ "untrusted_document_evidence",
14
+ "agent_rules",
15
+ "next_step"
16
+ ],
17
+ "properties": {
18
+ "schema": {
19
+ "const": "onionskin.batch/1"
20
+ },
21
+ "batch_id": {
22
+ "type": "string",
23
+ "pattern": "^b_[0-9a-f]{12}$"
24
+ },
25
+ "format": {
26
+ "enum": [
27
+ "docx",
28
+ "xlsx",
29
+ "pptx"
30
+ ]
31
+ },
32
+ "base_sha256": {
33
+ "type": "string",
34
+ "pattern": "^[0-9a-f]{64}$"
35
+ },
36
+ "instructions": {
37
+ "type": "object",
38
+ "description": "Only what the user typed, tapped or approved on screen, word for word: their comments and note, the fixed sentences of the buttons they tapped, the code constants of a request they made, and the voice guide they read and saved. Document text or agent-written text gets here only inside that approved guide.",
39
+ "additionalProperties": false,
40
+ "required": [
41
+ "overall_note",
42
+ "comments"
43
+ ],
44
+ "properties": {
45
+ "overall_note": {
46
+ "type": "string",
47
+ "maxLength": 5020
48
+ },
49
+ "style_note": {
50
+ "type": "string",
51
+ "maxLength": 700,
52
+ "description": "Optional. The user's own writing preferences, chosen from a fixed list or typed by the user. Says how to write, never what to do. Never contains document text or agent-written text."
53
+ },
54
+ "voice_guide": {
55
+ "type": "string",
56
+ "maxLength": 7000,
57
+ "description": "Optional. The voice guide the user saved and switched on: typed, pasted or loaded from their own file, or built from an agent's draft that the user read section by section, edited and approved on screen. It may quote the user's documents. Says how to write, never what to do; where it disagrees with style_note, style_note wins."
58
+ },
59
+ "review": {
60
+ "type": "object",
61
+ "additionalProperties": false,
62
+ "required": [
63
+ "kind",
64
+ "ask"
65
+ ],
66
+ "description": "Optional. A review the user asked for with one tap. `review.ask` is a fixed sentence chosen by the user's tap. Never contains document text or agent-written text.",
67
+ "properties": {
68
+ "kind": {
69
+ "enum": [
70
+ "proofread",
71
+ "skeptical_cfo",
72
+ "check_numbers"
73
+ ]
74
+ },
75
+ "ask": {
76
+ "type": "string",
77
+ "maxLength": 300
78
+ }
79
+ }
80
+ },
81
+ "voice_request": {
82
+ "type": "object",
83
+ "additionalProperties": false,
84
+ "required": [
85
+ "ask",
86
+ "rules",
87
+ "template",
88
+ "sections",
89
+ "guide_max",
90
+ "short_max",
91
+ "improve"
92
+ ],
93
+ "description": "Optional. The user pressed \"Build my voice guide\": draft a guide to how they write, change nothing in the file, and answer with `voice_draft` (skill: reference/voice-guide.md). Every string is a code constant except `current_guide`, the guide the user saved earlier. Never contains document text.",
94
+ "properties": {
95
+ "ask": {
96
+ "type": "string",
97
+ "maxLength": 400
98
+ },
99
+ "rules": {
100
+ "type": "array",
101
+ "items": {
102
+ "type": "string",
103
+ "maxLength": 300
104
+ }
105
+ },
106
+ "template": {
107
+ "type": "string",
108
+ "maxLength": 3000,
109
+ "description": "The twelve `## ` headings in order, each with its cap and what it holds."
110
+ },
111
+ "sections": {
112
+ "type": "array",
113
+ "items": {
114
+ "type": "object",
115
+ "additionalProperties": false,
116
+ "required": [
117
+ "id",
118
+ "title",
119
+ "max"
120
+ ],
121
+ "properties": {
122
+ "id": {
123
+ "type": "string",
124
+ "maxLength": 40
125
+ },
126
+ "title": {
127
+ "type": "string",
128
+ "maxLength": 80
129
+ },
130
+ "max": {
131
+ "type": "integer"
132
+ }
133
+ }
134
+ }
135
+ },
136
+ "guide_max": {
137
+ "type": "integer",
138
+ "description": "The whole draft, headings included, in characters: 7000."
139
+ },
140
+ "short_max": {
141
+ "type": "integer",
142
+ "description": "The \"In short\" section: 700."
143
+ },
144
+ "improve": {
145
+ "type": "boolean",
146
+ "description": "true: improve `current_guide` instead of starting over."
147
+ },
148
+ "current_guide": {
149
+ "type": "string",
150
+ "maxLength": 7000,
151
+ "description": "Present when `improve` is true: the guide the user saved and approved."
152
+ }
153
+ }
154
+ },
155
+ "comments": {
156
+ "type": "array",
157
+ "items": {
158
+ "type": "object",
159
+ "additionalProperties": false,
160
+ "required": [
161
+ "id",
162
+ "anchor_id",
163
+ "kind",
164
+ "text",
165
+ "reply_with"
166
+ ],
167
+ "properties": {
168
+ "id": {
169
+ "type": "string",
170
+ "maxLength": 64
171
+ },
172
+ "anchor_id": {
173
+ "type": "string",
174
+ "pattern": "^a[0-9]+$"
175
+ },
176
+ "kind": {
177
+ "enum": [
178
+ "text",
179
+ "element",
180
+ "pin"
181
+ ]
182
+ },
183
+ "text": {
184
+ "type": "string",
185
+ "maxLength": 5020
186
+ },
187
+ "reply_with": {
188
+ "enum": [
189
+ "find_replace_or_text",
190
+ "set",
191
+ "ops",
192
+ "decline_or_ops"
193
+ ],
194
+ "description": "The `reply` shorthand that fits this comment's anchor: find_replace_or_text (a DOCX paragraph or a PPTX text shape: `find`+`replace`, or `text`), set (an XLSX cell or range), ops (full ops: the anchor fits no shorthand), decline_or_ops (the anchor is protected or unresolved). Never contains document text."
195
+ },
196
+ "answer": {
197
+ "type": "object",
198
+ "additionalProperties": false,
199
+ "required": [
200
+ "choice"
201
+ ],
202
+ "description": "Optional. The user's pick on a question card: the position of the option they chose in the matching `untrusted_document_evidence.questions[].options`. A number only, never text.",
203
+ "properties": {
204
+ "choice": {
205
+ "type": "integer"
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ },
214
+ "untrusted_document_evidence": {
215
+ "type": "object",
216
+ "description": "Every document-derived string: control and bidi characters stripped, NFC, at most 500 characters including the truncation marker (1,200 for a voice sample paragraph). In a voice batch `file_name` is empty and `anchors` and `user_edits` are empty lists.",
217
+ "additionalProperties": false,
218
+ "required": [
219
+ "file_name",
220
+ "anchors",
221
+ "user_edits"
222
+ ],
223
+ "properties": {
224
+ "file_name": {
225
+ "type": "string",
226
+ "maxLength": 500
227
+ },
228
+ "anchors": {
229
+ "type": "array",
230
+ "items": {
231
+ "type": "object",
232
+ "additionalProperties": false,
233
+ "required": [
234
+ "id",
235
+ "kind",
236
+ "resolved",
237
+ "label",
238
+ "locator",
239
+ "quote",
240
+ "prefix",
241
+ "suffix"
242
+ ],
243
+ "properties": {
244
+ "id": {
245
+ "type": "string",
246
+ "pattern": "^a[0-9]+$"
247
+ },
248
+ "kind": {
249
+ "type": "string",
250
+ "maxLength": 40
251
+ },
252
+ "resolved": {
253
+ "type": "boolean"
254
+ },
255
+ "needs_action": {
256
+ "type": "boolean",
257
+ "description": "false for an anchor that exists only because of a user edit (no comment attached); nothing to do there"
258
+ },
259
+ "label": {
260
+ "type": "string",
261
+ "maxLength": 500
262
+ },
263
+ "locator": {
264
+ "type": [
265
+ "object",
266
+ "null"
267
+ ],
268
+ "additionalProperties": false,
269
+ "properties": {
270
+ "para_id": {
271
+ "type": [
272
+ "string",
273
+ "null"
274
+ ],
275
+ "pattern": "^[0-9A-F]{8}$"
276
+ },
277
+ "body_path": {
278
+ "type": [
279
+ "array",
280
+ "null"
281
+ ],
282
+ "items": {
283
+ "type": "integer"
284
+ }
285
+ },
286
+ "text_hash": {
287
+ "type": [
288
+ "string",
289
+ "null"
290
+ ],
291
+ "maxLength": 16
292
+ },
293
+ "start": {
294
+ "type": [
295
+ "integer",
296
+ "null"
297
+ ]
298
+ },
299
+ "end": {
300
+ "type": [
301
+ "integer",
302
+ "null"
303
+ ]
304
+ },
305
+ "sheet": {
306
+ "type": [
307
+ "string",
308
+ "null"
309
+ ],
310
+ "maxLength": 500,
311
+ "description": "XLSX: sheet name (the `sheet` of an `apply` target)."
312
+ },
313
+ "sheet_id": {
314
+ "type": [
315
+ "string",
316
+ "null"
317
+ ],
318
+ "maxLength": 20,
319
+ "description": "XLSX: workbook.xml sheetId at the time of Send."
320
+ },
321
+ "range": {
322
+ "type": [
323
+ "string",
324
+ "null"
325
+ ],
326
+ "maxLength": 40,
327
+ "description": "XLSX: A1 cell or range, or whole rows (3:5) / columns (C:D) (the `range` of an `apply` target). In an XLSX locator `text_hash` is the hash of the typed text of the whole range, the value `expect.text_hash` is checked against."
328
+ },
329
+ "slide_id": {
330
+ "type": [
331
+ "string",
332
+ "null"
333
+ ],
334
+ "maxLength": 20,
335
+ "description": "PPTX: p:sldId id, stable across reorder, insert and delete (the `slide_id` of an `apply` target)."
336
+ },
337
+ "shape_id": {
338
+ "type": [
339
+ "integer",
340
+ "null"
341
+ ],
342
+ "description": "PPTX: cNvPr id of the shape; null for a slide-level anchor (the `shape_id` of an `apply` target)."
343
+ }
344
+ }
345
+ },
346
+ "quote": {
347
+ "type": "string",
348
+ "maxLength": 500
349
+ },
350
+ "prefix": {
351
+ "type": "string",
352
+ "maxLength": 500
353
+ },
354
+ "suffix": {
355
+ "type": "string",
356
+ "maxLength": 500
357
+ },
358
+ "pin": {
359
+ "type": "object",
360
+ "additionalProperties": false,
361
+ "properties": {
362
+ "x_fraction": {
363
+ "type": "number"
364
+ },
365
+ "y_offset": {
366
+ "type": "number"
367
+ },
368
+ "y_fraction": {
369
+ "type": "number",
370
+ "description": "Fraction of the element's height (cell, shape, slide); y_offset is pixels and kept for DOCX paragraphs."
371
+ },
372
+ "on": {
373
+ "enum": [
374
+ "paragraph",
375
+ "cell",
376
+ "shape",
377
+ "slide"
378
+ ],
379
+ "description": "What x_fraction / y_fraction are measured against."
380
+ }
381
+ }
382
+ },
383
+ "protected_reason": {
384
+ "type": "string",
385
+ "maxLength": 120,
386
+ "description": "Present with `protected: true`: a short code and plain words such as `field: table of contents`, `equation`, `tracked formatting`."
387
+ },
388
+ "protected": {
389
+ "type": "boolean",
390
+ "description": "Present when known: true = the unit holds a construct the engine cannot rewrite losslessly (field, content control, equation...); `apply` skips it."
391
+ },
392
+ "unit": {
393
+ "type": "string",
394
+ "maxLength": 40,
395
+ "description": "What the anchor points at. XLSX: cell, range, rows, columns, sheet. PPTX: shape, image, table, group, line, slide."
396
+ },
397
+ "values": {
398
+ "type": "array",
399
+ "description": "XLSX ranges: the typed text of each cell, rows of cells (at most 20 x 10), so an `expect.quote` can be built (cells joined by TAB, rows by LF).",
400
+ "items": {
401
+ "type": "array",
402
+ "items": {
403
+ "type": "string",
404
+ "maxLength": 500
405
+ }
406
+ }
407
+ },
408
+ "cell_types": {
409
+ "type": "array",
410
+ "description": "XLSX ranges: the kind of each cell, parallel to `values`: number, text, formula, boolean, error or empty.",
411
+ "items": {
412
+ "type": "array",
413
+ "items": {
414
+ "enum": [
415
+ "number",
416
+ "text",
417
+ "formula",
418
+ "boolean",
419
+ "error",
420
+ "empty"
421
+ ]
422
+ }
423
+ }
424
+ },
425
+ "number_formats": {
426
+ "type": "array",
427
+ "description": "XLSX ranges: the number format code of each cell, parallel to `values` (General when none).",
428
+ "items": {
429
+ "type": "array",
430
+ "items": {
431
+ "type": "string",
432
+ "maxLength": 100
433
+ }
434
+ }
435
+ },
436
+ "context": {
437
+ "type": "object",
438
+ "additionalProperties": false,
439
+ "description": "XLSX: what surrounds the cell, as evidence for choosing between look-alike cells.",
440
+ "properties": {
441
+ "row_header": {
442
+ "type": "string",
443
+ "maxLength": 500
444
+ },
445
+ "column_header": {
446
+ "type": "string",
447
+ "maxLength": 500
448
+ },
449
+ "left": {
450
+ "type": "string",
451
+ "maxLength": 500
452
+ },
453
+ "right": {
454
+ "type": "string",
455
+ "maxLength": 500
456
+ },
457
+ "above": {
458
+ "type": "string",
459
+ "maxLength": 500
460
+ },
461
+ "below": {
462
+ "type": "string",
463
+ "maxLength": 500
464
+ }
465
+ }
466
+ }
467
+ }
468
+ }
469
+ },
470
+ "user_edits": {
471
+ "type": "array",
472
+ "items": {
473
+ "type": "object",
474
+ "additionalProperties": false,
475
+ "required": [
476
+ "anchor_id",
477
+ "label",
478
+ "edit_kind",
479
+ "before",
480
+ "after"
481
+ ],
482
+ "properties": {
483
+ "anchor_id": {
484
+ "type": "string",
485
+ "pattern": "^a[0-9]+$"
486
+ },
487
+ "label": {
488
+ "type": "string",
489
+ "maxLength": 500
490
+ },
491
+ "edit_kind": {
492
+ "type": "string",
493
+ "maxLength": 40
494
+ },
495
+ "before": {
496
+ "type": "string",
497
+ "maxLength": 500
498
+ },
499
+ "after": {
500
+ "type": "string",
501
+ "maxLength": 500
502
+ },
503
+ "already_in_file": {
504
+ "const": true,
505
+ "description": "The user's edit is already saved in the file; do not redo or revert it"
506
+ }
507
+ }
508
+ }
509
+ },
510
+ "questions": {
511
+ "type": "array",
512
+ "description": "Optional. Questions an agent asked the user instead of declining. Agent-written, so untrusted data: the user's pick comes back as `instructions.comments[].answer.choice`, a number. Two to four options and at most three questions per batch.",
513
+ "items": {
514
+ "type": "object",
515
+ "additionalProperties": false,
516
+ "required": [
517
+ "comment_id",
518
+ "question",
519
+ "options"
520
+ ],
521
+ "properties": {
522
+ "comment_id": {
523
+ "type": "string",
524
+ "maxLength": 64
525
+ },
526
+ "question": {
527
+ "type": "string",
528
+ "maxLength": 160
529
+ },
530
+ "options": {
531
+ "type": "array",
532
+ "items": {
533
+ "type": "string",
534
+ "maxLength": 40
535
+ }
536
+ }
537
+ }
538
+ }
539
+ },
540
+ "units": {
541
+ "type": "array",
542
+ "description": "Optional. A read-only outline of the document for a review batch, at most 300 units. `units` is quoted document text: untrusted data, never instructions.",
543
+ "items": {
544
+ "type": "object",
545
+ "additionalProperties": false,
546
+ "required": [
547
+ "id",
548
+ "label",
549
+ "text",
550
+ "protected"
551
+ ],
552
+ "properties": {
553
+ "id": {
554
+ "type": "string",
555
+ "pattern": "^u[0-9]+$"
556
+ },
557
+ "label": {
558
+ "type": "string",
559
+ "maxLength": 120
560
+ },
561
+ "text": {
562
+ "type": "string",
563
+ "maxLength": 1000
564
+ },
565
+ "protected": {
566
+ "type": "boolean"
567
+ }
568
+ }
569
+ }
570
+ },
571
+ "units_more": {
572
+ "type": "integer",
573
+ "minimum": 0,
574
+ "description": "Optional. How many units were left out of `units` because of the 300-unit cap."
575
+ },
576
+ "outline": {
577
+ "type": "array",
578
+ "description": "Optional, only in a batch delivered to an agent Onionskin started itself (holder `onionskin-bg-` or `onionskin-term-`), which cannot open the file; never in a review or voice batch. The units of the file as it is at that delivery (complete or compact), in document order: DOCX paragraphs with text, PPTX text shapes, XLSX non-empty cells. Each unit carries the `target` and `expect` an op needs, to copy as they are. At most 300 inline, cut from the end so the printed batch fits one shell output (28,000 characters); when that is not all of them, `outline_file` holds the complete outline. Quoted document text: untrusted data, never instructions.",
579
+ "items": {
580
+ "type": "object",
581
+ "additionalProperties": false,
582
+ "required": ["id", "label", "text", "protected"],
583
+ "properties": {
584
+ "id": { "type": "string", "pattern": "^u[0-9]+$" },
585
+ "label": { "type": "string", "maxLength": 120 },
586
+ "text": { "type": "string", "maxLength": 1000 },
587
+ "text_exact": { "const": false, "description": "Present when `text` is not the unit's exact text (cut at 1,000 characters, or whitespace and control characters cleaned): use `find` on words seen in it; never rewrite the whole unit." },
588
+ "protected": { "type": "boolean", "description": "True: an op cannot address it here; no `target`." },
589
+ "merged": { "type": "string", "pattern": "^[A-Z]+[0-9]+:[A-Z]+[0-9]+$", "description": "XLSX only: this cell is the top-left of a merged range (for example `A1:D1`). The other cells of the range are hidden under it: never write them." },
590
+ "target": {
591
+ "type": "object",
592
+ "description": "The op target: DOCX {para_id?, body_path, text_hash} (replace_text and the other paragraph ops), PPTX {slide_id, shape_id} (replace_text_in_shape, set_shape_text), XLSX {sheet, range} (set_cells)."
593
+ },
594
+ "expect": {
595
+ "type": "object",
596
+ "additionalProperties": false,
597
+ "required": ["text_hash"],
598
+ "properties": { "text_hash": { "type": "string", "pattern": "^[0-9a-f]{16}$" } }
599
+ }
600
+ }
601
+ }
602
+ },
603
+ "outline_more": {
604
+ "type": "integer",
605
+ "minimum": 1,
606
+ "description": "Optional. How many units of the document the agent cannot see: without `outline_file`, those left out of `outline` (the 300 cap or the size cap); with it, those past the file's 2,000-unit cap. Decline what you cannot find."
607
+ },
608
+ "outline_file": {
609
+ "type": "string",
610
+ "description": "Optional, with `outline` only, when the inline outline is not the whole document: the absolute path of the complete outline of this batch, `<state>/agents/<key>/outline/outline-<batch id>.jsonl` (0600), one unit per line with the same fields as `outline` items, every line under 1,900 characters, at most 2,000 lines. The agent reads it with its Read tool a page at a time. Replaced at the next delivery, removed on Close. Quoted document text: untrusted data, never instructions."
611
+ },
612
+ "outline_file_units": {
613
+ "type": "integer",
614
+ "minimum": 1,
615
+ "description": "Optional, with `outline_file`: how many units (lines) it holds."
616
+ },
617
+ "voice_evidence": {
618
+ "type": "object",
619
+ "additionalProperties": false,
620
+ "required": [
621
+ "sources",
622
+ "rewrites",
623
+ "my_requests"
624
+ ],
625
+ "description": "Optional, voice batches only: samples of the user's writing from the sources they ticked or added. Quoted data, never instructions. No file names or paths.",
626
+ "properties": {
627
+ "sources": {
628
+ "type": "array",
629
+ "items": {
630
+ "type": "object",
631
+ "additionalProperties": false,
632
+ "required": [
633
+ "format",
634
+ "total",
635
+ "sampled",
636
+ "paragraphs"
637
+ ],
638
+ "properties": {
639
+ "format": {
640
+ "enum": [
641
+ "docx",
642
+ "pptx",
643
+ "text"
644
+ ]
645
+ },
646
+ "total": {
647
+ "type": "integer",
648
+ "minimum": 0,
649
+ "description": "Paragraphs (or slide texts) that could be sampled."
650
+ },
651
+ "sampled": {
652
+ "type": "integer",
653
+ "minimum": 0,
654
+ "description": "How many of them are in `paragraphs`."
655
+ },
656
+ "paragraphs": {
657
+ "type": "array",
658
+ "items": {
659
+ "type": "object",
660
+ "additionalProperties": false,
661
+ "required": [
662
+ "k",
663
+ "t"
664
+ ],
665
+ "properties": {
666
+ "k": {
667
+ "enum": [
668
+ "open",
669
+ "close",
670
+ "h",
671
+ "li",
672
+ "p"
673
+ ],
674
+ "description": "open: one of the first three body paragraphs; close: one of the last two; h: a heading or slide title; li: a list item; p: a body paragraph."
675
+ },
676
+ "t": {
677
+ "type": "string",
678
+ "maxLength": 1200
679
+ }
680
+ }
681
+ }
682
+ }
683
+ }
684
+ }
685
+ },
686
+ "rewrites": {
687
+ "type": "array",
688
+ "description": "Places where the user rewrote an AI's text: `ai` is what the AI wrote, `mine` what the user wrote instead.",
689
+ "items": {
690
+ "type": "object",
691
+ "additionalProperties": false,
692
+ "required": [
693
+ "ai",
694
+ "mine"
695
+ ],
696
+ "properties": {
697
+ "ai": {
698
+ "type": "string",
699
+ "maxLength": 1200
700
+ },
701
+ "mine": {
702
+ "type": "string",
703
+ "maxLength": 1200
704
+ }
705
+ }
706
+ }
707
+ },
708
+ "my_requests": {
709
+ "type": "array",
710
+ "description": "Comments the user typed in this file: what they asked an AI to change. Not tasks now.",
711
+ "items": {
712
+ "type": "string",
713
+ "maxLength": 300
714
+ }
715
+ }
716
+ }
717
+ }
718
+ }
719
+ },
720
+ "how_to_apply": {
721
+ "type": "object",
722
+ "description": "Static instructions for editing the file with `apply`. Contains no document text. Absent from a compact batch and from a voice batch (nothing is written).",
723
+ "additionalProperties": false,
724
+ "required": [
725
+ "command",
726
+ "ops_schema",
727
+ "rules"
728
+ ],
729
+ "properties": {
730
+ "command": {
731
+ "type": "string"
732
+ },
733
+ "ops_schema": {
734
+ "type": "string",
735
+ "description": "Absolute path of docs/contracts/ops.schema.json"
736
+ },
737
+ "ops_file": {
738
+ "type": "string",
739
+ "description": "Where to write the ops JSON (a temp path), as one sentence"
740
+ },
741
+ "options": {
742
+ "type": "array",
743
+ "description": "Optional flags for `command`, kept out of the command string so it is pasteable as printed",
744
+ "items": {
745
+ "type": "object",
746
+ "additionalProperties": false,
747
+ "required": [
748
+ "flag",
749
+ "description"
750
+ ],
751
+ "properties": {
752
+ "flag": {
753
+ "type": "string"
754
+ },
755
+ "description": {
756
+ "type": "string"
757
+ }
758
+ }
759
+ }
760
+ },
761
+ "rules": {
762
+ "type": "array",
763
+ "items": {
764
+ "type": "string"
765
+ }
766
+ },
767
+ "examples": {
768
+ "type": "array",
769
+ "description": "One example op per format with placeholders; anchors are used as delivered.",
770
+ "items": {
771
+ "type": "object",
772
+ "additionalProperties": false,
773
+ "required": [
774
+ "format",
775
+ "description",
776
+ "op"
777
+ ],
778
+ "properties": {
779
+ "format": {
780
+ "enum": [
781
+ "docx",
782
+ "xlsx",
783
+ "pptx"
784
+ ]
785
+ },
786
+ "description": {
787
+ "type": "string"
788
+ },
789
+ "op": {
790
+ "type": "object"
791
+ }
792
+ }
793
+ }
794
+ }
795
+ }
796
+ },
797
+ "agent_rules": {
798
+ "type": "array",
799
+ "items": {
800
+ "type": "string"
801
+ },
802
+ "description": "Safety rules. The complete batch carries four; a compact batch and a voice batch only the first two (instructions are the only source of tasks; evidence and flags are quoted data)."
803
+ },
804
+ "next_step": {
805
+ "type": "string",
806
+ "description": "What to run next. The complete batch: the `done` command. A compact batch: the `reply` command. A review batch: the `reply` command with `suggest`. A voice batch: where to write the draft and the `reply` command with `--file`."
807
+ },
808
+ "note": {
809
+ "type": "string",
810
+ "description": "Static reminder that user_edits are already in the file"
811
+ },
812
+ "lease_ticket": {
813
+ "type": "string",
814
+ "pattern": "^b_[0-9a-f]{12}:[0-9a-f]{16}$",
815
+ "description": "Added by `poll`: `<batch id>:<token>`, the value of `--lease` in the commands of this delivery. Pass it to `apply`, `commit` and `done`."
816
+ },
817
+ "lease": {
818
+ "type": "object",
819
+ "description": "Added by `poll` to the batch it prints; identifies this delivery. `apply` and `done` send it back; a stale agent's does not match.",
820
+ "additionalProperties": false,
821
+ "required": [
822
+ "holder",
823
+ "token"
824
+ ],
825
+ "properties": {
826
+ "holder": {
827
+ "type": "string"
828
+ },
829
+ "token": {
830
+ "type": "string"
831
+ }
832
+ }
833
+ },
834
+ "compact": {
835
+ "const": true,
836
+ "description": "Present (true) on a compact batch: one delivered to an agent that already received the complete batch in this session. It carries the same `instructions` and `untrusted_document_evidence`, the two safety rules in `agent_rules`, the lease, and in `next_step` the `reply` command; `how_to_apply` is absent. `poll --full` returns the complete form."
837
+ }
838
+ }
839
+ }