feat(codemode): add confined execution package (#35079)
This commit is contained in:
parent
379adee35c
commit
2409c7a3d5
20 changed files with 9109 additions and 15 deletions
10
packages/codemode/src/token.ts
Normal file
10
packages/codemode/src/token.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Token estimation for budgeting model-facing text. Copied from
|
||||
* `@opencode-ai/core/util/token` (chars / 4) so this package stays
|
||||
* dependency-free; keep the two in sync if the heuristic ever changes.
|
||||
*/
|
||||
export * as Token from "./token.js"
|
||||
|
||||
const CHARS_PER_TOKEN = 4
|
||||
|
||||
export const estimate = (input: string) => Math.max(0, Math.round(input.length / CHARS_PER_TOKEN))
|
||||
Loading…
Add table
Add a link
Reference in a new issue