fittings-text-char-edit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExact character-position string edit
精确字符位置字符串编辑
text.char-edithttps://fittings.shInsert, delete, replace, extract, locate or measure at exact character offsets, counting by grapheme, code point or UTF-16 unit, with the affected range reported in both the chosen unit and UTF-16.
text.char-edithttps://fittings.sh可在精确的字符偏移位置执行插入、删除、替换、提取、定位或测量操作,支持按grapheme、code point或UTF-16单位计数,受影响范围会同时以所选单位和UTF-16单位返回。
The call
调用方式
POST https://fittings.sh/v1/text/char-edit| Field | Type | Required | Notes |
|---|---|---|---|
| string | yes | Text to operate on, 20000 UTF-16 units or fewer |
| string | yes | insert | delete | replace | extract | find | measure |
| string | no | grapheme | codepoint (default) | utf16 |
| number | no | insert: offset to insert before |
| number | no | delete, replace, extract: first offset in the range |
| number | no | delete, replace, extract: offset just past the range |
| string | no | insert, replace: text to put in, 5000 UTF-16 units or fewer |
| string | no | find: substring to locate |
| number | no | find: offset to start searching at, default 0 |
Example input:
json
{
"text": "The quick brown fox",
"op": "replace",
"unit": "codepoint",
"start": 4,
"end": 9,
"value": "slow"
}POST https://fittings.sh/v1/text/char-edit| 字段 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| string | 是 | 要操作的文本,最多20000个UTF-16单位 |
| string | 是 | insert | delete | replace | extract | find | measure |
| string | 否 | grapheme | codepoint(默认)| utf16 |
| number | 否 | insert:插入位置的偏移量(插入到该位置之前) |
| number | 否 | delete、replace、extract:范围的起始偏移量 |
| number | 否 | delete、replace、extract:范围的结束偏移量(不包含该位置) |
| string | 否 | insert、replace:要插入/替换的文本,最多5000个UTF-16单位 |
| string | 否 | find:要定位的子字符串 |
| number | 否 | find:搜索的起始偏移量,默认值为0 |
示例输入:
json
{
"text": "The quick brown fox",
"op": "replace",
"unit": "codepoint",
"start": 4,
"end": 9,
"value": "slow"
}Metered
计量方式
The 402 quotes a ceiling — the price of the declared cap, 20000 characters — and settlement is for what the call actually used. A small request settles for less than it was quoted, so read the quote as an upper bound rather than a price.
402响应会给出一个上限报价——即声明的最大容量(20000字符)对应的价格——而最终结算则按调用实际使用的字符数计算。小请求的结算金额会低于报价,因此请将报价视为上限而非固定价格。
Cost and provenance
费用与来源
| Price | $0.003 per call, metered per characters |
| Source | none (pure compute) |
| Licence | none-needed |
| 价格 | 每次调用0.003美元,按字符数计量 |
| 数据源 | 无(纯计算服务) |
| 许可证 | 无需许可证 |
Why call it rather than answer from memory
为何调用该服务而非自行实现
Character-indexed string edits are a measured failure mode for language models (arXiv:2409.15452), and the index a model reasons about is rarely the index a runtime uses: a skin-toned emoji is one grapheme, two code points and four UTF-16 units, so an offset is wrong until the unit is named.
基于字符索引的字符串编辑是语言模型的一个已被证实的失效场景(arXiv:2409.15452),且模型推理时使用的索引与运行时使用的索引往往不同:一个带肤色的emoji是1个grapheme、2个code point和4个UTF-16单位,因此在明确计数单位前,偏移量是不准确的。
Calling it
调用指南
A skill is loaded on its own, so this document has to be enough by itself. It
does not assume the general skill is also loaded.
ships alongside this file; if it is missing (this document reached you without
the rest of the skill), fetch it once with
.
fittingscall.mjscurl -sO https://fittings.sh/skill/call.mjsFree, and needs no wallet. Read the schema and see what a call would cost:
bash
curl -s https://fittings.sh/catalog/text.char-edit | jqPaying. The endpoint answers with a signed quote,
you sign an authorization, and a facilitator settles it — you never send a
transaction and never pay gas. Before it spends anything, the client checks its
own hash against the gateway and refuses rather than sign with logic the
gateway has moved past:
402 Payment Requiredbash
undefined该技能是独立加载的,因此本文档本身包含所有必要信息,无需依赖通用的技能。文件与本文档一同提供;如果缺失(本文档单独发送给您),可通过以下命令获取:
。
fittingscall.mjscurl -sO https://fittings.sh/skill/call.mjs免费操作,无需钱包。查看接口schema并了解调用费用:
bash
curl -s https://fittings.sh/catalog/text.char-edit | jq付费调用。接口会返回响应及签名报价,您需签署授权信息,由服务商完成结算——您无需发送交易,也无需支付gas费用。在产生费用前,客户端会将自身哈希与网关进行校验,若网关逻辑已更新则会拒绝签署:
402 Payment Requiredbash
undefinedDry run. Prints the quote and pays nothing, because no key is set.
预演。仅打印报价,无需支付,因为未设置密钥。
node call.mjs text.char-edit text="The quick brown fox" op=replace unit=codepoint start=4 end=9 value=slow
node call.mjs text.char-edit text="The quick brown fox" op=replace unit=codepoint start=4 end=9 value=slow
For real: a wallet holding USDC on Base, and nothing else.
实际调用:使用持有Base网络USDC的钱包,无需其他资产。
export FITTINGS_PRIVATE_KEY=0x...
node call.mjs text.char-edit text="The quick brown fox" op=replace unit=codepoint start=4 end=9 value=slow
Spending is never a side effect of curiosity: with no `FITTINGS_PRIVATE_KEY`
the client fetches the quote and stops. `FITTINGS_MAX_PRICE` caps what it will
pay without asking, and defaults to $0.05.
**Use a throwaway wallet holding a few dollars, not a main one.** The key sits
in plaintext wherever the agent runs, and the whole cost of entry is USDC on
Base — no account, no API key, and no ETH, because the payer signs off-chain and
the facilitator broadcasts and pays the gas.
Writing your own client instead of using this one? `@x402/core` and
`@x402/evm` on npm, and the `fittings` skill records the two things that cost
real debugging time: the challenge is in a response header rather than the body,
and it must be re-signed from the exact request being retried.
If this is not the right service, `https://fittings.sh/catalog/search?q=...`
searches all of them for free.export FITTINGS_PRIVATE_KEY=0x...
node call.mjs text.char-edit text="The quick brown fox" op=replace unit=codepoint start=4 end=9 value=slow
仅出于好奇的操作不会产生费用:未设置`FITTINGS_PRIVATE_KEY`时,客户端只会获取报价后停止操作。`FITTINGS_MAX_PRICE`用于设置无需确认的最高支付限额,默认值为0.05美元。
**请使用仅持有少量资金的临时钱包,不要使用主钱包**。密钥会以明文形式存储在代理运行的环境中,入门成本仅为Base网络上的USDC——无需账户、API密钥或ETH,因为付款方进行链下签名,由服务商负责广播交易并支付gas费用。
不想使用该客户端,希望自行开发?可使用npm上的`@x402/core`和`@x402/evm`包,`fittings`技能记录了两个耗费大量调试时间的要点:挑战信息位于响应头而非响应体中,且必须针对重试的精确请求重新签名。
如果该服务不符合您的需求,可通过`https://fittings.sh/catalog/search?q=...`免费搜索所有可用服务。