@sogni-ai/sogni-creative-agent-skill 3.3.4 → 3.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.
@@ -0,0 +1,37 @@
1
+ // Zero-dependency Node.js version guard.
2
+ //
3
+ // This module is imported FIRST by sogni-agent.mjs (before `sharp` and the
4
+ // Sogni SDK). ES modules evaluate their dependencies in source order, so this
5
+ // runs — and can exit cleanly — before any modern-syntax/native dependency is
6
+ // loaded. That turns "wrong Node version" from a cryptic native/ESM stack
7
+ // trace into a one-line, actionable message.
8
+ //
9
+ // Keep this file import-free and syntactically conservative so it parses and
10
+ // runs on old Node versions too.
11
+
12
+ var MIN_NODE_VERSION = [22, 11, 0];
13
+
14
+ function isVersionAtLeast(current, required) {
15
+ for (var i = 0; i < required.length; i++) {
16
+ var currentValue = current[i] || 0;
17
+ var requiredValue = required[i] || 0;
18
+ if (currentValue > requiredValue) return true;
19
+ if (currentValue < requiredValue) return false;
20
+ }
21
+ return true;
22
+ }
23
+
24
+ try {
25
+ var raw = (process && process.versions && process.versions.node) || '0';
26
+ var current = String(raw).split('.').map(function (part) { return Number(part); });
27
+ if (!isVersionAtLeast(current, MIN_NODE_VERSION)) {
28
+ var required = MIN_NODE_VERSION.join('.');
29
+ process.stderr.write(
30
+ 'Error: Sogni requires Node.js >= ' + required + ' (you have ' + raw + ').\n' +
31
+ 'Hint: Upgrade Node — e.g. with nvm (`nvm install ' + MIN_NODE_VERSION[0] + '`), fnm, or volta — then re-run.\n'
32
+ );
33
+ process.exit(1);
34
+ }
35
+ } catch (err) {
36
+ // Never let the guard itself crash the CLI; fall through to normal startup.
37
+ }
@@ -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.3.4",
5
+ "version": "3.4.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.3.4",
3
+ "version": "3.4.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",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "openclaw:sync": "node scripts/sync-openclaw-plugin.mjs",
12
- "sync:creative-agent-runtime": "node ../sogni-creative-agent/scripts/sync-skill-runtime.mjs",
12
+ "sync:creative-agent-runtime": "node scripts/sync-creative-agent-runtime.mjs",
13
13
  "check:creative-agent-source": "node scripts/check-creative-agent-source.mjs",
14
14
  "check:creative-agent-source:strict": "node scripts/check-creative-agent-source.mjs --strict-network",
15
15
  "check:creative-agent-runtime": "node scripts/check-creative-agent-runtime.mjs",
@@ -56,6 +56,7 @@
56
56
  "skill-package.json",
57
57
  "scripts/check-creative-agent-runtime.mjs",
58
58
  "scripts/check-creative-agent-source.mjs",
59
+ "scripts/sync-creative-agent-runtime.mjs",
59
60
  "version.mjs",
60
61
  "scripts/sync-openclaw-plugin.mjs",
61
62
  "openclaw-plugin.mjs",
@@ -63,11 +64,12 @@
63
64
  "env.mjs",
64
65
  "ssrf-guard.mjs",
65
66
  "update-check.mjs",
67
+ "node-version-check.mjs",
66
68
  "generated/creative-agent-runtime.mjs",
67
69
  "sogni-agent.mjs"
68
70
  ],
69
71
  "dependencies": {
70
- "@sogni-ai/sogni-intelligence-client": "^3.0.8",
72
+ "@sogni-ai/sogni-intelligence-client": "^3.0.13",
71
73
  "execa": "^9.6.1",
72
74
  "json5": "^2.2.3",
73
75
  "sharp": "^0.34.5"
@@ -4,9 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { spawnSync } from 'node:child_process';
5
5
 
6
6
  const repoRoot = dirname(dirname(fileURLToPath(import.meta.url)));
7
- const syncScript = process.env.SOGNI_CREATIVE_AGENT_SYNC_SCRIPT
8
- ? process.env.SOGNI_CREATIVE_AGENT_SYNC_SCRIPT
9
- : join(repoRoot, '..', 'sogni-creative-agent', 'scripts', 'sync-skill-runtime.mjs');
7
+ const syncScript = join(repoRoot, 'scripts', 'sync-creative-agent-runtime.mjs');
10
8
  const generatedPath = join(repoRoot, 'generated', 'creative-agent-runtime.mjs');
11
9
  const generatedRelativePath = 'generated/creative-agent-runtime.mjs';
12
10
 
@@ -0,0 +1,98 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { spawnSync } from 'node:child_process';
5
+
6
+ const repoRoot = dirname(dirname(fileURLToPath(import.meta.url)));
7
+ const upstreamSyncScript = process.env.SOGNI_CREATIVE_AGENT_SYNC_SCRIPT
8
+ ? process.env.SOGNI_CREATIVE_AGENT_SYNC_SCRIPT
9
+ : join(repoRoot, '..', 'sogni-creative-agent', 'scripts', 'sync-skill-runtime.mjs');
10
+ const generatedPath = join(repoRoot, 'generated', 'creative-agent-runtime.mjs');
11
+
12
+ const STALE_COST_LIMIT_REPAIR_NOTE =
13
+ 'You have hit the credit limit for this turn. Top up credits or wait for the daily refill.';
14
+ const SPARK_PACKS_COST_LIMIT_REPAIR_NOTE =
15
+ 'You have hit the credit limit for this turn. Buy Spark Packs to continue: https://docs.sogni.ai/pricing/#spark-packs';
16
+ const PUBLIC_RUNTIME_REEXPORT = "export * from '@sogni-ai/sogni-intelligence-client/public-skill-runtime';";
17
+ const PUBLIC_RUNTIME_OVERRIDE_MARKER = 'PUBLIC_SKILL_SPARK_PACKS_COST_LIMIT_OVERRIDE';
18
+
19
+ function run(command, args, options = {}) {
20
+ const result = spawnSync(command, args, {
21
+ cwd: repoRoot,
22
+ encoding: 'utf8',
23
+ ...options,
24
+ });
25
+ if (result.error) throw result.error;
26
+ return result;
27
+ }
28
+
29
+ function applyPublicRuntimeOverrides(source) {
30
+ let updated = source.replaceAll(STALE_COST_LIMIT_REPAIR_NOTE, SPARK_PACKS_COST_LIMIT_REPAIR_NOTE);
31
+ if (updated.includes(PUBLIC_RUNTIME_REEXPORT) && !updated.includes(PUBLIC_RUNTIME_OVERRIDE_MARKER)) {
32
+ const costLimitMessage = JSON.stringify(SPARK_PACKS_COST_LIMIT_REPAIR_NOTE);
33
+ const overrideBlock = `
34
+ // ${PUBLIC_RUNTIME_OVERRIDE_MARKER}
35
+ import {
36
+ PUBLIC_SKILL_DEFAULT_POLICIES as SOGNI_PUBLIC_SKILL_DEFAULT_POLICIES,
37
+ PUBLIC_SKILL_DEFAULT_PROMPT_CONTRACTS as SOGNI_PUBLIC_SKILL_DEFAULT_PROMPT_CONTRACTS,
38
+ PUBLIC_SKILL_DEFAULT_REPAIR_RECIPES as SOGNI_PUBLIC_SKILL_DEFAULT_REPAIR_RECIPES,
39
+ createPublicSkillContractRuntime as createSogniPublicSkillContractRuntime,
40
+ } from '@sogni-ai/sogni-intelligence-client/public-skill-runtime';
41
+
42
+ export const PUBLIC_SKILL_DEFAULT_REPAIR_RECIPES = SOGNI_PUBLIC_SKILL_DEFAULT_REPAIR_RECIPES.map((recipe) =>
43
+ recipe.errorCode === 'COST_LIMIT_EXCEEDED'
44
+ ? { ...recipe, message: ${costLimitMessage} }
45
+ : recipe
46
+ );
47
+
48
+ export function createPublicSkillDefaultContractRuntime(input = {}) {
49
+ return createSogniPublicSkillContractRuntime({
50
+ policies: [
51
+ ...SOGNI_PUBLIC_SKILL_DEFAULT_POLICIES,
52
+ ...(input.policies ?? []),
53
+ ],
54
+ promptContracts: [
55
+ ...SOGNI_PUBLIC_SKILL_DEFAULT_PROMPT_CONTRACTS,
56
+ ...(input.promptContracts ?? []),
57
+ ],
58
+ repairRecipes: [
59
+ ...PUBLIC_SKILL_DEFAULT_REPAIR_RECIPES,
60
+ ...(input.repairRecipes ?? []),
61
+ ],
62
+ });
63
+ }
64
+ `;
65
+ updated = updated.replace(PUBLIC_RUNTIME_REEXPORT, `${PUBLIC_RUNTIME_REEXPORT}\n${overrideBlock}`);
66
+ }
67
+ return updated;
68
+ }
69
+
70
+ if (!existsSync(upstreamSyncScript)) {
71
+ console.error(`Missing Sogni Creative Agent runtime sync script: ${upstreamSyncScript}`);
72
+ console.error('Set SOGNI_CREATIVE_AGENT_SYNC_SCRIPT or check out sogni-creative-agent as a sibling repo.');
73
+ process.exit(1);
74
+ }
75
+
76
+ const syncResult = run(process.execPath, [upstreamSyncScript], {
77
+ env: {
78
+ ...process.env,
79
+ SOGNI_CREATIVE_AGENT_SKILL_DIR: repoRoot,
80
+ },
81
+ stdio: 'inherit',
82
+ });
83
+ if (syncResult.status !== 0) {
84
+ process.exit(syncResult.status || 1);
85
+ }
86
+
87
+ if (!existsSync(generatedPath)) {
88
+ console.error('Runtime sync completed but generated/creative-agent-runtime.mjs was not created.');
89
+ process.exit(1);
90
+ }
91
+
92
+ const generated = readFileSync(generatedPath, 'utf8');
93
+ const updated = applyPublicRuntimeOverrides(generated);
94
+ if (updated !== generated) {
95
+ mkdirSync(dirname(generatedPath), { recursive: true });
96
+ writeFileSync(generatedPath, updated);
97
+ console.log(`Applied public skill runtime overrides to ${generatedPath}`);
98
+ }
@@ -3,7 +3,7 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "@sogni-ai/sogni-intelligence-client": "^3.0.8",
6
+ "@sogni-ai/sogni-intelligence-client": "^3.0.13",
7
7
  "execa": "^9.6.1",
8
8
  "json5": "^2.2.3",
9
9
  "sharp": "^0.34.5"