@cloudhal/mcp-server 0.10.1 → 0.12.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.
- package/README.md +5 -2
- package/dist/src/asset-tools.d.ts +54 -2
- package/dist/src/asset-tools.js +51 -22
- package/dist/src/body-tools.d.ts +6 -0
- package/dist/src/body-tools.js +22 -5
- package/dist/src/changes.d.ts +8 -0
- package/dist/src/changes.js +14 -1
- package/dist/src/collection-listings.d.ts +2 -0
- package/dist/src/collection-listings.js +8 -2
- package/dist/src/common.d.ts +25 -1
- package/dist/src/common.js +26 -1
- package/dist/src/elevation-tools.js +13 -8
- package/dist/src/entry-list.d.ts +3 -2
- package/dist/src/entry-list.js +4 -3
- package/dist/src/field-hints.js +4 -0
- package/dist/src/http.d.ts +10 -1
- package/dist/src/http.js +25 -3
- package/dist/src/pending-changes.d.ts +4 -0
- package/dist/src/pending-changes.js +159 -0
- package/dist/src/publish-gate.d.ts +31 -0
- package/dist/src/publish-gate.js +115 -0
- package/dist/src/publish-tools.d.ts +4 -8
- package/dist/src/publish-tools.js +12 -36
- package/dist/src/render/cdp.js +6 -0
- package/dist/src/render-tools.js +21 -1
- package/dist/src/section-queries.js +7 -1
- package/dist/src/server-call.js +1 -0
- package/dist/src/server-instructions.d.ts +3 -1
- package/dist/src/server-instructions.js +6 -2
- package/dist/src/server.d.ts +3 -1
- package/dist/src/server.js +7 -2
- package/dist/src/structured-data-tools.js +3 -1
- package/dist/src/tools.d.ts +1 -1
- package/dist/src/tools.js +12 -55
- package/dist/src/upload-hints.d.ts +13 -0
- package/dist/src/upload-hints.js +116 -0
- package/dist/src/upload-tools.d.ts +12 -0
- package/dist/src/upload-tools.js +328 -0
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ The playground and the local stdio server (`cloudhal mcp`) take none of these: a
|
|
|
31
31
|
## Tool reference
|
|
32
32
|
|
|
33
33
|
<!-- tools:start (generated by scripts/mcp-tools-doc.ts; do not edit) -->
|
|
34
|
-
**
|
|
34
|
+
**114 tools**, in the order the server lists them.
|
|
35
35
|
|
|
36
36
|
| Tool | Scopes | Kind | Approval | What it does |
|
|
37
37
|
|---|---|---|---|---|
|
|
@@ -110,11 +110,14 @@ The playground and the local stdio server (`cloudhal mcp`) take none of these: a
|
|
|
110
110
|
| `retire_asset` | `asset:manage` | write | by the key's mode | Hide a file from the library and pickers so nothing new uses it. |
|
|
111
111
|
| `restore_asset` | `asset:manage` | write | by the key's mode | Make a retired file available again. |
|
|
112
112
|
| `delete_asset` | `asset:manage` | write (destructive) | by the key's mode | Delete a file from the media library. |
|
|
113
|
+
| `create_upload` | `asset:upload` | write | by the key's mode | Get a short-lived link to PUT one file from your machine into the site's media library, without sending its bytes through this conversation (for files on disk when you have a shel… |
|
|
114
|
+
| `complete_upload` | `asset:upload` | write | depends on the call | Turn an upload you sent to a create_upload link into an asset of the site's media library, with the alt text and fields given to create_upload; it answers as upload_asset does. |
|
|
113
115
|
| `create_snapshot` | `content:draft:own` | write | by the key's mode | Freeze the current state of the site as an immutable, labelled snapshot. |
|
|
114
116
|
| `list_snapshots` | `site:read` | read | — | Snapshots of a site, newest first, and which one is live. |
|
|
115
117
|
| `diff_snapshots` | `site:read` | read | — | Added, changed and removed nodes between two snapshots. |
|
|
116
118
|
| `preview_page` | `preview:create` | read | — | Render a page (or an article by entryId) to HTML as the site would show it, plus a preview link (signed, to the deployed site, or the `cloudhal dev` URL). |
|
|
117
|
-
| `
|
|
119
|
+
| `pending_changes` | `site:read` | read | — | Before `publish`: what publishing the current state would change against the live version. |
|
|
120
|
+
| `publish` | `site:publish` | write (destructive) | a person, except a low-risk article publish in `auto` | Snapshot the current state and make it live. |
|
|
118
121
|
| `rollback` | `site:rollback` | write (destructive) | always a person | Point production at an earlier snapshot (must be an ancestor of the live one). |
|
|
119
122
|
| `get_analytics` | `analytics:read` | read | — | How the site is doing over a range: page views, visits (entrances from other sites or typed in), unique visitors when the site counts them, the estimated cache-hit ratio (on Cloud… |
|
|
120
123
|
| `top_content` | `analytics:read` | read | — | The most viewed pages, articles and archives in a range, with their current title and path (renamed articles show their new ones; deleted ones read as gone) and the change of page… |
|
|
@@ -1,5 +1,57 @@
|
|
|
1
|
-
import type { Asset } from "@cloudhal/core-contracts";
|
|
2
|
-
import { type ToolDefinition } from "./common.js";
|
|
1
|
+
import type { Asset, Site } from "@cloudhal/core-contracts";
|
|
2
|
+
import { type JsonSchema, type ToolContext, type ToolDefinition } from "./common.js";
|
|
3
|
+
export declare const WRITE: {
|
|
4
|
+
readonly readOnlyHint: false;
|
|
5
|
+
readonly destructiveHint: false;
|
|
6
|
+
readonly idempotentHint: false;
|
|
7
|
+
readonly openWorldHint: false;
|
|
8
|
+
};
|
|
9
|
+
export declare const MB: number;
|
|
10
|
+
/** What agents may fetch: every accepted type except SVG (people only in v1). */
|
|
11
|
+
export declare const FETCH_TYPES: string[];
|
|
12
|
+
export declare const TEXT_FIELDS: {
|
|
13
|
+
alt: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
decorative: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
title: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
caption: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
credit: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
license: {
|
|
34
|
+
$defs: Record<string, JsonSchema>;
|
|
35
|
+
};
|
|
36
|
+
locale: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare const ASSET_OUT: JsonSchema;
|
|
42
|
+
export declare function url(asset: Asset): string;
|
|
43
|
+
export declare function texts(site: Site, a: Record<string, unknown>): Pick<Asset, "alt" | "title" | "caption"> & {
|
|
44
|
+
credit?: string;
|
|
45
|
+
decorative?: true;
|
|
46
|
+
};
|
|
3
47
|
/** "image "Bosphorus at dawn" (JPEG, 3000×2000, 482 KB)" — quoted and shortened (§6.2). */
|
|
4
48
|
export declare function describeAsset(asset: Asset, locale: string | undefined): string;
|
|
49
|
+
/**
|
|
50
|
+
* Agent limits per key per day (§5.6), checked before anything is fetched or stored. Open upload
|
|
51
|
+
* links (RFC-0048 §3.3) count with their declared bytes: they become assets without another check.
|
|
52
|
+
*/
|
|
53
|
+
export declare function dailyLimit(ctx: ToolContext, addBytes: number): Promise<void>;
|
|
54
|
+
/** A file name without path separators or control characters (kept for search only). */
|
|
55
|
+
export declare function cleanName(name: string | undefined): string | undefined;
|
|
56
|
+
export declare function report(ctx: ToolContext, asset: Asset, extra?: Record<string, unknown>): void;
|
|
5
57
|
export declare function assetTools(): ToolDefinition[];
|
package/dist/src/asset-tools.js
CHANGED
|
@@ -46,22 +46,22 @@ const READ = {
|
|
|
46
46
|
idempotentHint: true,
|
|
47
47
|
openWorldHint: false,
|
|
48
48
|
} ;
|
|
49
|
-
const WRITE = {
|
|
49
|
+
export const WRITE = {
|
|
50
50
|
readOnlyHint: false,
|
|
51
51
|
destructiveHint: false,
|
|
52
52
|
idempotentHint: false,
|
|
53
53
|
openWorldHint: false,
|
|
54
54
|
} ;
|
|
55
55
|
|
|
56
|
-
const MB = 1024 * 1024;
|
|
56
|
+
export const MB = 1024 * 1024;
|
|
57
57
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
58
58
|
|
|
59
59
|
/** What agents may fetch: every accepted type except SVG (people only in v1). */
|
|
60
|
-
const FETCH_TYPES = Object.entries(MEDIA_TYPES)
|
|
60
|
+
export const FETCH_TYPES = Object.entries(MEDIA_TYPES)
|
|
61
61
|
.filter(([, info]) => !info.peopleOnly)
|
|
62
62
|
.map(([type]) => type);
|
|
63
63
|
|
|
64
|
-
const TEXT_FIELDS = {
|
|
64
|
+
export const TEXT_FIELDS = {
|
|
65
65
|
alt: str(
|
|
66
66
|
"Alternative text in `locale` (default: the site's default locale). Images need it, or decorative: true.",
|
|
67
67
|
{ minLength: 1, maxLength: 500 },
|
|
@@ -77,7 +77,7 @@ const TEXT_FIELDS = {
|
|
|
77
77
|
locale: str("BCP 47 locale of alt, title and caption; defaults to the site's default locale"),
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const ASSET_OUT = obj(
|
|
80
|
+
export const ASSET_OUT = obj(
|
|
81
81
|
{
|
|
82
82
|
asset: ASSET,
|
|
83
83
|
existing: { type: "boolean", description: "The site already had these bytes" },
|
|
@@ -88,11 +88,11 @@ const ASSET_OUT = obj(
|
|
|
88
88
|
["asset", "existing", "url", "usage"],
|
|
89
89
|
);
|
|
90
90
|
|
|
91
|
-
function url(asset ) {
|
|
91
|
+
export function url(asset ) {
|
|
92
92
|
return asset.storage.kind === "external" ? asset.storage.url : mediaPath(asset);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function texts(
|
|
95
|
+
export function texts(
|
|
96
96
|
site ,
|
|
97
97
|
a ,
|
|
98
98
|
) {
|
|
@@ -133,13 +133,19 @@ function requireAlt(head , a ) {
|
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
/**
|
|
137
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Agent limits per key per day (§5.6), checked before anything is fetched or stored. Open upload
|
|
138
|
+
* links (RFC-0048 §3.3) count with their declared bytes: they become assets without another check.
|
|
139
|
+
*/
|
|
140
|
+
export async function dailyLimit(ctx , addBytes ) {
|
|
138
141
|
if (ctx.principal.actor.kind !== "agent") return;
|
|
139
142
|
const maxAssets = ctx.media?.agentDailyAssets ?? 100;
|
|
140
143
|
const maxBytes = ctx.media?.agentDailyBytes ?? 500 * MB;
|
|
141
|
-
const
|
|
142
|
-
const
|
|
144
|
+
const now = ctx.now?.() ?? new Date();
|
|
145
|
+
const since = new Date(now.getTime() - DAY_MS).toISOString();
|
|
146
|
+
const done = await ctx.store.assetUploadStats(ctx.principal.actor.id, since);
|
|
147
|
+
const open = await ctx.store.uploads.stats(ctx.principal.actor, since, now);
|
|
148
|
+
const used = { count: done.count + open.count, bytes: done.bytes + open.bytes };
|
|
143
149
|
if (used.count >= maxAssets || used.bytes + addBytes > maxBytes)
|
|
144
150
|
throw new ToolError(
|
|
145
151
|
"denied",
|
|
@@ -148,7 +154,7 @@ async function dailyLimit(ctx , addBytes ) {
|
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
/** A file name without path separators or control characters (kept for search only). */
|
|
151
|
-
function cleanName(name ) {
|
|
157
|
+
export function cleanName(name ) {
|
|
152
158
|
const clean = [...(name ?? "")]
|
|
153
159
|
.filter((c) => c.charCodeAt(0) >= 0x20 && c.charCodeAt(0) !== 0x7f && c !== "/" && c !== "\\")
|
|
154
160
|
.join("")
|
|
@@ -156,6 +162,34 @@ function cleanName(name ) {
|
|
|
156
162
|
return clean || undefined;
|
|
157
163
|
}
|
|
158
164
|
|
|
165
|
+
/** `upload_asset`'s file name: the original name, whose extension must match the content. */
|
|
166
|
+
const UPLOAD_FILENAME = str(
|
|
167
|
+
"Original file name, e.g. ferries.jpg (its extension must match the content)",
|
|
168
|
+
{ minLength: 1, maxLength: 255, pattern: "^[^/\\\\\\u0000-\\u001f\\u007f]+$" },
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
/** #250 B: the SHA-256 the agent expects of the decoded bytes, so a damaged copy is refused. */
|
|
172
|
+
const UPLOAD_SHA256 = str(
|
|
173
|
+
"The file's SHA-256 (64 hex digits). When given, the decoded bytes must match it, or nothing is stored",
|
|
174
|
+
{ pattern: "^[0-9a-fA-F]{64}$" },
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Refuses bytes whose SHA-256 is not the one the caller expected: base64 copied into a tool call
|
|
179
|
+
* can lose or change a character and still decode, and the media pipeline would accept the result.
|
|
180
|
+
*/
|
|
181
|
+
async function expectChecksum(bytes , expected ) {
|
|
182
|
+
if (!expected) return;
|
|
183
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes );
|
|
184
|
+
const actual = [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
185
|
+
if (actual === expected.toLowerCase()) return;
|
|
186
|
+
throw new ToolError(
|
|
187
|
+
"invalid",
|
|
188
|
+
`the decoded data's SHA-256 is ${actual}, not the expected ${expected.toLowerCase()}: the base64 was changed or cut on the way. Nothing was stored; send the file's data again.`,
|
|
189
|
+
{ reason: "checksum_mismatch", expected: expected.toLowerCase(), actual },
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
159
193
|
function decodeBase64(data ) {
|
|
160
194
|
const clean = data.replace(/\s+/g, "");
|
|
161
195
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(clean) || clean.length % 4 === 1)
|
|
@@ -189,7 +223,7 @@ async function usesOf(ctx , asset , locale ) {
|
|
|
189
223
|
return out;
|
|
190
224
|
}
|
|
191
225
|
|
|
192
|
-
function report(ctx , asset , extra = {}) {
|
|
226
|
+
export function report(ctx , asset , extra = {}) {
|
|
193
227
|
ctx.report?.({
|
|
194
228
|
asset: {
|
|
195
229
|
id: asset.id,
|
|
@@ -364,22 +398,16 @@ export function assetTools() {
|
|
|
364
398
|
{
|
|
365
399
|
name: "upload_asset",
|
|
366
400
|
title: "Upload media",
|
|
367
|
-
description: `Add a file to the site's media library from base64 data (at most ${MEDIA_LIMITS.uploadAsset / MB} MB decoded). The server checks the type from the bytes (JPEG, PNG, WebP, AVIF, GIF, MP4, WebM, MP3, M4A, Ogg, WAV, PDF, CSV, TSV, JSON, NDJSON, Parquet; no SVG), strips photo metadata such as GPS, and returns the asset. Images need alt text or decorative: true. Uploading the same bytes again returns the existing asset (existing: true). Use it in an article with coverImage: {assetId} or in markdown as . Nothing is public until the site is published.`,
|
|
401
|
+
description: `Add a file to the site's media library from base64 data (at most ${MEDIA_LIMITS.uploadAsset / MB} MB decoded). The server checks the type from the bytes (JPEG, PNG, WebP, AVIF, GIF, MP4, WebM, MP3, M4A, Ogg, WAV, PDF, CSV, TSV, JSON, NDJSON, Parquet; no SVG), strips photo metadata such as GPS, and returns the asset. Images need alt text or decorative: true. Uploading the same bytes again returns the existing asset (existing: true). Pass sha256 (of the file) to have the decoded bytes checked: a mismatch stores nothing. Use it in an article with coverImage: {assetId} or in markdown as . Nothing is public until the site is published. For files you have on disk and a shell to PUT them, create_upload keeps the bytes out of the call.`,
|
|
368
402
|
inputSchema: obj(
|
|
369
403
|
{
|
|
370
404
|
siteId: id,
|
|
371
|
-
filename:
|
|
372
|
-
"Original file name, e.g. ferries.jpg (its extension must match the content)",
|
|
373
|
-
{
|
|
374
|
-
minLength: 1,
|
|
375
|
-
maxLength: 255,
|
|
376
|
-
pattern: "^[^/\\\\\\u0000-\\u001f\\u007f]+$",
|
|
377
|
-
},
|
|
378
|
-
),
|
|
405
|
+
filename: UPLOAD_FILENAME,
|
|
379
406
|
data: str("The file's bytes, base64", {
|
|
380
407
|
minLength: 4,
|
|
381
408
|
maxLength: Math.ceil((MEDIA_LIMITS.uploadAsset * 4) / 3) + 8,
|
|
382
409
|
}),
|
|
410
|
+
sha256: UPLOAD_SHA256,
|
|
383
411
|
mediaType: str(
|
|
384
412
|
"What you believe the type is, e.g. image/png (checked against the bytes)",
|
|
385
413
|
{
|
|
@@ -409,6 +437,7 @@ export function assetTools() {
|
|
|
409
437
|
},
|
|
410
438
|
precheck: async (a, ctx) => {
|
|
411
439
|
const bytes = decodeBase64(a.data );
|
|
440
|
+
await expectChecksum(bytes, a.sha256 );
|
|
412
441
|
if (bytes.byteLength > MEDIA_LIMITS.uploadAsset)
|
|
413
442
|
throw new ToolError(
|
|
414
443
|
"too_large",
|
package/dist/src/body-tools.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ export interface BodyEditResult {
|
|
|
33
33
|
export declare function editBody(a: Record<string, unknown>, ctx: ToolContext, writer: BlockWriter): Promise<BodyEditResult>;
|
|
34
34
|
export declare function bodyTools(): ToolDefinition[];
|
|
35
35
|
type Node = ContentEntry | Page;
|
|
36
|
+
/**
|
|
37
|
+
* The top-level fields that differ between two versions of any node (compared as canonical JSON, so
|
|
38
|
+
* key order never counts), sorted; `rev`, timestamps
|
|
39
|
+
* and `schemaVersion` left out, and `also` (e.g. the site's live pointer, #279).
|
|
40
|
+
*/
|
|
41
|
+
export declare function changedFields(before: object | undefined, after: object | undefined, also?: readonly string[]): string[];
|
|
36
42
|
/** Changed fields, and each markdown body's block diff (unchanged blocks without their text). */
|
|
37
43
|
export declare function nodeChanges(before: Node | undefined, after: Node | undefined): {
|
|
38
44
|
fields: string[];
|
package/dist/src/body-tools.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
|
|
18
18
|
BodyOpError,
|
|
19
19
|
bodyDiff,
|
|
20
|
+
canonicalJson,
|
|
20
21
|
currentBlocks,
|
|
21
22
|
|
|
22
23
|
expandBlockOps,
|
|
@@ -668,15 +669,31 @@ export function bodyTools() {
|
|
|
668
669
|
|
|
669
670
|
const IGNORED = new Set(["rev", "updatedAt", "createdAt", "schemaVersion"]);
|
|
670
671
|
|
|
671
|
-
/**
|
|
672
|
-
|
|
672
|
+
/**
|
|
673
|
+
* The top-level fields that differ between two versions of any node (compared as canonical JSON, so
|
|
674
|
+
* key order never counts), sorted; `rev`, timestamps
|
|
675
|
+
* and `schemaVersion` left out, and `also` (e.g. the site's live pointer, #279).
|
|
676
|
+
*/
|
|
677
|
+
export function changedFields(
|
|
678
|
+
before ,
|
|
679
|
+
after ,
|
|
680
|
+
also = [],
|
|
681
|
+
) {
|
|
673
682
|
const keys = new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})]);
|
|
674
|
-
const get = (n
|
|
675
|
-
|
|
683
|
+
const get = (n , k ) => (n )?.[k];
|
|
684
|
+
return [...keys]
|
|
676
685
|
.filter(
|
|
677
|
-
(k) =>
|
|
686
|
+
(k) =>
|
|
687
|
+
!IGNORED.has(k) &&
|
|
688
|
+
!also.includes(k) &&
|
|
689
|
+
canonicalJson(get(before, k)) !== canonicalJson(get(after, k)),
|
|
678
690
|
)
|
|
679
691
|
.sort();
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** Changed fields, and each markdown body's block diff (unchanged blocks without their text). */
|
|
695
|
+
export function nodeChanges(before , after ) {
|
|
696
|
+
const fields = changedFields(before, after);
|
|
680
697
|
const bodies = [];
|
|
681
698
|
const add = (field , a , b ) => {
|
|
682
699
|
if (a === b) return;
|
package/dist/src/changes.d.ts
CHANGED
|
@@ -8,3 +8,11 @@ export declare const KIND_LABEL: Record<string, string>;
|
|
|
8
8
|
* deltas (RFC-0002 §6.4): `~ article "…" (+tag ai, −tag llms, primary category → News)`.
|
|
9
9
|
*/
|
|
10
10
|
export declare function describeChanges(ctx: ToolContext, diff: SnapshotDiff, site?: Site): Promise<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* The lines of the `publish` approval prompt: one per changed node (`describeChanges`), then the
|
|
13
|
+
* menu effects of other changes (`publishMenuLines`). `pending_changes` shows the same lines, so
|
|
14
|
+
* an agent sees before `publish` what the person will be asked to approve.
|
|
15
|
+
*/
|
|
16
|
+
export declare function publishLines(ctx: ToolContext, diff: SnapshotDiff, site: Site): Promise<string[]>;
|
|
17
|
+
/** `+2 added, ~1 changed, −0 removed`, as the `publish` prompt counts them. */
|
|
18
|
+
export declare const publishCounts: (diff: SnapshotDiff) => string;
|
package/dist/src/changes.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { termName } from "@cloudhal/core-ts";
|
|
6
6
|
import { describeAsset } from "./asset-tools.js";
|
|
7
7
|
import { quote, } from "./common.js";
|
|
8
|
-
import { menuChangeSummary } from "./menu-tools.js";
|
|
8
|
+
import { menuChangeSummary, publishMenuLines } from "./menu-tools.js";
|
|
9
9
|
import { assignmentDeltas, describeDeltas, termLookup } from "./terms.js";
|
|
10
10
|
|
|
11
11
|
export const KIND_LABEL = {
|
|
@@ -110,3 +110,16 @@ export async function describeChanges(
|
|
|
110
110
|
}
|
|
111
111
|
return out;
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The lines of the `publish` approval prompt: one per changed node (`describeChanges`), then the
|
|
116
|
+
* menu effects of other changes (`publishMenuLines`). `pending_changes` shows the same lines, so
|
|
117
|
+
* an agent sees before `publish` what the person will be asked to approve.
|
|
118
|
+
*/
|
|
119
|
+
export async function publishLines(ctx , diff , site ) {
|
|
120
|
+
return [...(await describeChanges(ctx, diff, site)), ...(await publishMenuLines(ctx, site))];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** `+2 added, ~1 changed, −0 removed`, as the `publish` prompt counts them. */
|
|
124
|
+
export const publishCounts = (diff ) =>
|
|
125
|
+
`+${diff.added.length} added, ~${diff.changed.length} changed, −${diff.removed.length} removed`;
|
|
@@ -33,6 +33,8 @@ interface PathView {
|
|
|
33
33
|
fields: readonly string[];
|
|
34
34
|
entry: readonly string[];
|
|
35
35
|
site: readonly string[];
|
|
36
|
+
/** RFC-0045 step 8b: a referenced entry's card properties the path takes. */
|
|
37
|
+
reference: readonly string[];
|
|
36
38
|
constant: boolean;
|
|
37
39
|
vocabulary?: string[];
|
|
38
40
|
}
|
|
@@ -59,7 +59,7 @@ export const LISTINGS_INPUT = {
|
|
|
59
59
|
listFields: {
|
|
60
60
|
anyOf: [SETTINGS_PROPS.listFields, { type: "null" }],
|
|
61
61
|
description:
|
|
62
|
-
"Up to 4 field keys that listings (contentList where/orderBy, list_entries) may filter and sort by, in column order; null removes them. A field contentList sections still use cannot be dropped (list_field_in_use)",
|
|
62
|
+
"Up to 4 field keys that listings (contentList where/orderBy, list_entries) may filter and sort by, in column order; null removes them. A field contentList sections still use cannot be dropped (list_field_in_use); a field whose type takes no operator (list_collections → listFields[].ops; a repeater) cannot be added (list_field_type)",
|
|
63
63
|
$defs: { FieldKey: DEFS.FieldKey },
|
|
64
64
|
},
|
|
65
65
|
expiry: nullable(
|
|
@@ -69,12 +69,13 @@ export const LISTINGS_INPUT = {
|
|
|
69
69
|
),
|
|
70
70
|
structuredData: nullable(
|
|
71
71
|
"StructuredDataPreset",
|
|
72
|
-
`A JSON-LD preset the entry pages emit instead of BlogPosting: a type and its properties, each mapped to a source ({"kind":"field","field":"startsAt"}, {"kind":"entry","property":"title"}, {"kind":"site","property":"name"}
|
|
72
|
+
`A JSON-LD preset the entry pages emit instead of BlogPosting: a type and its properties, each mapped to a source ({"kind":"field","field":"startsAt"}, {"kind":"entry","property":"title"}, {"kind":"site","property":"name"}, {"kind":"constant","value":"EUR"}, or the entry a single reference field with one target collection names: {"kind":"reference","field":"venue","property":"title"} (title, url or summary) or {"kind":"reference","field":"venue","targetField":"city"} (a field of the target collection, by the same type rules)). Unmapped paths with a default read it; required values (*) come from the entry, never a constant. Paths: ${presetSummary()}. Check an entry's output with preview_structured_data. null removes it`,
|
|
73
73
|
{
|
|
74
74
|
StructuredDataPreset: DEFS.StructuredDataPreset,
|
|
75
75
|
StructuredDataSource: DEFS.StructuredDataSource,
|
|
76
76
|
EntryValueProperty: DEFS.EntryValueProperty,
|
|
77
77
|
SiteValueProperty: DEFS.SiteValueProperty,
|
|
78
|
+
ReferenceValueProperty: DEFS.ReferenceValueProperty,
|
|
78
79
|
FieldKey: DEFS.FieldKey,
|
|
79
80
|
},
|
|
80
81
|
),
|
|
@@ -156,6 +157,8 @@ function sourceText(source ) {
|
|
|
156
157
|
return `site ${source.property}`;
|
|
157
158
|
case "constant":
|
|
158
159
|
return `"${quote(source.value, 30)}"`;
|
|
160
|
+
case "reference":
|
|
161
|
+
return `${source.field}'s ${source.targetField ?? source.property ?? "title"}`;
|
|
159
162
|
default:
|
|
160
163
|
return "?";
|
|
161
164
|
}
|
|
@@ -227,6 +230,8 @@ export async function describeListings(
|
|
|
227
230
|
|
|
228
231
|
|
|
229
232
|
|
|
233
|
+
|
|
234
|
+
|
|
230
235
|
|
|
231
236
|
|
|
232
237
|
|
|
@@ -242,6 +247,7 @@ function pathsOf(type ) {
|
|
|
242
247
|
fields: [...sources.fields, ...(spec.alsoFields ?? [])],
|
|
243
248
|
entry: sources.entry,
|
|
244
249
|
site: sources.site,
|
|
250
|
+
reference: sources.reference,
|
|
245
251
|
constant: sources.constant && !spec.required,
|
|
246
252
|
...(spec.vocabulary ? { vocabulary: VOCABULARIES[spec.vocabulary].map((v) => v.key) } : {}),
|
|
247
253
|
};
|
package/dist/src/common.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type ApprovalStore, type AuditLog, type CallClass, type Decision, type OwnershipResolver, type OwnLimit, type PolicyEngine, type Principal, type Scope, type ToolAnnotations } from "@cloudhal/agent-runtime";
|
|
6
6
|
import type { AnalyticsService } from "@cloudhal/analytics/service";
|
|
7
7
|
import type { Actor, ContentEntry, Page, Site, Snapshot } from "@cloudhal/core-contracts";
|
|
8
|
-
import type { InvariantCode, SiteGraphStore } from "@cloudhal/core-ts";
|
|
8
|
+
import type { AgentUpload, InvariantCode, SiteGraphStore } from "@cloudhal/core-ts";
|
|
9
9
|
import type { BodyDiff } from "@cloudhal/core-ts/body-blocks";
|
|
10
10
|
import type { FetchTransport } from "@cloudhal/core-ts/media";
|
|
11
11
|
import type { CommentsDeps } from "./comments.js";
|
|
@@ -117,6 +117,22 @@ export interface MediaToolOptions {
|
|
|
117
117
|
/** Per agent key per day (default 100 assets and 500 MB; audited as a denial when exceeded). */
|
|
118
118
|
agentDailyAssets?: number | undefined;
|
|
119
119
|
agentDailyBytes?: number | undefined;
|
|
120
|
+
/** RFC-0048: `false` turns agents' upload links off (`create_upload` answers unsupported). */
|
|
121
|
+
agentUploads?: boolean | undefined;
|
|
122
|
+
/** RFC-0048: an upload link's cap per file (default 25 MB, at most 100 MB and the type's cap). */
|
|
123
|
+
agentUploadBytes?: number | undefined;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* RFC-0048 §2: what `create_upload` needs to hand out a link. Only HTTP `/mcp` has it: stdio has no
|
|
127
|
+
* listener for the PUT, so there `uploads.signedUrl` is false.
|
|
128
|
+
*/
|
|
129
|
+
export interface UploadLinkDeps {
|
|
130
|
+
/** The link's path and signed query (the API's `agentUploadPath` and `signAgentUpload`). */
|
|
131
|
+
link(upload: AgentUpload): Promise<string>;
|
|
132
|
+
/** Where the link points: the deployment's configured base URL, else the `/mcp` request's. */
|
|
133
|
+
readonly origin: string;
|
|
134
|
+
/** False where another instance could not verify the link (no shared secret). */
|
|
135
|
+
readonly verifiable: boolean;
|
|
120
136
|
}
|
|
121
137
|
/** What `render_page` renders with (RFC-0021 §4). */
|
|
122
138
|
export interface RenderDeps {
|
|
@@ -125,6 +141,12 @@ export interface RenderDeps {
|
|
|
125
141
|
readonly limiter?: RenderLimiter | undefined;
|
|
126
142
|
/** Per call (default 20 s). */
|
|
127
143
|
readonly timeoutMs?: number | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Where this browser reaches the site, when that is not the site's public origin (RFC-0047,
|
|
146
|
+
* #292: a self-host Chrome sidecar on a private network, `http://cloudhal:8788`). The browser
|
|
147
|
+
* then opens the same signed preview link at this origin, also for a site with no domain yet.
|
|
148
|
+
*/
|
|
149
|
+
readonly origin?: string | undefined;
|
|
128
150
|
}
|
|
129
151
|
/**
|
|
130
152
|
* Watches drafts being built (RFC-0020 §6): Studio's Build view follows a page while agents
|
|
@@ -176,6 +198,8 @@ export interface ToolContext {
|
|
|
176
198
|
limit?: OwnLimit | undefined;
|
|
177
199
|
/** Media settings (fetch transport, host lists, daily limits). */
|
|
178
200
|
media?: MediaToolOptions | undefined;
|
|
201
|
+
/** RFC-0048: agents' upload links; absent on stdio (`uploads.signedUrl` is false there). */
|
|
202
|
+
uploads?: UploadLinkDeps | undefined;
|
|
179
203
|
/** Site analytics (RFC-0006): the analytics tools answer `analytics_disabled` without it. */
|
|
180
204
|
analytics?: AnalyticsService | undefined;
|
|
181
205
|
/** Reader comments (RFC-0007): the comment tools answer `comments_disabled` without them. */
|
package/dist/src/common.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
|
|
20
20
|
import { CommentsError } from "@cloudhal/comments";
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
import {
|
|
24
24
|
ConflictError,
|
|
25
25
|
FilterError,
|
|
@@ -136,6 +136,23 @@ import { ScheduleRequestError, } from "./sch
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* RFC-0048 §2: what `create_upload` needs to hand out a link. Only HTTP `/mcp` has it: stdio has no
|
|
147
|
+
* listener for the PUT, so there `uploads.signedUrl` is false.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
139
156
|
|
|
140
157
|
|
|
141
158
|
/** What `render_page` renders with (RFC-0021 §4). */
|
|
@@ -145,6 +162,12 @@ import { ScheduleRequestError, } from "./sch
|
|
|
145
162
|
|
|
146
163
|
|
|
147
164
|
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
148
171
|
|
|
149
172
|
|
|
150
173
|
/**
|
|
@@ -213,6 +236,8 @@ export async function notifyBuild(report )
|
|
|
213
236
|
|
|
214
237
|
|
|
215
238
|
|
|
239
|
+
|
|
240
|
+
|
|
216
241
|
|
|
217
242
|
|
|
218
243
|
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import { canonicalJson, sha256Hex } from "@cloudhal/core-ts";
|
|
23
23
|
import { budgetLeft, runEndsAt } from "@cloudhal/schedules";
|
|
24
24
|
import { ToolError } from "./common.js";
|
|
25
|
+
import { UPLOADS_MODE_SCHEMA, uploadCapability } from "./upload-tools.js";
|
|
25
26
|
|
|
26
27
|
export const REQUEST_ELEVATION = "request_elevation";
|
|
27
28
|
|
|
@@ -104,6 +105,15 @@ async function latestRequest(ctx ) {
|
|
|
104
105
|
return latest;
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
/** `get_mode`'s `person`. */
|
|
109
|
+
const PERSON = {
|
|
110
|
+
type: "object",
|
|
111
|
+
additionalProperties: false,
|
|
112
|
+
description: "Whose key this is (RFC-0005): you never do more than this person's role allows.",
|
|
113
|
+
properties: { role: { type: "string" }, name: { type: "string" } },
|
|
114
|
+
required: ["role"],
|
|
115
|
+
};
|
|
116
|
+
|
|
107
117
|
export function elevationTools() {
|
|
108
118
|
return [
|
|
109
119
|
{
|
|
@@ -135,14 +145,7 @@ export function elevationTools() {
|
|
|
135
145
|
canRequestElevation: { type: "boolean" },
|
|
136
146
|
requestableModes: { type: "array", items: { type: "string" } },
|
|
137
147
|
latestRequest: REQUEST,
|
|
138
|
-
person:
|
|
139
|
-
type: "object",
|
|
140
|
-
additionalProperties: false,
|
|
141
|
-
description:
|
|
142
|
-
"Whose key this is (RFC-0005): you never do more than this person's role allows.",
|
|
143
|
-
properties: { role: { type: "string" }, name: { type: "string" } },
|
|
144
|
-
required: ["role"],
|
|
145
|
-
},
|
|
148
|
+
person: PERSON,
|
|
146
149
|
scopes: {
|
|
147
150
|
type: "array",
|
|
148
151
|
items: { type: "string" },
|
|
@@ -171,6 +174,7 @@ export function elevationTools() {
|
|
|
171
174
|
},
|
|
172
175
|
required: ["runId", "automationId", "endsAt", "budgetLeft", "tainted"],
|
|
173
176
|
},
|
|
177
|
+
uploads: UPLOADS_MODE_SCHEMA,
|
|
174
178
|
},
|
|
175
179
|
required: ["mode", "ownMode", "canRequestElevation", "requestableModes"],
|
|
176
180
|
},
|
|
@@ -204,6 +208,7 @@ export function elevationTools() {
|
|
|
204
208
|
? { person: { role: person.role, ...(person.name ? { name: person.name } : {}) } }
|
|
205
209
|
: {}),
|
|
206
210
|
scopes: [...ctx.principal.scopes],
|
|
211
|
+
uploads: uploadCapability(ctx),
|
|
207
212
|
...runInfo,
|
|
208
213
|
};
|
|
209
214
|
if (mode === null)
|
package/dist/src/entry-list.d.ts
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* as before. Problems are refused as `invalid_query` with their paths (`where/0/value`).
|
|
7
7
|
*
|
|
8
8
|
* RFC-0045 §6: each entry carries its `groupId` (`COALESCE(translation.group, id)`), the value a
|
|
9
|
-
* reference field stores.
|
|
10
|
-
*
|
|
9
|
+
* reference field stores. A listed reference field filters by group ids (`eq`, `ne`, `in`, `set`,
|
|
10
|
+
* `unset`; rollout step 8a), and a member's own id given in `where` reads as its group's; a
|
|
11
|
+
* condition may name a field one hop through it (`venue.city`, step 8c).
|
|
11
12
|
*/
|
|
12
13
|
import type { ContentEntry } from "@cloudhal/core-contracts";
|
|
13
14
|
import { type EntryQuery } from "@cloudhal/core-ts";
|
package/dist/src/entry-list.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* as before. Problems are refused as `invalid_query` with their paths (`where/0/value`).
|
|
7
7
|
*
|
|
8
8
|
* RFC-0045 §6: each entry carries its `groupId` (`COALESCE(translation.group, id)`), the value a
|
|
9
|
-
* reference field stores.
|
|
10
|
-
*
|
|
9
|
+
* reference field stores. A listed reference field filters by group ids (`eq`, `ne`, `in`, `set`,
|
|
10
|
+
* `unset`; rollout step 8a), and a member's own id given in `where` reads as its group's; a
|
|
11
|
+
* condition may name a field one hop through it (`venue.city`, step 8c).
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import { SiteSchema } from "@cloudhal/core-contracts";
|
|
@@ -30,7 +31,7 @@ export const ENTRY_QUERY_INPUT = {
|
|
|
30
31
|
maxItems: 4,
|
|
31
32
|
items: { $ref: "#/$defs/FieldCondition" },
|
|
32
33
|
description:
|
|
33
|
-
'Conditions on the collection\'s list fields (list_collections → listFields, with each field\'s ops), ANDed, e.g. [{"field":"startsAt","op":"gte","value":"now"},{"field":"format","op":"in","values":["talk"]}]. Values are strings read by the field\'s type: a number, YYYY-MM-DD, an RFC 3339 instant, true/false, an option value, or now',
|
|
34
|
+
'Conditions on the collection\'s list fields (list_collections → listFields, with each field\'s ops), ANDed, e.g. [{"field":"startsAt","op":"gte","value":"now"},{"field":"format","op":"in","values":["talk"]}]. Values are strings read by the field\'s type: a number, YYYY-MM-DD, an RFC 3339 instant, true/false, an option value, an entry\'s groupId for a reference field (a member\'s own id reads as its group\'s), or now. A condition may also name a list field one hop through a listed single-target reference: {"field":"venue.city","op":"eq","value":"Istanbul"} (the venue the entry shows in its language; no venue, no match)',
|
|
34
35
|
$defs: { FieldCondition: DEFS.FieldCondition },
|
|
35
36
|
},
|
|
36
37
|
orderBy: {
|
package/dist/src/field-hints.js
CHANGED
|
@@ -60,6 +60,10 @@ const HINTS = {
|
|
|
60
60
|
"field operations on reference and repeater fields are not available on this server yet; edit the entries instead",
|
|
61
61
|
field_key_in_use:
|
|
62
62
|
"entries of the collection already hold a value under that key: pick another key, or convert the existing field with change_field_type",
|
|
63
|
+
list_field_type:
|
|
64
|
+
"a repeater cannot be a list field: leave it out of listFields (the rest of the change can go ahead); filter by one of its collection's other fields instead",
|
|
65
|
+
reference_listings_unsupported:
|
|
66
|
+
"this site's renderer does not read listings, conditions or structured data by reference yet: ask a person to deploy this release's site Worker (cloudhal deploy, for self-host and attached site Workers too), then try again; until then leave the reference out of listFields and contentList where/orderBy (the rest of the change can go ahead without it)",
|
|
63
67
|
list_field_in_use:
|
|
64
68
|
"contentList sections on the pages in details.pages still filter or sort by that field: change their where/orderBy first (update_page), then try again",
|
|
65
69
|
};
|
package/dist/src/http.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ApprovalStore, AuditLog, LoadedSkill, OwnershipResolver, Principal } from "@cloudhal/agent-runtime";
|
|
7
7
|
import type { AnalyticsService } from "@cloudhal/analytics/service";
|
|
8
|
-
import type { SiteGraphStore } from "@cloudhal/core-ts";
|
|
8
|
+
import type { AgentUpload, SiteGraphStore } from "@cloudhal/core-ts";
|
|
9
9
|
import type { CommentsDeps } from "./comments.js";
|
|
10
10
|
import type { BuildObserver, MediaToolOptions, RenderDeps } from "./common.js";
|
|
11
11
|
import type { SchedulesDeps } from "./schedules.js";
|
|
@@ -19,6 +19,15 @@ export interface HttpOptions {
|
|
|
19
19
|
previewSecret?: string | undefined;
|
|
20
20
|
/** Media settings for the asset tools (RFC-0004). */
|
|
21
21
|
media?: MediaToolOptions | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* RFC-0048: agents' upload links. `baseUrl` is where links point (the deployment's configured
|
|
24
|
+
* origin); without it, each `/mcp` request's own origin.
|
|
25
|
+
*/
|
|
26
|
+
uploads?: {
|
|
27
|
+
link(upload: AgentUpload): Promise<string>;
|
|
28
|
+
readonly verifiable: boolean;
|
|
29
|
+
readonly baseUrl?: string | undefined;
|
|
30
|
+
} | undefined;
|
|
22
31
|
/** Site analytics for the read-only analytics tools (RFC-0006 §9.3). */
|
|
23
32
|
analytics?: AnalyticsService | undefined;
|
|
24
33
|
/** Reader comments for the comment tools (RFC-0007 §11). */
|