@alwith/module-chat 0.1.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/LICENSE +94 -0
- package/README.md +54 -0
- package/THIRD_PARTY_NOTICES.md +43 -0
- package/dist/activity-host.d.ts +32 -0
- package/dist/activity-host.js +1 -0
- package/dist/approval/choice-elicitation-form.d.ts +15 -0
- package/dist/approval/choice-elicitation-form.js +1 -0
- package/dist/approval/choice-schema.d.ts +18 -0
- package/dist/approval/choice-schema.js +1 -0
- package/dist/approval/permission-options.d.ts +7 -0
- package/dist/approval/permission-options.js +1 -0
- package/dist/approval/permission-view.d.ts +19 -0
- package/dist/approval/permission-view.js +1 -0
- package/dist/approval/schema-elicitation-form.d.ts +29 -0
- package/dist/approval/schema-elicitation-form.js +1 -0
- package/dist/approval/url-elicitation-card.d.ts +8 -0
- package/dist/approval/url-elicitation-card.js +1 -0
- package/dist/codex/activity-group.d.ts +15 -0
- package/dist/codex/activity-group.js +6 -0
- package/dist/codex/assistant-message.d.ts +43 -0
- package/dist/codex/assistant-message.js +2 -0
- package/dist/codex/disclosure-state.d.ts +2 -0
- package/dist/codex/disclosure-state.js +1 -0
- package/dist/codex/edited-files-card.d.ts +15 -0
- package/dist/codex/edited-files-card.js +2 -0
- package/dist/codex/markdown-renderer.d.ts +11 -0
- package/dist/codex/markdown-renderer.js +6 -0
- package/dist/codex/markdown.css +760 -0
- package/dist/codex/navigation-audio.d.ts +18 -0
- package/dist/codex/navigation-audio.js +1 -0
- package/dist/codex/navigation-instruments.d.ts +54 -0
- package/dist/codex/navigation-instruments.js +1 -0
- package/dist/codex/navigation-preview.d.ts +8 -0
- package/dist/codex/navigation-preview.js +1 -0
- package/dist/codex/navigation-rail.css +216 -0
- package/dist/codex/navigation-rail.d.ts +25 -0
- package/dist/codex/navigation-rail.js +1 -0
- package/dist/codex/patch-view.d.ts +8 -0
- package/dist/codex/patch-view.js +2 -0
- package/dist/codex/plan.d.ts +4 -0
- package/dist/codex/plan.js +1 -0
- package/dist/codex/styles.css +1238 -0
- package/dist/codex/terminal-output.d.ts +3 -0
- package/dist/codex/terminal-output.js +1 -0
- package/dist/codex/thread-virtualizer.d.ts +52 -0
- package/dist/codex/thread-virtualizer.js +1 -0
- package/dist/codex/user-message.d.ts +30 -0
- package/dist/codex/user-message.js +1 -0
- package/dist/codex/virtualized-turn-list.d.ts +16 -0
- package/dist/codex/virtualized-turn-list.js +1 -0
- package/dist/composer/completion-filter.d.ts +12 -0
- package/dist/composer/completion-filter.js +1 -0
- package/dist/composer/completion-menu.d.ts +21 -0
- package/dist/composer/completion-menu.js +3 -0
- package/dist/composer/completion-trigger.d.ts +8 -0
- package/dist/composer/completion-trigger.js +3 -0
- package/dist/composer/effort-slider.d.ts +10 -0
- package/dist/composer/effort-slider.js +1 -0
- package/dist/composer/menu-radio.d.ts +15 -0
- package/dist/composer/menu-radio.js +1 -0
- package/dist/composer/model-select.d.ts +56 -0
- package/dist/composer/model-select.js +1 -0
- package/dist/composer/permission-mode-select.d.ts +13 -0
- package/dist/composer/permission-mode-select.js +1 -0
- package/dist/composer/prompt-input-attachments.d.ts +16 -0
- package/dist/composer/prompt-input-attachments.js +1 -0
- package/dist/composer/prompt-input-clipboard.d.ts +10 -0
- package/dist/composer/prompt-input-clipboard.js +1 -0
- package/dist/composer/prompt-input-context.d.ts +59 -0
- package/dist/composer/prompt-input-context.js +1 -0
- package/dist/composer/prompt-input-textarea.d.ts +13 -0
- package/dist/composer/prompt-input-textarea.js +3 -0
- package/dist/composer/prompt-input.d.ts +44 -0
- package/dist/composer/prompt-input.js +1 -0
- package/dist/image-lightbox.d.ts +5 -0
- package/dist/image-lightbox.js +1 -0
- package/dist/image-preview-dialog.d.ts +14 -0
- package/dist/image-preview-dialog.js +1 -0
- package/dist/lib/code-highlighter.d.ts +27 -0
- package/dist/lib/code-highlighter.js +1 -0
- package/dist/lib/code-highlighter.worker.d.ts +1 -0
- package/dist/lib/code-highlighter.worker.js +1 -0
- package/dist/lib/fuzzy.d.ts +11 -0
- package/dist/lib/fuzzy.js +1 -0
- package/dist/lib/group-blocks.d.ts +5 -0
- package/dist/lib/group-blocks.js +1 -0
- package/dist/lib/image-encode.d.ts +1 -0
- package/dist/lib/image-encode.js +1 -0
- package/dist/lib/limits.d.ts +5 -0
- package/dist/lib/limits.js +1 -0
- package/dist/lib/markdown-parser.d.ts +34 -0
- package/dist/lib/markdown-parser.js +1 -0
- package/dist/lib/markdown-parser.worker.d.ts +1 -0
- package/dist/lib/markdown-parser.worker.js +1 -0
- package/dist/lib/markdown-rules.d.ts +9 -0
- package/dist/lib/markdown-rules.js +1 -0
- package/dist/lib/pointer-centered-zoom.d.ts +13 -0
- package/dist/lib/pointer-centered-zoom.js +1 -0
- package/dist/lib/prepare-prompt-files.d.ts +7 -0
- package/dist/lib/prepare-prompt-files.js +1 -0
- package/dist/lib/stream-entry.d.ts +28 -0
- package/dist/lib/stream-entry.js +0 -0
- package/dist/lib/stream-style.d.ts +15 -0
- package/dist/lib/stream-style.js +2 -0
- package/dist/lib/streaming-markdown.d.ts +4 -0
- package/dist/lib/streaming-markdown.js +2 -0
- package/dist/locales.d.ts +489 -0
- package/dist/locales.js +1 -0
- package/dist/search/chat-search.d.ts +19 -0
- package/dist/search/chat-search.js +1 -0
- package/dist/search/dom-matches.d.ts +1 -0
- package/dist/search/dom-matches.js +1 -0
- package/dist/search/find-bar.d.ts +14 -0
- package/dist/search/find-bar.js +1 -0
- package/dist/search/literal-matches.d.ts +12 -0
- package/dist/search/literal-matches.js +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.js +0 -0
- package/dist/ui/badge.d.ts +7 -0
- package/dist/ui/badge.js +1 -0
- package/dist/ui/button.d.ts +8 -0
- package/dist/ui/button.js +1 -0
- package/dist/ui/card.d.ts +11 -0
- package/dist/ui/card.js +1 -0
- package/dist/ui/checkbox.d.ts +3 -0
- package/dist/ui/checkbox.js +1 -0
- package/dist/ui/dialog.d.ts +17 -0
- package/dist/ui/dialog.js +1 -0
- package/dist/ui/dropdown-menu.d.ts +29 -0
- package/dist/ui/dropdown-menu.js +1 -0
- package/dist/ui/field.d.ts +24 -0
- package/dist/ui/field.js +1 -0
- package/dist/ui/hover-card.d.ts +5 -0
- package/dist/ui/hover-card.js +1 -0
- package/dist/ui/input-group-textarea.d.ts +2 -0
- package/dist/ui/input-group-textarea.js +1 -0
- package/dist/ui/input-group.d.ts +17 -0
- package/dist/ui/input-group.js +1 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +1 -0
- package/dist/ui/label.d.ts +3 -0
- package/dist/ui/label.js +1 -0
- package/dist/ui/radio-group.d.ts +5 -0
- package/dist/ui/radio-group.js +1 -0
- package/dist/ui/separator.d.ts +3 -0
- package/dist/ui/separator.js +1 -0
- package/dist/ui/switch.d.ts +5 -0
- package/dist/ui/switch.js +1 -0
- package/dist/ui/textarea.d.ts +3 -0
- package/dist/ui/textarea.js +1 -0
- package/dist/ui/tooltip.d.ts +6 -0
- package/dist/ui/tooltip.js +1 -0
- package/licenses/Apache-2.0.txt +191 -0
- package/licenses/_agentclientprotocol_sdk-LICENSE +191 -0
- package/licenses/_base-ui_react-LICENSE +21 -0
- package/licenses/_floating-ui_dom-LICENSE +20 -0
- package/licenses/ai-elements-notice.txt +13 -0
- package/licenses/ansi_up-LICENSE +22 -0
- package/licenses/class-variance-authority-LICENSE +190 -0
- package/licenses/cn-LICENSE +21 -0
- package/licenses/diff2html-LICENSE.md +14 -0
- package/licenses/entities-LICENSE +11 -0
- package/licenses/highlight.js-LICENSE +29 -0
- package/licenses/katex-LICENSE +21 -0
- package/licenses/lucide-react-LICENSE +43 -0
- package/licenses/marked-LICENSE +44 -0
- package/licenses/marked-linkify-it-LICENSE +21 -0
- package/licenses/react-LICENSE +21 -0
- package/licenses/react-dom-LICENSE +21 -0
- package/licenses/shadcn-ui-MIT.txt +21 -0
- package/package.json +314 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface CodeHighlightRequest {
|
|
2
|
+
clientId: number;
|
|
3
|
+
revision: number;
|
|
4
|
+
code: string;
|
|
5
|
+
language: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export type CodeHighlightResponse = {
|
|
8
|
+
clientId: number;
|
|
9
|
+
revision: number;
|
|
10
|
+
ok: true;
|
|
11
|
+
html: string | null;
|
|
12
|
+
} | {
|
|
13
|
+
clientId: number;
|
|
14
|
+
revision: number;
|
|
15
|
+
ok: false;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
18
|
+
export interface CodeHighlightResult {
|
|
19
|
+
code: string;
|
|
20
|
+
language: string | undefined;
|
|
21
|
+
html: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface CodeHighlighter {
|
|
24
|
+
update: (code: string, language: string | undefined) => void;
|
|
25
|
+
dispose: () => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function createCodeHighlighter(onResult: (result: CodeHighlightResult) => void, onError: (error: Error) => void): CodeHighlighter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class s{worker=new Worker(new URL("./code-highlighter.worker.js",import.meta.url),{type:"module"});clients=new Map;pending=new Map;active=null;failure=null;nextClientId=0;constructor(){this.worker.onmessage=(i)=>{let e=this.active,t=i.data;if(e===null||t.clientId!==e.clientId||t.revision!==e.revision){this.fail(Error("Code highlighting worker returned an unexpected request"));return}if(this.active=null,!t.ok){this.fail(Error(t.error));return}let n=this.clients.get(e.clientId);if(n!==void 0&&n.revision===e.revision)n.onResult({code:e.code,language:e.language,html:t.html});this.dispatch()},this.worker.onerror=(i)=>this.fail(Error(i.message)),this.worker.onmessageerror=()=>this.fail(Error("Cannot deserialize code highlighting result"))}fail(i){this.failure=i,this.worker.terminate(),this.pending.clear(),this.active=null;for(let e of this.clients.values())e.onError(i)}dispatch(){if(this.active!==null||this.pending.size===0)return;let i=this.pending.values().next().value;this.pending.delete(i.clientId),this.active=i;try{this.worker.postMessage(i)}catch(e){this.fail(e instanceof Error?e:Error(String(e)))}}connect(i,e){if(this.failure!==null)throw this.failure;let t=++this.nextClientId,n={revision:0,onResult:i,onError:e};return this.clients.set(t,n),{update:(l,o)=>{if(this.failure!==null)throw this.failure;n.revision+=1,this.pending.set(t,{clientId:t,revision:n.revision,code:l,language:o}),this.dispatch()},dispose:()=>{if(this.clients.delete(t),this.pending.delete(t),this.clients.size===0)this.worker.terminate(),r=void 0}}}}var r;function h(i,e){if(r===void 0)r=new s;return r.connect(i,e)}export{h as createCodeHighlighter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import g from"highlight.js";self.onmessage=(s)=>{let{clientId:n,revision:l,code:o,language:t}=s.data,a;try{let e;if(t===void 0||t.length===0)e=g.highlightAuto(o).value;else{let r=t.toLowerCase();e=g.getLanguage(r)===void 0?null:g.highlight(o,{language:r}).value}a={clientId:n,revision:l,ok:!0,html:e}}catch(e){a={clientId:n,revision:l,ok:!1,error:e instanceof Error?e.message:String(e)}}self.postMessage(a)};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FuzzyMatch {
|
|
2
|
+
score: number;
|
|
3
|
+
indices: number[];
|
|
4
|
+
}
|
|
5
|
+
export declare function fuzzyMatch(candidate: string, query: string): FuzzyMatch | null;
|
|
6
|
+
export interface FuzzyResult<T> {
|
|
7
|
+
item: T;
|
|
8
|
+
score: number;
|
|
9
|
+
indices: number[];
|
|
10
|
+
}
|
|
11
|
+
export declare function fuzzyFilter<T>(items: T[], query: string, getString: (item: T) => string, limit?: number): FuzzyResult<T>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=/[\\/._\- ]/;function a(o,r){if(r===0)return!0;let s=o[r-1];if(p.test(s))return!0;let n=o[r];if(s===s.toLowerCase()&&n!==n.toLowerCase())return!0;return!1}function w(o,r){if(!r)return{score:0,indices:[]};let s=o.toLowerCase(),n=r.toLowerCase(),i=[],e=0,t=0,u=-2;for(let f=0;f<n.length;f++){let h=n[f],c=-1;while(e<s.length){if(s[e]===h){c=e;break}e++}if(c<0)return null;if(t+=1,c===u+1)t+=4;if(a(o,c))t+=5;let l=o.lastIndexOf("/");if(l>=0&&c>l)t+=2;i.push(c),u=c,e=c+1}if(t-=Math.floor(o.length/50),o.includes(r))t+=3;return{score:t,indices:i}}function g(o,r,s,n=100){if(!r)return o.slice(0,n).map((e)=>({item:e,score:0,indices:[]}));let i=[];for(let e of o){let t=w(s(e),r);if(!t)continue;i.push({item:e,score:t.score,indices:t.indices})}return i.sort((e,t)=>t.score-e.score),i.slice(0,n)}export{g as fuzzyFilter,w as fuzzyMatch};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentBlock } from "../types.js";
|
|
2
|
+
import type { StreamEntry } from "./stream-entry.js";
|
|
3
|
+
import { type StreamStyle } from "./stream-style.js";
|
|
4
|
+
export type { BlockEntry, CodexActivityBlock, CodexActivityGroupEntry, StreamEntry, ToolGroupEntry, ToolUseBlock } from "./stream-entry.js";
|
|
5
|
+
export declare function groupBlocksForStyle(blocks: ContentBlock[], style: StreamStyle): StreamEntry[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isCodexLook as r}from"./stream-style.js";function f(t,o){if(r(o))return s(t);return t.map((i)=>({kind:"block",block:i}))}function u(t){return t.type==="thinking"||t.type==="tool_use"||t.type==="subagent"}function c(t){return t.type==="tool_use"&&t.kind!=="think"}function s(t){let o=[],i=[],e=()=>{if(i.length===0)return;o.push({kind:"codexActivityGroup",blocks:i}),i=[]};for(let n of t){if(u(n)&&c(n)){i.push(n);continue}if(e(),u(n)){o.push({kind:"codexActivityGroup",blocks:[n]});continue}o.push({kind:"block",block:n})}return e(),o}export{f as groupBlocksForStyle};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertBlobUrlToDataUrl(url: string, mediaType?: string): Promise<string | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function I(w,u){try{let n=await(await fetch(w)).blob(),s=u??n.type??"";if(!s.startsWith("image/"))return new Promise((e)=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(n)});let g=s.includes("svg"),a,o,r;if(g){let e=new Image,t=URL.createObjectURL(n);e.src=t;try{await new Promise((f,b)=>{e.onload=()=>f(),e.onerror=()=>b(Error("svg load failed"))})}finally{URL.revokeObjectURL(t)}o=e.naturalWidth||1024,r=e.naturalHeight||1024,a=e}else{let e=await createImageBitmap(n);o=e.width,r=e.height,a=e}let c=Math.min(1,2000/Math.max(o,r)),i=Math.round(o*c),l=Math.round(r*c),d=new OffscreenCanvas(i,l),m=d.getContext("2d");if(!m)throw Error("image-encode: OffscreenCanvas 2d context 不可用");if(m.drawImage(a,0,0,i,l),a instanceof ImageBitmap)a.close();let h=await d.convertToBlob({type:"image/webp",quality:0.85});return new Promise((e)=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(h)})}catch{return null}}export{I as convertBlobUrlToDataUrl};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const BYTES_PER_MB = 1000000;
|
|
2
|
+
export declare const MAX_TOTAL_IMAGE_BYTES: number;
|
|
3
|
+
export declare function exceedsImageLimit(usedBytes: number, additionBytes: number): boolean;
|
|
4
|
+
export declare function formatImageSizeMb(bytes: number): string;
|
|
5
|
+
export declare const MAX_TOTAL_IMAGE_MB: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var E=1e6,T=5000000;function e(_,t){return _+t>=5000000}function M(_){return(_/1e6).toFixed(1)}var o=5;export{E as BYTES_PER_MB,T as MAX_TOTAL_IMAGE_BYTES,o as MAX_TOTAL_IMAGE_MB,e as exceedsImageLimit,M as formatImageSizeMb};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Token } from "marked";
|
|
2
|
+
export interface MarkdownParseInput {
|
|
3
|
+
source: string;
|
|
4
|
+
text: string;
|
|
5
|
+
isStreaming: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface MarkdownParseResult extends MarkdownParseInput {
|
|
8
|
+
tokens: Token[];
|
|
9
|
+
}
|
|
10
|
+
export type MarkdownWorkerRequest = {
|
|
11
|
+
type: "parse";
|
|
12
|
+
clientId: number;
|
|
13
|
+
revision: number;
|
|
14
|
+
source: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: "dispose";
|
|
17
|
+
clientId: number;
|
|
18
|
+
};
|
|
19
|
+
export type MarkdownParseResponse = {
|
|
20
|
+
clientId: number;
|
|
21
|
+
revision: number;
|
|
22
|
+
ok: true;
|
|
23
|
+
tokens: Token[];
|
|
24
|
+
} | {
|
|
25
|
+
clientId: number;
|
|
26
|
+
revision: number;
|
|
27
|
+
ok: false;
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
export interface MarkdownParser {
|
|
31
|
+
update: (input: MarkdownParseInput) => void;
|
|
32
|
+
dispose: () => void;
|
|
33
|
+
}
|
|
34
|
+
export declare function createMarkdownParser(onResult: (result: MarkdownParseResult) => void, onError: (error: Error) => void): MarkdownParser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class o{worker=new Worker(new URL("./markdown-parser.worker.js",import.meta.url),{type:"module"});clients=new Map;pending=new Map;active=null;failure=null;nextClientId=0;constructor(){this.worker.onmessage=(e)=>{let t=e.data,i=this.active;if(i===null||t.clientId!==i.clientId||t.revision!==i.revision){this.fail(Error("Markdown worker returned an unexpected request"));return}if(this.active=null,!t.ok){this.fail(Error(t.error));return}let n=this.clients.get(i.clientId),r=this.pending.get(i.clientId),l=r!==void 0&&i.input.isStreaming&&r.input.isStreaming&&r.input.text.startsWith(i.input.text);if(n!==void 0&&(n.revision===i.revision||l))n.onResult({...i.input,tokens:t.tokens});this.dispatch()},this.worker.onerror=(e)=>this.fail(Error(e.message)),this.worker.onmessageerror=()=>this.fail(Error("Cannot deserialize Markdown parsing result"))}fail(e){this.failure=e,this.worker.terminate(),this.pending.clear(),this.active=null;for(let t of this.clients.values())t.onError(e)}send(e){try{this.worker.postMessage(e)}catch(t){this.fail(t instanceof Error?t:Error(String(t)))}}dispatch(){if(this.active!==null||this.pending.size===0)return;let e=this.pending.values().next().value;this.pending.delete(e.clientId),this.active=e,this.send({type:"parse",clientId:e.clientId,revision:e.revision,source:e.input.source})}connect(e,t){if(this.failure!==null)throw this.failure;let i=++this.nextClientId,n={revision:0,onResult:e,onError:t};return this.clients.set(i,n),{update:(r)=>{if(this.failure!==null)throw this.failure;n.revision+=1,this.pending.set(i,{clientId:i,revision:n.revision,input:r}),this.dispatch()},dispose:()=>{if(!this.clients.delete(i))return;if(this.pending.delete(i),this.clients.size===0)this.worker.terminate(),s=void 0;else if(this.failure===null)this.send({type:"dispose",clientId:i})}}}}var s;function a(e,t){if(s===void 0)s=new o;return s.connect(e,t)}export{a as createMarkdownParser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createStreamingMarkdownLexer as c}from"./streaming-markdown.js";var o=new Map;self.onmessage=(a)=>{let s=a.data;if(s.type==="dispose"){o.delete(s.clientId);return}let{clientId:r,revision:n,source:i}=s,t;try{let e=o.get(r);if(e===void 0)e=c(),o.set(r,e);t={clientId:r,revision:n,ok:!0,tokens:e.parse(i)}}catch(e){t={clientId:r,revision:n,ok:!1,error:e instanceof Error?e.message:String(e)}}self.postMessage(t)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Marked as p}from"marked";import m from"marked-linkify-it";var h=/<(task-notification|system-reminder|antml:[\w-]+)\b[^>]*>/,k=/^<(task-notification|system-reminder|antml:[\w-]+)\b[^>]*>[\s\S]*?(?:<\/\1\s*>|$)/,u=/^\$\$([\s\S]+?)\$\$/,x={extensions:[{name:"math",level:"block",tokenizer(e){let n=u.exec(e);if(n===null)return;return{type:"math",raw:n[0],text:n[1].trim(),display:!0}}},{name:"math",level:"inline",start(e){return e.indexOf("$")},tokenizer(e){let n=u.exec(e);if(n!==null)return{type:"math",raw:n[0],text:n[1].trim(),display:!0};let r=/^\$(?!\$)((?:\\[^\n]|[^\\$\n])+?)\$(?![\d$])/.exec(e);if(r===null||/^\s|\s$/.test(r[1]))return;return{type:"math",raw:r[0],text:r[1],display:!1}}}]};function g(){let e=new p({gfm:!0}),n=m(),r=n.extensions[0],f=r.tokenizer;r.tokenizer=function(s,a){let t=f.call(this,s,a);if(t===void 0)return;if(t.raw.startsWith("<"))return t;let o=/^(?:[a-z][a-z\d+.-]*:\/\/|www\.)[^/?#]+[/?#]/i.exec(t.raw);if(o===null)return t;let c=o[0].length-1,l=t.raw.slice(c).search(/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u);if(l===-1)return t;let i=t.raw.slice(0,c+l),d=t.href.slice(0,t.href.length-(t.raw.length-i.length));return{...t,raw:i,href:d,text:i,tokens:[{type:"text",raw:i,text:i}]}},e.use(x,n);for(let s of["block","inline"])e.use({extensions:[{name:"internalMessage",level:s,...s==="inline"?{start(a){return h.exec(a)?.index}}:{},tokenizer(a){let t=k.exec(a);if(t===null)return;return{type:"internalMessage",raw:t[0]}},renderer(){return""}}]});return e}function z(e){let n=e.replace(/[\p{Cc}\s]/gu,"");return!/^(?:data|javascript|vbscript):/i.test(n)}export{g as createChatMarkdown,z as isSafeMarkdownUrl};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type PointerCenteredZoomParams = {
|
|
2
|
+
container: HTMLElement;
|
|
3
|
+
target: HTMLElement;
|
|
4
|
+
clientX: number;
|
|
5
|
+
clientY: number;
|
|
6
|
+
currentScale: number;
|
|
7
|
+
nextScale: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function getPointerCenteredScrollPosition({ container, target, clientX, clientY, currentScale, nextScale }: PointerCenteredZoomParams): {
|
|
10
|
+
left: number;
|
|
11
|
+
top: number;
|
|
12
|
+
} | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function w({container:s,target:r,clientX:e,clientY:o,currentScale:i,nextScale:h}){if(i<=0||h<=0)return null;let n=s.getBoundingClientRect(),t=r.getBoundingClientRect();if(t.width===0||t.height===0)return null;let f=e>=t.left&&e<=t.right&&o>=t.top&&o<=t.bottom,g=f?(e-t.left)/t.width:0.5,l=f?(o-t.top)/t.height:0.5,c=t.width/i,d=t.height/i,p=c*h,a=d*h,u=e-n.left,x=o-n.top,C=s.scrollLeft+(t.left-n.left)+t.width/2,P=s.scrollTop+(t.top-n.top)+t.height/2,R=(g-0.5)*p,v=(l-0.5)*a;return{left:Math.max(0,C+R-u),top:Math.max(0,P+v-x)}}export{w as getPointerCenteredScrollPosition};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{convertBlobUrlToDataUrl as d}from"./image-encode.js";async function f(r){try{let i=await(await fetch(r)).blob();if(typeof createImageBitmap==="function")return(await createImageBitmap(i)).close(),!0;return await new Promise((e)=>{let n=new Image;n.onload=()=>e(!0),n.onerror=()=>e(!1),n.src=r})}catch{return!1}}async function g(r){let s=await Promise.all(r.map(async({id:e,lastModified:n,sourcePath:p,...a})=>{let t=a.url;if(a.url.startsWith("blob:")){let l=await d(a.url,a.mediaType);if(l===null)return null;t=l}let o=a.mediaType.toLowerCase().startsWith("image/"),c=t.startsWith("data:image/");if(o&&c&&!await f(t))return null;let u=t.startsWith("data:")?t.slice(5,t.indexOf(";")):a.mediaType;return{...a,url:t,mediaType:u}})),i=s.filter((e)=>e!==null);return{files:i,rejectedCount:s.length-i.length}}export{g as preparePromptFiles};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContentBlock } from "../types.js";
|
|
2
|
+
export type ToolUseBlock = Extract<ContentBlock, {
|
|
3
|
+
type: "tool_use";
|
|
4
|
+
}>;
|
|
5
|
+
export interface BlockEntry {
|
|
6
|
+
kind: "block";
|
|
7
|
+
block: ContentBlock;
|
|
8
|
+
}
|
|
9
|
+
export interface ToolGroupEntry {
|
|
10
|
+
kind: "toolGroup";
|
|
11
|
+
blocks: ToolUseBlock[];
|
|
12
|
+
}
|
|
13
|
+
export type CodexActivityBlock = Extract<ContentBlock, {
|
|
14
|
+
type: "thinking" | "tool_use" | "subagent";
|
|
15
|
+
}>;
|
|
16
|
+
export interface CodexActivityGroupEntry {
|
|
17
|
+
kind: "codexActivityGroup";
|
|
18
|
+
blocks: CodexActivityBlock[];
|
|
19
|
+
}
|
|
20
|
+
export interface CollapsedReadSearch {
|
|
21
|
+
kind: "collapsedReadSearch";
|
|
22
|
+
blocks: ToolUseBlock[];
|
|
23
|
+
readCount: number;
|
|
24
|
+
searchCount: number;
|
|
25
|
+
listCount: number;
|
|
26
|
+
isActive: boolean;
|
|
27
|
+
}
|
|
28
|
+
export type StreamEntry = BlockEntry | ToolGroupEntry | CodexActivityGroupEntry | CollapsedReadSearch;
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContentBlock, ToolCallStatus } from "../types.js";
|
|
2
|
+
export declare const STREAM_STYLES: readonly ["full", "compact", "codexUI"];
|
|
3
|
+
export type StreamStyle = (typeof STREAM_STYLES)[number];
|
|
4
|
+
export declare function isCodexLook(style: StreamStyle): boolean;
|
|
5
|
+
export declare const TOOL_CATEGORIES: readonly ["read", "edit", "delete", "move", "search", "execute", "think", "fetch", "switch_mode", "other"];
|
|
6
|
+
export type ToolCategory = (typeof TOOL_CATEGORIES)[number];
|
|
7
|
+
export interface ToolDescription {
|
|
8
|
+
category: ToolCategory;
|
|
9
|
+
target?: string;
|
|
10
|
+
filePath?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function describeToolUse(block: Extract<ContentBlock, {
|
|
13
|
+
type: "tool_use";
|
|
14
|
+
}>): ToolDescription;
|
|
15
|
+
export declare function toolDotClass(status: ToolCallStatus, isAwaitingPermission: boolean): string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var p=["full","compact","codexUI"];function l(e){return e==="compact"||e==="codexUI"}var d=["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"];function a(e){let n=e.split(/[/\\]/);return n[n.length-1]||e}function f(e){let n=d.includes(e.kind)?e.kind:"other",s=e.rawInput,t=(i)=>{let r=s[i];return typeof r==="string"&&r.length>0?r:void 0},o=e.locations?.[0]?.path??t("file_path")??t("notebook_path"),c=o!==void 0?a(o):t("command")?.split(`
|
|
2
|
+
`)[0]??t("pattern")??t("url")??t("query")??t("description");return{category:n,...c===void 0?{}:{target:c},...o===void 0?{}:{filePath:o}}}function h(e,n){if(n)return"dot-permission";switch(e){case"completed":return"dot-success";case"failed":return"dot-error";case"in_progress":return"dot-in-progress";case"pending":return"dot-pending";case"interrupted":return"dot-interrupted";default:return console.warn("[acp] unknown tool call status:",e),"dot-pending"}}export{p as STREAM_STYLES,d as TOOL_CATEGORIES,f as describeToolUse,l as isCodexLook,h as toolDotClass};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createChatMarkdown as w}from"./markdown-rules.js";function g(e,s){let l=Object.keys(e);return l.length===Object.keys(s).length&&l.every((r)=>{let i=s[r];return i!==void 0&&e[r].href===i.href&&e[r].title===i.title})}function b(e,s){let l=2,r=0;for(let n=e.length-1;n>=0;n-=1){if(e[n].type==="space")continue;if(l-=1,l===0){r=n;break}}let i=0;for(let n=0;n<r;n+=1){let a=e[n];if(a.type==="def"||/^ {0,3}(?:\[|<|\$\$)/.test(a.raw))return i;let o=!1;if(s.walkTokens([e[n]],(c)=>{if(c.type==="html"&&(("inLink"in c)&&c.inLink||("inRawBlock"in c)&&c.inRawBlock))o=!0}),o)return i;if(/\n[\t ]*\n$/.test(e[n].raw))i=n+1}return i}function x(e=w()){let s="",l=[],r={},i={};return{parse(n){let a=n.replace(/\r\n|\r/g,`
|
|
2
|
+
`);if(!a.startsWith(s))s="",l=[],r={},i={};let o=new e.Lexer(e.defaults);o.tokens.links={...r};let c=o.lex(a.slice(s.length)),f=[...l,...c],u=c.links;if(l.length>0&&!g(i,u)){let t=e.lexer(a);f=Array.from(t),u=t.links}i=u;let k=0,h=[];for(let t of f){if(!a.startsWith(t.raw,k))break;h.push(t),k+=t.raw.length}return l=h.slice(0,b(h,e)),s=a.slice(0,l.reduce((t,d)=>t+d.raw.length,0)),r=Object.create(null),e.walkTokens(l,(t)=>{if(t.type==="def"&&!Object.hasOwn(r,t.tag))r[t.tag]={href:t.href,title:t.title}}),structuredClone(f)}}}export{x as createStreamingMarkdownLexer};
|