Skip to content

Commit d34b495

Browse files
prosdevclaude
andcommitted
docs(plans): correct spike findings — SDK works via ESM
CJS bug only affects CJS consumers. All dev-agent packages use ESM ("type": "module"), so @antfly/sdk works fine. Use it directly instead of building a raw fetch() wrapper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3eb7961 commit d34b495

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

.claude/da-plans/core/phase-1-antfly-migration/1.1-spike-findings.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| 4 | What does `client.tables.get()` return? | Returns table info including `storage_status.disk_usage` (bytes), index configs, and shard info. **No direct doc count** — need to use a query with limit to count. |
1515
| 5 | Latency of lookup vs vector search? | Lookup is near-instant. Semantic search ~1-2ms for 10 docs. Both fast at this scale. |
1616
| 6 | Can we full-scan without a query vector? | **Yes** — use the global `/api/v1/query` endpoint with just `table` and `limit`, no `semantic_search`. Returns all docs. |
17-
| 7 | Does the SDK handle connection errors gracefully? | **SDK has a CJS/ESM interop bug** `TypeError: (0 , import_openapi_fetch.default) is not a function`. Direct REST API works fine. See SDK issues section below. |
17+
| 7 | Does the SDK handle connection errors gracefully? | **SDK works fine via ESM** (our default). CJS build has a bug with `openapi-fetch` default export — only affects CJS consumers. See SDK notes below. |
1818
| 8 | What happens when antfly server is not running? | curl gets `ECONNREFUSED`. Clear and fast failure. |
1919
| 9 | Does `getAll()` paginate beyond 10000 docs? | Not tested at scale in this spike. The query endpoint accepts `limit` — likely works up to a reasonable size. Need to test with a real repo index. |
2020
| 10 | Does `dev index` need to wait for embedding completion? | **Yes.** There's a ~2s delay between insert and searchability. For a full index run, we should wait for all embeddings to complete before declaring success. Poll embedding status or add a brief wait. |
@@ -75,28 +75,23 @@ not found. This is a massive improvement over the current `get()` implementation
7575
`client.tables.get()` returns `storage_status.disk_usage` in bytes. This can replace
7676
the `storageSize` field in `VectorStats` (currently reads local LanceDB directory).
7777

78-
## SDK Issues
78+
## SDK Notes
7979

80-
### CJS/ESM interop bug
80+
### CJS build has a bug (doesn't affect us)
8181

82-
The `@antfly/sdk` v0.0.14 fails when imported in a CJS context (e.g., via `tsx`):
82+
The SDK's CJS bundle (`dist/index.cjs`) fails because `openapi-fetch` is ESM-only.
83+
`tsup` wraps it with `__toESM(require("openapi-fetch"))` and accesses `.default`,
84+
which is `undefined` in CJS context.
8385

84-
```
85-
TypeError: (0 , import_openapi_fetch.default) is not a function
86-
```
86+
**This doesn't affect dev-agent.** All our packages use `"type": "module"` (ESM).
87+
The ESM import path (`dist/index.js`) works correctly.
8788

88-
The SDK's CJS bundle (`dist/index.cjs`) doesn't correctly handle the `openapi-fetch`
89-
default export.
89+
The spike error was from `npx tsx` which loaded the CJS path — not representative
90+
of our actual runtime.
9091

91-
**Workaround options:**
92-
1. Use ESM imports only (our packages use ESM anyway)
93-
2. Use the REST API directly with `fetch()` instead of the SDK
94-
3. Report the bug to antfly team (the user's friend built it)
95-
96-
**Recommendation:** Start with direct REST API calls via `fetch()`. The SDK is thin
97-
(just openapi-fetch wrapper) and we need only 6-7 endpoints. Building our own thin
98-
client gives us full control and avoids SDK version coupling. We can adopt the SDK
99-
later when it stabilizes (v0.0.x is very early).
92+
**Recommendation:** Use `@antfly/sdk` directly. It's type-safe, auto-generated from
93+
OpenAPI spec, and works fine via ESM. Worth mentioning the CJS bug to the antfly
94+
team (fix: `noExternal: ['openapi-fetch']` in tsup config) for other consumers.
10095

10196
## Docker Findings
10297

@@ -119,7 +114,7 @@ Need to verify Docker image + `swarm` command works end-to-end.
119114

120115
## Impact on Plan
121116

122-
1. **Use direct REST API instead of SDK**avoids CJS/ESM bug and early SDK instability
117+
1. **Use `@antfly/sdk` directly** — ESM works fine, type-safe, auto-generated from OpenAPI
123118
2. **Model pull: use default variant** (not `--variants i8`) until i8 is fixed
124119
3. **`dev index` must wait for embeddings** — poll or add brief sleep after batch insert
125120
4. **Table info provides disk_usage** — can populate `VectorStats.storageSize`

0 commit comments

Comments
 (0)