@x-otto/interchange 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/dist/index.d.ts +1373 -0
- package/dist/index.js +2 -0
- package/package.json +28 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`[Conversation Summary]`;function t(e){return e.content.filter(e=>e.type===`tool_call`)}function n(e){return e.content.some(e=>e.type===`tool_call`)}function r(e){return Array.isArray(e.input)&&e.input.includes(`image`)}function i(e){return e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2
|
+
`)}const a=/^data:([^;,]*)(?:;[^,]*)?,(.*)$/s;function o(e,t){let n=a.exec(e),r=(n?n[2]??``:e).replace(/\s+/g,``);return{base64:r,mediaType:((n?n[1]:``)||t||``).toLowerCase(),valid:s(r)}}function s(e){return e.length===0||e===`undefined`||e.length%4==1?!1:/^[A-Za-z0-9+/]*={0,2}$/.test(e)}function c(e,t){switch(e.toLowerCase()){case`image/jpeg`:case`image/jpg`:return`image/jpeg`;case`image/png`:return`image/png`;case`image/gif`:return`image/gif`;case`image/webp`:return`image/webp`;default:return l(t)}}function l(e){return e.startsWith(`/9j/`)?`image/jpeg`:e.startsWith(`iVBOR`)?`image/png`:e.startsWith(`R0lGOD`)?`image/gif`:e.startsWith(`UklGR`)?`image/webp`:`image/png`}function u(e){return e===`hashtag`?`#`:`@`}const d=/(?:^|\s)([#@])(\S*)$/;function f(e,t){let n=e.slice(0,t).match(d);if(!n)return null;let r=n[1],i=n[2]??``;return{sigil:r,query:i,anchor:t-i.length-1}}function p(e,t){return!!t&&t.sigil===e.sigil&&t.anchor===e.anchor}function m(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=n-r,a=0;for(;a<i&&e[e.length-1-a]===t[t.length-1-a];)a++;return{start:r,end:e.length-a,delta:t.length-e.length}}function h(e,t,n){if(!e||t===n)return e;let{start:r,end:i,delta:a}=m(t,n),o=e.anchor+e.tokenLength;return i<=e.anchor?{...e,anchor:e.anchor+a}:r>=o||r>e.anchor&&r<o?e:null}function g(e,t,n,r){if(n<0||n>t)return{text:e,offset:t};let i=t>=e.length?` `:``;return{text:e.slice(0,n)+r.value+i+e.slice(t),offset:n+r.value.length+(i?1:0)}}function _(e,t,n,r){return t<0||t>n||n>e.length?{text:e,offset:n}:{text:e.slice(0,t)+r.value+e.slice(n),offset:t+r.value.length}}function v(e){let{source:t,oldText:n,newText:r,cursorOffset:i}=e,a=e.sigilFilter??(e=>e===`@`),o=h(e.dismissed,n,r);if(t!==`typing`||r.length<=n.length)return{action:`suppress`,dismissed:o};let s=f(r,i),c=s&&a(s.sigil)?s:null;return c?p(c,o)?{action:`suppress`,dismissed:o}:{action:`open`,trigger:c,dismissed:null}:{action:`close`,dismissed:o}}export{e as CONVERSATION_SUMMARY_PREFIX,h as adjustDismissedSigil,g as applySigilCompletion,_ as applySigilReplacement,v as evaluateSigilTrigger,f as extractSigilPrefix,i as extractToolResultText,t as getToolCallsByAssistantMessage,n as hasToolCalls,p as isSigilDismissed,r as modelSupportsImages,o as normalizeImageData,u as sigilOf,c as toAnthropicImageMime};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-otto/interchange",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org",
|
|
19
|
+
"tag": "alpha"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsdown && rm -f dist/*.map && sed -i '' '\\|//# sourceMappingURL=|d' dist/*.js dist/browser/index.js 2>/dev/null; true",
|
|
23
|
+
"typecheck:project": "tsc -p tsconfig.json --noEmit",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"clean": "rm -rf dist"
|
|
27
|
+
}
|
|
28
|
+
}
|