@autopo/mcp 0.1.0 → 0.2.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 CHANGED
@@ -54,7 +54,7 @@ Prefer to run the server on your machine with any tool? `npx -y @autopo/mcp` wit
54
54
 
55
55
  | | |
56
56
  |---|---|
57
- | **63 tools** | the company at a glance, briefings, the inbox, tasks, the team's chats, runs, knowledge, the Studio, marketing, money, and `api_request` for every other endpoint of the REST API with `api_reference` as the manual |
57
+ | **65 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), 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 |
package/dist/api.d.ts CHANGED
@@ -29,10 +29,15 @@ export interface ApiOptions {
29
29
  export declare class Api {
30
30
  readonly baseUrl: string;
31
31
  private readonly token;
32
- private readonly fetchImpl;
32
+ readonly fetchImpl: typeof fetch;
33
33
  private readonly userAgent;
34
34
  constructor(options: ApiOptions);
35
35
  request<T = unknown>(method: string, path: string, body?: unknown, query?: Query): Promise<T>;
36
+ /**
37
+ * Send a raw body: bytes (`application/octet-stream`, the Studio's upload chunks), a Blob, or a FormData (multipart,
38
+ * the content type set by fetch). `contentType` is left unset for FormData.
39
+ */
40
+ send<T = unknown>(method: string, path: string, body?: NonNullable<RequestInit['body']>, contentType?: string, query?: Query): Promise<T>;
36
41
  get<T = unknown>(path: string, query?: Query): Promise<T>;
37
42
  post<T = unknown>(path: string, body?: unknown, query?: Query): Promise<T>;
38
43
  patch<T = unknown>(path: string, body: unknown): Promise<T>;
package/dist/api.js CHANGED
@@ -28,6 +28,15 @@ export class Api {
28
28
  this.userAgent = options.userAgent ?? 'autopoiesis-mcp';
29
29
  }
30
30
  async request(method, path, body, query) {
31
+ if (body === undefined)
32
+ return this.send(method, path, undefined, undefined, query);
33
+ return this.send(method, path, JSON.stringify(body), 'application/json', query);
34
+ }
35
+ /**
36
+ * Send a raw body: bytes (`application/octet-stream`, the Studio's upload chunks), a Blob, or a FormData (multipart,
37
+ * the content type set by fetch). `contentType` is left unset for FormData.
38
+ */
39
+ async send(method, path, body, contentType, query) {
31
40
  if (!path.startsWith('/api/')) {
32
41
  throw new ApiError(400, { error: { code: 'validation_error', message: 'Paths start with /api/ (see the API reference).' } });
33
42
  }
@@ -43,11 +52,11 @@ export class Api {
43
52
  'User-Agent': this.userAgent,
44
53
  'X-Client': 'mcp',
45
54
  };
46
- if (body !== undefined)
47
- headers['Content-Type'] = 'application/json';
55
+ if (contentType)
56
+ headers['Content-Type'] = contentType;
48
57
  const init = { method, headers };
49
58
  if (body !== undefined)
50
- init.body = JSON.stringify(body);
59
+ init.body = body;
51
60
  const response = await this.fetchImpl(url, init);
52
61
  const text = await response.text();
53
62
  let data = null;
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAQ;IACd,IAAI,CAAoB;IACxB,IAAI,CAAc;IAE3B,YAAY,MAAc,EAAE,IAAkB;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAA;QAC/G,KAAK,CAAC,OAAO,CAAC,CAAA;QACd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AAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAE,IAA8B,CAAC,OAAO,CAAC;QAAE,OAAQ,IAAyB,CAAC,OAAO,CAAA;IACzI,OAAO,EAAE,CAAA;AACX,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,OAAO,CAA8B,IAAa,EAAE,KAAK,GAAG,EAAE;IAC5E,MAAM,GAAG,GAAG,IAAI,CAAI,IAAI,CAAC,CAAA;IACzB,MAAM,KAAK,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAQ,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"}
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,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,CAAA;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6GAA6G,CAAC,CAAA;QACnI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;QACvI,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,CAAC,OAAO,IAAI,CAAC;KAChF,CAAC,CAAA;IACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,OAAO,eAAe,MAAM,IAAI,CAAC,CAAA;IACzE,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAClE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC1B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AAC7B,CAAC"}
@@ -0,0 +1,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;
package/dist/files.js ADDED
@@ -0,0 +1,378 @@
1
+ /**
2
+ * Your own files into the Studio. When the server runs on the person's machine (stdio, `npx -y @autopo/mcp`), a tool
3
+ * can take paths: the server reads them itself and uploads in 8 MB chunks through the Studio's upload API, the same
4
+ * way the web app does. Hosted, it takes URLs. Nothing travels through the MCP connection, which carries only JSON.
5
+ */
6
+ import { open, readdir, readFile, stat } from 'node:fs/promises';
7
+ import { homedir } from 'node:os';
8
+ import { basename, extname, join, relative, resolve } from 'node:path';
9
+ import { ApiError } from './api.js';
10
+ import { ToolError } from './kit.js';
11
+ import { bufferRange, handleRange, isZip, zipDataOffset, zipEntries, zipRead } from './zip.js';
12
+ export const MEDIA_TYPES = {
13
+ '.mp4': 'video/mp4', '.m4v': 'video/mp4', '.mov': 'video/quicktime', '.webm': 'video/webm', '.mkv': 'video/x-matroska', '.avi': 'video/x-msvideo',
14
+ '.mp3': 'audio/mpeg', '.wav': 'audio/wav', '.m4a': 'audio/mp4', '.aac': 'audio/aac', '.ogg': 'audio/ogg', '.flac': 'audio/flac', '.aif': 'audio/aiff', '.aiff': 'audio/aiff',
15
+ '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif', '.heic': 'image/heic', '.avif': 'image/avif', '.bmp': 'image/bmp', '.tif': 'image/tiff', '.tiff': 'image/tiff',
16
+ };
17
+ export function mediaType(name) {
18
+ return MEDIA_TYPES[extname(name).toLowerCase()];
19
+ }
20
+ const MAX_IN_MEMORY = 512 * 1024 * 1024;
21
+ export function expandHome(path) {
22
+ return path.replace(/^~(?=$|\/)/, homedir());
23
+ }
24
+ const byName = (a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' });
25
+ /** A file, or a folder's media files in name order (2 before 10). */
26
+ export async function expandPath(path) {
27
+ const full = resolve(expandHome(path));
28
+ const info = await stat(full).catch(() => null);
29
+ if (!info)
30
+ throw new ToolError(`${path}: no such file or folder on this machine (paths are read where the server runs; absolute paths are safest).`);
31
+ if (info.isFile())
32
+ return [full];
33
+ const names = (await readdir(full, { withFileTypes: true }))
34
+ .filter((d) => d.isFile() && !d.name.startsWith('.') && mediaType(d.name))
35
+ .map((d) => d.name)
36
+ .sort(byName);
37
+ if (names.length === 0)
38
+ throw new ToolError(`${path}: no images, clips or audio files in that folder.`);
39
+ return names.map((n) => join(full, n));
40
+ }
41
+ export async function pathSource(path) {
42
+ const full = resolve(expandHome(path));
43
+ const info = await stat(full).catch(() => null);
44
+ if (!info?.isFile())
45
+ throw new ToolError(`${path}: no such file on this machine.`);
46
+ const type = mediaType(full) ?? '';
47
+ return {
48
+ name: basename(full),
49
+ size: info.size,
50
+ type,
51
+ async *chunks(size) {
52
+ const handle = await open(full, 'r');
53
+ try {
54
+ let offset = 0;
55
+ while (offset < info.size) {
56
+ const want = Math.min(size, info.size - offset);
57
+ const part = await handleRange(handle, info.size).read(offset, want);
58
+ if (part.length === 0)
59
+ break;
60
+ offset += part.length;
61
+ yield part;
62
+ }
63
+ }
64
+ finally {
65
+ await handle.close();
66
+ }
67
+ },
68
+ };
69
+ }
70
+ function nameFromResponse(url, response) {
71
+ const disposition = response.headers.get('content-disposition') ?? '';
72
+ const m = /filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(disposition);
73
+ if (m?.[1])
74
+ return decodeURIComponent(m[1]);
75
+ const last = new URL(url).pathname.split('/').filter(Boolean).pop();
76
+ return last ? decodeURIComponent(last) : 'download';
77
+ }
78
+ /** A public link: streamed when its size is known, read whole (up to 512 MB) when it is not. */
79
+ export async function urlSource(url, fetchImpl = globalThis.fetch) {
80
+ let parsed;
81
+ try {
82
+ parsed = new URL(url);
83
+ }
84
+ catch {
85
+ throw new ToolError(`${url}: not a URL.`);
86
+ }
87
+ if (!['http:', 'https:'].includes(parsed.protocol))
88
+ throw new ToolError(`${url}: only http(s) links can be fetched.`);
89
+ const response = await fetchImpl(url);
90
+ if (!response.ok || !response.body)
91
+ throw new ToolError(`${url}: HTTP ${response.status}.`);
92
+ const name = nameFromResponse(url, response);
93
+ const header = (response.headers.get('content-type') ?? '').split(';')[0].trim();
94
+ const type = /^(image|video|audio)\//.test(header) ? header : (mediaType(name) ?? '');
95
+ const length = Number(response.headers.get('content-length'));
96
+ if (Number.isFinite(length) && length > 0) {
97
+ const body = response.body;
98
+ return {
99
+ name,
100
+ size: length,
101
+ type,
102
+ async *chunks(size) {
103
+ const reader = body.getReader();
104
+ let pending = [];
105
+ let have = 0;
106
+ for (;;) {
107
+ const { done, value } = await reader.read();
108
+ if (value) {
109
+ pending.push(value);
110
+ have += value.length;
111
+ }
112
+ while (have >= size || (done && have > 0)) {
113
+ const out = Buffer.concat(pending);
114
+ const piece = out.subarray(0, Math.min(size, out.length));
115
+ const rest = out.subarray(piece.length);
116
+ pending = rest.length ? [rest] : [];
117
+ have = rest.length;
118
+ yield piece;
119
+ }
120
+ if (done)
121
+ break;
122
+ }
123
+ },
124
+ };
125
+ }
126
+ const data = Buffer.from(await response.arrayBuffer());
127
+ if (data.length > MAX_IN_MEMORY)
128
+ throw new ToolError(`${url}: over 512 MB with no Content-Length; upload it from a machine instead.`);
129
+ return bytesSource(name, data, type);
130
+ }
131
+ export function bytesSource(name, data, type = mediaType(name) ?? '') {
132
+ return {
133
+ name,
134
+ size: data.length,
135
+ type,
136
+ async *chunks(size) {
137
+ for (let offset = 0; offset < data.length; offset += size)
138
+ yield data.subarray(offset, Math.min(offset + size, data.length));
139
+ },
140
+ };
141
+ }
142
+ /** A zip entry: streamed by range when stored, inflated whole when deflated. */
143
+ export function zipSource(range, entry) {
144
+ const name = basename(entry.name);
145
+ return {
146
+ name,
147
+ size: entry.size,
148
+ type: mediaType(name) ?? '',
149
+ async *chunks(size) {
150
+ if (entry.method === 0) {
151
+ const start = await zipDataOffset(range, entry);
152
+ for (let offset = 0; offset < entry.size; offset += size)
153
+ yield await range.read(start + offset, Math.min(size, entry.size - offset));
154
+ return;
155
+ }
156
+ const data = await zipRead(range, entry);
157
+ for (let offset = 0; offset < data.length; offset += size)
158
+ yield data.subarray(offset, Math.min(offset + size, data.length));
159
+ },
160
+ };
161
+ }
162
+ /** Progress notifications to the host, when it asked for them (a progressToken on the request). */
163
+ export function progressOf(ctx) {
164
+ const token = ctx.mcpReq._meta?.progressToken;
165
+ return async (progress, total, message) => {
166
+ if (token === undefined || token === null)
167
+ return;
168
+ try {
169
+ await ctx.mcpReq.notify({ method: 'notifications/progress', params: { progressToken: token, progress, ...(total !== undefined ? { total } : {}), message } });
170
+ }
171
+ catch {
172
+ /* a host that takes no progress loses nothing */
173
+ }
174
+ };
175
+ }
176
+ export const mb = (n) => `${(n / (1024 * 1024)).toFixed(n < 10 * 1024 * 1024 ? 1 : 0)} MB`;
177
+ /** One file into the library: begin, the chunks in order, complete. Returns the media (processing, soon ready). */
178
+ export async function upload(s, companyId, source, options = {}) {
179
+ if (source.size <= 0)
180
+ throw new ToolError(`${source.name}: the file is empty.`);
181
+ const begun = await s.api.post(`/api/companies/${companyId}/studio/uploads`, {
182
+ filename: source.name,
183
+ content_type: source.type,
184
+ byte_size: source.size,
185
+ ...(options.production ? { production: options.production } : {}),
186
+ });
187
+ const id = begun.media.id;
188
+ const chunkBytes = begun.chunk_bytes && begun.chunk_bytes > 0 ? begun.chunk_bytes : 8 * 1024 * 1024;
189
+ let offset = 0;
190
+ for await (const part of source.chunks(chunkBytes)) {
191
+ if (options.signal?.aborted)
192
+ throw new ToolError(`${source.name}: upload cancelled.`);
193
+ const bytes = new Uint8Array(part.buffer, part.byteOffset, part.byteLength);
194
+ await s.api.send('PUT', `/api/studio/uploads/${id}`, bytes, 'application/octet-stream', { offset });
195
+ offset += part.byteLength;
196
+ await options.onBytes?.(offset, source.size);
197
+ }
198
+ if (offset !== source.size)
199
+ throw new ToolError(`${source.name}: read ${offset} of ${source.size} bytes; the file changed while uploading.`);
200
+ let media = await s.api.post(`/api/studio/uploads/${id}/complete`);
201
+ if (options.title && options.title !== media.title)
202
+ media = await s.api.patch(`/api/studio/media/${id}`, { title: options.title });
203
+ return media;
204
+ }
205
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
206
+ /** Wait until uploads are ready (the Studio reads each file's shape and makes a thumbnail; recordings become web video). */
207
+ export async function waitReady(s, ids, options = {}) {
208
+ const out = {};
209
+ const deadline = Date.now() + (options.timeoutMs ?? 240_000);
210
+ let waiting = [...ids];
211
+ while (waiting.length > 0) {
212
+ const still = [];
213
+ for (const id of waiting) {
214
+ const media = await s.api.get(`/api/studio/media/${id}`);
215
+ if (media.status === 'ready')
216
+ out[id] = media;
217
+ else if (media.status === 'failed')
218
+ throw new ToolError(`${media.title ?? id} couldn't be read: ${media.error ?? 'the Studio could not process it'}.`);
219
+ else
220
+ still.push(id);
221
+ }
222
+ waiting = still;
223
+ if (waiting.length === 0)
224
+ break;
225
+ if (options.signal?.aborted)
226
+ throw new ToolError('Cancelled while the Studio was processing the files.');
227
+ if (Date.now() > deadline)
228
+ throw new ToolError(`${waiting.length} file(s) are still processing; try again in a minute (list_media shows their state).`);
229
+ await options.progress?.(ids.length - waiting.length, ids.length, `Processing ${ids.length - waiting.length}/${ids.length} files…`);
230
+ await sleep(2000);
231
+ }
232
+ return out;
233
+ }
234
+ export const FILE_REF = 'file:';
235
+ export const ICON_REF = 'icon:';
236
+ /** The plan's `file:…` and `icon:…` references, found like the platform does: exact path, else the file's name, else its stem. */
237
+ export function findFile(files, ref) {
238
+ const name = ref.slice(ref.indexOf(':') + 1).trim();
239
+ if (name in files)
240
+ return name;
241
+ const wanted = basename(name);
242
+ const stem = wanted.replace(/\.[^.]+$/, '');
243
+ for (const key of Object.keys(files)) {
244
+ const base = basename(key);
245
+ if (base === wanted || base.replace(/\.[^.]+$/, '') === stem)
246
+ return key;
247
+ }
248
+ return undefined;
249
+ }
250
+ export function isFileRef(value) {
251
+ return typeof value === 'string' && (value.startsWith(FILE_REF) || value.startsWith(ICON_REF));
252
+ }
253
+ /** Every file reference in a plan, deep, in order of first appearance. */
254
+ export function fileRefs(value, out = []) {
255
+ if (isFileRef(value)) {
256
+ if (!out.includes(value))
257
+ out.push(value);
258
+ }
259
+ else if (Array.isArray(value)) {
260
+ for (const v of value)
261
+ fileRefs(v, out);
262
+ }
263
+ else if (value && typeof value === 'object') {
264
+ for (const v of Object.values(value))
265
+ fileRefs(v, out);
266
+ }
267
+ return out;
268
+ }
269
+ /** The plan with each file reference replaced by the id it became. */
270
+ export function rewriteRefs(value, ids) {
271
+ if (isFileRef(value))
272
+ return (ids[value] ?? value);
273
+ if (Array.isArray(value))
274
+ return value.map((v) => rewriteRefs(v, ids));
275
+ if (value && typeof value === 'object') {
276
+ const out = {};
277
+ for (const [k, v] of Object.entries(value))
278
+ out[k] = rewriteRefs(v, ids);
279
+ return out;
280
+ }
281
+ return value;
282
+ }
283
+ function parsePlan(text, where) {
284
+ let plan;
285
+ try {
286
+ plan = JSON.parse(text);
287
+ }
288
+ catch (error) {
289
+ throw new ToolError(`${where}: the plan isn't valid JSON (${error.message}).`);
290
+ }
291
+ if (!plan || typeof plan !== 'object' || Array.isArray(plan))
292
+ throw new ToolError(`${where}: the plan is an object {title, shots, …}.`);
293
+ return plan;
294
+ }
295
+ async function walk(dir, root = dir, out = []) {
296
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
297
+ if (entry.name.startsWith('.') || entry.name === 'node_modules')
298
+ continue;
299
+ const full = join(dir, entry.name);
300
+ if (entry.isDirectory())
301
+ await walk(full, root, out);
302
+ else if (entry.isFile())
303
+ out.push(relative(root, full).split('\\').join('/'));
304
+ }
305
+ return out;
306
+ }
307
+ async function zipBundle(range, where, close) {
308
+ const entries = await zipEntries(range);
309
+ const planEntry = entries.find((e) => basename(e.name) === 'plan.json');
310
+ if (!planEntry) {
311
+ await close();
312
+ throw new ToolError(`${where}: the zip has no plan.json.`);
313
+ }
314
+ const root = planEntry.name.slice(0, -'plan.json'.length);
315
+ const plan = parsePlan((await zipRead(range, planEntry)).toString('utf8'), where);
316
+ const files = {};
317
+ for (const entry of entries) {
318
+ if (entry === planEntry || basename(entry.name).startsWith('.'))
319
+ continue;
320
+ const key = entry.name.startsWith(root) ? entry.name.slice(root.length) : entry.name;
321
+ files[key] = async () => zipSource(range, entry);
322
+ }
323
+ return { plan, files, close };
324
+ }
325
+ /** A plan from this machine: a zip, a plan.json (the files beside it come along), or a folder holding plan.json. */
326
+ export async function planFromPath(path) {
327
+ const full = resolve(expandHome(path));
328
+ const info = await stat(full).catch(() => null);
329
+ if (!info)
330
+ throw new ToolError(`${path}: no such file or folder on this machine.`);
331
+ let dir = full;
332
+ let planPath = full;
333
+ if (info.isDirectory()) {
334
+ planPath = join(full, 'plan.json');
335
+ if (!(await stat(planPath).catch(() => null)))
336
+ throw new ToolError(`${path}: no plan.json in that folder.`);
337
+ }
338
+ else {
339
+ const handle = await open(full, 'r');
340
+ const range = handleRange(handle, info.size);
341
+ if (await isZip(range))
342
+ return zipBundle(range, path, () => handle.close());
343
+ await handle.close();
344
+ dir = resolve(full, '..');
345
+ }
346
+ const plan = parsePlan(await readFile(planPath, 'utf8'), path);
347
+ const files = {};
348
+ for (const rel of await walk(dir)) {
349
+ if (join(dir, rel) === planPath)
350
+ continue;
351
+ files[rel] = () => pathSource(join(dir, rel));
352
+ }
353
+ return { plan, files, close: async () => { } };
354
+ }
355
+ /** A plan from a link: a zip or a plan.json, read whole (up to 512 MB). */
356
+ export async function planFromUrl(url, fetchImpl = globalThis.fetch) {
357
+ const response = await fetchImpl(url);
358
+ if (!response.ok)
359
+ throw new ToolError(`${url}: HTTP ${response.status}.`);
360
+ const data = Buffer.from(await response.arrayBuffer());
361
+ if (data.length > MAX_IN_MEMORY)
362
+ throw new ToolError(`${url}: over 512 MB; import it from a machine with the file instead.`);
363
+ const range = bufferRange(data);
364
+ if (await isZip(range))
365
+ return zipBundle(range, url, async () => { });
366
+ return { plan: parsePlan(data.toString('utf8'), url), files: {}, close: async () => { } };
367
+ }
368
+ /** Why a path can't be read on this connection, with the way out. */
369
+ export function noLocalFiles(s, companyId) {
370
+ const studio = companyId ? ` or drop the files into the Studio library (${s.link(`/c/${companyId}/studio`)}) and use their media ids` : '';
371
+ return new ToolError(`This connection runs in the cloud, so it can't read files on your computer. Give public URLs instead, run the server on your machine (npx -y @autopo/mcp, see https://docs.autopoiesis.app/clients)${studio}.`);
372
+ }
373
+ export function describeApiError(error) {
374
+ if (error instanceof ApiError)
375
+ return `${error.message} (HTTP ${error.status})`;
376
+ return error instanceof Error ? error.message : String(error);
377
+ }
378
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEtE,OAAO,EAAE,QAAQ,EAAE,M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EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC,CAAA;IACpE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,EAAE,CAAA;AAC1F,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,CAAU,EAAE,SAAkB;IACzD,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,IAAI,CAAC,MAAM,SAAS,SAAS,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAA;IAC1I,OAAO,IAAI,SAAS,CAAC,sMAAsM,MAAM,GAAG,CAAC,CAAA;AACvO,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,GAAG,KAAK,CAAC,OAAO,UAAU,KAAK,CAAC,MAAM,GAAG,CAAA;IAC/E,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC"}
package/dist/guides.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Guides served as resources and read by the prompts: short, in plain words, the way the platform writes. */
2
- export declare const STUDIO_GUIDE = "# The Studio, in short\n\nThe Studio makes images, clips, voice lines and music, and cuts them into videos. A video is a storyboard: shots in\norder, each with a picture (generated, footage you have, a title card, or a presenter), a line of voice-over, text on\nscreen, a length in seconds, and direction for the critic.\n\n## Who does what\n- **You** say what the video is for and how it should feel. One paragraph is enough: who it is for, what it must show,\n the one thing to feel.\n- **The platform** drafts the storyboard from that brief for free (create_video with draft on).\n- **Rose, the Creative Director** (ask_agent creative, with production set to the video id) tightens shots, writes\n better lines, picks looks and models, and proposes changes you apply with apply_chat_action.\n- **The critic** (critique_video) judges takes against each shot's direction and keeps the best.\n\n## Models and money\nstudio_overview lists every model the company can run with its price per image, per second of clip, per voice line or\nper track. update_video {style: {models: {clip, keyframe, voice, music}}} picks them for one video; studio_settings\nsets the defaults. Keyframes (one still per shot) cost cents and lock the look before clips, which cost the most. Every\ntool that spends asks you first, through your tool's own dialog, with the amount.\n\n## The order that works\n1. create_video \u2192 2. get_video, read the shots \u2192 3. ask_agent creative to tighten \u2192 4. update_video models if needed \u2192\n5. video_keyframes \u2192 wait_for_video \u2192 critique_video keyframes \u2192 6. make_video_media all \u2192 wait_for_video \u2192\ncritique_video clips \u2192 7. render_video \u2192 wait_for_video \u2192 the render link, or open_in_app video.\n\n## Shapes and lengths\n16:9 for the web and decks, 9:16 for Reels, Shorts and TikTok, 1:1 and 4:5 for feeds. Teasers run 15 to 30 seconds;\na product walkthrough 60 to 90. Fewer, longer shots read better than many short ones.\n\n## When something is missing\nget_video and wait_for_video list what still blocks a render: a shot without media, a voice line not made, music not\ncomposed. make_video_media takes a `what` (visuals, voice, music or all) to fill only that gap. A failed generation can\nbe retried with update_media {action: retry}.\n";
3
- export declare const TEASER_GUIDE = "# Making a teaser from a terminal\n\nThe loop, tool by tool (the make_a_teaser prompt runs it for you):\n\n1. brand_brain: the voice, the audience, the enemy.\n2. create_video {title, brief, aspect_ratio, seconds: 20}: a storyboard is drafted for free.\n3. get_video: read the shots. ask_agent {agent: \"creative\", production: <video id>, message: ...}: Rose tightens them;\n apply_chat_action on her proposals, or set_video_shots to write them yourself.\n4. studio_overview, then update_video {style: {models}} only if the defaults don't fit.\n5. video_keyframes: cents per shot, you confirm. wait_for_video. critique_video {stage: \"keyframes\"}.\n6. make_video_media {what: \"all\"}: the clips and voice lines, you confirm the cost. wait_for_video until nothing is\n generating. critique_video {stage: \"clips\"}.\n7. render_video (free). wait_for_video. The render link is in the result; open_in_app {what: \"video\", id} shows it.\n\nNothing is spent without the dialog. wait_for_video returns what is still missing when it cannot go on.\n";
2
+ export declare const STUDIO_GUIDE = "# The Studio, in short\n\nThe Studio makes images, clips, voice lines and music, and cuts them into videos. A video is a storyboard: shots in\norder, each with a picture (generated, footage you have, a title card, or a presenter), a line of voice-over, text on\nscreen, a length in seconds, and direction for the critic.\n\n## Who does what\n- **You** say what the video is for and how it should feel. One paragraph is enough: who it is for, what it must show,\n the one thing to feel.\n- **The platform** drafts the storyboard from that brief for free (create_video with draft on).\n- **Rose, the Creative Director** (ask_agent creative, with production set to the video id) tightens shots, writes\n better lines, picks looks and models, and proposes changes you apply with apply_chat_action.\n- **The critic** (critique_video) judges takes against each shot's direction and keeps the best.\n\n## Models and money\nstudio_overview lists every model the company can run with its price per image, per second of clip, per voice line or\nper track. update_video {style: {models: {clip, keyframe, voice, music}}} picks them for one video; studio_settings\nsets the defaults. Keyframes (one still per shot) cost cents and lock the look before clips, which cost the most. Every\ntool that spends asks you first, through your tool's own dialog, with the amount.\n\n## The order that works\n1. create_video \u2192 2. get_video, read the shots \u2192 3. ask_agent creative to tighten \u2192 4. update_video models if needed \u2192\n5. video_keyframes \u2192 wait_for_video \u2192 critique_video keyframes \u2192 6. make_video_media all \u2192 wait_for_video \u2192\ncritique_video clips \u2192 7. render_video \u2192 wait_for_video \u2192 the render link, or open_in_app video.\n\n## Shapes and lengths\n16:9 for the web and decks, 9:16 for Reels, Shorts and TikTok, 1:1 and 4:5 for feeds. Teasers run 15 to 30 seconds;\na product walkthrough 60 to 90. Fewer, longer shots read better than many short ones.\n\n## Your own files\nRecordings, screen captures, photos, a voice track, music: upload_media puts them in the library. When the server runs\non your machine (npx -y @autopo/mcp, what Claude Code, Codex and Cursor launch), each file is a path, or a folder of\nthem; hosted, each is a public URL. With a video, in_order puts the files on the shots that have no picture yet, and\nshot puts one file on one shot (a clip or image as its footage, audio as its voice line); attach_media does the same\nfor something already in the library. A whole plan with its files (a zip with plan.json, or the folder) goes in with\nimport_video_plan {path}. Files never travel through the MCP connection: the server uploads them to the platform.\n\n## When something is missing\nget_video and wait_for_video list what still blocks a render: a shot without media, a voice line not made, music not\ncomposed. make_video_media takes a `what` (visuals, voice, music or all) to fill only that gap. A failed generation can\nbe retried with update_media {action: retry}.\n";
3
+ export declare const TEASER_GUIDE = "# Making a teaser from a terminal\n\nThe loop, tool by tool (the make_a_teaser prompt runs it for you):\n\n1. brand_brain: the voice, the audience, the enemy.\n2. create_video {title, brief, aspect_ratio, seconds: 20}: a storyboard is drafted for free.\n3. get_video: read the shots. ask_agent {agent: \"creative\", production: <video id>, message: ...}: Rose tightens them;\n apply_chat_action on her proposals, or set_video_shots to write them yourself.\n4. studio_overview, then update_video {style: {models}} only if the defaults don't fit.\n5. video_keyframes: cents per shot, you confirm. wait_for_video. critique_video {stage: \"keyframes\"}.\n6. make_video_media {what: \"all\"}: the clips and voice lines, you confirm the cost. wait_for_video until nothing is\n generating. critique_video {stage: \"clips\"}.\n7. render_video (free). wait_for_video. The render link is in the result; open_in_app {what: \"video\", id} shows it.\n\nFootage you already have (recordings, screen captures): upload_media {video, files: [{path: \"footage/\"}], in_order: true}\nputs the files on the shots in order, so nothing is generated for them; a whole plan with its files comes in with\nimport_video_plan {path: \"teaser.zip\"}. Paths work when the server runs on your machine; hosted, give URLs.\n\nNothing is spent without the dialog. wait_for_video returns what is still missing when it cannot go on.\n";