@autopo/mcp 0.1.1 → 0.4.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 +17 -2
- package/dist/api.d.ts +12 -1
- package/dist/api.js +25 -3
- package/dist/api.js.map +1 -1
- package/dist/calllog.d.ts +4 -0
- package/dist/calllog.js +59 -0
- package/dist/calllog.js.map +1 -0
- package/dist/cli.js +7 -2
- package/dist/cli.js.map +1 -1
- package/dist/files.d.ts +70 -0
- package/dist/files.js +378 -0
- package/dist/files.js.map +1 -0
- package/dist/guides.d.ts +3 -2
- package/dist/guides.js +60 -0
- package/dist/guides.js.map +1 -1
- package/dist/http.d.ts +2 -0
- package/dist/http.js +1 -1
- package/dist/http.js.map +1 -1
- package/dist/kit.d.ts +3 -0
- package/dist/kit.js +2 -0
- package/dist/kit.js.map +1 -1
- package/dist/prompts.js +1 -0
- package/dist/prompts.js.map +1 -1
- package/dist/resources.js +15 -1
- package/dist/resources.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/studio.d.ts +5 -0
- package/dist/tools/studio.js +329 -9
- package/dist/tools/studio.js.map +1 -1
- package/dist/zip.d.ts +26 -0
- package/dist/zip.js +85 -0
- package/dist/zip.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,12 +54,12 @@ Prefer to run the server on your machine with any tool? `npx -y @autopo/mcp` wit
|
|
|
54
54
|
|
|
55
55
|
| | |
|
|
56
56
|
|---|---|
|
|
57
|
-
| **
|
|
57
|
+
| **72 tools** | the company at a glance, briefings, the inbox, tasks, the team's chats, runs, knowledge, the Studio (with your own footage uploaded from your machine, and videos cut as code), marketing, money, and `api_request` for every other endpoint of the REST API with `api_reference` as the manual |
|
|
58
58
|
| **Asks before it spends** | anything that spends credits or cannot be undone opens a confirmation dialog in your tool, with the cost: generate media, keyframes, clips, decide a card, post, cancel, delete |
|
|
59
59
|
| **Inline views** | the inbox, a video's storyboard, the media library, your home and the money page render inside Cursor, Claude Desktop and ChatGPT ([MCP Apps](https://modelcontextprotocol.io/extensions/apps/overview)); Claude Code and Codex CLI get the same results as text |
|
|
60
60
|
| **Docs** | [docs.autopoiesis.app](https://docs.autopoiesis.app): quickstart per client, guides, the tool reference, the REST API |
|
|
61
61
|
| **Prompts** | `/autopoiesis:make_a_teaser`, `morning_review`, `decide_inbox`, `studio_status`, `weekly_marketing` |
|
|
62
|
-
| **Resources** | the Studio guide, the teaser guide, a company's home and brand brain, the API's OpenAPI document |
|
|
62
|
+
| **Resources** | the Studio guide, the teaser guide, the code-film guide, a company's home and brand brain, the API's OpenAPI document |
|
|
63
63
|
| **Both protocol eras** | the stateless 2026-07-28 revision and the 2025 `initialize` handshake today's clients speak, from one endpoint |
|
|
64
64
|
|
|
65
65
|
Everything happens as you: your permissions, member access areas, limits and billing hold exactly as in the app, and it all shows in the app as you did it. A token can be scoped to one company and revoked at any time; it can never make tokens, delete the account or hand a company over.
|
|
@@ -77,6 +77,20 @@ brand_brain → create_video {title, brief, seconds: 20}
|
|
|
77
77
|
|
|
78
78
|
The `make_a_teaser` prompt runs this for you, step by step, stopping at every dialog.
|
|
79
79
|
|
|
80
|
+
## Code films
|
|
81
|
+
|
|
82
|
+
A video can be cut in code instead of by the joiner: its storyboard compiles to a small Remotion project you edit file by file from your terminal, checked on every write, with free stills and renders. The same seven tools, with the same names and arguments, are on the hosted server.
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
convert_video_to_code {video} → version 1 from the compiler, the scenes, the first check
|
|
86
|
+
→ get_video_code {video} · {video, file: "src/Film.tsx"}
|
|
87
|
+
→ write_video_code {video, files: [{path, content}], note} (a new version, checked at once: tsc + the lint, file:line)
|
|
88
|
+
→ check_video_code → video_frames {frames | every_seconds} (up to 12 stills, free)
|
|
89
|
+
→ render_video (free) → wait_for_video · video_code_versions / restore_video_code to go back
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The guide: `autopoiesis://guide/code-film`, or [docs.autopoiesis.app/guides/code-film](https://docs.autopoiesis.app/guides/code-film).
|
|
93
|
+
|
|
80
94
|
## Run it yourself
|
|
81
95
|
|
|
82
96
|
```sh
|
|
@@ -115,6 +129,7 @@ Layout: `src/tools/*` (the tools, grouped the way the app is), `src/kit.ts` (ses
|
|
|
115
129
|
- The token is a hashed secret the platform checks on every call; this server forwards it and never stores it.
|
|
116
130
|
- Every tool is a thin wrapper over the public REST API, so nothing here can do what you could not do in the app.
|
|
117
131
|
- Confirmations are host-enforced dialogs (MCP elicitation), not instructions the model may skip. Hosts that cannot show them get a refusal, never a silent spend.
|
|
132
|
+
- Each tool, resource and prompt call is recorded in your account's activity on the platform: its name, how it ended, and its arguments with secrets masked and long text cut. Results are not kept.
|
|
118
133
|
- Report a vulnerability to security@autopoiesis.app.
|
|
119
134
|
|
|
120
135
|
MIT © Autopoiesis. Questions: support@autopoiesis.app
|
package/dist/api.d.ts
CHANGED
|
@@ -26,13 +26,24 @@ export interface ApiOptions {
|
|
|
26
26
|
fetch?: typeof fetch;
|
|
27
27
|
userAgent?: string;
|
|
28
28
|
}
|
|
29
|
+
export declare const inCall: <T>(call: {
|
|
30
|
+
id: string;
|
|
31
|
+
tool: string;
|
|
32
|
+
}, run: () => T) => T;
|
|
29
33
|
export declare class Api {
|
|
30
34
|
readonly baseUrl: string;
|
|
31
35
|
private readonly token;
|
|
32
|
-
|
|
36
|
+
readonly fetchImpl: typeof fetch;
|
|
33
37
|
private readonly userAgent;
|
|
34
38
|
constructor(options: ApiOptions);
|
|
35
39
|
request<T = unknown>(method: string, path: string, body?: unknown, query?: Query): Promise<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Send a raw body: bytes (`application/octet-stream`, the Studio's upload chunks), a Blob, or a FormData (multipart,
|
|
42
|
+
* the content type set by fetch). `contentType` is left unset for FormData.
|
|
43
|
+
*/
|
|
44
|
+
send<T = unknown>(method: string, path: string, body?: NonNullable<RequestInit['body']>, contentType?: string, query?: Query): Promise<T>;
|
|
45
|
+
/** One line for the person's action log, sent and forgotten: whether it lands never matters to the call it describes. */
|
|
46
|
+
reportCall(call: Record<string, unknown>): void;
|
|
36
47
|
get<T = unknown>(path: string, query?: Query): Promise<T>;
|
|
37
48
|
post<T = unknown>(path: string, body?: unknown, query?: Query): Promise<T>;
|
|
38
49
|
patch<T = unknown>(path: string, body: unknown): Promise<T>;
|
package/dist/api.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* endpoints, so permissions, member access areas, limits, billing and the user action log hold exactly as in the app:
|
|
4
4
|
* the server never sees anything the person could not do themselves.
|
|
5
5
|
*/
|
|
6
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
7
|
export class ApiError extends Error {
|
|
7
8
|
status;
|
|
8
9
|
code;
|
|
@@ -16,6 +17,9 @@ export class ApiError extends Error {
|
|
|
16
17
|
this.body = body;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
20
|
+
/** The MCP call being served: its API calls name it, so the user action log can tie them together (API_CONTRACT §90.3). */
|
|
21
|
+
const currentCall = new AsyncLocalStorage();
|
|
22
|
+
export const inCall = (call, run) => currentCall.run(call, run);
|
|
19
23
|
export class Api {
|
|
20
24
|
baseUrl;
|
|
21
25
|
token;
|
|
@@ -28,6 +32,15 @@ export class Api {
|
|
|
28
32
|
this.userAgent = options.userAgent ?? 'autopoiesis-mcp';
|
|
29
33
|
}
|
|
30
34
|
async request(method, path, body, query) {
|
|
35
|
+
if (body === undefined)
|
|
36
|
+
return this.send(method, path, undefined, undefined, query);
|
|
37
|
+
return this.send(method, path, JSON.stringify(body), 'application/json', query);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Send a raw body: bytes (`application/octet-stream`, the Studio's upload chunks), a Blob, or a FormData (multipart,
|
|
41
|
+
* the content type set by fetch). `contentType` is left unset for FormData.
|
|
42
|
+
*/
|
|
43
|
+
async send(method, path, body, contentType, query) {
|
|
31
44
|
if (!path.startsWith('/api/')) {
|
|
32
45
|
throw new ApiError(400, { error: { code: 'validation_error', message: 'Paths start with /api/ (see the API reference).' } });
|
|
33
46
|
}
|
|
@@ -43,11 +56,16 @@ export class Api {
|
|
|
43
56
|
'User-Agent': this.userAgent,
|
|
44
57
|
'X-Client': 'mcp',
|
|
45
58
|
};
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
const call = currentCall.getStore();
|
|
60
|
+
if (call) {
|
|
61
|
+
headers['X-MCP-Call'] = call.id;
|
|
62
|
+
headers['X-MCP-Tool'] = call.tool;
|
|
63
|
+
}
|
|
64
|
+
if (contentType)
|
|
65
|
+
headers['Content-Type'] = contentType;
|
|
48
66
|
const init = { method, headers };
|
|
49
67
|
if (body !== undefined)
|
|
50
|
-
init.body =
|
|
68
|
+
init.body = body;
|
|
51
69
|
const response = await this.fetchImpl(url, init);
|
|
52
70
|
const text = await response.text();
|
|
53
71
|
let data = null;
|
|
@@ -65,6 +83,10 @@ export class Api {
|
|
|
65
83
|
}
|
|
66
84
|
return data;
|
|
67
85
|
}
|
|
86
|
+
/** One line for the person's action log, sent and forgotten: whether it lands never matters to the call it describes. */
|
|
87
|
+
reportCall(call) {
|
|
88
|
+
void this.post('/api/me/mcp-calls', call).catch(() => undefined);
|
|
89
|
+
}
|
|
68
90
|
get(path, query) {
|
|
69
91
|
return this.request('GET', path, undefined, query);
|
|
70
92
|
}
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAOpD,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAQ;IACd,IAAI,CAAoB;IACxB,IAAI,CAAc;IAE3B,YAA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AQ,IAA4B,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,IAA0B,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA;IAC1J,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAK,IAA2B,CAAC,IAAI,CAAC,CAAA;IAC3F,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG,KAAK,IAAI,IAAI,EAAE,CAAA;AAClF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,IAAI,CAAoC,GAAM,EAAE,IAAuB;IACrF,MAAM,GAAG,GAA4B,EAAE,CAAA;IACvC,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,IAAI,GAAG,IAAI,GAAG;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3D,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
import { type Api } from './api.js';
|
|
3
|
+
/** Log everything registered on `server` from here on: tools (the App views' too), resources and prompts. */
|
|
4
|
+
export declare function logCalls(server: McpServer, api: Api): void;
|
package/dist/calllog.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every call this server takes lands in the person's user action log on the platform (API_CONTRACT §90.3), the same row
|
|
3
|
+
* the server inside the API writes for itself: which tool, what it was given, how it ended. The API calls a tool makes
|
|
4
|
+
* carry its id (X-MCP-Call, X-MCP-Tool), so the platform ties them together. A report never holds up or fails a call.
|
|
5
|
+
*/
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
7
|
+
import { inCall } from './api.js';
|
|
8
|
+
/** Short enough that the platform's own cut (500 chars) leaves the note of the real length in place. */
|
|
9
|
+
const MAX_TEXT = 480;
|
|
10
|
+
const MAX_ARGUMENTS = 100_000;
|
|
11
|
+
function forLog(value) {
|
|
12
|
+
const text = JSON.stringify(value ?? {}, (_key, v) => typeof v === 'string' && v.length > MAX_TEXT ? `${v.slice(0, MAX_TEXT)}… (${v.length.toLocaleString('en-US')} chars)` : v);
|
|
13
|
+
return text.length <= MAX_ARGUMENTS ? JSON.parse(text) : { omitted: `${text.length.toLocaleString('en-US')} chars` };
|
|
14
|
+
}
|
|
15
|
+
function outcome(result) {
|
|
16
|
+
const r = (result ?? {});
|
|
17
|
+
if (r.resultType === 'input_required')
|
|
18
|
+
return { status: 202 }; // it asked the person; the answer comes as a new call
|
|
19
|
+
if (!r.isError)
|
|
20
|
+
return { status: 200 };
|
|
21
|
+
const error = r.content?.[0]?.text ?? '';
|
|
22
|
+
const status = /\(HTTP (\d{3})/.exec(error)?.[1];
|
|
23
|
+
return { status: status ? Number(status) : 400, error };
|
|
24
|
+
}
|
|
25
|
+
async function logged(server, api, what, run) {
|
|
26
|
+
const id = randomUUID();
|
|
27
|
+
const started = Date.now();
|
|
28
|
+
const report = (ended) => {
|
|
29
|
+
const client = server.server.getClientVersion();
|
|
30
|
+
api.reportCall({
|
|
31
|
+
call_id: id,
|
|
32
|
+
method: what.method,
|
|
33
|
+
tool: what.tool ?? '',
|
|
34
|
+
arguments: forLog(what.arguments),
|
|
35
|
+
duration_ms: Date.now() - started,
|
|
36
|
+
...ended,
|
|
37
|
+
...(client ? { client: { name: client.name, version: client.version } } : {}),
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
const result = await inCall({ id, tool: what.tool ?? '' }, run);
|
|
42
|
+
report(outcome(result));
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
report({ status: 500, error: error instanceof Error ? error.message : String(error) });
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Log everything registered on `server` from here on: tools (the App views' too), resources and prompts. */
|
|
51
|
+
export function logCalls(server, api) {
|
|
52
|
+
const tool = server.registerTool.bind(server);
|
|
53
|
+
const resource = server.registerResource.bind(server);
|
|
54
|
+
const prompt = server.registerPrompt.bind(server);
|
|
55
|
+
server.registerTool = ((name, config, handler) => tool(name, config, (...args) => logged(server, api, { method: 'tools/call', tool: name, arguments: args.length > 1 ? args[0] : {} }, () => handler(...args))));
|
|
56
|
+
server.registerResource = ((name, uri, config, handler) => resource(name, uri, config, (...args) => logged(server, api, { method: 'resources/read', arguments: { name, uri: String(args[0]) } }, () => handler(...args))));
|
|
57
|
+
server.registerPrompt = ((name, config, handler) => prompt(name, config, (...args) => logged(server, api, { method: 'prompts/get', arguments: { name, arguments: args.length > 1 ? args[0] : {} } }, () => handler(...args))));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=calllog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calllog.js","sourceRoot":"","sources":["../src/calllog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,MAAM,EAAY,MAAM,UAAU,CAAA;AAE3C,wGAAwG;AACxG,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,MAAM,aAAa,GAAG,OAAO,CAAA;AAE7B,SAAS,MAAM,CAAC,KAAc;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAU,EAAE,EAAE,CAC5D,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CA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,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAU,CAAA;AACvL,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -23,6 +23,11 @@ Options
|
|
|
23
23
|
--host <addr> --http only (default 0.0.0.0)
|
|
24
24
|
--version, --help
|
|
25
25
|
|
|
26
|
+
Files
|
|
27
|
+
On stdio the server runs on your machine, so upload_media and import_video_plan take paths (a recording, a folder of
|
|
28
|
+
footage, a plan.json or zip) and upload them to the Studio in 8 MB chunks. Hosted servers take URLs; set
|
|
29
|
+
AUTOPOIESIS_ALLOW_PATHS=1 to let a server you run for yourself read its host's files too.
|
|
30
|
+
|
|
26
31
|
Get a token: open the app → Connectors → MCP → Make the token. Docs: https://docs.autopoiesis.app
|
|
27
32
|
`;
|
|
28
33
|
function arg(name) {
|
|
@@ -43,7 +48,7 @@ else if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
|
43
48
|
else if (process.argv.includes('--http')) {
|
|
44
49
|
const port = Number(arg('--port') ?? env.PORT ?? 8080);
|
|
45
50
|
const host = arg('--host') ?? env.HOST ?? '0.0.0.0';
|
|
46
|
-
serveHttp({ port, host, apiUrl, appUrl, ...(publicUrl ? { publicUrl } : {}), mediaDomains });
|
|
51
|
+
serveHttp({ port, host, apiUrl, appUrl, ...(publicUrl ? { publicUrl } : {}), mediaDomains, local: env.AUTOPOIESIS_ALLOW_PATHS === '1' });
|
|
47
52
|
}
|
|
48
53
|
else {
|
|
49
54
|
const token = arg('--token') ?? env.AUTOPOIESIS_TOKEN;
|
|
@@ -51,7 +56,7 @@ else {
|
|
|
51
56
|
process.stderr.write('autopoiesis-mcp: no token. Set AUTOPOIESIS_TOKEN (make one in the app: Connectors → MCP) or pass --token.\n');
|
|
52
57
|
process.exit(1);
|
|
53
58
|
}
|
|
54
|
-
const handle = serveStdio(() => createServer({ token, apiUrl, appUrl, mediaDomains, ...(publicUrl ? { publicUrl } : {}) }), {
|
|
59
|
+
const handle = serveStdio(() => createServer({ token, apiUrl, appUrl, mediaDomains, local: true, ...(publicUrl ? { publicUrl } : {}) }), {
|
|
55
60
|
legacy: 'serve',
|
|
56
61
|
onerror: (error) => process.stderr.write(`autopoiesis-mcp: ${error.message}\n`),
|
|
57
62
|
});
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,IAAI,GAAG,mBAAmB,OAAO;;;;;;;;;;4EAUqC,eAAe;kFACT,eAAe
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,IAAI,GAAG,mBAAmB,OAAO;;;;;;;;;;4EAUqC,eAAe;kFACT,eAAe;;;;;;;;;;;;CAYhG,CAAA;AAED,SAAS,GAAG,CAAC,IAAY;IACvB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACjD,CAAC;AAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AACvB,MAAM,MAAM,GAAG,GAAG,CAAC,WA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,70 @@
|
|
|
1
|
+
import type { ServerContext } from '@modelcontextprotocol/server';
|
|
2
|
+
import { Session, ToolError } from './kit.js';
|
|
3
|
+
import { type ByteRange, type ZipEntry } from './zip.js';
|
|
4
|
+
export declare const MEDIA_TYPES: Record<string, string>;
|
|
5
|
+
export declare function mediaType(name: string): string | undefined;
|
|
6
|
+
export interface Media {
|
|
7
|
+
id: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
kind?: string;
|
|
10
|
+
status?: string;
|
|
11
|
+
url?: string | null;
|
|
12
|
+
byte_size?: number;
|
|
13
|
+
error?: string | null;
|
|
14
|
+
}
|
|
15
|
+
/** Something to upload: its name, size and type, and its bytes in pieces of at most `size`. */
|
|
16
|
+
export interface Source {
|
|
17
|
+
name: string;
|
|
18
|
+
size: number;
|
|
19
|
+
type: string;
|
|
20
|
+
chunks(size: number): AsyncIterable<Uint8Array>;
|
|
21
|
+
}
|
|
22
|
+
export declare function expandHome(path: string): string;
|
|
23
|
+
/** A file, or a folder's media files in name order (2 before 10). */
|
|
24
|
+
export declare function expandPath(path: string): Promise<string[]>;
|
|
25
|
+
export declare function pathSource(path: string): Promise<Source>;
|
|
26
|
+
/** A public link: streamed when its size is known, read whole (up to 512 MB) when it is not. */
|
|
27
|
+
export declare function urlSource(url: string, fetchImpl?: typeof fetch): Promise<Source>;
|
|
28
|
+
export declare function bytesSource(name: string, data: Buffer, type?: string): Source;
|
|
29
|
+
/** A zip entry: streamed by range when stored, inflated whole when deflated. */
|
|
30
|
+
export declare function zipSource(range: ByteRange, entry: ZipEntry): Source;
|
|
31
|
+
export type Progress = (progress: number, total: number | undefined, message: string) => Promise<void>;
|
|
32
|
+
/** Progress notifications to the host, when it asked for them (a progressToken on the request). */
|
|
33
|
+
export declare function progressOf(ctx: ServerContext): Progress;
|
|
34
|
+
export interface UploadOptions {
|
|
35
|
+
production?: string | undefined;
|
|
36
|
+
title?: string | undefined;
|
|
37
|
+
signal?: AbortSignal | undefined;
|
|
38
|
+
onBytes?: ((sent: number, total: number) => Promise<void>) | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare const mb: (n: number) => string;
|
|
41
|
+
/** One file into the library: begin, the chunks in order, complete. Returns the media (processing, soon ready). */
|
|
42
|
+
export declare function upload(s: Session, companyId: string, source: Source, options?: UploadOptions): Promise<Media>;
|
|
43
|
+
/** Wait until uploads are ready (the Studio reads each file's shape and makes a thumbnail; recordings become web video). */
|
|
44
|
+
export declare function waitReady(s: Session, ids: string[], options?: {
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
signal?: AbortSignal | undefined;
|
|
47
|
+
progress?: Progress;
|
|
48
|
+
}): Promise<Record<string, Media>>;
|
|
49
|
+
export declare const FILE_REF = "file:";
|
|
50
|
+
export declare const ICON_REF = "icon:";
|
|
51
|
+
/** The plan's `file:…` and `icon:…` references, found like the platform does: exact path, else the file's name, else its stem. */
|
|
52
|
+
export declare function findFile<T>(files: Record<string, T>, ref: string): string | undefined;
|
|
53
|
+
export declare function isFileRef(value: unknown): value is string;
|
|
54
|
+
/** Every file reference in a plan, deep, in order of first appearance. */
|
|
55
|
+
export declare function fileRefs(value: unknown, out?: string[]): string[];
|
|
56
|
+
/** The plan with each file reference replaced by the id it became. */
|
|
57
|
+
export declare function rewriteRefs<T>(value: T, ids: Record<string, string>): T;
|
|
58
|
+
export interface PlanBundle {
|
|
59
|
+
plan: Record<string, unknown>;
|
|
60
|
+
/** The files that came with it, by their path inside the bundle. */
|
|
61
|
+
files: Record<string, () => Promise<Source>>;
|
|
62
|
+
close(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/** A plan from this machine: a zip, a plan.json (the files beside it come along), or a folder holding plan.json. */
|
|
65
|
+
export declare function planFromPath(path: string): Promise<PlanBundle>;
|
|
66
|
+
/** A plan from a link: a zip or a plan.json, read whole (up to 512 MB). */
|
|
67
|
+
export declare function planFromUrl(url: string, fetchImpl?: typeof fetch): Promise<PlanBundle>;
|
|
68
|
+
/** Why a path can't be read on this connection, with the way out. */
|
|
69
|
+
export declare function noLocalFiles(s: Session, companyId?: string): ToolError;
|
|
70
|
+
export declare function describeApiError(error: unknown): string;
|