bantamkit-mcp 0.26.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 (148) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +398 -0
  3. package/assets/contracts/default.yaml +90 -0
  4. package/assets/evals/devteam/manifest.yaml +351 -0
  5. package/assets/evals/devteam/repo/HISTORY.md +18 -0
  6. package/assets/evals/devteam/repo/README.md +12 -0
  7. package/assets/evals/devteam/repo/docs/architecture.md +17 -0
  8. package/assets/evals/devteam/repo/docs/runbook.md +10 -0
  9. package/assets/evals/devteam/repo/issues/142-settlement-timeout.md +23 -0
  10. package/assets/evals/devteam/repo/patches/0009-retry-budget.patch +38 -0
  11. package/assets/evals/devteam/repo/src/ledger/__init__.py +3 -0
  12. package/assets/evals/devteam/repo/src/ledger/config.py +35 -0
  13. package/assets/evals/devteam/repo/src/ledger/errors.py +13 -0
  14. package/assets/evals/devteam/repo/src/ledger/posting.py +12 -0
  15. package/assets/evals/devteam/repo/src/ledger/registry.py +7 -0
  16. package/assets/evals/devteam/repo/src/ledger/report.py +9 -0
  17. package/assets/evals/devteam/repo/src/ledger/retry.py +17 -0
  18. package/assets/evals/devteam/repo/src/ledger/settle.py +16 -0
  19. package/assets/evals/devteam/repo/src/ledger/validate.py +14 -0
  20. package/assets/evals/devteam/repo/tests/test_posting.py +13 -0
  21. package/assets/evals/devteam/repo/tests/test_settle.py +9 -0
  22. package/assets/evals/devteam/tasks/dt-error-contract.yaml +186 -0
  23. package/assets/evals/devteam/tasks/dt-handler-map.yaml +183 -0
  24. package/assets/evals/devteam/tasks/dt-patch-before-after.yaml +182 -0
  25. package/assets/evals/devteam/tasks/dt-retry-attempts.yaml +181 -0
  26. package/assets/evals/devteam/tasks/dt-settlement-config.yaml +185 -0
  27. package/assets/evals/devteam/tasks/dt-symbol-home.yaml +181 -0
  28. package/assets/evals/devteam/tasks/dt-trace-blame.yaml +182 -0
  29. package/assets/evals/devteam/tasks/dt-unread-key.yaml +180 -0
  30. package/assets/evals/document/tasks/doc-large-in-137.yaml +38 -0
  31. package/assets/evals/document/tasks/doc-large-in-359.yaml +44 -0
  32. package/assets/evals/document/tasks/doc-large-in-372.yaml +38 -0
  33. package/assets/evals/document/tasks/doc-large-out-11764.yaml +37 -0
  34. package/assets/evals/document/tasks/doc-large-out-4137.yaml +37 -0
  35. package/assets/evals/document/tasks/doc-large-out-8022.yaml +37 -0
  36. package/assets/evals/document/tasks/doc-small-137.yaml +37 -0
  37. package/assets/evals/document/tasks/doc-small-261.yaml +37 -0
  38. package/assets/evals/document/tasks/doc-small-388.yaml +37 -0
  39. package/assets/evals/fixtures/.gitkeep +0 -0
  40. package/assets/evals/fixtures/catalog.json +6 -0
  41. package/assets/evals/perturbations/task-completion.yaml +576 -0
  42. package/assets/evals/tasks/.gitkeep +0 -0
  43. package/assets/evals/tasks/extract-contact.yaml +14 -0
  44. package/assets/evals/tasks/extract-invoice.yaml +14 -0
  45. package/assets/evals/tasks/extract-order.yaml +15 -0
  46. package/assets/evals/tasks/extract-schedule.yaml +14 -0
  47. package/assets/evals/tasks/extract-versions.yaml +17 -0
  48. package/assets/evals/tasks/nav-prod-port.yaml +84 -0
  49. package/assets/evals/tasks/nav-release-bundle.yaml +87 -0
  50. package/assets/evals/tasks/recall-audit-retention.yaml +17 -0
  51. package/assets/evals/tasks/recall-cache-ttl.yaml +13 -0
  52. package/assets/evals/tasks/recall-db-port.yaml +17 -0
  53. package/assets/evals/tasks/recall-deploy.yaml +13 -0
  54. package/assets/evals/tasks/recall-env-endpoint.yaml +18 -0
  55. package/assets/evals/tasks/recall-oncall-rotation.yaml +21 -0
  56. package/assets/evals/tasks/recall-oncall.yaml +13 -0
  57. package/assets/evals/tasks/recall-org-quota.yaml +18 -0
  58. package/assets/evals/tasks/recall-owner.yaml +13 -0
  59. package/assets/evals/tasks/shop-basket-total.yaml +10 -0
  60. package/assets/evals/tasks/shop-cheapest.yaml +9 -0
  61. package/assets/evals/tasks/shop-compare.yaml +9 -0
  62. package/assets/evals/tasks/shop-gadget-value.yaml +9 -0
  63. package/assets/evals/tasks/shop-stock-total.yaml +9 -0
  64. package/assets/evals/tasks/shop-total.yaml +9 -0
  65. package/assets/profiles/default.yaml +31 -0
  66. package/assets/profiles/patient.yaml +31 -0
  67. package/assets/rubrics/.gitkeep +0 -0
  68. package/assets/rubrics/code-quality.yaml +20 -0
  69. package/assets/rubrics/grounded-completion.yaml +37 -0
  70. package/assets/rubrics/task-completion.yaml +28 -0
  71. package/assets/schemas/shiftwork-checkpoint.json +188 -0
  72. package/assets/skills/.gitkeep +0 -0
  73. package/assets/skills/file-graph.md +7 -0
  74. package/assets/skills/memory.md +35 -0
  75. package/assets/tools/.gitkeep +0 -0
  76. package/assets/tools/bantamkit_read.json +48 -0
  77. package/assets/tools/bantamkit_status.json +25 -0
  78. package/assets/tools/build_identity.json +17 -0
  79. package/assets/tools/document_list.json +12 -0
  80. package/assets/tools/document_read.json +31 -0
  81. package/assets/tools/file_graph.json +12 -0
  82. package/assets/tools/memory_compact.json +31 -0
  83. package/assets/tools/memory_recall.json +38 -0
  84. package/assets/tools/memory_save.json +61 -0
  85. package/assets/tools/shiftwork_clock_in.json +25 -0
  86. package/assets/tools/shiftwork_clock_out.json +60 -0
  87. package/assets/tools/shiftwork_status.json +25 -0
  88. package/assets/tools/skill_audit.json +70 -0
  89. package/assets/tools/validate_json.json +31 -0
  90. package/dist/assets.d.ts +48 -0
  91. package/dist/assets.js +109 -0
  92. package/dist/charsets.d.ts +17 -0
  93. package/dist/charsets.js +580 -0
  94. package/dist/cli.d.ts +12 -0
  95. package/dist/cli.js +280 -0
  96. package/dist/contract.d.ts +145 -0
  97. package/dist/contract.js +608 -0
  98. package/dist/docread.d.ts +357 -0
  99. package/dist/docread.js +3315 -0
  100. package/dist/errors.d.ts +11 -0
  101. package/dist/errors.js +14 -0
  102. package/dist/eventlog.d.ts +137 -0
  103. package/dist/eventlog.js +294 -0
  104. package/dist/htmlentities.d.ts +2 -0
  105. package/dist/htmlentities.js +16 -0
  106. package/dist/index.d.ts +23 -0
  107. package/dist/index.js +13 -0
  108. package/dist/mcp/identity.d.ts +25 -0
  109. package/dist/mcp/identity.js +275 -0
  110. package/dist/mcp/pyargs.d.ts +80 -0
  111. package/dist/mcp/pyargs.js +362 -0
  112. package/dist/mcp/sdkjson.d.ts +56 -0
  113. package/dist/mcp/sdkjson.js +91 -0
  114. package/dist/mcp/server.d.ts +45 -0
  115. package/dist/mcp/server.js +740 -0
  116. package/dist/mcp/status.d.ts +210 -0
  117. package/dist/mcp/status.js +357 -0
  118. package/dist/mcp/transport.d.ts +68 -0
  119. package/dist/mcp/transport.js +111 -0
  120. package/dist/mcpreport.d.ts +214 -0
  121. package/dist/mcpreport.js +758 -0
  122. package/dist/memory/cli.d.ts +2 -0
  123. package/dist/memory/cli.js +396 -0
  124. package/dist/memory/component.d.ts +256 -0
  125. package/dist/memory/component.js +497 -0
  126. package/dist/memory/factfile.d.ts +120 -0
  127. package/dist/memory/factfile.js +406 -0
  128. package/dist/memory/layers.d.ts +92 -0
  129. package/dist/memory/layers.js +410 -0
  130. package/dist/memory/pyfs.d.ts +521 -0
  131. package/dist/memory/pyfs.js +1608 -0
  132. package/dist/memory/pyyaml.d.ts +155 -0
  133. package/dist/memory/pyyaml.js +868 -0
  134. package/dist/memory/store.d.ts +478 -0
  135. package/dist/memory/store.js +1034 -0
  136. package/dist/pyargparse.d.ts +141 -0
  137. package/dist/pyargparse.js +813 -0
  138. package/dist/pyjson.d.ts +110 -0
  139. package/dist/pyjson.js +524 -0
  140. package/dist/pyjsonschema.d.ts +50 -0
  141. package/dist/pyjsonschema.js +951 -0
  142. package/dist/shiftwork.d.ts +60 -0
  143. package/dist/shiftwork.js +324 -0
  144. package/dist/skillaudit.d.ts +172 -0
  145. package/dist/skillaudit.js +914 -0
  146. package/dist/statusline.d.ts +106 -0
  147. package/dist/statusline.js +281 -0
  148. package/package.json +45 -0
@@ -0,0 +1,155 @@
1
+ /**
2
+ * PyYAML's `safe_dump` — the parts of it a six-key fact-file frontmatter reaches, ported
3
+ * arm for arm from PyYAML 6.0.3's `emitter.py` and `resolver.py`.
4
+ *
5
+ * WHY THIS FILE EXISTS INSTEAD OF `js-yaml`
6
+ * -----------------------------------------
7
+ * `_write_fact` in `runtime-py/src/bantamkit/memory/store.py` writes
8
+ *
9
+ * "---\n" + yaml.safe_dump(meta, sort_keys=False, allow_unicode=True) + "---\n\n" + ...
10
+ *
11
+ * and `_stamp` rewrites a fact file on EVERY recall hit, so a Node server re-emits
12
+ * Python's files continuously from day one. 35 of the 65 files in the live store carry
13
+ * PyYAML's 80-column plain-scalar wrap. Measured on a copy of that store: js-yaml 5.3.0
14
+ * emits a `>-` folded block where PyYAML emits a wrapped plain scalar, `lineWidth:-1`
15
+ * removes the wrap rather than reproducing it, and `noArrayIndent:true` is a no-op. No
16
+ * option combination matches. The failure would raise nothing — the file still parses to
17
+ * the same string — the store would just silently stop being diffable against Python's.
18
+ *
19
+ * So this is not a YAML emitter. It is PyYAML's emitter for one document shape: a
20
+ * root-level block mapping whose values are strings, `null`, or lists of strings.
21
+ * Everything outside that shape throws rather than guessing.
22
+ *
23
+ * COLUMNS ARE CODEPOINTS. PyYAML does `self.column += len(data)` on a `str`, which counts
24
+ * codepoints. `String.length` in JS counts UTF-16 units and charges 2 for an astral
25
+ * emoji, which moves the wrap. Every scalar here is handled as an array of codepoints for
26
+ * exactly that reason.
27
+ */
28
+ export declare const STR_TAG = "tag:yaml.org,2002:str";
29
+ export declare const NULL_TAG = "tag:yaml.org,2002:null";
30
+ export declare const TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
31
+ /**
32
+ * A value this emitter can write.
33
+ *
34
+ * `PyScalar` is here because a fact file is READ as well as written: `_stamp` rewrites a
35
+ * file on every recall hit, so whatever `safe_load` built out of a hand-edited
36
+ * `created: 2026-08-23` has to go back through `safe_dump` unchanged. See the constructor
37
+ * half at the bottom of this file.
38
+ */
39
+ export type YamlValue = YamlScalar | ReadonlyArray<YamlScalar>;
40
+ export type YamlScalar = string | null | PyScalar;
41
+ export declare class YamlEmitError extends Error {
42
+ }
43
+ /**
44
+ * The tag PyYAML's resolver gives the PLAIN spelling of `value`.
45
+ *
46
+ * A string may be written plain only when this answers `str` — otherwise reading the file
47
+ * back gives a different type. That is the whole reason `created: '2026-08-23'` is
48
+ * quoted: bare, it resolves to `timestamp` and comes back as a `datetime.date`.
49
+ */
50
+ export declare function resolveImplicitTag(value: string): string;
51
+ /**
52
+ * `yaml.safe_dump(mapping, sort_keys=False, allow_unicode=True)` for a root block mapping.
53
+ *
54
+ * `entries` is an ordered array rather than an object because the ORDER is the contract —
55
+ * `sort_keys=False` means the emitted order is the insertion order of `_write_fact`'s
56
+ * dict literal, and an object here would invite someone to reorder it without noticing.
57
+ */
58
+ export declare function safeDumpMapping(entries: ReadonlyArray<readonly [string, YamlValue]>): string;
59
+ /**
60
+ * `SafeConstructor`, for the tags a fact-file frontmatter can resolve to — the READ side of
61
+ * the resolver above.
62
+ *
63
+ * WHY THIS EXISTS. `_facts` in `runtime-py` does no type check: it puts `yaml.safe_load`'s
64
+ * answer straight into the `Fact` dataclass, so `description: 2026` gives Python an `int`
65
+ * and `created: 2026-08-23` gives it a `datetime.date`, and the store then interpolates
66
+ * those into `index.md`, into the file NAME on disk, into the token text the duplicate gate
67
+ * scores, and back through `yaml.safe_dump` on the next `_stamp`. Measured over 26 shapes:
68
+ * CPython raises on FOUR of them and answers on the other 22. This port used to raise on
69
+ * ALL of them, and one hand-edited fact file therefore took `memory_recall`, `memory_save`
70
+ * and the index rebuild down for a whole store the Python server was still serving.
71
+ *
72
+ * THE RULING — WHAT A `Fact` FIELD HOLDS. A `string` when PyYAML resolves `str`, `null` when
73
+ * it resolves `null`, and otherwise a `PyScalar`: a frozen record of the three things the
74
+ * store can observe about the value — how `str()` spells it, how `safe_dump` re-emits it,
75
+ * and whether it is truthy. Not a `Date`, not a `number`, not a `bigint` at the field. The
76
+ * reason is that the store never does arithmetic on these; it renders them, at nine places,
77
+ * and two of the renderings DIFFER (`True` against `true`, `inf` against `.inf`). A field
78
+ * holding a JS `number` would have to re-derive both at every one of those nine, which is
79
+ * how the index line and the file on disk come to spell one fact two ways.
80
+ */
81
+ export declare class PyScalar {
82
+ /** The resolved YAML tag, which is also the tag the emitter writes it back under. */
83
+ readonly tag: string;
84
+ /** `type(value).__name__` — what `list()` and a failed `<` put in a `TypeError`. */
85
+ readonly pyType: string;
86
+ /** `str(value)`: what an f-string interpolates. */
87
+ readonly text: string;
88
+ /** `safe_dump`'s plain scalar: what `_write_fact` puts back on disk. */
89
+ readonly yaml: string;
90
+ /** `bool(value)`: `created or _mtime_date(path)` and `links or []` both read it. */
91
+ readonly truthy: boolean;
92
+ /** What `<` orders on. `recall`'s tie-break is the only reader; see `store.pyCompareLt`. */
93
+ readonly ord: PyOrder;
94
+ constructor(tag: string, pyType: string, text: string, yaml: string, truthy: boolean, ord: PyOrder);
95
+ /** So a bare template literal spells it Python's way; `pyText` is the explicit route. */
96
+ toString(): string;
97
+ }
98
+ /**
99
+ * A tag `SafeConstructor` has no constructor for, or a value its constructor refuses.
100
+ *
101
+ * Both are `_facts`-catchable in the reference — `ConstructorError` is a `YAMLError` and
102
+ * `datetime`'s complaints are `ValueError` — so both come out as `malformed fact file
103
+ * <name>: <reason>`. The REASONS differ in the two cases and this port only claims the
104
+ * second: see the ruling on `constructPlain`.
105
+ */
106
+ export declare class YamlConstructError extends Error {
107
+ }
108
+ /**
109
+ * The orderable content of a `PyScalar`, split the way Python's `<` splits it.
110
+ *
111
+ * `num` is one family: `True < 7 < 7.5` all compare, and `bool` is an `int`. `date` and
112
+ * `datetime` are two families that do NOT compare with each other, and an aware `datetime`
113
+ * does not compare with a naive one — so the tag alone is not enough and the flag is here.
114
+ * A datetime is reduced to whole seconds plus microseconds because a UTC-normalised
115
+ * `days*86400 + micros` does not fit a double.
116
+ */
117
+ export type PyOrder = {
118
+ readonly kind: 'num';
119
+ readonly n: bigint | number;
120
+ } | {
121
+ readonly kind: 'date';
122
+ readonly iso: string;
123
+ } | {
124
+ readonly kind: 'datetime';
125
+ readonly aware: boolean;
126
+ readonly sec: number;
127
+ readonly us: number;
128
+ };
129
+ /**
130
+ * What `yaml.safe_load` builds from ONE plain scalar in a fact-file frontmatter.
131
+ *
132
+ * RULING — THE WIDTH OF THIS, measured over 26 shapes against the reference and not
133
+ * generalised from any of them:
134
+ *
135
+ * - `str` and `null` come back as a JS `string` and `null`. Unchanged.
136
+ * - `bool`, `int`, `float` and `timestamp` come back as a `PyScalar` carrying `str()`,
137
+ * `safe_dump`'s spelling and `bool()`. 22 of the 26 shapes land here, including the
138
+ * ten N8 named, and each is compared at all nine render points in the `store` suite.
139
+ * - `timestamp` whose fields are out of range RAISES with CPython's own `ValueError`
140
+ * text (`month must be in 1..12`, `day is out of range for month`,
141
+ * `hour must be in 0..23`, `minute must be in 0..59`, `second must be in 0..59`,
142
+ * `year N is out of range`, and the `timedelta` sentence for a tz past 24 hours).
143
+ * Matched exactly, because `_facts` catches `ValueError` and interpolates it.
144
+ * - `merge` (`<<`) and `value` (`=`) RAISE, as CPython does, and the SENTENCE DIFFERS:
145
+ * PyYAML's `ConstructorError` carries the source marks and a rendered snippet. That is
146
+ * the same surface the module already refuses to port for `ScannerError`, and it is
147
+ * carried as a must-differ case rather than claimed.
148
+ * - `yaml` (`!`, `&`, `*`) RAISES, and CPython does NOT agree for all three: `k: !` is a
149
+ * tag PROPERTY on an empty node in the real scanner and answers `None`, while `&` and
150
+ * `*` are an anchor and an alias and answer with a `ScannerError`. This codec has no
151
+ * scanner and sees three plain scalars. All three are must-differ cases; `!` is the one
152
+ * where CPython answers and this port refuses, and it is written down as that rather
153
+ * than filed with the other two.
154
+ */
155
+ export declare function constructPlain(value: string): string | null | PyScalar;