cmskite-mcp 0.1.1 → 0.1.3
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 +13 -5
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/diagnose.js +18 -0
- package/dist/tools/diagnose.js.map +1 -1
- package/dist/tools/integrate.js +68 -23
- package/dist/tools/integrate.js.map +1 -1
- package/dist/tools/workspace.js +20 -1
- package/dist/tools/workspace.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,11 @@ what the assistant needs; the defaults are read and write content. The token is
|
|
|
10
10
|
shown once, and that dialogue generates the block below for whichever client you
|
|
11
11
|
pick — **Set up a client** on the same screen shows it again afterwards.
|
|
12
12
|
|
|
13
|
+
The first start downloads the package, which can take longer than a client
|
|
14
|
+
waits for a server (often 30 seconds). If yours reports a timeout, run
|
|
15
|
+
`npx -y cmskite-mcp@latest` once in a terminal to fill the cache, or
|
|
16
|
+
`npm install -g cmskite-mcp` and use `cmskite-mcp` as the command.
|
|
17
|
+
|
|
13
18
|
Every client runs the same process. They disagree only about where it is written
|
|
14
19
|
and under what key, and a block copied from the wrong one pastes without
|
|
15
20
|
complaint and then does nothing.
|
|
@@ -113,7 +118,8 @@ Settings (`cmd-shift-p` → “open settings”) — context servers, marked cus
|
|
|
113
118
|
|
|
114
119
|
## Tools
|
|
115
120
|
|
|
116
|
-
**Where am I** — `whoami`, `list_projects`, `get_project`, `get_project_summary
|
|
121
|
+
**Where am I** — `whoami`, `list_projects`, `get_project`, `get_project_summary`,
|
|
122
|
+
`update_project`
|
|
117
123
|
|
|
118
124
|
**Shape** — `create_workspace`, `create_project`, `list_categories`,
|
|
119
125
|
`create_category`, `update_category`, `delete_category`, `list_tags`,
|
|
@@ -125,9 +131,11 @@ Settings (`cmd-shift-p` → “open settings”) — context servers, marked cus
|
|
|
125
131
|
**Keys** — `list_api_keys`, `create_api_key`
|
|
126
132
|
|
|
127
133
|
**Connecting a website** — `get_integration_guide`, `check_integration`,
|
|
128
|
-
`get_content_analytics`
|
|
134
|
+
`get_content_analytics`, `get_post_analytics`
|
|
129
135
|
|
|
130
|
-
Start with `whoami`, then `list_projects` for a `prj_…` id.
|
|
136
|
+
Start with `whoami`, then `list_projects` for a `prj_…` id. `whoami` returns
|
|
137
|
+
`agentGrants`, the token's own list: a tool works only when that list and the
|
|
138
|
+
owner's role both allow it. Every content tool
|
|
131
139
|
needs one unless `CMSKITE_PROJECT_ID` is set.
|
|
132
140
|
|
|
133
141
|
### Connecting a website
|
|
@@ -149,7 +157,7 @@ Each tool needs the matching grant, and a token has only what was ticked:
|
|
|
149
157
|
|---|---|
|
|
150
158
|
| `whoami` | `member.read` — tick it, or the first call an assistant makes is the one that fails |
|
|
151
159
|
| `list_projects`, `get_project`, `get_project_summary` | `project.read` |
|
|
152
|
-
| `create_project` | `project.write` |
|
|
160
|
+
| `create_project`, `update_project` (including allowed origins) | `project.write` |
|
|
153
161
|
| `create_workspace` | `workspace.create` |
|
|
154
162
|
| `list_*`, `get_post`, `search_posts` | `content.read` |
|
|
155
163
|
| `create_*`, `update_*` | `content.write` |
|
|
@@ -158,7 +166,7 @@ Each tool needs the matching grant, and a token has only what was ticked:
|
|
|
158
166
|
| `list_api_keys` | `apikey.read` |
|
|
159
167
|
| `create_api_key` | `apikey.write` |
|
|
160
168
|
| `check_integration` | `project.read` |
|
|
161
|
-
| `get_content_analytics` | `analytics.read` |
|
|
169
|
+
| `get_content_analytics`, `get_post_analytics` | `analytics.read` |
|
|
162
170
|
| `get_integration_guide` | none — it reads nothing and changes nothing |
|
|
163
171
|
|
|
164
172
|
New posts are drafts. Publishing is `update_post` with `status: "published"` —
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
5
|
import { CmsKiteClient } from './client.js';
|
|
@@ -14,10 +15,12 @@ import { allTools, registerTools } from './tools/index.js';
|
|
|
14
15
|
* translator, not a second authorization layer, which is the only arrangement
|
|
15
16
|
* where the two cannot disagree.
|
|
16
17
|
*/
|
|
18
|
+
/** From package.json, so the handshake reports the version that is actually running. */
|
|
19
|
+
const { version } = createRequire(import.meta.url)('../package.json');
|
|
17
20
|
async function main() {
|
|
18
21
|
const config = readConfig();
|
|
19
22
|
const client = new CmsKiteClient(config);
|
|
20
|
-
const server = new McpServer({ name: 'cmskite', version
|
|
23
|
+
const server = new McpServer({ name: 'cmskite', version }, {
|
|
21
24
|
instructions: 'CMSKite manages blog content behind an API. A workspace holds projects; a project is ' +
|
|
22
25
|
'one website and holds the posts, categories, tags and authors. Start with `whoami`, ' +
|
|
23
26
|
'then `list_projects` to get a `prj_...` id — every content tool needs one unless ' +
|
|
@@ -31,7 +34,7 @@ async function main() {
|
|
|
31
34
|
// message corrupts the stream and the client drops the connection, so every
|
|
32
35
|
// diagnostic in this process goes to stderr.
|
|
33
36
|
await server.connect(new StdioServerTransport());
|
|
34
|
-
process.stderr.write(`cmskite-mcp ready: ${allTools.length} tools against ${config.apiUrl}\n`);
|
|
37
|
+
process.stderr.write(`cmskite-mcp ${version} ready: ${allTools.length} tools against ${config.apiUrl}\n`);
|
|
35
38
|
}
|
|
36
39
|
main().catch((err) => {
|
|
37
40
|
process.stderr.write(`cmskite-mcp failed to start: ${err instanceof Error ? err.message : String(err)}\n`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM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F,CAAA;IAED,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAEvC,gFAAgF;IAChF,4EAA4E;IAC5E,6CAA6C;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAA;IAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,OAAO,WAAW,QAAQ,CAAC,MAAM,kBAAkB,MAAM,CAAC,MAAM,IAAI,CAAC,CAAA;AAC3G,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC1G,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/tools/diagnose.js
CHANGED
|
@@ -74,5 +74,23 @@ export const diagnosticTools = [
|
|
|
74
74
|
return { summary, topPosts: top };
|
|
75
75
|
},
|
|
76
76
|
}),
|
|
77
|
+
defineTool({
|
|
78
|
+
name: 'get_post_analytics',
|
|
79
|
+
title: 'One post, day by day',
|
|
80
|
+
description: 'Views, unique readers and clicks for one post, per day. The way to check that a specific ' +
|
|
81
|
+
'post\'s view landed after wiring up tracking: open the post in a real browser (headless ' +
|
|
82
|
+
'browsers are not counted), wait about a minute for the rollup, then call this. A reader ' +
|
|
83
|
+
'counts once per post per day. Requires the analytics.read grant.',
|
|
84
|
+
input: {
|
|
85
|
+
projectId: z.string().describe('The project id, as `prj_...`.'),
|
|
86
|
+
postId: z.string().describe('The post id, as `post_...`. Not the slug.'),
|
|
87
|
+
from: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe('Inclusive UTC day. Defaults to 30 days ago.'),
|
|
88
|
+
to: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe('Inclusive UTC day. Defaults to today.'),
|
|
89
|
+
},
|
|
90
|
+
readOnly: true,
|
|
91
|
+
run: (client, args) => client.request(`/v1/analytics/content/posts/${segment(args.postId)}`, {
|
|
92
|
+
query: { projectId: args.projectId, from: args.from, to: args.to },
|
|
93
|
+
}),
|
|
94
|
+
}),
|
|
77
95
|
];
|
|
78
96
|
//# sourceMappingURL=diagnose.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../src/tools/diagnose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,CAAC;QACT,IAAI,EAAE,mBAAmB;QACzB,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EACT,uFAAuF;YACvF,oFAAoF;YACpF,2DAA2D;YAC3D,0FAA0F;YAC1F,0FAA0F;YAC1F,4EAA4E;QAC9E,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE;QAC1E,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACpB,MAAM,CAAC,OAAO,CAAC,gBAAgB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;KAC/E,CAAC;IAEF,UAAU,CAAC;QACT,IAAI,EAAE,uBAAuB;QAC7B,KAAK,EAAE,2BAA2B;QAClC,WAAW,EACT,yFAAyF;YACzF,uFAAuF;YACvF,sFAAsF;YACtF,6EAA6E;YAC7E,uBAAuB;QACzB,KAAK,EAAE;YACL,SAAS,EAA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,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;YAChH,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;SACzG;QACD,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACpB,MAAM,CAAC,OAAO,CAAC,+BAA+B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;YACpE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;SACnE,CAAC;KACL,CAAC;CACM,CAAA"}
|
package/dist/tools/integrate.js
CHANGED
|
@@ -23,6 +23,7 @@ import { defineTool } from './register.js';
|
|
|
23
23
|
const framework = z
|
|
24
24
|
.enum([
|
|
25
25
|
'nextjs-app',
|
|
26
|
+
'nextjs',
|
|
26
27
|
'nextjs-pages',
|
|
27
28
|
'react',
|
|
28
29
|
'node',
|
|
@@ -34,7 +35,8 @@ const framework = z
|
|
|
34
35
|
'other',
|
|
35
36
|
])
|
|
36
37
|
.describe('What the project is. Look at the files rather than guessing. ' +
|
|
37
|
-
'JavaScript: `next` in package.json with an app/ directory is `nextjs-app
|
|
38
|
+
'JavaScript: `next` in package.json with an app/ directory is `nextjs-app` (`nextjs` is ' +
|
|
39
|
+
'accepted as the same thing), `next` with ' +
|
|
38
40
|
'pages/ is `nextjs-pages`, `react` without `next` is `react`, a package.json with no ' +
|
|
39
41
|
'framework is `node`. ' +
|
|
40
42
|
'Not JavaScript: .html files and no build step is `html`; wp-config.php or a wp-content/ ' +
|
|
@@ -76,15 +78,20 @@ const RAW = new Set(['html', 'php', 'wordpress', 'laravel', 'python', 'other']);
|
|
|
76
78
|
/** A site whose content is fetched by the browser, not by a server. */
|
|
77
79
|
const BROWSER_FETCHED = new Set(['html', 'react']);
|
|
78
80
|
function guide(args) {
|
|
81
|
+
// The obvious first guess. The App Router is what `create-next-app` makes today.
|
|
82
|
+
if (args.framework === 'nextjs')
|
|
83
|
+
args = { ...args, framework: 'nextjs-app' };
|
|
79
84
|
const analytics = args.includeAnalytics !== false;
|
|
80
85
|
const raw = RAW.has(args.framework);
|
|
81
86
|
const notes = [
|
|
82
87
|
'Fetch the content on the server, report the view from the browser. That split IS the ' +
|
|
83
88
|
'integration, and it is the part that gets missed: a site that only fetches content ' +
|
|
84
89
|
'works perfectly and counts nobody.',
|
|
85
|
-
'A
|
|
86
|
-
'
|
|
87
|
-
'
|
|
90
|
+
'A website uses ONE project key, which starts `csk_live_`. It is read-only and returns ' +
|
|
91
|
+
'published content only, so it is safe in a page, and the same key both fetches the ' +
|
|
92
|
+
'content and reports views. An AGENT token (`cka_live_`, the kind ' +
|
|
93
|
+
'this MCP server runs on) is not a website key: it can write and delete, and must never ' +
|
|
94
|
+
'be put in a browser bundle or reused as the site key, even though it can read content.',
|
|
88
95
|
'A view is reported by the page that renders the post, never inferred from an API ' +
|
|
89
96
|
'request. A build fetching every post is two hundred requests and no readers.',
|
|
90
97
|
'The tracker needs the post’s `id` (`post_...`), not its slug. Render the id into the ' +
|
|
@@ -99,26 +106,55 @@ function guide(args) {
|
|
|
99
106
|
notes.push('Set allowed origins under Project → Settings → Allowed origins. Until that is set, any ' +
|
|
100
107
|
'page anywhere can read this project’s published content.');
|
|
101
108
|
}
|
|
109
|
+
if (args.framework.startsWith('nextjs') || args.framework === 'react') {
|
|
110
|
+
notes.push('Browser variables (NEXT_PUBLIC_*, VITE_*) are compiled into the bundle at BUILD time. ' +
|
|
111
|
+
'Setting one on the host changes nothing until the site is rebuilt and redeployed; until ' +
|
|
112
|
+
'then the tracker reads undefined and stays off. The tracker below is written so a ' +
|
|
113
|
+
'missing key switches it off instead of failing.');
|
|
114
|
+
}
|
|
115
|
+
notes.push('Views count once per reader, per post, per day, and only from a real browser: headless ' +
|
|
116
|
+
'browsers, curl and scripts are dropped silently (the endpoint still answers 202). To ' +
|
|
117
|
+
'verify, open a post in an ordinary browser and look for the POST to /v1/blog/events.');
|
|
102
118
|
if (args.projectId) {
|
|
103
|
-
notes.push(`Create the
|
|
119
|
+
notes.push(`Create the key for project ${args.projectId} with the create_api_key tool. That needs ` +
|
|
120
|
+
'the apikey.write grant; if this token lacks it, the person creates the key in the ' +
|
|
121
|
+
'dashboard under Project → API keys and puts it in the site themselves.');
|
|
104
122
|
}
|
|
105
|
-
const keys =
|
|
123
|
+
const keys = args.framework.startsWith('nextjs')
|
|
106
124
|
? [
|
|
107
125
|
{
|
|
108
|
-
name: '
|
|
109
|
-
where: '
|
|
110
|
-
why: '
|
|
111
|
-
'
|
|
126
|
+
name: 'NEXT_PUBLIC_CMSKITE_KEY',
|
|
127
|
+
where: 'The host’s environment variables (.env.local for development). The only CMSKite variable the site needs.',
|
|
128
|
+
why: 'One project key for both halves: the server code fetches posts with it and the tracker ' +
|
|
129
|
+
'reports views with it. It is read-only, so being in the bundle is fine. Restrict its ' +
|
|
130
|
+
'origins in project settings.',
|
|
112
131
|
},
|
|
113
132
|
]
|
|
114
|
-
:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
: args.framework === 'react'
|
|
134
|
+
? [
|
|
135
|
+
{
|
|
136
|
+
name: 'VITE_CMSKITE_KEY',
|
|
137
|
+
where: 'The build environment (.env for development). The only CMSKite variable the site needs.',
|
|
138
|
+
why: 'One project key: the app fetches posts and reports views with it. Restrict its origins in project settings.',
|
|
139
|
+
},
|
|
140
|
+
]
|
|
141
|
+
: browserOnly(args.framework)
|
|
142
|
+
? [
|
|
143
|
+
{
|
|
144
|
+
name: 'the project key, pasted directly into the page',
|
|
145
|
+
where: 'In the HTML. There is no server to hide it behind, and nothing to hide.',
|
|
146
|
+
why: 'Reads published content and reports views. Restrict its origins in project ' +
|
|
147
|
+
'settings — that is the control that matters here, not secrecy.',
|
|
148
|
+
},
|
|
149
|
+
]
|
|
150
|
+
: [
|
|
151
|
+
{
|
|
152
|
+
name: 'CMSKITE_API_KEY',
|
|
153
|
+
where: serverKeyHome(args.framework),
|
|
154
|
+
why: 'Fetches content while the page is being rendered or built.',
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
if (analytics && RAW.has(args.framework) && !browserOnly(args.framework)) {
|
|
122
158
|
keys.push({
|
|
123
159
|
name: publicKeyName(args.framework),
|
|
124
160
|
where: 'In the page the reader loads, deliberately.',
|
|
@@ -221,10 +257,12 @@ function filesFor(kind, analytics) {
|
|
|
221
257
|
const rawFiles = rawFilesFor(kind, analytics);
|
|
222
258
|
if (rawFiles)
|
|
223
259
|
return rawFiles;
|
|
260
|
+
// Next.js reads the one key the tracker also uses; a plain Node app has no browser half.
|
|
261
|
+
const keyVar = kind.startsWith('nextjs') ? 'NEXT_PUBLIC_CMSKITE_KEY' : 'CMSKITE_API_KEY';
|
|
224
262
|
const client = `import { createCMSKite } from 'cmskite'
|
|
225
263
|
|
|
226
264
|
// Created once and reused. It holds no connection and no mutable state.
|
|
227
|
-
export const cms = createCMSKite({ apiKey: process.env
|
|
265
|
+
export const cms = createCMSKite({ apiKey: process.env.${keyVar}! })
|
|
228
266
|
`;
|
|
229
267
|
const tracker = `'use client'
|
|
230
268
|
|
|
@@ -237,8 +275,13 @@ import { useTrackView } from 'cmskite/react'
|
|
|
237
275
|
* and the tracker remembers the post for the tab besides. Nothing here can
|
|
238
276
|
* throw, and nothing blocks the page.
|
|
239
277
|
*/
|
|
278
|
+
// A project key (csk_live_...), never an agent token. NEXT_PUBLIC_ values are
|
|
279
|
+
// baked in at build time: after setting it, redeploy.
|
|
280
|
+
const KEY = process.env.NEXT_PUBLIC_CMSKITE_KEY
|
|
281
|
+
|
|
240
282
|
export function TrackView({ postId }: { postId: string }) {
|
|
241
|
-
|
|
283
|
+
// Off until the key exists, and off in \`next dev\` so local reloads are not counted.
|
|
284
|
+
useTrackView(postId, { apiKey: KEY ?? '', enabled: Boolean(KEY) && process.env.NODE_ENV === 'production' })
|
|
242
285
|
return null
|
|
243
286
|
}
|
|
244
287
|
`;
|
|
@@ -309,7 +352,7 @@ ${analytics ? "import { useTrackView } from 'cmskite/react'\n" : ''}import type
|
|
|
309
352
|
import { cms } from '../../lib/cmskite'
|
|
310
353
|
|
|
311
354
|
export default function BlogPost({ post }: { post: Post }) {
|
|
312
|
-
${analytics ? " useTrackView(post.id, {
|
|
355
|
+
${analytics ? " // Off until NEXT_PUBLIC_CMSKITE_KEY exists (it is baked in at build time), and off in dev.\n useTrackView(post.id, {\n apiKey: process.env.NEXT_PUBLIC_CMSKITE_KEY ?? '',\n enabled: Boolean(process.env.NEXT_PUBLIC_CMSKITE_KEY) && process.env.NODE_ENV === 'production',\n })\n\n" : ''} return (
|
|
313
356
|
<article>
|
|
314
357
|
<h1>{post.title}</h1>
|
|
315
358
|
<div dangerouslySetInnerHTML={{ __html: post.body }} />
|
|
@@ -356,7 +399,7 @@ export function BlogPost({ slug }: { slug: string }) {
|
|
|
356
399
|
const [post, setPost] = useState<Post | null>(null)
|
|
357
400
|
const [error, setError] = useState<string | null>(null)
|
|
358
401
|
|
|
359
|
-
${analytics ? " useTrackView(post?.id, {
|
|
402
|
+
${analytics ? " // Off until VITE_CMSKITE_KEY exists (it is baked in at build time), and off in dev.\n useTrackView(post?.id, {\n apiKey: import.meta.env.VITE_CMSKITE_KEY ?? '',\n enabled: Boolean(import.meta.env.VITE_CMSKITE_KEY) && import.meta.env.PROD,\n })\n\n" : ''} useEffect(() => {
|
|
360
403
|
// Cancelled on unmount, and when a newer slug supersedes this one.
|
|
361
404
|
const controller = new AbortController()
|
|
362
405
|
cms.posts
|
|
@@ -416,7 +459,9 @@ ${analytics
|
|
|
416
459
|
* posts with a key, and post the view from the page.
|
|
417
460
|
*/
|
|
418
461
|
function rawFilesFor(kind, analytics) {
|
|
419
|
-
const tracker = analytics
|
|
462
|
+
const tracker = analytics
|
|
463
|
+
? [{ path: 'the-post-page (tracking snippet)', contents: RAW_TRACKER }]
|
|
464
|
+
: [];
|
|
420
465
|
if (kind === 'html') {
|
|
421
466
|
return [
|
|
422
467
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrate.js","sourceRoot":"","sources":["../../src/tools/integrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,SAAS,GAAG,CAAC;KAChB,IAAI,CAAC;IACJ,YAAY;IACZ,cAAc;IACd,OAAO;IACP,MAAM;IACN,MAAM;IACN,KAAK;IACL,WAAW;IACX,SAAS;IACT,QAAQ;IACR,OAAO;CACR,CAAC;KACD,QAAQ,CACP,+DAA+D;IAC7D,yFAAyF;IACzF,sFAAsF;IACtF,uBAAuB;IACvB,0FAA0F;IAC1F,2FAA2F;IAC3F,gFAAgF;IAChF,0FAA0F;IAC1F,WAAW,CACd,CAAA;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU,CAAC;QACT,IAAI,EAAE,uBAAuB;QAC7B,KAAK,EAAE,4CAA4C;QACnD,WAAW,EACT,0FAA0F;YAC1F,0FAA0F;YAC1F,wFAAwF;YACxF,iFAAiF;YACjF,yFAAyF;YACzF,uFAAuF;YACvF,uCAAuC;YACvC,uFAAuF;YACvF,sDAAsD;YACtD,8CAA8C;QAChD,KAAK,EAAE;YACL,SAAS;YACT,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,8DAA8D,CAAC;YAC3E,gBAAgB,EAAE,CAAC;iBAChB,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,QAAQ,
|
|
1
|
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ools/workspace.js
CHANGED
|
@@ -14,7 +14,9 @@ export const workspaceTools = [
|
|
|
14
14
|
name: 'whoami',
|
|
15
15
|
title: 'Who this token is',
|
|
16
16
|
description: 'The account this token acts as and the workspaces it can see. Call this first in a new ' +
|
|
17
|
-
'conversation: it confirms the token works and names the workspace everything else happens in.'
|
|
17
|
+
'conversation: it confirms the token works and names the workspace everything else happens in. ' +
|
|
18
|
+
'`agentGrants` is what THIS TOKEN may do; `permissions` is what its owner may do. A tool ' +
|
|
19
|
+
'works only when both allow it, so read `agentGrants` to know which tools will succeed.',
|
|
18
20
|
input: {},
|
|
19
21
|
readOnly: true,
|
|
20
22
|
run: (client) => client.request('/v1/auth/me'),
|
|
@@ -61,6 +63,23 @@ export const workspaceTools = [
|
|
|
61
63
|
},
|
|
62
64
|
run: (client, args) => client.request('/v1/projects', { method: 'POST', body: args }),
|
|
63
65
|
}),
|
|
66
|
+
defineTool({
|
|
67
|
+
name: 'update_project',
|
|
68
|
+
title: 'Update a project',
|
|
69
|
+
description: 'Change a project\'s name, description, website, or allowed origins. Only the fields ' +
|
|
70
|
+
'passed change. `allowedOrigins` REPLACES the list: pass every origin, like ' +
|
|
71
|
+
'["https://example.com", "https://www.example.com"] — scheme and host, no path. It decides ' +
|
|
72
|
+
'which websites may use the project key from a browser. Requires the project.write grant.',
|
|
73
|
+
input: {
|
|
74
|
+
projectId: z.string().describe('The project id, as `prj_...`.'),
|
|
75
|
+
name: z.string().min(1).max(200).optional(),
|
|
76
|
+
description: z.string().max(500).nullable().optional(),
|
|
77
|
+
websiteName: z.string().max(200).nullable().optional(),
|
|
78
|
+
websiteUrl: z.string().max(300).nullable().optional().describe('Display only. Not a CORS allowance.'),
|
|
79
|
+
allowedOrigins: z.array(z.string()).max(20).optional().describe('The complete list. [] removes the restriction.'),
|
|
80
|
+
},
|
|
81
|
+
run: (client, { projectId, ...body }) => client.request(`/v1/projects/${segment(projectId)}`, { method: 'PATCH', body }),
|
|
82
|
+
}),
|
|
64
83
|
defineTool({
|
|
65
84
|
name: 'get_project_summary',
|
|
66
85
|
title: 'Project summary',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/tools/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,CAAC;QACT,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,yFAAyF;YACzF
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/tools/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,CAAC;QACT,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,yFAAyF;YACzF,gGAAgG;YAChG,0FAA0F;YAC1F,wFAAwF;QAC1F,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC;KAC/C,CAAC;IAEF,UAAU,CAAC;QACT,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EACT,4EAA4E;YAC5E,yFAAyF;YACzF,wFAAwF;YACxF,mFAAmF;QACrF,KAAK,EAAE;YACL,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAA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