bantamkit-mcp 0.35.7 → 0.35.9

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 (53) hide show
  1. package/README.md +24 -9
  2. package/assets/tools/memory_compact.json +1 -2
  3. package/assets/tools/memory_recall.json +1 -3
  4. package/assets/tools/shiftwork_clock_in.json +1 -1
  5. package/assets/tools/shiftwork_clock_out.json +1 -1
  6. package/assets/tools/validate_json.json +1 -1
  7. package/assets/tools/work_plan.json +14 -8
  8. package/dist/assets.js +28 -4
  9. package/dist/cli.js +83 -24
  10. package/dist/contract.d.ts +0 -9
  11. package/dist/contract.js +51 -12
  12. package/dist/eventlog.d.ts +22 -2
  13. package/dist/eventlog.js +30 -3
  14. package/dist/hookadapter.js +263 -43
  15. package/dist/hostinstall.d.ts +2 -2
  16. package/dist/hostinstall.js +318 -84
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.js +1 -1
  19. package/dist/mcp/identity.js +27 -1
  20. package/dist/mcp/pyargs.d.ts +22 -6
  21. package/dist/mcp/pyargs.js +113 -39
  22. package/dist/mcp/server.js +177 -41
  23. package/dist/mcp/status.js +11 -4
  24. package/dist/mcp/transport.d.ts +51 -6
  25. package/dist/mcp/transport.js +217 -26
  26. package/dist/mcpreport.d.ts +12 -0
  27. package/dist/mcpreport.js +67 -15
  28. package/dist/memory/cli.js +18 -3
  29. package/dist/memory/component.d.ts +17 -0
  30. package/dist/memory/component.js +51 -7
  31. package/dist/memory/factfile.d.ts +21 -3
  32. package/dist/memory/factfile.js +351 -12
  33. package/dist/memory/layers.d.ts +19 -0
  34. package/dist/memory/layers.js +102 -2
  35. package/dist/memory/pyyaml.d.ts +6 -4
  36. package/dist/memory/pyyaml.js +6 -4
  37. package/dist/memory/store.d.ts +82 -7
  38. package/dist/memory/store.js +277 -29
  39. package/dist/npminstall.d.ts +18 -0
  40. package/dist/npminstall.js +26 -5
  41. package/dist/pyargparse.js +48 -2
  42. package/dist/pyjsonschema.d.ts +85 -4
  43. package/dist/pyjsonschema.js +1812 -181
  44. package/dist/selfupdate.d.ts +112 -32
  45. package/dist/selfupdate.js +221 -79
  46. package/dist/shiftwork.d.ts +46 -7
  47. package/dist/shiftwork.js +246 -42
  48. package/dist/tokenledger.js +20 -4
  49. package/dist/updatecheck.d.ts +15 -3
  50. package/dist/updatecheck.js +23 -8
  51. package/dist/workplan.d.ts +8 -3
  52. package/dist/workplan.js +62 -3
  53. package/package.json +2 -2
@@ -2,6 +2,24 @@ import { type PyValue } from './pyjson.js';
2
2
  export declare class PyJsonSchemaUnsupported extends Error {
3
3
  constructor(message: string);
4
4
  }
5
+ /**
6
+ * A schema the validator will not resolve, answered — not raised. `contract.schemaError`
7
+ * returns the message as the feedback sentence, so `validate_json` says `{"valid": false,
8
+ * "feedback": …}` where it used to say `isError` (#125). The Python side prints the same
9
+ * sentence from `contract._unsupported_schema` and from the `referencing` exceptions.
10
+ */
11
+ export declare class PyJsonSchemaRefusal extends Error {
12
+ constructor(message: string);
13
+ }
14
+ /** The drafts this port validates. Draft 3 is looked up so it can be refused by name. */
15
+ export type Draft = 4 | 6 | 7 | 2019 | 2020;
16
+ /**
17
+ * `urllib.parse.urlsplit(uri).geturl()` — `_utils.URIDict.normalize`, the function every
18
+ * `$schema` goes through before `_META_SCHEMAS` is consulted. 3.12 strips leading C0/space,
19
+ * removes every tab/CR/LF, lowercases the scheme, and `urlunsplit` drops an empty query and
20
+ * an empty fragment. Measured in `tools/conformance/suites/validate.mjs` (`dialect/…`).
21
+ */
22
+ export declare function pyUrlNormalize(uri: string): string;
5
23
  /**
6
24
  * `jsonschema.exceptions.ValidationError`, narrowed to the fields the relevance heuristic
7
25
  * and `schema_error` read.
@@ -11,6 +29,9 @@ export declare class PyJsonSchemaUnsupported extends Error {
11
29
  * is what `schema_error` interpolates. Keeping the two apart is not pedantry: `best_match`
12
30
  * ranks context errors by their relative paths and then `schema_error` prints an absolute
13
31
  * one, and a port that conflated them would name the wrong field inside every `anyOf`.
32
+ *
33
+ * `draft` is the dialect the keyword ran under — `error._type_checker`, which
34
+ * `_matches_type` consults, and the one place the dialect reaches `best_match`.
14
35
  */
15
36
  export interface PyValidationError {
16
37
  message: string;
@@ -21,11 +42,69 @@ export interface PyValidationError {
21
42
  path: (string | number)[];
22
43
  context: PyValidationError[];
23
44
  parent: PyValidationError | null;
45
+ draft: Draft;
24
46
  }
25
47
  export declare function absolutePath(error: PyValidationError): (string | number)[];
26
48
  /** `jsonschema._utils.equal`: JSON equality that refuses `True == 1`. */
27
49
  export declare function pyEqual(a: PyValue, b: PyValue): boolean;
28
- declare function iterErrors(instance: PyValue, schema: PyValue | boolean): PyValidationError[];
50
+ /** What a keyword needs beyond its own value: the root resource and the dialect in force. */
51
+ interface Ctx {
52
+ root: PyValue;
53
+ draft: Draft;
54
+ /** The ROOT's dialect — anchors are found by the resource's specification, not the leaf's. */
55
+ rootDraft: Draft;
56
+ }
57
+ declare function iterErrors(instance: PyValue, schema: PyValue | boolean, ctx?: Ctx): PyValidationError[];
58
+ /**
59
+ * `re.search(pattern, string)` — the reference's dialect, translated, bounded (#131, #132).
60
+ *
61
+ * THE DIALECT IS PYTHON'S. Until job65 this was `new RegExp(pattern, 'u')` with a silent
62
+ * fallback to a non-`u` RegExp, so the two runtimes disagreed on 5 of 5 of #131's probes:
63
+ * `\d`/`\w` are Unicode-wide in `re` and ASCII in JS, `$` matches before a final newline in
64
+ * `re`, `(?P<x>…)` refused here, and the fallback read `\Z` as a literal `Z`. JSON Schema
65
+ * recommends ECMA-262, but the product's contract is the reference's verdict, so the pattern
66
+ * is parsed the way `re._parser` parses it and re-emitted as a `v`-mode RegExp whose every
67
+ * construct means what it means in `re`:
68
+ *
69
+ * - `\d` → `\p{Nd}`; `\w` → `[\p{L}\p{N}_]` (`str.isalnum() or "_"`); `\s` → the 29
70
+ * codepoints `str.isspace()` names (JS's `\s` adds U+FEFF and drops U+001C-1F, U+0085);
71
+ * `\b`/`\B` are look-arounds over that `\w`, and `\B` never matches the empty string
72
+ * (`SRE_AT_UNI_NON_BOUNDARY`, CPython 3.11-3.13). Measured over every codepoint: the
73
+ * three classes are equal except for the codepoints Unicode 16 assigned after the
74
+ * reference's Unicode 15 (5,004 for `\w`, 80 for `\d`, 0 for `\s`).
75
+ * - `.` → `[^\n]` (JS also stops at `\r`, U+2028, U+2029); `$` → `(?=\n?$)`; `\A` → `^`;
76
+ * `\Z` → `$`; `(?P<n>…)` → a group; `{,n}` → `{0,n}`; a `{` that is not a repeat is a
77
+ * literal; every literal is emitted as `\u{…}`, so no JS syntax rule can reach it.
78
+ *
79
+ * A pattern `re` itself refuses is a `PyReError` (what `re.error` is on the reference: the
80
+ * schema check raises it). Constructs with no faithful translation — inline flags,
81
+ * look-behind (fixed-width in `re`, any width in JS), backreferences (a JS backreference to
82
+ * a group that did not take part matches the empty string; `re`'s fails), atomic groups,
83
+ * possessive quantifiers, conditional groups and `\N{…}` (no Unicode name table here) — are
84
+ * parsed, so that a broken pattern is still an error, and then REFUSED on both runtimes with
85
+ * one sentence (`unsupportedPatternSentence`; `contract._pattern_unsupported` on the
86
+ * reference), never answered differently.
87
+ */
88
+ export declare class PyReError extends Error {
89
+ constructor(message: string);
90
+ }
91
+ interface PyReTranslation {
92
+ /** The `v`-mode source, or `null` when the pattern uses a construct refused above. */
93
+ source: string | null;
94
+ }
95
+ /** `re._parser.parse(pattern)` + `fix_flags`, re-emitted for a `v`-mode RegExp. */
96
+ export declare function translatePyPattern(pattern: string): PyReTranslation;
97
+ /** The sentence both runtimes answer for a pattern outside the shared dialect (#131). */
98
+ export declare function unsupportedPatternSentence(pattern: string): string;
99
+ /** The milliseconds a document's patterns may spend, in total, before the validation is refused (#132). */
100
+ export declare const PATTERN_BUDGET_MS = 500;
101
+ /** The sentence both runtimes answer when a document's patterns run past the budget (#132). */
102
+ export declare function patternBudgetSentence(pattern: string): string;
103
+ /**
104
+ * At most `limit` codepoints of `text`, then `…(N more)` (#153). Codepoints, not UTF-16
105
+ * units, because `len()` on the reference counts codepoints.
106
+ */
107
+ export declare function clipText(text: string, limit?: number): string;
29
108
  /**
30
109
  * `jsonschema.exceptions.best_match`.
31
110
  *
@@ -38,13 +117,15 @@ declare function iterErrors(instance: PyValue, schema: PyValue | boolean): PyVal
38
117
  * parent stands.
39
118
  */
40
119
  export declare function bestMatch(errors: PyValidationError[]): PyValidationError | null;
41
- export declare function checkSchema(schema: PyValue | boolean, where?: string): void;
120
+ export declare function checkSchema(schema: PyValue | boolean, where?: string, draft?: Draft): void;
42
121
  /**
43
122
  * `jsonschema.validate(instance, schema)` reduced to what `contract.schema_error` needs:
44
123
  * the single error `best_match` chooses, or `null`.
45
124
  *
46
- * `check_schema` runs FIRST, as it does in the reference. See `checkSchema` for what that
47
- * means here and for the five wrong answers it replaced.
125
+ * In the reference's order: `validator_for` (the dialect, which raises on a non-string
126
+ * `$schema`), then the one-resource pre-scan `contract.py` runs before `validate`, then
127
+ * `check_schema`, then the instance. A `PyJsonSchemaRefusal` out of here is an ANSWER —
128
+ * `contract.schemaError` returns its sentence — and a `PyJsonSchemaUnsupported` is a raise.
48
129
  */
49
130
  export declare function validate(instance: PyValue, schema: PyValue): PyValidationError | null;
50
131
  export { iterErrors };