@sogni-ai/sogni-creative-agent-skill 3.13.0 β†’ 3.14.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.14.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.13.0...v3.14.0) (2026-07-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * **desktop:** add import_media tool bridging chat attachments to local files ([a259bcf](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/a259bcf36d4a747bb2cbe9d71ff8ec9da9e6c1c9))
7
+
1
8
  # [3.13.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.12.0...v3.13.0) (2026-07-05)
2
9
 
3
10
 
package/SKILL.md CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sogni-creative-agent-skill
3
3
  description: "Sogni Creative Agent Skill: agent skill and CLI for image, video, and music generation using Sogni AI's decentralized GPU network. Supports personas (named people with saved reference photos and voice clips), persistent memories, custom personality, style transfer, angle synthesis, Seedance/HappyHorse/LTX/WAN video, music/lyrics, hosted chat, durable workflows, replay records, and multi-step creative workflows. Ask the agent to \"draw\", \"generate\", \"create an image\", \"make a video/animate\", \"make music\", \"apply a style\", or \"generate me as a superhero\"."
4
4
  metadata:
5
- version: "3.12.0"
5
+ version: "3.13.0"
6
6
  homepage: https://sogni.ai
7
7
  openclaw:
8
8
  emoji: "🎨"
@@ -9,6 +9,27 @@ A dependency-free MCP stdio server that wraps the globally installed
9
9
  - `server/tools.mjs` β€” tool schemas + pure argv builders
10
10
  - `server/resolve.mjs` β€” absolute-path resolution (agent, ffmpeg, child env);
11
11
  Claude Desktop's GUI environment has a minimal PATH, so nothing here relies on PATH lookup
12
+ - `server/import-media.mjs` β€” local handler for `import_media` (see below); the
13
+ only tool that runs inside the server instead of spawning the CLI
14
+
15
+ ## Chat attachments and import_media
16
+
17
+ Files attached to a chat never reach this server: Claude Desktop keeps
18
+ attachments in its remote sandbox, and MCP has no client→server file
19
+ transfer. Every media input (`ref`, `context_images`, …) therefore only
20
+ accepts paths on this machine or URLs β€” the tool descriptions say so, and
21
+ point the model at the bridge:
22
+
23
+ `import_media` accepts base64-encoded bytes and writes them into the Sogni
24
+ media inbox (`SOGNI_MEDIA_INBOUND_DIR`, default `~/.openclaw/media/inbound/`
25
+ β€” the same directory `list_media` reads), returning the absolute path to feed
26
+ into the generation tools. Large files arrive in chunks: first call passes
27
+ `filename`, later calls pass `append_to_path` from the previous result.
28
+ Guardrails: media-only extensions, filenames reduced to their basename,
29
+ existing files never overwritten (suffixed instead), appends confined to the
30
+ inbox, 2MB per chunk / 25MB per file. In practice the model reads the
31
+ attachment in its code-execution sandbox, downscales images to ~1024px JPEG,
32
+ and relays the base64 β€” token-expensive, so previews beat full-res originals.
12
33
 
13
34
  ## Inline images
14
35
 
@@ -2,7 +2,7 @@
2
2
  "manifest_version": "0.3",
3
3
  "name": "sogni-creative-agent",
4
4
  "display_name": "Sogni Creative Agent",
5
- "version": "3.12.0",
5
+ "version": "3.13.0",
6
6
  "description": "Generate images, video, and music on Sogni AI's decentralized GPU network β€” with personas, memories, and safe video editing tools.",
7
7
  "author": { "name": "Sogni AI", "url": "https://sogni.ai" },
8
8
  "homepage": "https://sogni.ai",
@@ -0,0 +1,113 @@
1
+ // desktop-extension/server/import-media.mjs
2
+ // Local handler for the import_media tool: decodes base64 chunks sent by the
3
+ // model and writes them into the Sogni media inbox, returning the absolute
4
+ // path the generation tools can consume. This exists because chat clients
5
+ // (e.g. Claude Desktop) cannot hand attachment bytes to a local MCP server β€”
6
+ // the model relays them as base64 instead, chunked for anything beyond one
7
+ // tool call's worth of output. Runs entirely locally: no CLI spawn, no network.
8
+ import { appendFileSync, existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
9
+ import { homedir } from 'node:os';
10
+ import { basename, extname, join, resolve, sep } from 'node:path';
11
+
12
+ // Decoded-bytes ceilings. A chunk is one tool call's `data` payload; the total
13
+ // bounds the finished file so a runaway chunk loop can't fill the disk.
14
+ const MAX_CHUNK_BYTES = 2 * 1024 * 1024;
15
+ const MAX_TOTAL_BYTES = 25 * 1024 * 1024;
16
+
17
+ // Media-only allowlist: this tool imports generation inputs, not arbitrary
18
+ // files, so executable/document extensions are rejected outright.
19
+ const ALLOWED_EXTENSIONS = new Set([
20
+ '.png', '.jpg', '.jpeg', '.webp', '.gif',
21
+ '.mp3', '.wav', '.flac', '.m4a', '.ogg',
22
+ '.mp4', '.mov', '.webm',
23
+ ]);
24
+
25
+ // Mirrors the CLI's inbound-dir resolution (sogni-agent.mjs): env override
26
+ // first, then the OpenClaw inbox with a legacy clawdbot-era fallback. Keeping
27
+ // the same directory means --list-media sees imported files immediately.
28
+ function resolveInboundDir(env, home) {
29
+ if (env.SOGNI_MEDIA_INBOUND_DIR) return env.SOGNI_MEDIA_INBOUND_DIR;
30
+ const openclaw = join(home, '.openclaw', 'media', 'inbound');
31
+ const legacy = join(home, '.clawdbot', 'media', 'inbound');
32
+ return !existsSync(openclaw) && existsSync(legacy) ? legacy : openclaw;
33
+ }
34
+
35
+ function decodeChunk(data, maxChunkBytes) {
36
+ if (typeof data !== 'string' || data === '') {
37
+ throw new Error('data is required β€” the base64-encoded bytes of this chunk.');
38
+ }
39
+ const compact = data.replace(/\s+/g, '');
40
+ if (!/^[A-Za-z0-9+/]+={0,2}$/.test(compact) || compact.length % 4 !== 0) {
41
+ throw new Error('data is not valid base64.');
42
+ }
43
+ const bytes = Buffer.from(compact, 'base64');
44
+ if (bytes.length > maxChunkBytes) {
45
+ throw new Error(`Chunk too large: ${bytes.length} bytes decoded (max ${maxChunkBytes}). Send smaller chunks.`);
46
+ }
47
+ return bytes;
48
+ }
49
+
50
+ // New imports never clobber: pixel.png β†’ pixel-2.png β†’ pixel-3.png …
51
+ function uniquePath(dir, filename) {
52
+ const ext = extname(filename);
53
+ const stem = filename.slice(0, filename.length - ext.length);
54
+ let candidate = join(dir, filename);
55
+ for (let n = 2; existsSync(candidate); n += 1) {
56
+ candidate = join(dir, `${stem}-${n}${ext}`);
57
+ }
58
+ return candidate;
59
+ }
60
+
61
+ export async function importMedia(input, {
62
+ env = process.env,
63
+ home = homedir(),
64
+ maxChunkBytes = MAX_CHUNK_BYTES,
65
+ maxTotalBytes = MAX_TOTAL_BYTES,
66
+ } = {}) {
67
+ const bytes = decodeChunk(input.data, maxChunkBytes);
68
+ const dir = resolveInboundDir(env, home);
69
+
70
+ if (input.append_to_path) {
71
+ const target = resolve(String(input.append_to_path));
72
+ if (!target.startsWith(resolve(dir) + sep)) {
73
+ throw new Error('append_to_path must be a path inside the Sogni media inbox returned by a previous import_media call.');
74
+ }
75
+ if (!existsSync(target)) {
76
+ throw new Error('append_to_path does not exist β€” start the import with a filename first.');
77
+ }
78
+ const existing = statSync(target).size;
79
+ if (existing + bytes.length > maxTotalBytes) {
80
+ throw new Error(`Import would exceed the total size cap (${maxTotalBytes} bytes).`);
81
+ }
82
+ appendFileSync(target, bytes);
83
+ return { path: target, bytes: existing + bytes.length };
84
+ }
85
+
86
+ const filename = basename(String(input.filename ?? ''));
87
+ if (!filename || filename === '.' || filename === sep) {
88
+ throw new Error('filename is required for a new import, e.g. "photo.jpg".');
89
+ }
90
+ const ext = extname(filename).toLowerCase();
91
+ if (!ALLOWED_EXTENSIONS.has(ext)) {
92
+ throw new Error(`Unsupported extension "${ext || '(none)'}" β€” allowed: ${[...ALLOWED_EXTENSIONS].join(', ')}.`);
93
+ }
94
+ if (bytes.length > maxTotalBytes) {
95
+ throw new Error(`Import would exceed the total size cap (${maxTotalBytes} bytes).`);
96
+ }
97
+ mkdirSync(dir, { recursive: true });
98
+ const target = uniquePath(dir, filename);
99
+ writeFileSync(target, bytes);
100
+ return { path: target, bytes: bytes.length };
101
+ }
102
+
103
+ // Tool-call entry point used by index.mjs: wraps the core in the JSON shape
104
+ // the model reads back, including where to point the generation tools next.
105
+ export async function runImportMedia(input) {
106
+ const { path, bytes } = await importMedia(input ?? {});
107
+ return JSON.stringify({
108
+ path,
109
+ bytes,
110
+ note: 'Saved locally. To add more chunks, call import_media again with append_to_path set to this path. '
111
+ + 'When complete, pass this path as generate_video.ref, generate_image.context_images, photobooth.ref, or a persona ref.',
112
+ });
113
+ }
@@ -11,6 +11,7 @@ import { fileURLToPath } from 'node:url';
11
11
  import { TOOLS, getTool } from './tools.mjs';
12
12
  import { buildChildEnv, resolveAgentPath, resolveFfmpegPath } from './resolve.mjs';
13
13
  import { collectInlineImages } from './inline-images.mjs';
14
+ import { runImportMedia } from './import-media.mjs';
14
15
 
15
16
  const HERE = dirname(fileURLToPath(import.meta.url));
16
17
  const PROTOCOL_FALLBACK = '2025-06-18';
@@ -33,10 +34,22 @@ function textResult(text, isError = false) {
33
34
  return { content: [{ type: 'text', text }], isError };
34
35
  }
35
36
 
37
+ // Tools marked local in the registry run inside this process and must work
38
+ // even when the sogni-agent CLI is not installed yet.
39
+ const LOCAL_HANDLERS = { import_media: runImportMedia };
40
+
36
41
  async function callTool(name, input, progressToken) {
37
42
  const tool = getTool(name);
38
43
  if (!tool) return textResult(`Unknown tool: ${name}`, true);
39
44
 
45
+ if (tool.local) {
46
+ try {
47
+ return textResult(await LOCAL_HANDLERS[name](input ?? {}));
48
+ } catch (err) {
49
+ return textResult(err.message, true);
50
+ }
51
+ }
52
+
40
53
  const agentPath = resolveAgentPath();
41
54
  if (!agentPath) {
42
55
  return textResult(
@@ -20,6 +20,13 @@ function required(input, field, hint) {
20
20
  const str = (description) => ({ type: 'string', description });
21
21
  const num = (description) => ({ type: 'number', description });
22
22
 
23
+ // Chat clients (Claude Desktop etc.) never expose chat-attached files to this
24
+ // server's filesystem; without this warning the model wastes turns discovering
25
+ // that boundary by trial and error.
26
+ const CHAT_ATTACHMENT_NOTE =
27
+ 'Files attached to the chat are NOT visible to Sogni tools β€” import them with import_media first ' +
28
+ '(returns a local path), or pass a local absolute path, URL, or saved persona.';
29
+
23
30
  export const TOOLS = [
24
31
  {
25
32
  name: 'generate_image',
@@ -27,7 +34,7 @@ export const TOOLS = [
27
34
  'Generate one or more images from a text prompt on the Sogni GPU network. ' +
28
35
  'Pass output_path (absolute, .png/.jpg) to save locally; otherwise a hosted URL is returned. ' +
29
36
  'Use context_images for image editing ("make the background a beach") and persona to include a saved person. ' +
30
- 'Image results are attached inline in the tool result.',
37
+ 'Image results are attached inline in the tool result. ' + CHAT_ATTACHMENT_NOTE,
31
38
  inputSchema: {
32
39
  type: 'object',
33
40
  properties: {
@@ -67,7 +74,7 @@ export const TOOLS = [
67
74
  description:
68
75
  'Generate a video from a text prompt, optionally driven by reference media. ' +
69
76
  'ref = start frame image, ref_end = end frame, ref_audio = soundtrack/lip-sync audio, ref_video = motion reference. ' +
70
- 'Rendering takes minutes; prefer output_path (absolute .mp4).',
77
+ 'Rendering takes minutes; prefer output_path (absolute .mp4). ' + CHAT_ATTACHMENT_NOTE,
71
78
  inputSchema: {
72
79
  type: 'object',
73
80
  properties: {
@@ -144,7 +151,7 @@ export const TOOLS = [
144
151
  description:
145
152
  'Face-transfer portrait generation: renders the person in the ref photo into a new scene ' +
146
153
  '(e.g. "LinkedIn professional headshot", "80s fashion portrait"). ' +
147
- 'Image results are attached inline in the tool result.',
154
+ 'Image results are attached inline in the tool result. ' + CHAT_ATTACHMENT_NOTE,
148
155
  inputSchema: {
149
156
  type: 'object',
150
157
  properties: {
@@ -210,9 +217,30 @@ export const TOOLS = [
210
217
  throw new Error(`Unknown action "${action}".`);
211
218
  },
212
219
  },
220
+ {
221
+ name: 'import_media',
222
+ description:
223
+ 'Save base64-encoded media bytes to the local Sogni media inbox and return the absolute file path, ' +
224
+ 'ready to pass as ref / context_images / persona ref. Use this to hand chat-attached files to the ' +
225
+ 'generation tools: read the attachment bytes (e.g. via code execution), downscale large images to ' +
226
+ '~1024px JPEG first, base64-encode, and send. For anything over ~40KB, send multiple calls: the first ' +
227
+ 'with filename, each following chunk with append_to_path set to the returned path.',
228
+ inputSchema: {
229
+ type: 'object',
230
+ properties: {
231
+ data: str('Base64-encoded file bytes for this chunk (keep each chunk under ~64KB of base64)'),
232
+ filename: str('Filename with a media extension for a NEW import, e.g. "photo.jpg"'),
233
+ append_to_path: str('Path returned by the previous call β€” appends this chunk to that file instead of creating a new one'),
234
+ },
235
+ required: ['data'],
236
+ },
237
+ local: true, // handled inside the server (import-media.mjs); never spawns the CLI
238
+ },
213
239
  {
214
240
  name: 'list_media',
215
- description: 'List recent inbound media files the user sent to Sogni (images, audio, or all).',
241
+ description:
242
+ 'List recent files in the Sogni media inbox: media the user sent via connected messaging apps ' +
243
+ 'plus files saved by import_media. Chat attachments do NOT appear here unless imported first.',
216
244
  inputSchema: {
217
245
  type: 'object',
218
246
  properties: { type: { type: 'string', enum: ['images', 'audio', 'all'] } },
@@ -225,7 +253,7 @@ export const TOOLS = [
225
253
  name: 'manage_personas',
226
254
  description:
227
255
  'Manage saved personas (named people with reference photos and optional voice clips). ' +
228
- 'Actions: list, add (needs name + ref photo), remove, resolve (show details).',
256
+ 'Actions: list, add (needs name + ref photo), remove, resolve (show details). ' + CHAT_ATTACHMENT_NOTE,
229
257
  inputSchema: {
230
258
  type: 'object',
231
259
  properties: {
@@ -2,7 +2,7 @@
2
2
  "id": "sogni-creative-agent-skill",
3
3
  "name": "Sogni Creative Agent Skill β€” Image, Video & Music Generation",
4
4
  "description": "Agent skill and CLI for Sogni AI image, video, and music generation.",
5
- "version": "3.12.0",
5
+ "version": "3.13.0",
6
6
  "skills": [
7
7
  "."
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sogni-ai/sogni-creative-agent-skill",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "Sogni Creative Agent Skill: agent skill and CLI for Sogni AI image, video, and music generation.",
5
5
  "type": "module",
6
6
  "main": "sogni-agent.mjs",
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.12.0';
1
+ export const PACKAGE_VERSION = '3.13.0';