Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ jobs:
- uses: actions/setup-node@v7
with: { node-version: "22" }
- run: npm install
- name: Generated Worker types are fresh (wrangler types)
run: |
npm run gen:types
git diff --exit-code worker-configuration.d.ts
- run: npm run typecheck
- run: npm run lint
- run: npm run format:check
- run: npm run build
- name: Tests + production parity gate
run: npx vitest run
build:
Expand All @@ -26,5 +31,7 @@ jobs:
with: { node-version: "22" }
- run: npm install
- run: npm run build
# Strict bundle smoke: validate wrangler.jsonc and the full worker
# bundle without credentials. A failure fails the job.
- name: Bundle smoke (wrangler dry run, no credentials)
run: npx wrangler deploy --dry-run --outdir dist-worker || true
run: npx wrangler deploy --dry-run --outdir dist-worker
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
# dist ships committed: git-dependent installs cannot run prepare
coverage/
.wrangler/
dist-worker/
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,27 @@ Minimal `wrangler.jsonc`:
}
```

with `src/index.ts` re-exporting the package, then `wrangler deploy`.
A canonical `wrangler.jsonc` ships in this repository (no routes, no
secrets) — start from it, add your route, then `wrangler deploy`. It
includes an `alias` entry that redirects the engine's optional
`onnxruntime-node` probe to a stub (`stubs/onnxruntime-node.js`) so the
Worker bundle never traverses the native binary; if your own config
hits a "No loader is configured for \".node\" files" error, add the same
alias. If you edit the config, regenerate the ambient runtime types
with `npm run gen:types` (writes `worker-configuration.d.ts`).
See the [deployment repo](https://github.com/interscript/api.interscript.org)
for a complete, working example.
for a complete, working example (it pins this package and fetches a
release map artifact — the deploy commands there stay owner-run).

## Development

```bash
npm install
npm run build # tsc
npm test # vitest
npm run build # tsc + esbuild bundle
npm test # vitest (incl. the production parity gate)
npm run typecheck
npm run lint
npm run gen:types # regenerate worker-configuration.d.ts after wrangler.jsonc edits
```

Regenerating the map corpus (requires the interscript/maps and
Expand Down
6 changes: 6 additions & 0 deletions dist/src/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ const ENDPOINTS = [
{ method: "GET", path: "/v1/models", note: "neural model index (IMF v1)" },
{ method: "GET", path: "/v1/models/{id}", note: "one model's metadata" },
{ method: "POST", path: "/v1/infer", note: "{model, input} → {output}" },
{ method: "POST", path: "/v1/infer/batch", note: "{model, inputs[]} → per-item results (≤50)" },
{
method: "GET",
path: "/v1/assets/{tag}/{file}",
note: "CORS streaming proxy for release assets",
},
{ method: "POST", path: "/graphql", note: "GraphQL endpoint (introspection enabled)" },
{ method: "GET", path: "/openapi.json", note: "OpenAPI 3.1 document" },
];
Expand Down
20 changes: 15 additions & 5 deletions dist/src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
import { configure, transliterateAsync } from "interscript";
import { bundledSystemCodes, detectableSystemCodes, loadMap } from "./maps.js";
import { mapScripts } from "../maps/scripts.js";
import { detectInputScript, sourceMatchesScript } from "./scripts.js";
let configuredFor;
function ensureEngine(assets) {
if (configuredFor === assets)
Expand Down Expand Up @@ -33,14 +35,22 @@ function levenshtein(a, b) {
}
return prev[b.length];
}
// Mirrors interscript-ruby's detector: transliterate the input through
// every system, rank by Levenshtein distance to the output. Systems
// that fail (including ML-powered maps with no runtime configured) are
// skipped, exactly as the Ruby detector rescues per-map errors.
// Transliterate the input through every system whose source script
// matches the input, rank by Levenshtein distance to the output.
// Systems that fail (including ML-powered maps with no runtime
// configured) are skipped, exactly as the Ruby detector rescues
// per-map errors. The full-corpus walk is gone deliberately: it
// exceeded the Workers CPU budget (1102s in production).
export async function detect(assets, input, output) {
ensureEngine(assets);
// Only systems whose source script matches the input can rank: walking
// all 288 maps exhausts the Workers CPU budget (1102s in production).
const detected = detectInputScript(input);
const codes = detected
? detectableSystemCodes().filter((code) => sourceMatchesScript(mapScripts[code], detected))
: [];
const candidates = [];
for (const code of detectableSystemCodes()) {
for (const code of codes) {
try {
const transliterated = await transliterateAsync(code, input);
candidates.push({ mapName: code, distance: levenshtein(transliterated, output) });
Expand Down
Loading
Loading