@auvira.ai/sdk 0.6.2 → 0.6.3

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.md CHANGED
@@ -45,7 +45,7 @@ auvira-sdk-run --job <editJobId>
45
45
 
46
46
  See [docs/sandbox-runner.md](docs/sandbox-runner.md) for job schema, NDJSON protocol, host integration, and session resume.
47
47
 
48
- For image placement (attachments, completion rules, host tools), see [docs/host-integration-image-placement.md](docs/host-integration-image-placement.md).
48
+ For image placement (attachments, completion rules, host tools, **Plan → Apply → Polish** host pipeline), see [docs/host-integration-image-placement.md](docs/host-integration-image-placement.md).
49
49
 
50
50
  ## Quick start (local repo)
51
51
 
@@ -15,6 +15,94 @@ This guide maps the generic image-placement architecture to **SDK APIs (v0.6+)**
15
15
  | Vision bytes for model | Optional | `images[]` on send payload |
16
16
  | Serializable multi-file completion | Configures | `completion.rules` |
17
17
  | Built-in `get_attachment_urls` | Can override | Shipped generic tool |
18
+ | `classifyImageEditMode` / `runImageEditPipeline` | Yes — runs **before** `Agent.send` | No |
19
+ | Deterministic image applier + embedding verify/retry | Yes | No |
20
+ | Plan → Apply → Polish routing by intent | Yes | Speed + completion only |
21
+
22
+ ## Plan → Apply → Polish (host-owned pipeline)
23
+
24
+ For fast image edits, the **host orchestrator runs before `Agent.send`**. It classifies intent, applies images deterministically when possible, and calls the SDK agent only for polish or full creative work. The SDK stays generic — it does not know `siteConfig`, placement targets, or applier logic.
25
+
26
+ ```mermaid
27
+ flowchart TD
28
+ hostOrch[Host orchestrator before Agent.send]
29
+ direct[direct_embed]
30
+ plan[placement_plan]
31
+ style[embed_then_style]
32
+ creative[full_creative]
33
+
34
+ hostOrch --> direct
35
+ hostOrch --> plan
36
+ hostOrch --> style
37
+ hostOrch --> creative
38
+
39
+ direct --> hostApply1[Host deterministic applier]
40
+ plan --> hostPlan[Host JSON plan call]
41
+ hostPlan --> hostApply2[Host deterministic applier]
42
+ style --> hostApply3[Host deterministic applier]
43
+ style --> sdkPolish[SDK agent polish pass]
44
+ creative --> sdkAgent[SDK full agentic loop]
45
+ ```
46
+
47
+ | Mode | Host responsibility | SDK involvement |
48
+ | --- | --- | --- |
49
+ | **`direct_embed`** | Deterministic applier; **0 agent tools**; usually **no `Agent.send`** | Attachments / completion types only if a follow-up turn is needed |
50
+ | **`placement_plan`** | One JSON planning call (host LLM + schema); deterministic applier; **no SDK agentic file tools** | Not required for planning (host may use its own LLM client) |
51
+ | **`embed_then_style`** | Deterministic apply first (image URL already wired) | Short polish/style `Agent.send`; `completion.rules` must keep the wired URL present |
52
+ | **`full_creative`** | Classify + optional pre-context | Full agentic loop; v0.6.2 parallel read batches speed discovery |
53
+
54
+ **SDK owns:** attachments, host tools, completion rules, agentic loop, API queue, parallel read-only tools.
55
+
56
+ **Host owns:** image classification, placement mapping, deterministic applying, embedding verification, retry logic.
57
+
58
+ ### Example: `embed_then_style` polish pass
59
+
60
+ After the host applies the image (no agent file tools), call the SDK for animation/style only. Most consumers wire hero URLs in `siteConfig.ts`; some use `page.tsx` or a component — tune `pathPattern` to your repo.
61
+
62
+ **Recommended:** inject the exact URL the host just wired — strongest gate for the polish pass:
63
+
64
+ ```ts
65
+ const uploadedImagePublicUrl = attachments[0].publicUrl; // e.g. "/uploads/hero-abc.png"
66
+
67
+ function escapeRegex(value: string): string {
68
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
69
+ }
70
+
71
+ await agent.send(
72
+ {
73
+ text: styleOnWiredBaselinePrompt, // host-owned
74
+ attachments, // already wired by host applier
75
+ },
76
+ {
77
+ completion: {
78
+ mode: "multi_file_required",
79
+ multiStep: { minToolCalls: 1, maxExtraTurnsAfterStyleOnly: 2 },
80
+ rules: {
81
+ requiredContent: [
82
+ {
83
+ // siteConfig.ts is the common case; extend for inline page/component wiring
84
+ pathPattern: "(siteConfig\\.ts|page\\.tsx|.*components/.*\\.(tsx|ts))",
85
+ contentPattern: escapeRegex(uploadedImagePublicUrl),
86
+ nudge: `Keep the wired image URL ${uploadedImagePublicUrl}; add animation/style only.`,
87
+ },
88
+ ],
89
+ },
90
+ },
91
+ },
92
+ );
93
+ ```
94
+
95
+ **Alternative** (prefix-only, when `/uploads/` or `/assets/` is enough):
96
+
97
+ ```ts
98
+ contentPattern: 'backgroundImageUrl\\s*:\\s*["\']/(uploads|assets)/',
99
+ ```
100
+
101
+ For **`full_creative`**, use the normal agentic path with tuned `completion.rules`. v0.6.2 parallel read tools (`grep`, `read`, `glob`, etc.) reduce discovery latency when the model batches exploration.
102
+
103
+ **Not in SDK:** `classifyImageEditMode`, `runImageEditPipeline`, `ImagePlacementTarget`, `applyImageToConfig`, embedding verification, or gallery `ImagePlacementPlan` replacement — implement these in the consumer repo.
104
+
105
+ **Optional later:** a generic `planOnly` send mode (single structured JSON call, no tool loop) if the host wants to drop duplicated planner LLM client code. Defer until the consumer pipeline proves that need.
18
106
 
19
107
  ## Layer 1 — Attachments vs vision images
20
108
 
@@ -137,7 +137,9 @@ auvira-sdk-run --job <editJobId>
137
137
  - `hostTools` are **not** supported in `job.json` v1 — register them in-process via `Agent.create` / `Agent.send`.
138
138
  - `model.apiKey` is rejected by the validator.
139
139
 
140
- See [host-integration-image-placement.md](./host-integration-image-placement.md) for the full SDK vs website-repo split.
140
+ See [host-integration-image-placement.md](./host-integration-image-placement.md) for the full SDK vs website-repo split, including the **Plan → Apply → Polish** host pipeline (`direct_embed`, `placement_plan`, `embed_then_style`, `full_creative`).
141
+
142
+ For image edits routed by the host orchestrator: Cases 1–3 (deterministic apply / plan-then-apply) typically **do not** spawn a sandbox job or call `Agent.send`. Case 4 (`full_creative`) uses this runner; v0.6.2 parallel read tools and `AUVIRA_API_MAX_CONCURRENT` apply inside the VM the same as in-process runs.
141
143
 
142
144
  ## Result (`SandboxAuviraJobResult`)
143
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auvira.ai/sdk",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Cursor-SDK-compatible visual coding agent with custom model support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "test:runner:image-gen": "AUVIRA_REAL_IMAGE_GEN_E2E=true AUVIRA_IMAGE_GEN_ENABLED=true node --env-file=.env ./node_modules/vitest/vitest.mjs run src/__tests__/runner/run-cli-generate-image.real.e2e.test.ts",
50
50
  "test:real:image-api": "AUVIRA_REAL_IMAGE_API=true AUVIRA_IMAGE_GEN_ENABLED=true node --env-file=.env ./node_modules/vitest/vitest.mjs run src/__tests__/real/minimax-image-api.real.test.ts",
51
51
  "test:real:multi-image": "AUVIRA_REAL_MULTI_IMAGE_E2E=true node --env-file=.env ./node_modules/vitest/vitest.mjs run src/__tests__/real/agent-multi-image.e2e.test.ts src/__tests__/runner/run-cli-multi-image.real.e2e.test.ts",
52
- "test:real:attachment-placement": "AUVIRA_REAL_ATTACHMENT_E2E=true node --env-file=.env ./node_modules/vitest/vitest.mjs run src/__tests__/real/agent-attachment-placement.e2e.test.ts src/__tests__/runner/run-cli-attachment-placement.real.e2e.test.ts",
52
+ "test:real:attachment-placement": "AUVIRA_REAL_ATTACHMENT_E2E=true node --env-file=.env ./node_modules/vitest/vitest.mjs run src/__tests__/real/agent-attachment-placement.e2e.test.ts src/__tests__/real/agent-attachment-animation.e2e.test.ts src/__tests__/runner/run-cli-attachment-placement.real.e2e.test.ts",
53
53
  "test:runner:vibe": "node --env-file=.env ./node_modules/vitest/vitest.mjs run src/__tests__/runner/run-cli-vibe-consumer.real.e2e.test.ts"
54
54
  },
55
55
  "keywords": [