You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
Copy file name to clipboardExpand all lines: .claude/da-plans/core/phase-1-antfly-migration/1.1-spike-findings.md
+14-19Lines changed: 14 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
| 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. |
15
15
| 5 | Latency of lookup vs vector search? | Lookup is near-instant. Semantic search ~1-2ms for 10 docs. Both fast at this scale. |
16
16
| 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. |
18
18
| 8 | What happens when antfly server is not running? | curl gets `ECONNREFUSED`. Clear and fast failure. |
19
19
| 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. |
20
20
| 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
75
75
`client.tables.get()` returns `storage_status.disk_usage` in bytes. This can replace
76
76
the `storageSize` field in `VectorStats` (currently reads local LanceDB directory).
77
77
78
-
## SDK Issues
78
+
## SDK Notes
79
79
80
-
### CJS/ESM interop bug
80
+
### CJS build has a bug (doesn't affect us)
81
81
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.
83
85
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.
87
88
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.
90
91
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.
100
95
101
96
## Docker Findings
102
97
@@ -119,7 +114,7 @@ Need to verify Docker image + `swarm` command works end-to-end.
119
114
120
115
## Impact on Plan
121
116
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
123
118
2.**Model pull: use default variant** (not `--variants i8`) until i8 is fixed
124
119
3.**`dev index` must wait for embeddings** — poll or add brief sleep after batch insert
125
120
4.**Table info provides disk_usage** — can populate `VectorStats.storageSize`
0 commit comments