foundryvtt-mcp 1.5.0 → 1.5.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 (58) hide show
  1. package/README.md +23 -12
  2. package/dist/diagnostics/client.d.ts +8 -4
  3. package/dist/diagnostics/client.d.ts.map +1 -1
  4. package/dist/diagnostics/client.js +8 -3
  5. package/dist/diagnostics/client.js.map +1 -1
  6. package/dist/foundry/auth.d.ts +15 -0
  7. package/dist/foundry/auth.d.ts.map +1 -1
  8. package/dist/foundry/auth.js +33 -8
  9. package/dist/foundry/auth.js.map +1 -1
  10. package/dist/foundry/client.d.ts +127 -6
  11. package/dist/foundry/client.d.ts.map +1 -1
  12. package/dist/foundry/client.js +263 -43
  13. package/dist/foundry/client.js.map +1 -1
  14. package/dist/foundry/dice-formula.d.ts +79 -0
  15. package/dist/foundry/dice-formula.d.ts.map +1 -0
  16. package/dist/foundry/dice-formula.js +154 -0
  17. package/dist/foundry/dice-formula.js.map +1 -0
  18. package/dist/foundry/types.d.ts +11 -1
  19. package/dist/foundry/types.d.ts.map +1 -1
  20. package/dist/foundry/world-cache.d.ts +22 -0
  21. package/dist/foundry/world-cache.d.ts.map +1 -1
  22. package/dist/foundry/world-cache.js +56 -0
  23. package/dist/foundry/world-cache.js.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +2 -3
  27. package/dist/index.js.map +1 -1
  28. package/dist/load-env.d.ts +13 -0
  29. package/dist/load-env.d.ts.map +1 -0
  30. package/dist/load-env.js +14 -0
  31. package/dist/load-env.js.map +1 -0
  32. package/dist/tools/definitions.d.ts +9 -0
  33. package/dist/tools/definitions.d.ts.map +1 -1
  34. package/dist/tools/definitions.js +77 -54
  35. package/dist/tools/definitions.js.map +1 -1
  36. package/dist/tools/handlers/combat-mutations.d.ts +14 -0
  37. package/dist/tools/handlers/combat-mutations.d.ts.map +1 -1
  38. package/dist/tools/handlers/combat-mutations.js +33 -4
  39. package/dist/tools/handlers/combat-mutations.js.map +1 -1
  40. package/dist/tools/handlers/combat-order.d.ts +69 -0
  41. package/dist/tools/handlers/combat-order.d.ts.map +1 -0
  42. package/dist/tools/handlers/combat-order.js +94 -0
  43. package/dist/tools/handlers/combat-order.js.map +1 -0
  44. package/dist/tools/handlers/combat.d.ts.map +1 -1
  45. package/dist/tools/handlers/combat.js +5 -2
  46. package/dist/tools/handlers/combat.js.map +1 -1
  47. package/dist/tools/handlers/diagnostics.d.ts +25 -0
  48. package/dist/tools/handlers/diagnostics.d.ts.map +1 -1
  49. package/dist/tools/handlers/diagnostics.js +152 -38
  50. package/dist/tools/handlers/diagnostics.js.map +1 -1
  51. package/dist/tools/handlers/dice.d.ts +1 -1
  52. package/dist/tools/handlers/dice.d.ts.map +1 -1
  53. package/dist/tools/handlers/dice.js +2 -1
  54. package/dist/tools/handlers/dice.js.map +1 -1
  55. package/dist/tools/handlers/resources.d.ts.map +1 -1
  56. package/dist/tools/handlers/resources.js +16 -1
  57. package/dist/tools/handlers/resources.js.map +1 -1
  58. package/package.json +2 -1
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @fileoverview Shared combatant turn-order helper (#214).
3
+ *
4
+ * FoundryVTT resolves `Combat#turn` against the **initiative-sorted** turn
5
+ * order, not the stored (creation) order of `Combat#combatants`. Every handler
6
+ * that maps a `turn` index onto a combatant — the read path
7
+ * (`get_combat_state`) and the write path (`next_turn`) alike — must therefore
8
+ * derive that list here, so the two can never drift apart through slightly
9
+ * different comparators.
10
+ *
11
+ * The comparator mirrors core's `Combat._sortCombatants`: initiative
12
+ * descending, non-numeric (un-rolled) initiative last, ties broken by document
13
+ * id so the order is deterministic and stable.
14
+ */
15
+ import type { WorldCombat } from '../../foundry/types.js';
16
+ /** A single combatant embedded in a `WorldCombat` document. */
17
+ export type WorldCombatant = WorldCombat['combatants'][number];
18
+ /**
19
+ * Compares two combatants by Foundry's turn-order rules.
20
+ *
21
+ * Initiative descending; combatants without a rolled initiative go last; ties
22
+ * (including two un-rolled combatants, whose difference is `NaN`) fall back to
23
+ * the document id so the ordering is total and deterministic.
24
+ */
25
+ export declare function compareCombatants(a: WorldCombatant, b: WorldCombatant): number;
26
+ /**
27
+ * Returns the combatants of `combat` in turn order.
28
+ *
29
+ * Sorts a **copy** — `combat` is a live reference into the world-data cache, so
30
+ * sorting in place would silently reorder cached state as a side effect of a
31
+ * read.
32
+ */
33
+ export declare function getTurnOrder(combat: WorldCombat): WorldCombatant[];
34
+ /**
35
+ * Whether the encounter is under way, derived the way core derives it.
36
+ *
37
+ * `Combat#started` is a **client-side getter** (`turns.length > 0 && round >
38
+ * 0`), not schema data: `BaseCombat.defineSchema()` does not declare it, so a
39
+ * Combat document read out of `worldData` never carries the key. Reading
40
+ * `combat.started` therefore evaluates to `undefined` on every real world —
41
+ * only hand-written fixtures have it — so started-ness is computed here from
42
+ * the two fields the transport does deliver.
43
+ */
44
+ export declare function isCombatStarted(combat: WorldCombat): boolean;
45
+ /**
46
+ * Returns the combatant `combat.turn` currently points at, if any.
47
+ *
48
+ * Yields `undefined` when nobody is acting yet — the encounter has not been
49
+ * started (initiatives are commonly assigned during round 0 setup), `turn` is
50
+ * null, or the stored index no longer resolves to a combatant.
51
+ */
52
+ export declare function getCurrentCombatant(combat: WorldCombat): WorldCombatant | undefined;
53
+ /**
54
+ * Computes where `actingCombatantId` lands in the turn order once `change` is
55
+ * applied — i.e. the `turn` index that keeps the same combatant acting.
56
+ *
57
+ * The change is projected onto a copy rather than read back from the cache:
58
+ * `setCombatantInitiative` resolves on the `modifyDocument` ack, while the
59
+ * cache is updated by the separate broadcast, so the cached initiative may or
60
+ * may not have caught up by the time this runs. Projecting is correct either
61
+ * way (re-applying the same value is a no-op).
62
+ *
63
+ * @returns the new index, or `undefined` if the acting combatant is gone.
64
+ */
65
+ export declare function turnIndexAfterInitiativeChange(combat: WorldCombat, change: {
66
+ combatantId: string;
67
+ initiative: number;
68
+ }, actingCombatantId: string): number | undefined;
69
+ //# sourceMappingURL=combat-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combat-order.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/combat-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,+DAA+D;AAC/D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAS/D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,GAAG,MAAM,CAS9E;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,EAAE,CAElE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,GAAG,SAAS,CAKnF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACnD,iBAAiB,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CASpB"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @fileoverview Shared combatant turn-order helper (#214).
3
+ *
4
+ * FoundryVTT resolves `Combat#turn` against the **initiative-sorted** turn
5
+ * order, not the stored (creation) order of `Combat#combatants`. Every handler
6
+ * that maps a `turn` index onto a combatant — the read path
7
+ * (`get_combat_state`) and the write path (`next_turn`) alike — must therefore
8
+ * derive that list here, so the two can never drift apart through slightly
9
+ * different comparators.
10
+ *
11
+ * The comparator mirrors core's `Combat._sortCombatants`: initiative
12
+ * descending, non-numeric (un-rolled) initiative last, ties broken by document
13
+ * id so the order is deterministic and stable.
14
+ */
15
+ /** Un-rolled / malformed initiative sorts to the very end of the order. */
16
+ function initiativeOf(c) {
17
+ return typeof c.initiative === 'number' && Number.isFinite(c.initiative)
18
+ ? c.initiative
19
+ : Number.NEGATIVE_INFINITY;
20
+ }
21
+ /**
22
+ * Compares two combatants by Foundry's turn-order rules.
23
+ *
24
+ * Initiative descending; combatants without a rolled initiative go last; ties
25
+ * (including two un-rolled combatants, whose difference is `NaN`) fall back to
26
+ * the document id so the ordering is total and deterministic.
27
+ */
28
+ export function compareCombatants(a, b) {
29
+ const byInitiative = initiativeOf(b) - initiativeOf(a);
30
+ if (byInitiative && !Number.isNaN(byInitiative)) {
31
+ return byInitiative;
32
+ }
33
+ if (a._id === b._id) {
34
+ return 0;
35
+ }
36
+ return a._id > b._id ? 1 : -1;
37
+ }
38
+ /**
39
+ * Returns the combatants of `combat` in turn order.
40
+ *
41
+ * Sorts a **copy** — `combat` is a live reference into the world-data cache, so
42
+ * sorting in place would silently reorder cached state as a side effect of a
43
+ * read.
44
+ */
45
+ export function getTurnOrder(combat) {
46
+ return [...combat.combatants].sort(compareCombatants);
47
+ }
48
+ /**
49
+ * Whether the encounter is under way, derived the way core derives it.
50
+ *
51
+ * `Combat#started` is a **client-side getter** (`turns.length > 0 && round >
52
+ * 0`), not schema data: `BaseCombat.defineSchema()` does not declare it, so a
53
+ * Combat document read out of `worldData` never carries the key. Reading
54
+ * `combat.started` therefore evaluates to `undefined` on every real world —
55
+ * only hand-written fixtures have it — so started-ness is computed here from
56
+ * the two fields the transport does deliver.
57
+ */
58
+ export function isCombatStarted(combat) {
59
+ return combat.round > 0 && combat.combatants.length > 0;
60
+ }
61
+ /**
62
+ * Returns the combatant `combat.turn` currently points at, if any.
63
+ *
64
+ * Yields `undefined` when nobody is acting yet — the encounter has not been
65
+ * started (initiatives are commonly assigned during round 0 setup), `turn` is
66
+ * null, or the stored index no longer resolves to a combatant.
67
+ */
68
+ export function getCurrentCombatant(combat) {
69
+ if (!isCombatStarted(combat) || combat.turn === null || combat.turn === undefined) {
70
+ return undefined;
71
+ }
72
+ return getTurnOrder(combat)[combat.turn];
73
+ }
74
+ /**
75
+ * Computes where `actingCombatantId` lands in the turn order once `change` is
76
+ * applied — i.e. the `turn` index that keeps the same combatant acting.
77
+ *
78
+ * The change is projected onto a copy rather than read back from the cache:
79
+ * `setCombatantInitiative` resolves on the `modifyDocument` ack, while the
80
+ * cache is updated by the separate broadcast, so the cached initiative may or
81
+ * may not have caught up by the time this runs. Projecting is correct either
82
+ * way (re-applying the same value is a no-op).
83
+ *
84
+ * @returns the new index, or `undefined` if the acting combatant is gone.
85
+ */
86
+ export function turnIndexAfterInitiativeChange(combat, change, actingCombatantId) {
87
+ const projected = {
88
+ ...combat,
89
+ combatants: combat.combatants.map((c) => c._id === change.combatantId ? { ...c, initiative: change.initiative } : c),
90
+ };
91
+ const index = getTurnOrder(projected).findIndex((c) => c._id === actingCombatantId);
92
+ return index === -1 ? undefined : index;
93
+ }
94
+ //# sourceMappingURL=combat-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combat-order.js","sourceRoot":"","sources":["../../../src/tools/handlers/combat-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,2EAA2E;AAC3E,SAAS,YAAY,CAAC,CAAiB;IACrC,OAAO,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC;QACtE,CAAC,CAAC,CAAC,CAAC,UAAU;QACd,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAiB,EAAE,CAAiB;IACpE,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IACvD,IAAI,YAAY,IAAI,CAAC,MAAM,CAAC,K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AAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAC3E;KACF,CAAC;IACF,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC;IACpF,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"combat.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/combat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,aAAa,EAAE,aAAa;;;;;GAgD7B"}
1
+ {"version":3,"file":"combat.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/combat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,aAAa,EAAE,aAAa;;;;;GAkD7B"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Combat state tool handler
3
3
  */
4
+ import { getTurnOrder } from './combat-order.js';
4
5
  import { withToolError } from './utils.js';
5
6
  export async function handleGetCombatState(_args, foundryClient) {
6
7
  return withToolError('get combat state', async () => {
@@ -10,8 +11,10 @@ export async function handleGetCombatState(_args, foundryClient) {
10
11
  content: [{ type: 'text', text: 'No active combat encounter.' }],
11
12
  };
12
13
  }
13
- const combatants = combat.combatants
14
- .sort((a, b) => (b.initiative ?? -999) - (a.initiative ?? -999))
14
+ // `combat` is a live reference into the world-data cache: sort a COPY via
15
+ // the shared helper so a read never reorders cached state (#214). The same
16
+ // helper backs `next_turn`, so both tools agree on what `combat.turn` means.
17
+ const combatants = getTurnOrder(combat)
15
18
  .map((c, i) => {
16
19
  const current = combat.turn === i ? ' <-- CURRENT' : '';
17
20
  const status = c.defeated ? ' [DEFEATED]' : c.hidden ? ' [HIDDEN]' : '';
@@ -1 +1 @@
1
- {"version":3,"file":"combat.js","sourceRoot":"","sources":["../../../src/tools/handlers/combat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAA8B,EAC9B,aAA4B;IAE5B,OAAO,aAAa,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,EAAE,CAAC;QAE9C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;aACjE,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU;aACjC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,CAAC;aAC/D,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACZ,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;YACxD,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;YACx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AAE,UAAiD,CAAC;oBAC3E,MAAM,MAAM,GAAG,EAAE,EAAE,EAAkD,CAAC;oBACtE,MAAM,MAAM,GAAG,EAAE,EAAE,EAAoC,CAAC;oBACxD,IAAI,MAAM,EAAE,CAAC;wBACX,IAAI,IAAI,QAAQ,MAAM,CAAC,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;oBAC7D,CAAC;oBACD,IAAI,MAAM,EAAE,CAAC;wBACX,IAAI,IAAI,QAAQ,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;oBACxC,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;QACvE,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,6BAA6B,MAAM,CAAC,KAAK,OAAO,UAAU,EAAE;iBACnE;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -26,6 +26,13 @@ export declare function handleGetRecentLogs(args: {
26
26
  }>;
27
27
  /**
28
28
  * Handles log search requests
29
+ *
30
+ * `searchLogs()` resolves to a `LogSearchResponse` object; matched entries live
31
+ * under `response.logs` and the upstream match count under `response.matches`.
32
+ *
33
+ * - `level`: forwarded to the search request when it names a real log level
34
+ * - `limit`: applied to the rendered entries (default 50, hard cap 1000); it
35
+ * does not shrink the reported `matches` total
29
36
  */
30
37
  export declare function handleSearchLogs(args: {
31
38
  query: string;
@@ -39,6 +46,12 @@ export declare function handleSearchLogs(args: {
39
46
  }>;
40
47
  /**
41
48
  * Handles system health requests
49
+ *
50
+ * Every value rendered here is a field `SystemHealthSchema` actually declares.
51
+ * The schema strips unknown keys, so metrics it does not model (CPU, disk,
52
+ * response time, throughput) cannot be reported and are deliberately absent
53
+ * rather than rendered as a permanent `N/A`. Optional fields (`server.uptime`,
54
+ * `performance.memory`) are omitted when the server does not supply them.
42
55
  */
43
56
  export declare function handleGetSystemHealth(_args: Record<string, unknown>, diagnosticsClient: DiagnosticsClient): Promise<{
44
57
  content: {
@@ -59,6 +72,18 @@ export declare function handleDiagnoseErrors(args: {
59
72
  }>;
60
73
  /**
61
74
  * Handles comprehensive health status requests
75
+ *
76
+ * The system-health section reads the nested fields `SystemHealthSchema`
77
+ * declares. Playtime is not reported: `getWorldInfo()` has no genuine source
78
+ * for it and hard-codes 0.
79
+ *
80
+ * The world section carries {@link STALE_WORLD_DATA_NOTICE} whenever the cache
81
+ * has stopped following live document changes (#217). Reads keep being served
82
+ * from that snapshot, which is the right call — a flagged answer beats no
83
+ * answer — but rendering it bare presents a point-in-time copy as though it
84
+ * were live. It matters most right after an automatic reconnect, where the
85
+ * connection line legitimately reads "✅ Connected" while the cache is still
86
+ * missing every broadcast the outage swallowed.
62
87
  */
63
88
  export declare function handleGetHealthStatus(_args: Record<string, unknown>, foundryClient: FoundryClient, diagnosticsClient: DiagnosticsClient): Promise<{
64
89
  content: {
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AASnE;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE;IACJ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,iBAA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,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,iBAAiB,EAAE,iBAAiB;;;;;GA8CrC;AA0BD;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,iBAAiB,EAAE,iBAAiB;;;;;GAkDrC;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE;IACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,EACD,iBAAiB,EAAE,gBAAgB;;;;;GA+CpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB;;;;;GAyDrC"}
@@ -4,11 +4,21 @@
4
4
  * Handles system diagnostics, logging, and health monitoring.
5
5
  */
6
6
  import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
7
+ import { LogEntrySchema } from '../../diagnostics/types.js';
7
8
  import { withToolError } from './utils.js';
8
9
  /** Valid log levels recognized by the tool schema */
9
10
  const VALID_LOG_LEVELS = new Set(['debug', 'info', 'warn', 'error', 'log', 'notification']);
10
11
  /** Hard upper bound on entries returned, regardless of caller-supplied limit */
11
12
  const MAX_LOG_LIMIT = 1000;
13
+ /** Default number of search hits rendered when the caller supplies no limit */
14
+ const DEFAULT_SEARCH_LIMIT = 50;
15
+ /**
16
+ * Shown whenever `FoundryClient.isWorldDataStale()` is set (#217): the cached
17
+ * world snapshot is still being served, but it stopped following live document
18
+ * changes when the socket dropped and nothing replays the gap.
19
+ */
20
+ const STALE_WORLD_DATA_NOTICE = '⚠️ **Stale:** this snapshot stopped following live changes when the connection dropped, ' +
21
+ 'and document changes made since are missing. Run `refresh_world_data` to resync.';
12
22
  /**
13
23
  * Handles recent log retrieval requests
14
24
  *
@@ -76,33 +86,65 @@ ${logEntries || 'No log entries found.'}`,
76
86
  };
77
87
  });
78
88
  }
89
+ /**
90
+ * Resolves a caller-supplied level string to a level the search endpoint accepts.
91
+ *
92
+ * The tool schema advertises `debug`, which has no counterpart in the log
93
+ * entry level enum; such values are dropped rather than sent upstream.
94
+ *
95
+ * @returns the normalized level, or `undefined` when unsupported/absent
96
+ */
97
+ function resolveSearchLevel(level) {
98
+ if (typeof level !== 'string' || level === '') {
99
+ return undefined;
100
+ }
101
+ const parsed = LogEntrySchema.shape.level.safeParse(level.toLowerCase());
102
+ return parsed.success ? parsed.data : undefined;
103
+ }
79
104
  /**
80
105
  * Handles log search requests
106
+ *
107
+ * `searchLogs()` resolves to a `LogSearchResponse` object; matched entries live
108
+ * under `response.logs` and the upstream match count under `response.matches`.
109
+ *
110
+ * - `level`: forwarded to the search request when it names a real log level
111
+ * - `limit`: applied to the rendered entries (default 50, hard cap 1000); it
112
+ * does not shrink the reported `matches` total
81
113
  */
82
114
  export async function handleSearchLogs(args, diagnosticsClient) {
83
- const { query, level } = args;
115
+ const { query, level, limit } = args;
84
116
  if (!query || typeof query !== 'string') {
85
117
  throw new McpError(ErrorCode.InvalidParams, 'Query is required and must be a string');
86
118
  }
119
+ const searchLevel = resolveSearchLevel(level);
120
+ const effectiveLimit = Math.min(Math.max(1, limit ?? DEFAULT_SEARCH_LIMIT), MAX_LOG_LIMIT);
121
+ let levelLabel = 'All levels';
122
+ if (searchLevel !== undefined) {
123
+ levelLabel = searchLevel;
124
+ }
125
+ else if (level) {
126
+ levelLabel = `${level} (unsupported — not applied)`;
127
+ }
87
128
  return withToolError('search logs', async () => {
88
- const logs = await diagnosticsClient.searchLogs({ pattern: query });
89
- const logEntries = Array.isArray(logs)
90
- ? logs
91
- .map((log) => {
92
- const logEntry = log;
93
- return `[${logEntry.timestamp || new Date().toISOString()}] **${(logEntry.level || 'INFO').toUpperCase()}** ${logEntry.message || String(log)}`;
94
- })
95
- .join('\n')
96
- : 'No logs available';
97
- const logCount = Array.isArray(logs) ? logs.length : 0;
129
+ const response = await diagnosticsClient.searchLogs({
130
+ pattern: query,
131
+ ...(searchLevel !== undefined ? { level: searchLevel } : {}),
132
+ });
133
+ const shown = response.logs.slice(0, effectiveLimit);
134
+ const logEntries = shown
135
+ .map((entry) => `[${entry.timestamp}] **${entry.level.toUpperCase()}** ${entry.message}`)
136
+ .join('\n');
98
137
  return {
99
138
  content: [
100
139
  {
101
140
  type: 'text',
102
141
  text: `🔍 **Log Search Results**
103
142
  **Query:** "${query}"
104
- **Level Filter:** ${level || 'All levels'}
105
- **Results:** ${logCount}
143
+ **Level Filter:** ${levelLabel}
144
+ **Limit:** ${effectiveLimit}
145
+ **Timeframe:** ${response.searchTimeframe}
146
+ **Matches:** ${response.matches}
147
+ **Showing:** ${shown.length}
106
148
 
107
149
  ${logEntries || 'No matching log entries found.'}`,
108
150
  },
@@ -110,29 +152,76 @@ ${logEntries || 'No matching log entries found.'}`,
110
152
  };
111
153
  });
112
154
  }
155
+ /**
156
+ * Formats an uptime in seconds as a compact human-readable duration
157
+ */
158
+ function formatUptime(seconds) {
159
+ const total = Math.max(0, Math.floor(seconds));
160
+ const hours = Math.floor(total / 3600);
161
+ const minutes = Math.floor((total % 3600) / 60);
162
+ if (hours > 0) {
163
+ return `${hours}h ${minutes}m`;
164
+ }
165
+ if (minutes > 0) {
166
+ return `${minutes}m ${total % 60}s`;
167
+ }
168
+ return `${total}s`;
169
+ }
170
+ /**
171
+ * Formats a byte count (as reported by `process.memoryUsage()`) in binary
172
+ * megabytes (MiB, the unit Node.js tooling conventionally labels "MB")
173
+ */
174
+ function formatMegabytes(bytes) {
175
+ return `${Math.round(bytes / (1024 * 1024))} MB`;
176
+ }
113
177
  /**
114
178
  * Handles system health requests
179
+ *
180
+ * Every value rendered here is a field `SystemHealthSchema` actually declares.
181
+ * The schema strips unknown keys, so metrics it does not model (CPU, disk,
182
+ * response time, throughput) cannot be reported and are deliberately absent
183
+ * rather than rendered as a permanent `N/A`. Optional fields (`server.uptime`,
184
+ * `performance.memory`) are omitted when the server does not supply them.
115
185
  */
116
186
  export async function handleGetSystemHealth(_args, diagnosticsClient) {
117
187
  return withToolError('get system health', async () => {
118
188
  const health = await diagnosticsClient.getSystemHealth();
189
+ const { server, users, modules, performance, logs } = health;
190
+ const serverLines = [
191
+ `- **FoundryVTT Version:** ${server.foundryVersion}`,
192
+ `- **Game System:** ${server.systemVersion}`,
193
+ `- **World:** ${server.worldId}`,
194
+ ];
195
+ if (server.uptime !== undefined) {
196
+ serverLines.push(`- **Uptime:** ${formatUptime(server.uptime)}`);
197
+ }
198
+ const performanceLines = [`- **Connected Clients:** ${performance.connectedClients}`];
199
+ if (performance.memory) {
200
+ performanceLines.push(`- **Memory (heap):** ${formatMegabytes(performance.memory.heapUsed)} used / ${formatMegabytes(performance.memory.heapTotal)} total`, `- **Memory (RSS):** ${formatMegabytes(performance.memory.rss)}`);
201
+ }
119
202
  return {
120
203
  content: [
121
204
  {
122
205
  type: 'text',
123
206
  text: `🏥 **System Health Status**
124
- **Overall Status:** ${health.status || 'Unknown'}
125
- **CPU Usage:** ${health.cpu || 'N/A'}%
126
- **Memory Usage:** ${health.memory || 'N/A'}%
127
- **Disk Usage:** ${health.disk || 'N/A'}%
128
- **Uptime:** ${health.uptime || 'N/A'} seconds
207
+ **Overall Status:** ${health.status}
208
+ **Reported At:** ${health.timestamp}
129
209
 
130
- **Active Connections:** ${health.connections || 'N/A'}
131
- **Last Error:** ${health.lastError || 'None'}
210
+ **Server:**
211
+ ${serverLines.join('\n')}
132
212
 
133
- **Performance Metrics:**
134
- - **Response Time:** ${health.responseTime || 'N/A'}ms
135
- - **Throughput:** ${health.throughput || 'N/A'} requests/sec`,
213
+ **Sessions:**
214
+ - **Users:** ${users.active} active / ${users.total} total (${users.gm} GM)
215
+ - **Modules:** ${modules.active} active / ${modules.total} installed
216
+
217
+ **Performance:**
218
+ ${performanceLines.join('\n')}
219
+
220
+ **Logs:**
221
+ - **Buffer:** ${logs.bufferSize} entries
222
+ - **Recent Errors:** ${logs.recentErrors}
223
+ - **Recent Warnings:** ${logs.recentWarnings}
224
+ - **Error Rate:** ${logs.errorRate}%`,
136
225
  },
137
226
  ],
138
227
  };
@@ -182,6 +271,18 @@ ${diagnosis.recommendations.map((rec) => `- ${rec}`).join('\n')}
182
271
  }
183
272
  /**
184
273
  * Handles comprehensive health status requests
274
+ *
275
+ * The system-health section reads the nested fields `SystemHealthSchema`
276
+ * declares. Playtime is not reported: `getWorldInfo()` has no genuine source
277
+ * for it and hard-codes 0.
278
+ *
279
+ * The world section carries {@link STALE_WORLD_DATA_NOTICE} whenever the cache
280
+ * has stopped following live document changes (#217). Reads keep being served
281
+ * from that snapshot, which is the right call — a flagged answer beats no
282
+ * answer — but rendering it bare presents a point-in-time copy as though it
283
+ * were live. It matters most right after an automatic reconnect, where the
284
+ * connection line legitimately reads "✅ Connected" while the cache is still
285
+ * missing every broadcast the outage swallowed.
185
286
  */
186
287
  export async function handleGetHealthStatus(_args, foundryClient, diagnosticsClient) {
187
288
  return withToolError('get health status', async () => {
@@ -189,32 +290,45 @@ export async function handleGetHealthStatus(_args, foundryClient, diagnosticsCli
189
290
  foundryClient.getWorldInfo().catch(() => null),
190
291
  diagnosticsClient.getSystemHealth().catch(() => null),
191
292
  ]);
293
+ const worldLines = worldInfo
294
+ ? [
295
+ `- **Title:** ${worldInfo.title}`,
296
+ `- **System:** ${worldInfo.system}`,
297
+ `- **Core Version:** ${worldInfo.coreVersion}`,
298
+ ]
299
+ : ['ℹ️ Not available'];
300
+ if (foundryClient.isWorldDataStale()) {
301
+ worldLines.unshift(STALE_WORLD_DATA_NOTICE);
302
+ }
303
+ let healthSection = 'ℹ️ Not available';
304
+ if (systemHealth) {
305
+ const healthLines = [
306
+ `- **Status:** ${systemHealth.status}`,
307
+ `- **Users:** ${systemHealth.users.active} active / ${systemHealth.users.total} total`,
308
+ ];
309
+ if (systemHealth.server.uptime !== undefined) {
310
+ healthLines.push(`- **Uptime:** ${formatUptime(systemHealth.server.uptime)}`);
311
+ }
312
+ if (systemHealth.performance.memory) {
313
+ healthLines.push(`- **Memory (heap used):** ${formatMegabytes(systemHealth.performance.memory.heapUsed)}`);
314
+ }
315
+ healthLines.push(`- **Recent Errors:** ${systemHealth.logs.recentErrors} (warnings: ${systemHealth.logs.recentWarnings})`);
316
+ healthSection = `\n${healthLines.join('\n')}`;
317
+ }
192
318
  return {
193
319
  content: [
194
320
  {
195
321
  type: 'text',
196
- text: `🩺 **Comprehensive Health Status**
322
+ text: `\u{1FA7A} **Comprehensive Health Status**
197
323
 
198
324
  **FoundryVTT Connection:**
199
325
  ${foundryClient.isConnected() ? '✅ Connected' : '❌ Disconnected'}
200
326
 
201
327
  **World Information:**
202
- ${worldInfo
203
- ? `
204
- - **Title:** ${worldInfo.title}
205
- - **System:** ${worldInfo.system}
206
- - **Core Version:** ${worldInfo.coreVersion}
207
- - **Playtime:** ${Math.floor(worldInfo.playtime / 3600)} hours`
208
- : 'ℹ️ Not available'}
328
+ ${worldLines.join('\n')}
209
329
 
210
330
  **System Health:**
211
- ${systemHealth
212
- ? `
213
- - **Status:** ${systemHealth.status || 'Unknown'}
214
- - **CPU:** ${systemHealth.cpu || 'N/A'}%
215
- - **Memory:** ${systemHealth.memory || 'N/A'}%
216
- - **Uptime:** ${Math.floor((systemHealth.uptime || 0) / 3600)} hours`
217
- : 'ℹ️ Not available'}`,
331
+ ${healthSection}`,
218
332
  },
219
333
  ],
220
334
  };
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/tools/handlers/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,qDAAqD;AACrD,MAAM,gBAAgB,GAAG,IAAI,G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AAC,MAAM,EAAE,CAAC;gBACpC,WAAW,CAAC,IAAI,CACd,6BAA6B,eAAe,CAAC,YAAY,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CACzF,CAAC;YACJ,CAAC;YACD,WAAW,CAAC,IAAI,CACd,wBAAwB,YAAY,CAAC,IAAI,CAAC,YAAY,eAAe,YAAY,CAAC,IAAI,CAAC,cAAc,GAAG,CACzG,CAAC;YACF,aAAa,GAAG,KAAK,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;EAGd,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB;;;EAG9D,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGrB,aAAa,EAAE;iBACR;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -11,7 +11,7 @@ import { BaseTool, type ToolContext, type ToolResult } from '../base.js';
11
11
  */
12
12
  export declare class RollDiceTool extends BaseTool {
13
13
  readonly name = "roll_dice";
14
- readonly description = "Roll dice using standard RPG notation (e.g., 1d20, 3d6+4)";
14
+ readonly description = "Roll dice and return the total with a per-term breakdown. Dice terms and whole numbers joined by + or -, with whitespace allowed anywhere (\"1d20+5\", \"1d20 + 5\", \"1d20+5+3\", \"2d6 + 1d4\", \"3d6\"; a count-less \"d20\" means one die), always work and every term counts towards the total - that is the portable grammar, safe on either transport. Multiplication and Foundry modifier syntax such as \"4d6kh3\" or \"1d20r1\" are rejected on both transports, with an error naming the offending character and its position, never dropped from the total in silence. Parentheses are the one difference: with FOUNDRY_API_KEY set the formula goes to FoundryVTT's own Roll engine, which evaluates them, while the default Socket.IO transport rolls locally and rejects them by name - and a REST roll that cannot reach the server falls back to that same local roller, so a parenthesised formula can still fail there. Prefer the expanded form when it matters. Use when: the user asks for a check, save, attack, damage, or any random result.";
15
15
  readonly inputSchema: {
16
16
  type: string;
17
17
  properties: {
@@ -1 +1 @@
1
- {"version":3,"file":"dice.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/dice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzE;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,+DAA+D;IACnF,QAAQ,CAAC,WAAW;;;;;;;;;;;;;MAalB;cAEc,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;CAavB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,UAAU,CAAC,CAMrB"}
1
+ {"version":3,"file":"dice.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/dice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGzE;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,2gCAAyB;IAC7C,QAAQ,CAAC,WAAW;;;;;;;;;;;;;MAalB;cAEc,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;CAavB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,UAAU,CAAC,CAMrB"}
@@ -7,12 +7,13 @@
7
7
  import { logger } from '../../utils/logger.js';
8
8
  // import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
9
9
  import { BaseTool } from '../base.js';
10
+ import { ROLL_DICE_DESCRIPTION } from '../definitions.js';
10
11
  /**
11
12
  * Dice rolling tool implementation
12
13
  */
13
14
  export class RollDiceTool extends BaseTool {
14
15
  name = 'roll_dice';
15
- description = 'Roll dice using standard RPG notation (e.g., 1d20, 3d6+4)';
16
+ description = ROLL_DICE_DESCRIPTION;
16
17
  inputSchema = {
17
18
  type: 'object',
18
19
  properties: {
@@ -1 +1 @@
1
- {"version":3,"file":"dice.js","sourceRoot":"","sources":["../../../src/tools/handlers/dice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,4EAA4E;AAC5E,OAAO,EAAE,QAAQ,EAAqC,MAAM,YAAY,CAAC;AAEzE;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,QAAQ;IAC/B,IAAI,GAAG,WAAW,CAAC;IACnB,WAAW,GAAG,2DAA2D,CAAC;IAC1E,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sCAAsC;aACpD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;SACF;QACD,QAAQ,EAAE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","sources":["../../../src/tools/handlers/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB;;;;;;GAmCrC"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK7D,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB;;;;;;GAmCrC"}