@deepblend/dsh-blender-tool 0.4.0 → 0.6.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 (2) hide show
  1. package/lib/tools.js +44 -0
  2. package/package.json +2 -2
package/lib/tools.js CHANGED
@@ -96,6 +96,7 @@ const SCENE_SPEC_PARAMETER = {
96
96
  */
97
97
  export function apply(ctx) {
98
98
  ctx.tools.register(recipeList(ctx))
99
+ ctx.tools.register(recipeParameters(ctx))
99
100
  ctx.tools.register(projectCreate(ctx))
100
101
  ctx.tools.register(projectGet(ctx))
101
102
  ctx.tools.register(sceneGet(ctx))
@@ -107,6 +108,49 @@ export function apply(ctx) {
107
108
  }
108
109
 
109
110
  /** Read verified local package metadata through the Host; never load a package in the tool plane. */
111
+ function recipeParameters(ctx) {
112
+ return defineTool({
113
+ name: 'blender_recipe_parameters',
114
+ description: 'Read or update the saved geometry controls of an existing assembled recipe project. ' +
115
+ 'Read first to obtain current revision, parameter IDs, actual saved values and allowed ranges. ' +
116
+ 'Saving needs that exact baseRevision and numeric parameters. It updates the same project, preserves independent ' +
117
+ 'materials, bevels, photography and history, and refuses manually conflicting controlled geometry. ' +
118
+ 'A scene without declared assembly controls returns available:false; do not invent parameters or replace the project. ' +
119
+ 'Saving compiles a checkpoint and preview by default; explicit false flags can request a data-only revision. ' +
120
+ 'Use a unique idempotencyKey per user save and reuse it only when retrying the same intent.',
121
+ parameters: {
122
+ action: { type: 'string', enum: ['read', 'save'], description: 'read (default) is read-only; save creates one atomic revision.' },
123
+ projectId: { type: 'string', required: true, description: 'The existing project to inspect or resize.' },
124
+ revision: { type: 'string', description: 'Optional selected revision for read; defaults to the current version.' },
125
+ baseRevision: { type: 'string', description: 'Required for save. Use the revision returned by read.' },
126
+ parameters: { type: 'object', additionalProperties: true, description: 'For save, use only numeric parameter IDs/ranges returned by read. The Host validates every value before writing.' },
127
+ idempotencyKey: { type: 'string', description: 'A unique save intent; reuse for its retry, not for a new edit after restoring history.' },
128
+ saveCheckpoint: { type: 'boolean', description: 'Save a Blender checkpoint (default true).' },
129
+ renderPreview: { type: 'boolean', description: 'Render an actual new preview (default true).' },
130
+ },
131
+ output: TOOL_OUTPUT,
132
+ async execute(args, exec) {
133
+ const resolved = resolveStudio(ctx)
134
+ if (resolved.unavailable !== undefined) return { ok: false, ...resolved.unavailable }
135
+ try {
136
+ if (resolved.studio.recipeParameterEditingSupported !== true) throw new BlenderError('RECIPE_PARAMETER_UNAVAILABLE', 'Update the Host to edit saved assembly dimensions')
137
+ const action = args.action ?? 'read'
138
+ if (!['read', 'save'].includes(action)) throw new BlenderError('RECIPE_PARAMETER_INVALID', 'Choose read or save')
139
+ const result = action === 'read'
140
+ ? resolved.studio.getRecipeParameters(args.projectId, { revision: args.revision })
141
+ : resolved.studio.updateRecipeParameters({ projectId: args.projectId, baseRevision: args.baseRevision,
142
+ parameters: args.parameters, idempotencyKey: args.idempotencyKey,
143
+ saveCheckpoint: args.saveCheckpoint !== false, renderPreview: args.renderPreview !== false,
144
+ signal: exec?.signal })
145
+ const { data, canonicalWarnings } = await canonicalCall(result, warning)
146
+ return { ok: true, text: renderSuccess(action === 'read' ? 'Saved assembly controls.' : 'Assembly dimensions saved.', data, { warnings: canonicalWarnings }), data }
147
+ } catch (cause) { return { ok: false, ...renderFailure(cause, 'RECIPE_PARAMETER_FAILED') } }
148
+ },
149
+ presentCall: args => ({ card: 'generic', title: args?.action === 'save' ? 'Save assembly dimensions' : 'Read assembly dimensions',
150
+ kind: args?.action === 'save' ? 'edit' : 'read', projectId: args?.projectId }),
151
+ })
152
+ }
153
+
110
154
  function recipeList(ctx) {
111
155
  return defineTool({
112
156
  name: 'blender_recipe_list',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepblend/dsh-blender-tool",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Agent-preset tool consumer: registers the model-visible DeepBlend Blender tools. Publishes no service.",
6
6
  "main": "lib/index.js",
@@ -11,7 +11,7 @@
11
11
  "./package.json": "./package.json"
12
12
  },
13
13
  "dependencies": {
14
- "@deepblend/dsh-blender-contracts": "0.4.0"
14
+ "@deepblend/dsh-blender-contracts": "0.6.0"
15
15
  },
16
16
  "license": "MIT",
17
17
  "repository": {