@insmind/cli 1.8.0 → 1.9.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.
Files changed (58) hide show
  1. package/contracts/operations/model.get/input.schema.json +5 -0
  2. package/contracts/operations/model.get/output.schema.json +9 -1
  3. package/contracts/operations/tool.call/canvas-input.schema.json +60 -0
  4. package/contracts/operations/tool.call/models/image-edit-smart.schema.json +39 -0
  5. package/contracts/operations/tool.call/models/image-edit-standard.schema.json +31 -0
  6. package/contracts/operations/tool.call/models/image-enhance-smart.schema.json +26 -0
  7. package/contracts/operations/tool.call/models/image-enhance-standard.schema.json +25 -0
  8. package/contracts/operations/tool.call/models/image-expand-smart.schema.json +72 -0
  9. package/contracts/operations/tool.call/models/image-expand-standard.schema.json +58 -0
  10. package/contracts/operations/tool.call/models/image-layers-layout.schema.json +20 -0
  11. package/contracts/operations/tool.call/models/image-layers-smart.schema.json +26 -0
  12. package/contracts/operations/tool.call/models/image-matting-smart.schema.json +34 -0
  13. package/contracts/operations/tool.call/models/image-matting-standard.schema.json +24 -0
  14. package/contracts/operations/tool.call/models/image-ocr.schema.json +20 -0
  15. package/contracts/operations/tool.call/models/image-remove-smart.schema.json +30 -0
  16. package/contracts/operations/tool.call/models/image-remove-standard.schema.json +25 -0
  17. package/contracts/operations/tool.call/models/image-text-edit.schema.json +43 -0
  18. package/contracts/operations/tool.call/models/image-vectorize.schema.json +20 -0
  19. package/contracts/operations/tool.call/models/video-edit-smart.schema.json +68 -0
  20. package/contracts/operations/tool.call/models/video-enhance-smart.schema.json +32 -0
  21. package/contracts/operations/tool.call/models/video-enhance-standard.schema.json +26 -0
  22. package/contracts/operations/tool.call/ocr-payload.schema.json +65 -0
  23. package/contracts/operations/tool.call/output.schema.json +38 -0
  24. package/contracts/operations/tool.call/template-payload.schema.json +95 -0
  25. package/dist/src/bootstrap/create-runtime.js +50 -23
  26. package/dist/src/cli/agent-commands.js +1 -0
  27. package/dist/src/cli/errors.js +3 -3
  28. package/dist/src/cli/model-commands.js +6 -3
  29. package/dist/src/cli/tool-commands.js +2 -0
  30. package/dist/src/contracts/schema.js +4 -1
  31. package/dist/src/features/agent/creative-protocol.js +22 -5
  32. package/dist/src/features/agent/resource-authorizer.js +1 -0
  33. package/dist/src/features/agent/use-cases.js +15 -5
  34. package/dist/src/features/task/use-cases.js +4 -3
  35. package/dist/src/features/tool/canvas-copy.js +61 -0
  36. package/dist/src/features/tool/canvas-media.js +193 -0
  37. package/dist/src/features/tool/canvas-models.js +109 -0
  38. package/dist/src/features/tool/canvas-pricing.js +81 -0
  39. package/dist/src/features/tool/canvas-recovery.js +68 -0
  40. package/dist/src/features/tool/canvas-results.js +144 -0
  41. package/dist/src/features/tool/canvas-tool-adapter.js +366 -0
  42. package/dist/src/features/tool/canvas-video.js +84 -0
  43. package/dist/src/features/tool/catalog.js +35 -13
  44. package/dist/src/features/tool/dynamic-schema.js +48 -22
  45. package/dist/src/features/tool/matting-billing.js +103 -0
  46. package/dist/src/features/tool/mns-catalog-adapter.js +66 -19
  47. package/dist/src/features/tool/resource-authorizer.js +34 -0
  48. package/dist/src/features/tool/scene-catalog-adapter.js +35 -0
  49. package/dist/src/features/tool/tool-api-adapter.js +13 -4
  50. package/dist/src/features/tool/use-cases.js +28 -3
  51. package/dist/src/product/config.js +12 -1
  52. package/package.json +5 -4
  53. package/skills/insmind-cli/SKILL.md +2 -0
  54. package/skills/insmind-cli/references/creation.md +2 -0
  55. package/skills/insmind-cli/references/generation-constraints.md +3 -1
  56. package/skills/insmind-cli/references/matting.md +29 -0
  57. package/skills/insmind-cli/references/media-tools.md +40 -0
  58. package/skills/insmind-cli/references/tool.md +1 -1
@@ -1,6 +1,7 @@
1
1
  import { parseSafeRemoteAssetUrl, UrlSafetyError } from "../../platform/url-safety.js";
2
2
  import { findToolModel, defaultToolDefinitions, projectModelDetail, projectModelList, projectToolList, ToolInputError } from "./catalog.js";
3
3
  import { assertModelArguments, buildToolArgumentsSchema } from "./dynamic-schema.js";
4
+ import { hasCanvasMetering } from "./canvas-pricing.js";
4
5
  const mediaTypes = {
5
6
  avif: "image/avif",
6
7
  gif: "image/gif",
@@ -66,6 +67,17 @@ export function createToolUseCases(dependencies) {
66
67
  throw new ToolInputError("model_required", "/arguments/model");
67
68
  const selected = findToolModel(catalog, input.name, modelName);
68
69
  assertModelArguments(selected, input.arguments);
70
+ if (selected.execution?.kind === "canvas") {
71
+ for (const parameter of selected.parameters) {
72
+ const value = input.arguments[parameter.name];
73
+ const uris = parameter.type === "uri[]" ? value
74
+ : parameter.type === "uri" && typeof value === "string" ? [value] : undefined;
75
+ for (const [index, uri] of (uris ?? []).entries()) {
76
+ if (!uri.startsWith("file:"))
77
+ remoteMedia(uri, parameter.type === "uri[]" ? `${parameter.name}/${index}` : parameter.name);
78
+ }
79
+ }
80
+ }
69
81
  return selected;
70
82
  });
71
83
  const { model: ignoredModel, ...parameters } = input.arguments;
@@ -75,6 +87,11 @@ export function createToolUseCases(dependencies) {
75
87
  model_id: model.model,
76
88
  parameters
77
89
  });
90
+ if (model.execution?.kind === "canvas") {
91
+ const usage = { model: model.model, ...(model.cost === undefined || hasCanvasMetering(model) ? {} : { cost: model.cost }) };
92
+ await observe?.({ toolUsage: usage, generation: { tool: model.tool, model: model.model } });
93
+ return { invocation: { kind: "canvas", model, arguments: input.arguments }, usage };
94
+ }
78
95
  const prompt = [];
79
96
  const requestParameters = {};
80
97
  const directArguments = {};
@@ -166,14 +183,22 @@ export function createToolUseCases(dependencies) {
166
183
  return projectModelList(await load(access, signal), input.tool, dependencies.tools ?? defaultToolDefinitions);
167
184
  },
168
185
  async getModel({ input, access, signal }) {
169
- return projectModelDetail(await load(access, signal), input.model);
186
+ return projectModelDetail(await load(access, signal), input.model, input.tool);
170
187
  },
171
188
  async getArgumentsSchema({ name, access, signal }) {
172
189
  return buildToolArgumentsSchema(await load(access, signal), name, dependencies.modelDescription);
173
190
  },
174
191
  async call(input) {
175
- const { invocation, usage } = await prepare(input);
176
- const content = await dependencies.execution.execute({ invocation, access: input.access, signal: input.signal, ...(input.observe ? { observe: input.observe } : {}) });
192
+ const prepared = await prepare(input);
193
+ const { invocation } = prepared;
194
+ let usage = prepared.usage;
195
+ const observe = async (progress) => {
196
+ if (progress.toolUsage)
197
+ usage = progress.toolUsage;
198
+ await input.observe?.(progress);
199
+ };
200
+ const observer = invocation.kind === "canvas" ? observe : input.observe;
201
+ const content = await dependencies.execution.execute({ invocation, access: input.access, signal: input.signal, ...(observer ? { observe: observer } : {}) });
177
202
  return { content, usage };
178
203
  },
179
204
  async submit(input) {
@@ -75,6 +75,17 @@ export const insmindProduct = freezeProduct({
75
75
  name: "video.generate",
76
76
  title: "Video generation",
77
77
  description: "Generate videos with published video models using text and optional images, video, or audio."
78
- }
78
+ },
79
+ { "name": "image.edit", "title": "Image editing", "description": "Change a selected area or edit an image from instructions." },
80
+ { "name": "image.matting", "title": "Background removal", "description": "Separate original foreground pixels or reconstruct an occluded subject, returning a transparent PNG." },
81
+ { "name": "image.remove", "title": "Object removal", "description": "Remove selected or described content from an image." },
82
+ { "name": "image.enhance", "title": "Image enhancement", "description": "Upscale pixels or restore image details." },
83
+ { "name": "image.expand", "title": "Image expansion", "description": "Extend a canvas with explicit source placement." },
84
+ { "name": "image.text_edit", "title": "Image text editing", "description": "Replace specified text in an image." },
85
+ { "name": "image.ocr", "title": "Text recognition", "description": "Recognize text and its pixel coordinates." },
86
+ { "name": "image.layers", "title": "Image decomposition", "description": "Convert an image to an editable native template." },
87
+ { "name": "image.vectorize", "title": "Image vectorization", "description": "Convert a bitmap to vector SVG." },
88
+ { "name": "video.edit", "title": "Video editing", "description": "Edit a video using instructions and optional references." },
89
+ { "name": "video.enhance", "title": "Video enhancement", "description": "Upscale or restore a video." }
79
90
  ]
80
91
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insmind/cli",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "insMind command-line interface for agents and people.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,6 +32,7 @@
32
32
  "postinstall": "node -e \"const p='./dist/bin/postinstall.js'; if (require('node:fs').existsSync(p)) import(p)\""
33
33
  },
34
34
  "dependencies": {
35
+ "@ffprobe-installer/ffprobe": "2.1.2",
35
36
  "ajv": "8.20.0",
36
37
  "ajv-formats": "3.0.1",
37
38
  "ali-oss": "6.23.0",
@@ -46,8 +47,8 @@
46
47
  "@gaoding/cli": "workspace:*"
47
48
  },
48
49
  "gaodingRelease": {
49
- "sourceCommit": "d1722afac1b5acdc776ee3fbc2f2d69496e1a8af",
50
- "pipelineId": "230438",
51
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/230438"
50
+ "sourceCommit": "2836058427780a95d4b9ed152f122b81997df34e",
51
+ "pipelineId": "231960",
52
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/231960"
52
53
  }
53
54
  }
@@ -17,6 +17,8 @@ description: Use when creating images, videos or text with insMind CLI, operatin
17
17
  Read only the reference for the user's goal:
18
18
 
19
19
  - Choose Agent or Tool creation, discover models, and generate images, videos or text: [Creation](references/creation.md)
20
+ - Select image/video generation or processing tools, prepare references and review masks: [Media tool selection](references/media-tools.md)
21
+ - Remove backgrounds, extract a subject, deliver transparent PNGs, or reconstruct an occluded object: [Matting](references/matting.md)
20
22
  - Operate the current AI+ Editor work: [Editor](references/editor.md)
21
23
  - Discover repositories, folders and tags; find, upload, download or manage DAM assets: [Asset management](references/dam.md)
22
24
  - Sign in or inspect account credits: [Authentication](references/auth.md)
@@ -19,6 +19,8 @@ Choose the Creation Route before selecting or validating a Model. Both Agent and
19
19
  - Agent: a business deliverable, clarification, planning, multiple steps or outputs, or continuation of existing work. The service selects its Business Skill.
20
20
  - Tool: one atomic operation without business orchestration, discovered through `tool list`, or an explicit request to call an available Tool directly.
21
21
 
22
+ For Tool tasks, discover `image.generate` / `video.generate` for new images/videos or complete recreation from references. Use [image and video tool selection](media-tools.md) for purpose-specific processing of existing media. A reference image does not by itself require `image.edit`; multiple internal stages do not by themselves require a business Agent.
23
+
22
24
  Match these business intents by meaning:
23
25
 
24
26
  | Intent | Typical requests | Inputs and boundaries |
@@ -1,6 +1,8 @@
1
1
  # Generation constraints and media roles
2
2
 
3
- Use one Generation Constraints Part for a model and dynamic parameters. `model` is the machine identifier; copy parameter fields and values from `model get` and preserve the user's choices:
3
+ Use one Generation Constraints Part for a model and dynamic parameters. `model` is the machine identifier; read generation controls and values from `model get`, check the accepted Agent controls in `agent send --help`, and preserve the user's choices. The complete Tool `inputSchema` in model detail is not the field list for Agent `arguments`. Do not put Tool execution inputs such as selections, canvases or text replacements in generation constraints. Describe those requirements with text and asset Parts when the Agent plans the task; use the corresponding Tool Schema for direct field-by-field calls.
4
+
5
+ Generation constraints example:
4
6
 
5
7
  ```json
6
8
  {
@@ -0,0 +1,29 @@
1
+ # Matting and transparent output
2
+
3
+ Distinguish preserving visible source pixels from reconstructing a complete subject. A white background, a baked checkerboard and a file with real transparency are different deliverables.
4
+
5
+ ## Choose the workflow
6
+
7
+ | Goal | Workflow | Boundary |
8
+ | --- | --- | --- |
9
+ | Remove a background while preserving an intact product, face, text or texture | Standard matting: separate the visible foreground from the original | Does not reconstruct hidden parts; inspect fine edges, hair, translucent materials and occlusion |
10
+ | Extract an obstructed object and complete its hidden parts, or redraw a selected subject from a complex scene | When reconstruction is authorized, redraw from the reference, then apply standard matting to the redraw | Reconstructed details are generated guesses and may change geometry or texture; do not describe them as exact recovery |
11
+
12
+ A complex background alone does not require redrawing. For strict fidelity or a no-redraw constraint, prefer standard matting; explain limitations or request a more complete source if necessary. An explicit request to complete hidden parts authorizes reconstruction within that scope.
13
+
14
+ ## Discover and execute
15
+
16
+ 1. Follow [Creation](creation.md) to discover current Tools and Models, relevant help, public Schema and the selected Model detail. Determine whether the capability returns real transparency or only an intermediate redraw. A model title is not an output contract. Availability, parameters and prices depend on the current product and account.
17
+ 2. Standard matting and smart matting that already includes redraw/segmentation can both be atomic [Tool](tool.md) calls. Use [Agent](agent.md) when the user's task requires business planning, orchestration or multiple outputs. When supplying a mask, follow [mask review](media-tools.md#review-masks-before-submission) to inspect the source, mask and overlay. Never treat internal algorithms, editor entries or historical test-suite names as CLI models.
18
+ 3. Use the current source supplied by the user. For reconstruction, identify the subject, missing parts and structure/proportions to retain. If the discovered smart matting model already promises a transparent PNG, inspect that final file and do not pay for a second standard matting call. Only when the selected capability returns an intermediate redraw should you pass that actual redraw into a separate matting step. Do not matte the old occluded input or reuse another image's dimensions.
19
+ 4. If no transparent-matting capability is discoverable, report the gap. A transparency prompt, white background or checkerboard is not a substitute. Do not use internal endpoints to bypass product entitlements. An available redraw may be delivered as an intermediate result with the unfinished transparency step stated clearly.
20
+
21
+ A reconstruction prompt can specify: “Use the selected subject in this reference, complete these hidden parts, preserve these visible features and proportions, and render the complete subject against an easily separable solid background. Do not draw a checkerboard or add text or other objects.” Populate constraints from the request; the prompt itself does not create an alpha channel.
22
+
23
+ ## Verify and deliver
24
+
25
+ - The calling Agent or user downloads the output and inspects the actual format, dimensions and transparency. An extension, MIME declaration or model claim does not establish matting quality. Review the background and visible subject together rather than merely checking that alpha exists. Maximum alpha need not equal 255: hair, glass and shadows can be translucent. Do not use an alpha-maximum pass threshold or force opacity.
26
+ - Inspect against both light and dark backgrounds for edge damage, holes, hair, translucent regions, leftover background and baked checkerboards. Keep the original dimensions or crop to the subject as requested.
27
+ - For reconstruction, compare product geometry, marks, identity and visible details. Identify generated completions without promising pixel fidelity.
28
+ - Deliver the file or an authorized download link. A redraw or mask alone does not complete transparent matting; preserve intermediate results and state what remains.
29
+ - Explain costs from actual stage usage; do not present estimates as deductions. After acceptance, an interruption, timeout or postprocessing failure calls for querying the original task through [Errors](errors.md), not blindly repeating successful paid generation.
@@ -0,0 +1,40 @@
1
+ # Image and video processing
2
+
3
+ First choose Agent or Tool through [creation](creation.md). These guidelines select a Tool for a single operation; business orchestration still uses Agent. Honor explicitly requested routes and models.
4
+
5
+ ## Select by purpose
6
+
7
+ | Goal | Discovery direction |
8
+ | --- | --- |
9
+ | Create a new image, recreate from references, change overall style or blend images | `image.generate`; a reference image or the word “edit” alone does not require `image.edit` |
10
+ | Create a new video from text, images, first/last frames or references | `video.generate`; supported input combinations depend on the model Schema |
11
+ | Edit a particular target or selected region in an existing image | `image.edit` |
12
+ | Remove a background/object, enhance clarity, expand a canvas, replace/read text, decompose layers or vectorize | Discover the purpose-specific Tool rather than routing every image task to `image.edit` |
13
+ | Modify an existing video's content, or enhance its clarity | Discover `video.edit` or `video.enhance` respectively; generating video from an image still uses `video.generate` |
14
+
15
+ Read `tool list`, the relevant `model list --tool <tool>`, then `model get <model> --tool <tool>`. Use the complete `inputSchema`, purpose and current quote. Availability, fields and options come from this task's discovery; one model's fields do not apply to every Tool.
16
+
17
+ ## Select a model and prepare inputs
18
+
19
+ Use the public model identifier and description rather than matching backend display names. Standard/smart are stable public categories, but the difference is specific to each Tool: standard matting separates visible source pixels, while smart matting redraws before segmentation; ordinary upscaling differs from generative restoration. Standard editing, erasure and expansion can also generate content, so “standard” does not universally mean lossless. Check fidelity requirements against the model's actual scope. Redrawing may alter product geometry, text, faces or textures; hidden details are generated guesses. For transparency read [matting](matting.md).
20
+
21
+ Identify the current source, target changes and content to preserve. Include only necessary references and assign each a subject, style, color or layout role. Organize the prompt as target → change → preserved content → reference roles → output requirements, using the user's request and confirmed media. For style-only references, name the borrowed qualities; prefer relevant references to reduce conflicting instructions about ignoring a prominent subject. Put structured model controls in their actual fields.
22
+
23
+ Expansion uses natural-pixel canvas dimensions and source top-left placement without implicit scaling. Keep source, selection and references in their Schema-defined fields; a reference image is not a mask.
24
+
25
+ ## Review masks before submission
26
+
27
+ 1. Read the selected model's mask requirements, including whether it is required, its file rules and selection semantics. Use a mask for this exact source. A valid file can still select the wrong location.
28
+ 2. View the auto-oriented source and mask, then overlay the selection on the source for review. Verify that white covers the intended subject/part without omissions and black covers protected content. Check contours, holes, edges and alignment for shifts, stretching or background selection. The overlay is only a review preview; submit the original mask required by the Schema.
29
+ 3. White must be nonempty. Use an all-white mask only for an explicitly requested whole-image operation. Follow the target's contour rather than inventing an arbitrary rectangle, unless the user selected a rectangular region. Correct misplaced selections before submitting; ask for a selection or target clarification when reliable localization is unavailable.
30
+ 4. A smart model may use an optional mask only as a visual boundary cue. Consult its description; this does not guarantee unchanged pixels outside the selection. Compare protected content before delivery.
31
+
32
+ ## Execute and deliver
33
+
34
+ Submit once following [Tool](tool.md) and wait for that task. Read current metered prices and formulas; quotes are not deductions. Query the original task after interruption rather than repeating processing, uploads or settlement.
35
+
36
+ The calling Agent or user reviews visual/audio effects; CLI quality thresholds do not decide success. Compare protected regions after editing/removal, placement and canvas after expansion, all relevant text after replacement, OCR coordinates against the returned recognition image, native template layers/resources, actual SVG contents, and video duration, frames and sound. Audio presence does not establish soundtrack preservation. Deliver the actual service result and describe observed deviations; iterate within user authorization rather than automatically changing models or regenerating poor results.
37
+
38
+ Distinguish layer goals: layout decomposition targets editable text, images and layout; smart decomposition separates objects into individual layers. A layer limit does not guarantee the actual layer count, and object decomposition is not per-character OCR. Select from the current catalog and deliver the native JSON and resources, not PSD. If editor import is requested, discover the supported operations via [Editor](editor.md) and verify editable text, layers and substituted fonts.
39
+
40
+ For video editing with multiple references, use the media labels exposed by the model Schema to state each reference's purpose and the source content to preserve. The CLI adds original filename-to-label bindings; uploaded filenames change, so a download URL's filename alone cannot identify the source's role.
@@ -7,7 +7,7 @@ Discover live metadata in this order:
7
7
  ```bash
8
8
  insmind-cli tool list
9
9
  insmind-cli model list --tool <tool>
10
- insmind-cli model get <model>
10
+ insmind-cli model get <model> --tool <tool>
11
11
  insmind-cli tool call <tool> --input request.json --async
12
12
  insmind-cli task get <taskId>
13
13
  ```