@modootoday/datalab-extension-mcp 1.16.10 → 1.17.1

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.en.md CHANGED
@@ -61,7 +61,7 @@ One command finds **every** AI app on your computer and connects them automatica
61
61
  2. **Paste this command and press Enter.** The helper installs this version of the connector on your computer (`npm install -g`) and registers that installed copy with your AI apps, so an app does not download the connector again each time it starts. Once connected, the connector checks the canonical release and installs a newer version for the next start. Diagnostic environments can opt out with `--no-self-update`.
62
62
 
63
63
  ```
64
- npx -y @modootoday/datalab-extension-mcp@1.16.10 install
64
+ npx -y @modootoday/datalab-extension-mcp@1.17.1 install
65
65
  ```
66
66
 
67
67
  Lines of English scrolling by is normal. This installs the connector and adds only our entry to your AI apps' settings — it touches nothing else. Without permission for global npm installs, it falls back to having each app download and run the connector at start (a slower start).
@@ -262,7 +262,7 @@ Start it again after a full quit and it picks the tools up. If they still aren't
262
262
  - **When the connection disappears** — run the very command you used at the start once more; it safely re-registers. (Some AI apps clean up their settings file and drop the connection.)
263
263
 
264
264
  ```
265
- npx -y @modootoday/datalab-extension-mcp@1.16.10 install
265
+ npx -y @modootoday/datalab-extension-mcp@1.17.1 install
266
266
  ```
267
267
 
268
268
  - **`'npx' is not recognized...`** — Node.js isn't installed. Follow "No Node.js?" in Step 2, then run the command again.
@@ -292,7 +292,7 @@ Start it again after a full quit and it picks the tools up. If they still aren't
292
292
  1. Run this in a terminal (it removes the entries registered in your AI apps).
293
293
 
294
294
  ```
295
- npx -y @modootoday/datalab-extension-mcp@1.16.10 uninstall
295
+ npx -y @modootoday/datalab-extension-mcp@1.17.1 uninstall
296
296
  ```
297
297
 
298
298
  2. Turn **MCP 연결** off in the extension settings. The panel is the bridge, so with it off a leftover config line can look nothing up.
package/README.md CHANGED
@@ -55,7 +55,7 @@ Claude 같은 AI 앱을 데이터랩툴즈에 연결해 주는 작은 무료 프
55
55
  2. **아래 명령을 붙여넣고 Enter를 눌러요.** 도우미는 이 버전의 연결 프로그램을 이 컴퓨터에 설치(`npm install -g`)하고, AI 앱이 그 설치본을 바로 실행하도록 등록해요. 그래서 AI 앱이 시작할 때 연결 프로그램을 다시 내려받지 않아요. 연결이 열린 뒤 정본 릴리스를 확인해 새 버전이 있으면 설치해 두고, 다음 시작부터 그 버전을 써요. 진단 환경에서는 `--no-self-update`로 이 업데이트를 끌 수 있어요.
56
56
 
57
57
  ```
58
- npx -y @modootoday/datalab-extension-mcp@1.16.10 install
58
+ npx -y @modootoday/datalab-extension-mcp@1.17.1 install
59
59
  ```
60
60
 
61
61
  영어 글자가 여러 줄 올라오는 건 정상이에요. 이 명령은 연결 프로그램을 설치하고 AI 앱 설정에 우리 항목만 더할 뿐, 다른 건 건드리지 않아요. npm 전역 설치 권한이 없으면 예전처럼 AI 앱이 시작할 때마다 내려받아 실행하도록 연결해요(시작이 조금 느려요).
@@ -230,7 +230,7 @@ AI가 "그런 기능은 없다" 고 답하면, **"숨은 도구를 찾아보고
230
230
  - **연결이 사라졌을 때** — 처음 실행했던 그 명령을 한 번 더 실행하면 안전하게 다시 등록돼요. (일부 AI 앱이 설정 파일을 정리하며 연결을 지우기도 해요.)
231
231
 
232
232
  ```
233
- npx -y @modootoday/datalab-extension-mcp@1.16.10 install
233
+ npx -y @modootoday/datalab-extension-mcp@1.17.1 install
234
234
  ```
235
235
 
236
236
  - **`'npx'을(는) 내부 또는 외부 명령...`** — Node.js가 없는 거예요. 위 2단계의 "Node.js가 없다면"을 따라 설치한 뒤 다시 실행해요.
@@ -260,7 +260,7 @@ AI가 "그런 기능은 없다" 고 답하면, **"숨은 도구를 찾아보고
260
260
  1. 터미널에서 아래 명령을 실행해요(AI 앱에 등록된 설정을 지워 줘요).
261
261
 
262
262
  ```
263
- npx -y @modootoday/datalab-extension-mcp@1.16.10 uninstall
263
+ npx -y @modootoday/datalab-extension-mcp@1.17.1 uninstall
264
264
  ```
265
265
 
266
266
  2. 확장 설정에서 **MCP 연결을 꺼요.** 패널이 브릿지라, 꺼 두면 어딘가 설정 줄이 남아 있어도 AI 앱이 아무것도 조회할 수 없어요.
@@ -2,17 +2,29 @@ import {
2
2
  __export
3
3
  } from "./chunk-MLKGABMK.js";
4
4
 
5
- // ../mcp-server/dist/chunk-NSAXEEHJ.js
5
+ // ../mcp-server/dist/chunk-4WAZJ5ZG.js
6
6
  import { createHash } from "crypto";
7
7
  import { createHash as createHash2, randomUUID } from "crypto";
8
- import { mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
8
+ import { createReadStream, createWriteStream } from "fs";
9
+ import {
10
+ mkdir,
11
+ open as open2,
12
+ readFile,
13
+ readdir,
14
+ rename,
15
+ rm,
16
+ stat,
17
+ writeFile
18
+ } from "fs/promises";
9
19
  import { join } from "path";
20
+ import { Transform } from "stream";
21
+ import { pipeline } from "stream/promises";
10
22
  import {
11
23
  createServer
12
24
  } from "http";
13
- import { pipeline } from "stream/promises";
25
+ import { pipeline as pipeline2 } from "stream/promises";
14
26
  import { constants } from "fs";
15
- import { lstat, open as open2 } from "fs/promises";
27
+ import { lstat, open as open3 } from "fs/promises";
16
28
  import { basename, isAbsolute } from "path";
17
29
  import { Readable } from "stream";
18
30
  import {
@@ -35,7 +47,7 @@ import { timingSafeEqual as timingSafeEqual2 } from "crypto";
35
47
  import { createRequire } from "module";
36
48
  import { join as join5 } from "path";
37
49
  import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
38
- import { appendFile, mkdir as mkdir2, rename, rm as rm2, stat } from "fs/promises";
50
+ import { appendFile, mkdir as mkdir2, rename as rename2, rm as rm2, stat as stat2 } from "fs/promises";
39
51
  import { join as join4 } from "path";
40
52
  var __defProp = Object.defineProperty;
41
53
  var __export2 = (target, all) => {
@@ -20103,6 +20115,9 @@ var TOOL_TIERS = Object.freeze({
20103
20115
  photo_auto_collage: "write",
20104
20116
  photo_slideshow_set: "write",
20105
20117
  photo_upscale: "write",
20118
+ photo_inpaint: "write",
20119
+ photo_group: "write",
20120
+ photo_ungroup: "write",
20106
20121
  // ── Gallery: the free way in ────────────────────────────────────
20107
20122
  //
20108
20123
  // Destructive because it reads a path off the user's disk, the same
@@ -20162,6 +20177,7 @@ var TOOL_TIERS = Object.freeze({
20162
20177
  video_template_list: "read",
20163
20178
  video_template_apply: "destructive",
20164
20179
  video_post_import: "write",
20180
+ video_source_add: "write",
20165
20181
  // ── Post editor: reads ──────────────────────────────────────────
20166
20182
  editor_read: "read",
20167
20183
  editor_read_structure: "read",
@@ -20255,6 +20271,14 @@ var TOOL_TIERS = Object.freeze({
20255
20271
  editor_set_list: "write",
20256
20272
  editor_set_cover_image: "write",
20257
20273
  editor_insert_link_card: "write",
20274
+ // Runs the caller's own code in the page, so it can do anything the page can.
20275
+ editor_debug: "destructive",
20276
+ editor_edit_table: "write",
20277
+ editor_set_image_link: "write",
20278
+ editor_set_image_caption: "write",
20279
+ editor_insert_place: "write",
20280
+ editor_insert_file: "write",
20281
+ editor_insert_video: "write",
20258
20282
  editor_capture_document: "write",
20259
20283
  editor_insert_component: "write",
20260
20284
  editor_replace: "destructive"
@@ -20719,6 +20743,32 @@ function digestToken(token) {
20719
20743
  return createHash("sha256").update(token, "utf8").digest("hex");
20720
20744
  }
20721
20745
  var DEFAULT_RATE_LIMIT = BRIDGE_LIMITS;
20746
+ var STAGE_READ_TOOLS = /* @__PURE__ */ new Set([
20747
+ "video_source_add",
20748
+ "photo_node_update",
20749
+ "photo_apply",
20750
+ "video_node_update",
20751
+ "video_scene_update",
20752
+ "video_pip_update",
20753
+ "video_apply"
20754
+ ]);
20755
+ var STAGE_GRANT_TTL_MS = 30 * 60 * 1e3;
20756
+ var STAGE_GRANT_MAX = 64;
20757
+ var STAGE_HANDLE = /^stage:[0-9a-f]{32}$/;
20758
+ function stageHandlesIn(value, out = /* @__PURE__ */ new Set()) {
20759
+ if (typeof value === "string") {
20760
+ if (STAGE_HANDLE.test(value)) out.add(value);
20761
+ return out;
20762
+ }
20763
+ if (Array.isArray(value)) {
20764
+ for (const item of value) stageHandlesIn(item, out);
20765
+ return out;
20766
+ }
20767
+ if (typeof value === "object" && value !== null) {
20768
+ for (const item of Object.values(value)) stageHandlesIn(item, out);
20769
+ }
20770
+ return out;
20771
+ }
20722
20772
  var FILE_TOOLS = /* @__PURE__ */ new Set([
20723
20773
  "editor_insert_image",
20724
20774
  "gallery_image_add",
@@ -20823,6 +20873,7 @@ var Bridge = class {
20823
20873
  fileRequestBound: auth.fileRequestBound,
20824
20874
  streamActive: false,
20825
20875
  filePermits: /* @__PURE__ */ new Map(),
20876
+ stageGrants: /* @__PURE__ */ new Map(),
20826
20877
  pending: new PendingRegistry({
20827
20878
  now: this.#deps.now,
20828
20879
  timeoutMs: this.#deps.timeoutMs,
@@ -21001,6 +21052,31 @@ var Bridge = class {
21001
21052
  requestBound: true
21002
21053
  };
21003
21054
  }
21055
+ /**
21056
+ * A range read of a sealed handle some tool call in this session named.
21057
+ * Not consumed: a transfer is many reads, and the grant ends with its TTL or
21058
+ * the session.
21059
+ */
21060
+ authorizeStageRead(input22) {
21061
+ const entry = [...this.#sessions.values()].find(
21062
+ (candidate) => candidate.session.sessionId === input22.sessionId
21063
+ );
21064
+ if (!entry || !entry.streamActive) {
21065
+ return { ok: false, reason: "file_session_not_live" };
21066
+ }
21067
+ if (typeof input22.token !== "string" || input22.token.length === 0 || !this.#fileCredential(entry, input22.token)) {
21068
+ return { ok: false, reason: "file_session_token_mismatch" };
21069
+ }
21070
+ const now = (this.#deps.now ?? Date.now)();
21071
+ const expiresAt = entry.stageGrants.get(input22.handle);
21072
+ if (expiresAt === void 0 || expiresAt <= now) {
21073
+ entry.stageGrants.delete(input22.handle);
21074
+ return { ok: false, reason: "stage_not_granted" };
21075
+ }
21076
+ entry.stageGrants.delete(input22.handle);
21077
+ entry.stageGrants.set(input22.handle, now + STAGE_GRANT_TTL_MS);
21078
+ return { ok: true, key: entry.key, sessionId: entry.session.sessionId };
21079
+ }
21004
21080
  consumeFileRequest(auth) {
21005
21081
  const entry = this.#sessions.get(auth.key);
21006
21082
  if (!entry || !entry.streamActive || entry.session.sessionId !== auth.sessionId) {
@@ -21385,6 +21461,21 @@ var Bridge = class {
21385
21461
  const named = req.method === "tools/call" ? req.name : void 0;
21386
21462
  const fileTool = firstFileTool(named, delegatedTool);
21387
21463
  const fileArgs = delegatedArgs ?? (req.method === "tools/call" ? req.args : null);
21464
+ const calledTool = typeof delegatedTool === "string" ? delegatedTool : named;
21465
+ if (entry.fileRequestBound && typeof calledTool === "string" && STAGE_READ_TOOLS.has(calledTool)) {
21466
+ const now = (this.#deps.now ?? Date.now)();
21467
+ for (const [handle, expiresAt] of entry.stageGrants) {
21468
+ if (expiresAt <= now) entry.stageGrants.delete(handle);
21469
+ }
21470
+ for (const handle of stageHandlesIn(fileArgs)) {
21471
+ entry.stageGrants.delete(handle);
21472
+ entry.stageGrants.set(handle, now + STAGE_GRANT_TTL_MS);
21473
+ }
21474
+ for (const handle of entry.stageGrants.keys()) {
21475
+ if (entry.stageGrants.size <= STAGE_GRANT_MAX) break;
21476
+ entry.stageGrants.delete(handle);
21477
+ }
21478
+ }
21388
21479
  const path = fileTool !== null && ARTIFACT_TOOLS.has(fileTool) ? artifactPath(fileArgs?.["job"]) : fileArgs?.["path"] ?? stagedHandle(fileTool, fileArgs?.["handle"]);
21389
21480
  if (entry.fileRequestBound && fileTool !== null && typeof path === "string" && path.length > 0) {
21390
21481
  entry.filePermits.set(id, {
@@ -21429,7 +21520,74 @@ var BridgeError = class extends Error {
21429
21520
  if (timing) this.timing = timing;
21430
21521
  }
21431
21522
  };
21432
- var MAX_STAGE_BYTES = 10 * 1024 * 1024;
21523
+ var MIB = 1024 * 1024;
21524
+ var MAX_STAGE_BYTES = 500 * MIB;
21525
+ var STAGE_KIND_LIMITS = {
21526
+ image: 10 * MIB,
21527
+ video: 500 * MIB,
21528
+ audio: 500 * MIB,
21529
+ cube: 2 * MIB,
21530
+ other: 10 * MIB
21531
+ };
21532
+ var HEAD_BYTES = 16 * 1024;
21533
+ var IMAGE_BRANDS = /* @__PURE__ */ new Set([
21534
+ "heic",
21535
+ "heix",
21536
+ "heim",
21537
+ "heis",
21538
+ "mif1",
21539
+ "msf1",
21540
+ "avif",
21541
+ "avis"
21542
+ ]);
21543
+ var TooLarge = class extends Error {
21544
+ };
21545
+ function ascii(head, from, to) {
21546
+ return String.fromCharCode(...head.subarray(from, to));
21547
+ }
21548
+ function stageKindOf(head) {
21549
+ const riff = ascii(head, 0, 4) === "RIFF" ? ascii(head, 8, 12) : "";
21550
+ if (riff === "WEBP") return "image";
21551
+ if (riff === "WAVE") return "audio";
21552
+ if (head[0] === 137 && ascii(head, 1, 4) === "PNG") return "image";
21553
+ if (head[0] === 255 && head[1] === 216 && head[2] === 255) return "image";
21554
+ if (ascii(head, 0, 4) === "GIF8") return "image";
21555
+ if (ascii(head, 4, 8) === "ftyp") {
21556
+ const brand = ascii(head, 8, 12);
21557
+ if (IMAGE_BRANDS.has(brand)) return "image";
21558
+ return brand === "M4A " || brand === "M4B " ? "audio" : "video";
21559
+ }
21560
+ if (head[0] === 26 && head[1] === 69 && head[2] === 223) return "video";
21561
+ if (ascii(head, 0, 4) === "OggS" || ascii(head, 0, 4) === "fLaC") {
21562
+ return "audio";
21563
+ }
21564
+ if (ascii(head, 0, 3) === "ID3") return "audio";
21565
+ if (head[0] === 255 && ((head[1] ?? 0) & 224) === 224) return "audio";
21566
+ if (new TextDecoder().decode(head).includes("LUT_3D_SIZE")) return "cube";
21567
+ return "other";
21568
+ }
21569
+ async function readHead(path) {
21570
+ const file22 = await open2(path, "r");
21571
+ try {
21572
+ const buf = Buffer.alloc(HEAD_BYTES);
21573
+ const { bytesRead } = await file22.read(buf, 0, HEAD_BYTES, 0);
21574
+ return buf.subarray(0, bytesRead);
21575
+ } finally {
21576
+ await file22.close();
21577
+ }
21578
+ }
21579
+ async function hashFile(path) {
21580
+ const hash22 = createHash2("sha256");
21581
+ let bytes = 0;
21582
+ for await (const chunk of createReadStream(path)) {
21583
+ const buf = chunk;
21584
+ bytes += buf.byteLength;
21585
+ hash22.update(buf);
21586
+ }
21587
+ return { sha256: hash22.digest("hex"), bytes };
21588
+ }
21589
+ var MAX_RANGE_BYTES = MIB;
21590
+ var HANDLE = /^stage:([0-9a-f]{32})$/;
21433
21591
  var DEFAULT_TOKEN_TTL_MS = 30 * 60 * 1e3;
21434
21592
  var STAGE_CAPABILITY = "datalab-mcp-stage-v1";
21435
21593
  function refuse(reason, retryable, message) {
@@ -21445,6 +21603,15 @@ function createMediaStage(opts) {
21445
21603
  const blobDir = join(opts.root, "blob");
21446
21604
  const tokens = /* @__PURE__ */ new Map();
21447
21605
  const active = /* @__PURE__ */ new Map();
21606
+ const received = /* @__PURE__ */ new Map();
21607
+ const receiving = /* @__PURE__ */ new Set();
21608
+ void readdir(blobDir).then(
21609
+ (names) => Promise.all(
21610
+ names.filter(
21611
+ (name) => name.endsWith(".part") && !receiving.has(name.slice(0, -5))
21612
+ ).map((name) => rm(join(blobDir, name), { force: true }))
21613
+ )
21614
+ ).catch(() => void 0);
21448
21615
  const keyOf = (j) => segment(j.blogId, j.runId, j.actionId, j.jobId);
21449
21616
  const ledgerPath = (key) => join(ledgerDir, `${key}.json`);
21450
21617
  const blobPath = (key) => join(blobDir, key);
@@ -21517,25 +21684,52 @@ function createMediaStage(opts) {
21517
21684
  tokens.delete(token);
21518
21685
  return { ok: false, reason: "upload_expired" };
21519
21686
  }
21687
+ if (receiving.has(held.key)) {
21688
+ return { ok: false, reason: "upload_in_progress" };
21689
+ }
21690
+ receiving.add(held.key);
21520
21691
  active.set(held.key, (active.get(held.key) ?? 0) + 1);
21521
- try {
21522
- await mkdir(blobDir, { recursive: true });
21523
- const chunks = [];
21524
- let total = 0;
21525
- for await (const chunk of body) {
21692
+ const part = `${blobPath(held.key)}.part`;
21693
+ const hash22 = createHash2("sha256");
21694
+ let total = 0;
21695
+ let limit = MAX_STAGE_BYTES;
21696
+ const head = [];
21697
+ let headBytes = 0;
21698
+ const meter = new Transform({
21699
+ transform(chunk, _enc, done) {
21526
21700
  const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
21527
21701
  total += buf.byteLength;
21528
- if (total > MAX_STAGE_BYTES) {
21529
- return { ok: false, reason: "too_large" };
21702
+ if (headBytes < HEAD_BYTES) {
21703
+ head.push(buf);
21704
+ headBytes += buf.byteLength;
21705
+ if (headBytes >= HEAD_BYTES) {
21706
+ limit = STAGE_KIND_LIMITS[stageKindOf(Buffer.concat(head))];
21707
+ head.length = 0;
21708
+ }
21709
+ }
21710
+ if (total > limit) {
21711
+ done(new TooLarge());
21712
+ return;
21530
21713
  }
21531
- chunks.push(buf);
21714
+ hash22.update(buf);
21715
+ done(null, buf);
21532
21716
  }
21533
- await writeFile(blobPath(held.key), Buffer.concat(chunks));
21717
+ });
21718
+ try {
21719
+ await mkdir(blobDir, { recursive: true });
21720
+ await pipeline(body, meter, createWriteStream(part));
21721
+ await rename(part, blobPath(held.key));
21722
+ received.set(held.key, { sha256: hash22.digest("hex"), bytes: total });
21534
21723
  return { ok: true, bytes: total };
21724
+ } catch (err) {
21725
+ await rm(part, { force: true }).catch(() => void 0);
21726
+ if (err instanceof TooLarge) return { ok: false, reason: "too_large" };
21727
+ return { ok: false, reason: "write_failed" };
21535
21728
  } finally {
21729
+ receiving.delete(held.key);
21536
21730
  const left = (active.get(held.key) ?? 1) - 1;
21731
+ if (left > 0) active.set(held.key, left);
21537
21732
  if (left <= 0) active.delete(held.key);
21538
- else active.set(held.key, left);
21539
21733
  }
21540
21734
  },
21541
21735
  async commit(req) {
@@ -21559,40 +21753,55 @@ function createMediaStage(opts) {
21559
21753
  handle: row.handle,
21560
21754
  bytes: row.bytes ?? 0,
21561
21755
  sha256: row.sha256,
21756
+ kind: row.kind ?? "other",
21562
21757
  capabilityVersion: STAGE_CAPABILITY
21563
21758
  };
21564
21759
  }
21565
21760
  return refuse("already_sealed", false, "\uC774\uBBF8 \uBD09\uC778\uB41C \uC790\uC0B0\uC774\uC5D0\uC694.");
21566
21761
  }
21567
- let received;
21762
+ let digest;
21568
21763
  try {
21569
- received = await readFile(blobPath(key));
21764
+ digest = received.get(key) ?? await hashFile(blobPath(key));
21570
21765
  } catch {
21571
21766
  return refuse("upload_expired", false, "\uBC1B\uC740 \uBC14\uC774\uD2B8\uAC00 \uC5C6\uC5B4\uC694.");
21572
21767
  }
21573
- const actual = createHash2("sha256").update(received).digest("hex");
21574
- if (actual !== req.sha256 || received.byteLength !== req.bytes) {
21768
+ const actual = digest.sha256;
21769
+ if (actual !== req.sha256 || digest.bytes !== req.bytes) {
21575
21770
  return refuse(
21576
21771
  "hash_mismatch",
21577
21772
  false,
21578
21773
  "\uBC1B\uC740 \uBC14\uC774\uD2B8\uAC00 \uC54C\uB824\uC8FC\uC2E0 \uAC83\uACFC \uB2EC\uB77C\uC694."
21579
21774
  );
21580
21775
  }
21776
+ const kind = stageKindOf(await readHead(blobPath(key)));
21777
+ if (digest.bytes > STAGE_KIND_LIMITS[kind]) {
21778
+ received.delete(key);
21779
+ await rm(blobPath(key), { force: true });
21780
+ const cap = Math.round(STAGE_KIND_LIMITS[kind] / MIB);
21781
+ return refuse(
21782
+ "too_large",
21783
+ false,
21784
+ `\uC774 \uC885\uB958\uC758 \uD30C\uC77C\uC740 ${cap}MB \uAE4C\uC9C0 \uC62C\uB9B4 \uC218 \uC788\uC5B4\uC694.`
21785
+ );
21786
+ }
21581
21787
  const handle = `stage:${key}`;
21582
21788
  await writeRow(key, {
21583
21789
  state: "SEALED",
21584
21790
  fence: req.fence,
21585
21791
  jobId: req.jobId,
21586
21792
  sha256: actual,
21587
- bytes: received.byteLength,
21793
+ bytes: digest.bytes,
21588
21794
  handle,
21795
+ kind,
21589
21796
  at: now()
21590
21797
  });
21798
+ received.delete(key);
21591
21799
  return {
21592
21800
  state: "SEALED",
21593
21801
  handle,
21594
- bytes: received.byteLength,
21802
+ bytes: digest.bytes,
21595
21803
  sha256: actual,
21804
+ kind,
21596
21805
  capabilityVersion: STAGE_CAPABILITY
21597
21806
  };
21598
21807
  },
@@ -21609,7 +21818,7 @@ function createMediaStage(opts) {
21609
21818
  }
21610
21819
  let bytesReceived = 0;
21611
21820
  try {
21612
- bytesReceived = (await readFile(blobPath(key))).byteLength;
21821
+ bytesReceived = (await stat(blobPath(key))).size;
21613
21822
  } catch {
21614
21823
  bytesReceived = 0;
21615
21824
  }
@@ -21652,9 +21861,29 @@ function createMediaStage(opts) {
21652
21861
  async readSealed(handle) {
21653
21862
  return readFile(blobPath(handle.replace(/^stage:/, "")));
21654
21863
  },
21864
+ async sealedInfo(handle) {
21865
+ const key = HANDLE.exec(handle)?.[1];
21866
+ if (!key) return null;
21867
+ const row = await readRow(key);
21868
+ if (!row || row === "unreadable" || row.state !== "SEALED") return null;
21869
+ return { bytes: row.bytes ?? 0, kind: row.kind ?? "other" };
21870
+ },
21871
+ async readRange(handle, offset, length) {
21872
+ const key = HANDLE.exec(handle)?.[1];
21873
+ if (!key) throw new Error("not a stage handle");
21874
+ const want = Math.max(0, Math.min(length, MAX_RANGE_BYTES));
21875
+ const file22 = await open2(blobPath(key), "r");
21876
+ try {
21877
+ const buf = Buffer.alloc(want);
21878
+ const { bytesRead } = await file22.read(buf, 0, want, offset);
21879
+ return buf.subarray(0, bytesRead);
21880
+ } finally {
21881
+ await file22.close();
21882
+ }
21883
+ },
21655
21884
  async assetCount() {
21656
21885
  try {
21657
- return (await readdir(blobDir)).length;
21886
+ return (await readdir(blobDir)).filter((n) => !n.endsWith(".part")).length;
21658
21887
  } catch {
21659
21888
  return 0;
21660
21889
  }
@@ -21663,7 +21892,9 @@ function createMediaStage(opts) {
21663
21892
  const out = [];
21664
21893
  for (const dir of [ledgerDir, blobDir]) {
21665
21894
  try {
21666
- for (const name of await readdir(dir)) out.push(join(dir, name));
21895
+ for (const name of await readdir(dir)) {
21896
+ if (!name.endsWith(".part")) out.push(join(dir, name));
21897
+ }
21667
21898
  } catch {
21668
21899
  }
21669
21900
  }
@@ -21677,6 +21908,7 @@ var MEDIA_TOOL_NAMES = [
21677
21908
  "media_stage_status",
21678
21909
  "media_stage_cancel"
21679
21910
  ];
21911
+ var MEDIA_UPLOAD_PATH = "/media/upload";
21680
21912
  function isMediaTool(name) {
21681
21913
  return MEDIA_TOOL_NAMES.includes(name);
21682
21914
  }
@@ -21706,7 +21938,7 @@ function mediaToolDescriptors() {
21706
21938
  return [
21707
21939
  {
21708
21940
  name: "media_stage_begin",
21709
- description: "\uC774\uBBF8\uC9C0\uB97C \uC62C\uB9B4 \uC790\uB9AC\uB97C \uC5F0\uB2E4. \uBC14\uC774\uD2B8\uB294 \uC5EC\uAE30\uB85C \uBCF4\uB0B4\uC9C0 \uC54A\uACE0, \uB3CC\uB824\uBC1B\uC740 uploadUrl \uC5D0 uploadToken \uC744 \uC2E4\uC5B4 \uC2A4\uD2B8\uB9BC\uC73C\uB85C \uBCF4\uB0B8\uB2E4. \uAC19\uC740 jobId \uB85C \uB2E4\uC2DC \uBD88\uB7EC\uB3C4 \uC790\uB9AC\uB294 \uD558\uB098\uB2E4.",
21941
+ description: "\uC774\uBBF8\uC9C0 \xB7 \uC601\uC0C1 \xB7 \uC18C\uB9AC \xB7 LUT(.cube) \uD30C\uC77C\uC744 \uC62C\uB9B4 \uC790\uB9AC\uB97C \uC5F0\uB2E4. \uBC14\uC774\uD2B8\uB294 \uC5EC\uAE30\uB85C \uBCF4\uB0B4\uC9C0 \uC54A\uACE0, \uC774 MCP \uC5D4\uB4DC\uD3EC\uC778\uD2B8\uC640 \uAC19\uC740 \uC8FC\uC18C\uC758 \uB3CC\uB824\uBC1B\uC740 uploadPath(/media/upload)\uB85C uploadMethod(POST) \uD574\uC11C Authorization: Bearer <uploadToken> \uD5E4\uB354\uC640 \uD568\uAED8 \uBCF8\uBB38\uC5D0 \uBC14\uC774\uD2B8\uB97C \uC2A4\uD2B8\uB9BC\uC73C\uB85C \uBCF4\uB0B8\uB2E4. \uAC19\uC740 jobId \uB85C \uB2E4\uC2DC \uBD88\uB7EC\uB3C4 \uC790\uB9AC\uB294 \uD558\uB098\uB2E4. \uC0C1\uD55C\uC740 \uC601\uC0C1 \xB7 \uC18C\uB9AC 500MB, \uC774\uBBF8\uC9C0 10MB, LUT 2MB.",
21710
21942
  inputSchema: schema(
21711
21943
  {
21712
21944
  declaredBytes: { type: "integer" },
@@ -21717,7 +21949,7 @@ function mediaToolDescriptors() {
21717
21949
  },
21718
21950
  {
21719
21951
  name: "media_stage_commit",
21720
- description: "\uC62C\uB9B0 \uBC14\uC774\uD2B8\uB97C \uAC80\uC99D\uD558\uACE0 \uBD09\uC778\uD55C\uB2E4. \uBC1B\uC740 \uAC83\uC774 \uC54C\uB824\uC900 \uD574\uC2DC\xB7\uD06C\uAE30\uC640 \uB2E4\uB974\uBA74 \uBD09\uC778\uD558\uC9C0 \uC54A\uB294\uB2E4. \uAC19\uC740 \uBC14\uC774\uD2B8\uB85C \uB2E4\uC2DC \uBD80\uB974\uBA74 \uAC19\uC740 handle \uC744 \uB3CC\uB824\uC900\uB2E4.",
21952
+ description: "\uC62C\uB9B0 \uBC14\uC774\uD2B8\uB97C \uAC80\uC99D\uD558\uACE0 \uBD09\uC778\uD55C\uB2E4. \uBC1B\uC740 \uAC83\uC774 \uC54C\uB824\uC900 \uD574\uC2DC\xB7\uD06C\uAE30\uC640 \uB2E4\uB974\uBA74 \uBD09\uC778\uD558\uC9C0 \uC54A\uB294\uB2E4. \uAC19\uC740 \uBC14\uC774\uD2B8\uB85C \uB2E4\uC2DC \uBD80\uB974\uBA74 \uAC19\uC740 handle \uC744 \uB3CC\uB824\uC900\uB2E4. \uD30C\uC77C \uBA38\uB9AC\uB85C \uC54C\uC544\uB0B8 \uC885\uB958(image \xB7 video \xB7 audio \xB7 cube \xB7 other)\uB97C kind \uB85C \uD568\uAED8 \uB3CC\uB824\uC900\uB2E4.",
21721
21953
  inputSchema: schema(
21722
21954
  { sha256: { type: "string" }, bytes: { type: "integer" } },
21723
21955
  ["sha256", "bytes"]
@@ -21761,7 +21993,9 @@ async function callMediaTool(stage, name, args) {
21761
21993
  switch (name) {
21762
21994
  case "media_stage_begin": {
21763
21995
  const declaredBytes = typeof args["declaredBytes"] === "number" ? args["declaredBytes"] : 0;
21764
- return stage.begin({ ...job, declaredBytes });
21996
+ const begun = await stage.begin({ ...job, declaredBytes });
21997
+ if (begun.state !== "OPEN") return begun;
21998
+ return { ...begun, uploadMethod: "POST", uploadPath: MEDIA_UPLOAD_PATH };
21765
21999
  }
21766
22000
  case "media_stage_commit": {
21767
22001
  const sha256 = typeof args["sha256"] === "string" ? args["sha256"] : "";
@@ -22039,7 +22273,7 @@ async function openLocalImage(path) {
22039
22273
  message: "\uC774 \uD658\uACBD\uC5D0\uC11C\uB294 \uD30C\uC77C\uC744 \uC548\uC804\uD558\uAC8C \uC5F4 \uC218 \uC5C6\uC5B4\uC694."
22040
22274
  };
22041
22275
  }
22042
- handle = await open2(
22276
+ handle = await open3(
22043
22277
  path,
22044
22278
  constants.O_RDONLY | (process.platform === "win32" ? 0 : noFollow)
22045
22279
  );
@@ -22498,7 +22732,7 @@ function createHttpBridge(opts) {
22498
22732
  });
22499
22733
  owner = current;
22500
22734
  owner.fileStreams.add(source);
22501
- await pipeline(source, res);
22735
+ await pipeline2(source, res);
22502
22736
  } catch {
22503
22737
  if (!res.writableEnded) res.destroy();
22504
22738
  } finally {
@@ -22509,6 +22743,71 @@ function createHttpBridge(opts) {
22509
22743
  }).catch(() => json2(res, 400, { error: "bad request" }));
22510
22744
  return;
22511
22745
  }
22746
+ if (req.method === "POST" && url22.pathname === "/bridge/stage-range") {
22747
+ void readJson(req, MAX_BODY_BYTES).then(async (body) => {
22748
+ const b = body;
22749
+ const handle = typeof b?.handle === "string" ? b.handle : "";
22750
+ const offset = b?.offset;
22751
+ const length = b?.length;
22752
+ if (typeof b?.sessionId !== "string" || typeof offset !== "number" || typeof length !== "number" || !Number.isInteger(offset) || !Number.isInteger(length) || offset < 0 || length < 1) {
22753
+ json2(res, 400, {
22754
+ error: "bad_request",
22755
+ message: "\uC77D\uC744 \uBC94\uC704\uB97C \uD655\uC778\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694."
22756
+ });
22757
+ return;
22758
+ }
22759
+ const auth = opts.bridge.authorizeStageRead({
22760
+ sessionId: b.sessionId,
22761
+ token: typeof b.token === "string" ? b.token : "",
22762
+ handle
22763
+ });
22764
+ if (!auth.ok || !opts.mediaStage) {
22765
+ opts.log?.(
22766
+ `stage range refused: reason=${auth.ok ? "no_stage" : auth.reason}`
22767
+ );
22768
+ json2(res, 403, {
22769
+ error: "unauthorized",
22770
+ message: "\uC774 \uD30C\uC77C\uC744 \uC77D\uC744 \uAD8C\uD55C\uC774 \uC5C6\uC5B4\uC694."
22771
+ });
22772
+ return;
22773
+ }
22774
+ const info = await opts.mediaStage.sealedInfo(handle);
22775
+ if (!info) {
22776
+ json2(res, 404, {
22777
+ error: "not_found",
22778
+ message: "\uBD09\uC778\uB41C \uD30C\uC77C\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694."
22779
+ });
22780
+ return;
22781
+ }
22782
+ if (offset > info.bytes) {
22783
+ json2(res, 416, {
22784
+ error: "out_of_range",
22785
+ message: "\uD30C\uC77C \uB05D\uC744 \uB118\uC5B4 \uC77D\uC73C\uB824\uACE0 \uD588\uC5B4\uC694."
22786
+ });
22787
+ return;
22788
+ }
22789
+ const piece = await opts.mediaStage.readRange(handle, offset, length);
22790
+ res.writeHead(200, {
22791
+ "content-type": "application/octet-stream",
22792
+ "content-length": String(piece.byteLength),
22793
+ "x-total-bytes": String(info.bytes),
22794
+ "x-stage-kind": info.kind,
22795
+ "access-control-expose-headers": "x-total-bytes, x-stage-kind",
22796
+ "cache-control": "no-store"
22797
+ });
22798
+ res.end(piece);
22799
+ }).catch(() => {
22800
+ if (!res.headersSent) {
22801
+ json2(res, 400, {
22802
+ error: "bad_request",
22803
+ message: "\uC77D\uC744 \uBC94\uC704\uB97C \uD655\uC778\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694."
22804
+ });
22805
+ } else if (!res.writableEnded) {
22806
+ res.destroy();
22807
+ }
22808
+ });
22809
+ return;
22810
+ }
22512
22811
  if (req.method === "POST" && url22.pathname === "/bridge/artifact") {
22513
22812
  const store = opts.artifactStore;
22514
22813
  if (!store) {
@@ -22944,14 +23243,14 @@ function refuse2(reason, message) {
22944
23243
  }
22945
23244
  function createArtifactStore(opts) {
22946
23245
  const now = opts.now ?? Date.now;
22947
- const open32 = /* @__PURE__ */ new Map();
23246
+ const open42 = /* @__PURE__ */ new Map();
22948
23247
  async function drop(key, entry) {
22949
- open32.delete(key);
23248
+ open42.delete(key);
22950
23249
  await rm2(entry.partPath, { force: true });
22951
23250
  }
22952
23251
  async function expire() {
22953
23252
  const t = now();
22954
- for (const [key, entry] of open32) {
23253
+ for (const [key, entry] of open42) {
22955
23254
  if (t - entry.openedAt > OPEN_TTL_MS) await drop(key, entry);
22956
23255
  }
22957
23256
  }
@@ -22960,7 +23259,7 @@ function createArtifactStore(opts) {
22960
23259
  if (!BASE642.test(chunk.data)) {
22961
23260
  return refuse2("bad_chunk", "\uB0B4\uBCF4\uB0B8 \uD30C\uC77C \uC870\uAC01\uC744 \uC77D\uC9C0 \uBABB\uD588\uC5B4\uC694.");
22962
23261
  }
22963
- let entry = open32.get(chunk.key);
23262
+ let entry = open42.get(chunk.key);
22964
23263
  if (!entry) {
22965
23264
  if (chunk.offset !== 0) {
22966
23265
  return refuse2("bad_offset", "\uB0B4\uBCF4\uB0B8 \uD30C\uC77C\uC744 \uCC98\uC74C\uBD80\uD130 \uB2E4\uC2DC \uBCF4\uB0B4 \uC8FC\uC138\uC694.");
@@ -22978,7 +23277,7 @@ function createArtifactStore(opts) {
22978
23277
  hash: createHash3("sha256"),
22979
23278
  openedAt: now()
22980
23279
  };
22981
- open32.set(chunk.key, entry);
23280
+ open42.set(chunk.key, entry);
22982
23281
  }
22983
23282
  if (chunk.offset !== entry.received) {
22984
23283
  await drop(chunk.key, entry);
@@ -23004,9 +23303,9 @@ function createArtifactStore(opts) {
23004
23303
  );
23005
23304
  }
23006
23305
  if (entry.received === 0) await appendFile(entry.partPath, Buffer.alloc(0));
23007
- await rename(entry.partPath, entry.finalPath);
23008
- open32.delete(chunk.key);
23009
- const size = (await stat(entry.finalPath)).size;
23306
+ await rename2(entry.partPath, entry.finalPath);
23307
+ open42.delete(chunk.key);
23308
+ const size = (await stat2(entry.finalPath)).size;
23010
23309
  return {
23011
23310
  ok: true,
23012
23311
  state: "saved",
@@ -28396,7 +28695,7 @@ function bucketFor2(state, inst) {
28396
28695
  return bucket;
28397
28696
  }
28398
28697
  var handoff2;
28399
- var open3 = [];
28698
+ var open4 = [];
28400
28699
  var memo2 = {
28401
28700
  alloc(_inst, payload, empty) {
28402
28701
  const bucket = handoff2;
@@ -28405,7 +28704,7 @@ var memo2 = {
28405
28704
  handoff2 = void 0;
28406
28705
  const entry = { value: empty, issues: null };
28407
28706
  bucket.set(payload.value, entry);
28408
- open3.push(entry);
28707
+ open4.push(entry);
28409
28708
  return empty;
28410
28709
  },
28411
28710
  guard(inst) {
@@ -28476,10 +28775,10 @@ var memo2 = {
28476
28775
  return payload;
28477
28776
  }
28478
28777
  handoff2 = bucket;
28479
- const depth = open3.length;
28778
+ const depth = open4.length;
28480
28779
  const result = base(payload, ctx);
28481
28780
  handoff2 = void 0;
28482
- const entry = open3.length > depth ? open3.pop() : void 0;
28781
+ const entry = open4.length > depth ? open4.pop() : void 0;
28483
28782
  if (result instanceof Promise) {
28484
28783
  return result.then((r) => {
28485
28784
  if (entry)
@@ -43295,6 +43594,9 @@ var TOOL_TIERS2 = Object.freeze({
43295
43594
  photo_auto_collage: "write",
43296
43595
  photo_slideshow_set: "write",
43297
43596
  photo_upscale: "write",
43597
+ photo_inpaint: "write",
43598
+ photo_group: "write",
43599
+ photo_ungroup: "write",
43298
43600
  // ── Gallery: the free way in ────────────────────────────────────
43299
43601
  //
43300
43602
  // Destructive because it reads a path off the user's disk, the same
@@ -43354,6 +43656,7 @@ var TOOL_TIERS2 = Object.freeze({
43354
43656
  video_template_list: "read",
43355
43657
  video_template_apply: "destructive",
43356
43658
  video_post_import: "write",
43659
+ video_source_add: "write",
43357
43660
  // ── Post editor: reads ──────────────────────────────────────────
43358
43661
  editor_read: "read",
43359
43662
  editor_read_structure: "read",
@@ -43447,6 +43750,14 @@ var TOOL_TIERS2 = Object.freeze({
43447
43750
  editor_set_list: "write",
43448
43751
  editor_set_cover_image: "write",
43449
43752
  editor_insert_link_card: "write",
43753
+ // Runs the caller's own code in the page, so it can do anything the page can.
43754
+ editor_debug: "destructive",
43755
+ editor_edit_table: "write",
43756
+ editor_set_image_link: "write",
43757
+ editor_set_image_caption: "write",
43758
+ editor_insert_place: "write",
43759
+ editor_insert_file: "write",
43760
+ editor_insert_video: "write",
43450
43761
  editor_capture_document: "write",
43451
43762
  editor_insert_component: "write",
43452
43763
  editor_replace: "destructive"
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  resolveConfig,
5
5
  runAdapter,
6
6
  runDaemon
7
- } from "./chunk-G4RHWD4U.js";
7
+ } from "./chunk-FBY6AAOG.js";
8
8
  import "./chunk-MLKGABMK.js";
9
9
 
10
10
  // src/cli.ts
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  dispatchCli,
4
4
  ensureDaemonRunning,
5
5
  runAdapter
6
- } from "./chunk-G4RHWD4U.js";
6
+ } from "./chunk-FBY6AAOG.js";
7
7
  import "./chunk-MLKGABMK.js";
8
8
  export {
9
9
  createAdapterServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modootoday/datalab-extension-mcp",
3
- "version": "1.16.10",
3
+ "version": "1.17.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",