@cloudhal/mcp-server 0.7.0 → 0.7.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.
@@ -16,6 +16,7 @@ import {
16
16
  resolveChrome,
17
17
 
18
18
  } from "@cloudhal/core-ts/chrome";
19
+ import { isReservedKey } from "@cloudhal/core-ts/names";
19
20
  import { id, mapError, obj, ToolError } from "./common.js";
20
21
 
21
22
  async function requireSite(ctx , siteId ) {
@@ -24,12 +25,18 @@ async function requireSite(ctx , siteId ) {
24
25
  return site;
25
26
  }
26
27
 
27
- /** `patch` onto `current`: a value replaces the part, null removes it. */
28
+ /**
29
+ * `patch` onto `current`: a value replaces the part, null removes it. A reserved key
30
+ * (`__proto__`, `constructor`, `prototype`) is refused: JSON input can carry `__proto__` as an own
31
+ * key, and assigning it would swap the part's prototype instead of setting a field.
32
+ */
28
33
  function merge (current , patch ) {
29
34
  const out = { ...(current ?? {}) };
30
- for (const [k, v] of Object.entries(patch))
35
+ for (const [k, v] of Object.entries(patch)) {
36
+ if (isReservedKey(k)) throw new ToolError("invalid", `"${k}" is a reserved key`);
31
37
  if (v === null) delete out[k];
32
38
  else out[k] = v;
39
+ }
33
40
  return out ;
34
41
  }
35
42
 
@@ -13,7 +13,11 @@ type Values = Record<string, unknown>;
13
13
  export declare const FIELDS_INPUT: JsonSchema;
14
14
  /** `update_entry`'s `fields`: a merge patch. */
15
15
  export declare const FIELDS_PATCH: JsonSchema;
16
- /** The stored `fields` with `patch` applied: `null` removes a key. */
16
+ /**
17
+ * The stored `fields` with `patch` applied: `null` removes a key. A reserved key (`__proto__`,
18
+ * `constructor`, `prototype`) is refused, also for collections without field definitions: JSON
19
+ * input can carry `__proto__` as an own key, and assigning it would swap the object's prototype.
20
+ */
17
21
  export declare function mergeFields(current: Values | undefined, patch: Values): Values;
18
22
  /** What an entry write would store, for the check. */
19
23
  export interface FieldsCheck {
@@ -18,7 +18,8 @@ import {
18
18
  refuseFieldIssues,
19
19
  } from "@cloudhal/core-ts/fields";
20
20
  import { fieldAssetIssues, fieldAssetRefs } from "@cloudhal/core-ts/media";
21
- import { quote, } from "./common.js";
21
+ import { isReservedKey } from "@cloudhal/core-ts/names";
22
+ import { quote, ToolError } from "./common.js";
22
23
 
23
24
 
24
25
 
@@ -36,10 +37,15 @@ export const FIELDS_PATCH = {
36
37
  "Typed custom fields to change, as a merge patch: given keys are set, null removes a key, others stay. The collection's fieldsSchema (list_collections) lists the keys and allowed values.",
37
38
  };
38
39
 
39
- /** The stored `fields` with `patch` applied: `null` removes a key. */
40
+ /**
41
+ * The stored `fields` with `patch` applied: `null` removes a key. A reserved key (`__proto__`,
42
+ * `constructor`, `prototype`) is refused, also for collections without field definitions: JSON
43
+ * input can carry `__proto__` as an own key, and assigning it would swap the object's prototype.
44
+ */
40
45
  export function mergeFields(current , patch ) {
41
46
  const next = { ...(current ?? {}) };
42
47
  for (const [key, value] of Object.entries(patch)) {
48
+ if (isReservedKey(key)) throw new ToolError("invalid", `fields: "${key}" is a reserved key`);
43
49
  if (value === null) delete next[key];
44
50
  else next[key] = value;
45
51
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * What a deployment provides for RFC-0008 schedules (§16) — the store, the ticker, the purge, the
3
+ * limits and the release-published hook (#150) — and core-ts's `ReleaseService` over it, as the
4
+ * REST routes and MCP tools use them (re-exported by `schedules.ts`).
5
+ */
6
+ import type { SiteGraphStore } from "@cloudhal/core-ts";
7
+ import { type ReleasePublishedHook, type ReleasePurger, ReleaseService, type SchedulerControl } from "@cloudhal/core-ts/releases";
8
+ import type { SqlScheduleStore } from "@cloudhal/schedules/sql";
9
+ /** What a deployment provides for schedules (RFC-0008 §16). */
10
+ export interface SchedulesDeps {
11
+ readonly store: SqlScheduleStore;
12
+ /** `false` when the deployment turned schedules off. Default true. */
13
+ readonly available?: boolean | undefined;
14
+ /** `CLOUDHAL_AUTOMATIONS=off` → false: automations stop, releases and gates go on (§11.6). */
15
+ readonly automationsEnabled?: boolean | undefined;
16
+ /**
17
+ * The deployment's ticker (`ApiDeps.scheduler`): its mode for `/api/instance` and
18
+ * `/api/scheduler`, and `poke` when something becomes due sooner (a release scheduled, approved or
19
+ * moved, a window opened; §8.3).
20
+ */
21
+ readonly scheduler?: SchedulerControl | undefined;
22
+ /** "Publish now" purges the live site's cache like a tick does (absent: nothing is cached). */
23
+ readonly purge?: ReleasePurger | undefined;
24
+ /** New versions one call may pin (§6.1 step 4; Workers Free: 20, the default). */
25
+ readonly maxNewBodies?: number | undefined;
26
+ /** After "Publish now" commits a release (the Node server rebuilds its static site, #150). */
27
+ readonly onReleasePublished?: ReleasePublishedHook | undefined;
28
+ }
29
+ /** True when the deployment serves schedules. */
30
+ export declare const schedulesAvailable: (deps: SchedulesDeps | undefined) => deps is SchedulesDeps;
31
+ /** core-ts's `ReleaseService` over this graph, with the deployment's ticker and purge. */
32
+ export declare function releaseService(deps: SchedulesDeps, graph: SiteGraphStore, now?: () => Date): ReleaseService;
33
+ /** Tells the ticker something is due at `at` (never throws, never awaited by callers' answers). */
34
+ export declare function poke(deps: SchedulesDeps, at: string | undefined): void;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What a deployment provides for RFC-0008 schedules (§16) — the store, the ticker, the purge, the
3
+ * limits and the release-published hook (#150) — and core-ts's `ReleaseService` over it, as the
4
+ * REST routes and MCP tools use them (re-exported by `schedules.ts`).
5
+ */
6
+
7
+ import {
8
+
9
+
10
+ ReleaseService,
11
+
12
+ } from "@cloudhal/core-ts/releases";
13
+
14
+
15
+ /** What a deployment provides for schedules (RFC-0008 §16). */
16
+
17
+
18
+
19
+
20
+    
21
+
22
+
23
+
24
+
25
+  
26
+
27
+
28
+
29
+
30
+  
31
+
32
+
33
+
34
+
35
+
36
+ /** True when the deployment serves schedules. */
37
+ export const schedulesAvailable = (deps ) =>
38
+ deps !== undefined && deps.available !== false;
39
+
40
+ /** core-ts's `ReleaseService` over this graph, with the deployment's ticker and purge. */
41
+ export function releaseService(
42
+ deps ,
43
+ graph ,
44
+ now ,
45
+ ) {
46
+ return new ReleaseService({
47
+ graph,
48
+ ...(now ? { now } : {}),
49
+ ...(deps.scheduler ? { scheduler: deps.scheduler } : {}),
50
+ ...(deps.purge ? { purge: deps.purge } : {}),
51
+ ...(deps.maxNewBodies !== undefined ? { maxNewBodies: deps.maxNewBodies } : {}),
52
+ ...(deps.onReleasePublished ? { onReleasePublished: deps.onReleasePublished } : {}),
53
+ });
54
+ }
55
+
56
+ /** Tells the ticker something is due at `at` (never throws, never awaited by callers' answers). */
57
+ export function poke(deps , at ) {
58
+ if (!at || !deps.scheduler) return;
59
+ deps.scheduler.poke(at).catch(() => undefined);
60
+ }
@@ -9,33 +9,10 @@
9
9
  import { type AgentMode, type Approval, type ApprovalCause, type ApprovalStore, checkAutoRelease, type OwnershipResolver, type Principal, type Role } from "@cloudhal/agent-runtime";
10
10
  import type { Actor, Automation, AutomationJob, NodeRef, Release, ReleaseApproval, ReleaseNodeKind, ReleaseWhen, ScheduleRun, Site } from "@cloudhal/core-contracts";
11
11
  import { type SiteGraphStore } from "@cloudhal/core-ts";
12
- import { type ReleasePurger, ReleaseService, type SchedulerControl } from "@cloudhal/core-ts/releases";
13
12
  import { type ApprovalVerdict, type RunTaintState, type StoredReleaseItem } from "@cloudhal/schedules";
14
13
  import type { ReleaseRecord, SqlScheduleStore } from "@cloudhal/schedules/sql";
15
- /** What a deployment provides for schedules (RFC-0008 §16). */
16
- export interface SchedulesDeps {
17
- readonly store: SqlScheduleStore;
18
- /** `false` when the deployment turned schedules off. Default true. */
19
- readonly available?: boolean | undefined;
20
- /** `CLOUDHAL_AUTOMATIONS=off` → false: automations stop, releases and gates go on (§11.6). */
21
- readonly automationsEnabled?: boolean | undefined;
22
- /**
23
- * The deployment's ticker (`ApiDeps.scheduler`): its mode for `/api/instance` and
24
- * `/api/scheduler`, and `poke` when something becomes due sooner (a release scheduled, approved or
25
- * moved, a window opened; §8.3).
26
- */
27
- readonly scheduler?: SchedulerControl | undefined;
28
- /** "Publish now" purges the live site's cache like a tick does (absent: nothing is cached). */
29
- readonly purge?: ReleasePurger | undefined;
30
- /** New versions one call may pin (§6.1 step 4; Workers Free: 20, the default). */
31
- readonly maxNewBodies?: number | undefined;
32
- }
33
- /** True when the deployment serves schedules. */
34
- export declare const schedulesAvailable: (deps: SchedulesDeps | undefined) => deps is SchedulesDeps;
35
- /** core-ts's `ReleaseService` over this graph, with the deployment's ticker and purge. */
36
- export declare function releaseService(deps: SchedulesDeps, graph: SiteGraphStore, now?: () => Date): ReleaseService;
37
- /** Tells the ticker something is due at `at` (never throws, never awaited by callers' answers). */
38
- export declare function poke(deps: SchedulesDeps, at: string | undefined): void;
14
+ import { type SchedulesDeps } from "./schedules-deps.js";
15
+ export { poke, releaseService, type SchedulesDeps, schedulesAvailable, } from "./schedules-deps.js";
39
16
  /** The person approving on a local server without people (stdio, `bypass`, a confirmed elicitation). */
40
17
  export declare const LOCAL_PERSON: Readonly<{
41
18
  id: "user_localdev01";
@@ -38,11 +38,6 @@ import {
38
38
 
39
39
 
40
40
  import { nodeHash, sha256Hex } from "@cloudhal/core-ts";
41
- import {
42
-
43
- ReleaseService,
44
-
45
- } from "@cloudhal/core-ts/releases";
46
41
  import {
47
42
 
48
43
  approvalArgs,
@@ -59,50 +54,15 @@ import {
59
54
 
60
55
  import { releaseRiskFor } from "./release-risk.js";
61
56
  import { titleOf } from "./release-titles.js";
57
+ import { schedulesAvailable } from "./schedules-deps.js";
62
58
 
63
- /** What a deployment provides for schedules (RFC-0008 §16). */
64
-
65
-
66
-
67
-
68
-    
69
-
70
-
71
-
72
-
73
-  
74
-
75
-
76
-
77
-
78
-  
79
-
80
-
81
-
82
- /** True when the deployment serves schedules. */
83
- export const schedulesAvailable = (deps ) =>
84
- deps !== undefined && deps.available !== false;
85
-
86
- /** core-ts's `ReleaseService` over this graph, with the deployment's ticker and purge. */
87
- export function releaseService(
88
- deps ,
89
- graph ,
90
- now ,
91
- ) {
92
- return new ReleaseService({
93
- graph,
94
- ...(now ? { now } : {}),
95
- ...(deps.scheduler ? { scheduler: deps.scheduler } : {}),
96
- ...(deps.purge ? { purge: deps.purge } : {}),
97
- ...(deps.maxNewBodies !== undefined ? { maxNewBodies: deps.maxNewBodies } : {}),
98
- });
99
- }
100
-
101
- /** Tells the ticker something is due at `at` (never throws, never awaited by callers' answers). */
102
- export function poke(deps , at ) {
103
- if (!at || !deps.scheduler) return;
104
- deps.scheduler.poke(at).catch(() => undefined);
105
- }
59
+ // What a deployment provides (`SchedulesDeps`) and the service over it: `schedules-deps.ts`.
60
+ export {
61
+ poke,
62
+ releaseService,
63
+
64
+ schedulesAvailable,
65
+ } from "./schedules-deps.js";
106
66
 
107
67
  /** The person approving on a local server without people (stdio, `bypass`, a confirmed elicitation). */
108
68
  export const LOCAL_PERSON = Object.freeze({ id: "user_localdev01", name: "Local developer" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudhal/mcp-server",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Cloudhal MCP server: semantic site tools (pages, articles, snapshots, preview, publish) governed by the policy engine",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://cloudhal.dev",
@@ -56,15 +56,15 @@
56
56
  "README.md"
57
57
  ],
58
58
  "dependencies": {
59
- "@cloudhal/analytics": "0.7.0",
60
- "@cloudhal/agent-runtime": "0.7.0",
61
- "@cloudhal/astro-renderer": "0.7.0",
62
- "@cloudhal/comments": "0.7.0",
63
- "@cloudhal/core-contracts": "0.7.0",
64
- "@cloudhal/core-ts": "0.7.0",
65
- "@cloudhal/storage": "0.7.0",
59
+ "@cloudhal/analytics": "0.7.2",
60
+ "@cloudhal/agent-runtime": "0.7.2",
61
+ "@cloudhal/astro-renderer": "0.7.2",
62
+ "@cloudhal/comments": "0.7.2",
63
+ "@cloudhal/core-contracts": "0.7.2",
64
+ "@cloudhal/core-ts": "0.7.2",
65
+ "@cloudhal/storage": "0.7.2",
66
66
  "@modelcontextprotocol/server": "2.3.1",
67
- "@cloudhal/schedules": "0.7.0"
67
+ "@cloudhal/schedules": "0.7.2"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@cloudflare/workers-types": "^5.20261007.1",