@wukazis/euphony 0.1.45

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.
Files changed (103) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +13 -0
  3. package/README.md +266 -0
  4. package/bin/euphony.js +4 -0
  5. package/dist/apple-touch-icon.png +0 -0
  6. package/dist/assets/harmony-render-5ErAOXX9.js +3285 -0
  7. package/dist/assets/local-data-worker-CHLGzNeW.js +2 -0
  8. package/dist/assets/main-CmldcHcT.js +4047 -0
  9. package/dist/examples/euphony-convo-100.jsonl +8 -0
  10. package/dist/examples/simple-harmony-convos.jsonl +8 -0
  11. package/dist/favicon-48x48.png +0 -0
  12. package/dist/favicon.ico +0 -0
  13. package/dist/favicon.svg +3 -0
  14. package/dist/global.css +38 -0
  15. package/dist/index.html +22 -0
  16. package/dist/web-app-manifest-192x192.png +0 -0
  17. package/dist/web-app-manifest-512x512.png +0 -0
  18. package/lib/chunks/conversation.js +612 -0
  19. package/lib/chunks/css/codex.js +1 -0
  20. package/lib/chunks/css/confirm-dialog.js +1 -0
  21. package/lib/chunks/css/conversation.js +1 -0
  22. package/lib/chunks/css/floating-toolbar.js +1 -0
  23. package/lib/chunks/css/input-dialog.js +1 -0
  24. package/lib/chunks/css/json-viewer.js +1 -0
  25. package/lib/chunks/css/menu.js +1 -0
  26. package/lib/chunks/css/message-code.js +1 -0
  27. package/lib/chunks/css/message-developer-content.js +1 -0
  28. package/lib/chunks/css/message-editor-popover.js +1 -0
  29. package/lib/chunks/css/message-hidden.js +1 -0
  30. package/lib/chunks/css/message-system-content.js +1 -0
  31. package/lib/chunks/css/message-text.js +1 -0
  32. package/lib/chunks/css/message-unsupported.js +1 -0
  33. package/lib/chunks/css/pagination.js +1 -0
  34. package/lib/chunks/css/preference-window.js +1 -0
  35. package/lib/chunks/css/search-window.js +1 -0
  36. package/lib/chunks/css/toast.js +1 -0
  37. package/lib/chunks/css/token-window.js +1 -0
  38. package/lib/chunks/css-inline.js +1 -0
  39. package/lib/chunks/dompurify.js +1 -0
  40. package/lib/chunks/harmony-types.js +1 -0
  41. package/lib/chunks/icon-cross.js +1 -0
  42. package/lib/chunks/icon-play.js +1 -0
  43. package/lib/chunks/marked.js +1 -0
  44. package/lib/chunks/prismjs.js +1 -0
  45. package/lib/chunks/shoelace.js +1131 -0
  46. package/lib/chunks/third-party.js +1 -0
  47. package/lib/chunks/utils.js +16 -0
  48. package/lib/components/app/app.d.ts +192 -0
  49. package/lib/components/app/local-data-worker.d.ts +35 -0
  50. package/lib/components/app/request-worker.d.ts +45 -0
  51. package/lib/components/app/url-manager.d.ts +25 -0
  52. package/lib/components/codex/codex.d.ts +50 -0
  53. package/lib/components/codex/codex.js +36 -0
  54. package/lib/components/confirm-dialog/confirm-dialog.d.ts +42 -0
  55. package/lib/components/confirm-dialog/confirm-dialog.js +41 -0
  56. package/lib/components/conversation/conversation.d.ts +259 -0
  57. package/lib/components/conversation/conversation.js +1 -0
  58. package/lib/components/floating-toolbar/floating-toolbar.d.ts +47 -0
  59. package/lib/components/floating-toolbar/floating-toolbar.js +32 -0
  60. package/lib/components/input-dialog/input-dialog.d.ts +43 -0
  61. package/lib/components/input-dialog/input-dialog.js +51 -0
  62. package/lib/components/json-viewer/json-viewer.d.ts +33 -0
  63. package/lib/components/json-viewer/json-viewer.js +8 -0
  64. package/lib/components/menu/menu.d.ts +38 -0
  65. package/lib/components/menu/menu.js +9 -0
  66. package/lib/components/message-code/message-code.d.ts +20 -0
  67. package/lib/components/message-code/message-code.js +10 -0
  68. package/lib/components/message-developer-content/message-developer-content.d.ts +45 -0
  69. package/lib/components/message-developer-content/message-developer-content.js +72 -0
  70. package/lib/components/message-editor-popover/message-editor-popover.d.ts +36 -0
  71. package/lib/components/message-editor-popover/message-editor-popover.js +85 -0
  72. package/lib/components/message-hidden/message-hidden.d.ts +38 -0
  73. package/lib/components/message-hidden/message-hidden.js +10 -0
  74. package/lib/components/message-system-content/message-system-content.d.ts +52 -0
  75. package/lib/components/message-system-content/message-system-content.js +74 -0
  76. package/lib/components/message-text/message-text.d.ts +36 -0
  77. package/lib/components/message-text/message-text.js +14 -0
  78. package/lib/components/message-unsupported/message-unsupported.d.ts +19 -0
  79. package/lib/components/message-unsupported/message-unsupported.js +26 -0
  80. package/lib/components/pagination/pagination.d.ts +29 -0
  81. package/lib/components/pagination/pagination.js +35 -0
  82. package/lib/components/preference-window/preference-window.d.ts +107 -0
  83. package/lib/components/preference-window/preference-window.js +319 -0
  84. package/lib/components/search-window/search-window.d.ts +44 -0
  85. package/lib/components/search-window/search-window.js +71 -0
  86. package/lib/components/toast/toast.d.ts +34 -0
  87. package/lib/components/toast/toast.js +77 -0
  88. package/lib/components/token-window/token-window.d.ts +96 -0
  89. package/lib/components/token-window/token-window.js +1 -0
  90. package/lib/config/config.d.ts +273 -0
  91. package/lib/euphony.d.ts +11 -0
  92. package/lib/euphony.js +1 -0
  93. package/lib/types/common-types.d.ts +176 -0
  94. package/lib/types/harmony-types.d.ts +72 -0
  95. package/lib/utils/api-manager.d.ts +42 -0
  96. package/lib/utils/codex-session.d.ts +7 -0
  97. package/lib/utils/dompurify-configs.d.ts +2 -0
  98. package/lib/utils/harmony-render.d.ts +4 -0
  99. package/lib/utils/marked-katex-extension.d.ts +22 -0
  100. package/lib/utils/patch-preview.d.ts +2 -0
  101. package/lib/utils/utils.d.ts +80 -0
  102. package/package.json +84 -0
  103. package/server-dist/node-main.js +1273 -0
@@ -0,0 +1,72 @@
1
+ export interface Conversation {
2
+ id?: string | null;
3
+ messages: Message[];
4
+ create_time?: number | null;
5
+ metadata?: Record<string, unknown>;
6
+ }
7
+ export interface Message {
8
+ id?: string | null;
9
+ role: Role;
10
+ name?: string | null;
11
+ create_time?: number | null;
12
+ metadata?: Record<string, unknown>;
13
+ content: MessageContent[] | string;
14
+ channel?: string | null;
15
+ recipient?: string | null;
16
+ content_type?: string | null;
17
+ }
18
+ export declare enum Role {
19
+ User = "user",
20
+ Assistant = "assistant",
21
+ System = "system",
22
+ Developer = "developer",
23
+ Tool = "tool"
24
+ }
25
+ export declare enum RealAuthor {
26
+ ToolWeb = "tool:web"
27
+ }
28
+ export interface Author {
29
+ role: Role;
30
+ name?: string | null;
31
+ }
32
+ export type MessageContent = TextMessageContent | CodeMessageContent | SystemContentMessageContent | DeveloperContentMessageContent;
33
+ export declare const EUPHONY_MESSAGE_CONTENT_TYPES: readonly ["code", "developer", "system", "text"];
34
+ export type EuphonyMessageContentType = (typeof EUPHONY_MESSAGE_CONTENT_TYPES)[number];
35
+ export interface TextMessageContent {
36
+ text: string;
37
+ }
38
+ export interface CodeMessageContent {
39
+ content_type: 'code';
40
+ text: string;
41
+ language?: string | null;
42
+ }
43
+ export type ReasoningEffort = 'Low' | 'Medium' | 'High';
44
+ export interface ChannelConfig {
45
+ valid_channels: string[];
46
+ channel_required: boolean;
47
+ }
48
+ export interface ToolDescription {
49
+ name: string;
50
+ description: string;
51
+ parameters?: Record<string, unknown> | null;
52
+ }
53
+ export interface ToolNamespaceConfig {
54
+ name: string;
55
+ description?: string | null;
56
+ tools: ToolDescription[];
57
+ }
58
+ export interface SystemContentMessageContent {
59
+ model_identity?: string | null;
60
+ reasoning_effort?: ReasoningEffort | null;
61
+ conversation_start_date?: string | null;
62
+ knowledge_cutoff?: string | null;
63
+ channel_config?: ChannelConfig | null;
64
+ tools?: Record<string, ToolNamespaceConfig> | null;
65
+ }
66
+ export interface DeveloperContentMessageContent {
67
+ instructions?: string | null;
68
+ tools?: Record<string, ToolNamespaceConfig> | null;
69
+ }
70
+ export declare const getContentTypeFromContent: (content: MessageContent[] | string) => EuphonyMessageContentType;
71
+ export declare const tryGetContentTypeFromContent: (content: MessageContent[] | string) => EuphonyMessageContentType | null;
72
+ export declare const getContentFromContentOrString: (content: MessageContent[] | string) => MessageContent;
@@ -0,0 +1,42 @@
1
+ import { BlobJSONLPayload, HarmonyRenderResponse } from '../types/common-types';
2
+ import { Conversation } from '../types/harmony-types';
3
+ export declare let EUPHONY_API_URL: string;
4
+ export declare const extractConversationFromJSONL: (data: unknown[]) => Conversation[] | null;
5
+ export declare class APIManager {
6
+ apiBaseURL: string;
7
+ constructor(apiBaseURL: string);
8
+ getJSONL: ({ blobURL, offset, limit, noCache, jmespathQuery }: {
9
+ blobURL: string;
10
+ offset: number;
11
+ limit: number;
12
+ noCache: boolean;
13
+ jmespathQuery: string;
14
+ }) => Promise<BlobJSONLPayload>;
15
+ refreshRendererList: () => Promise<string[]>;
16
+ harmonyRender: (conversation: string, renderer: string) => Promise<HarmonyRenderResponse>;
17
+ }
18
+ export declare class BrowserAPIManager {
19
+ getJSONL: ({ blobURL, offset, limit, noCache, jmespathQuery }: {
20
+ blobURL: string;
21
+ offset: number;
22
+ limit: number;
23
+ noCache: boolean;
24
+ jmespathQuery: string;
25
+ }) => Promise<BlobJSONLPayload>;
26
+ validateOpenAIAPIKey(apiKey: string): Promise<boolean>;
27
+ /**
28
+ * Translates the given text using the OpenAI API directly from browser with a
29
+ * custom API key.
30
+ * @param text The text to translate.
31
+ * @param apiKey The OpenAI API key to use for the request.
32
+ * @returns A promise resolving to the translation result.
33
+ */
34
+ translateTextWithOpenAI(text: string, apiKey: string): Promise<{
35
+ translation: string;
36
+ is_translated: boolean;
37
+ language: string;
38
+ has_command: boolean;
39
+ }>;
40
+ refreshRendererList: () => string[];
41
+ harmonyRender: (conversation: string, renderer: string) => Promise<HarmonyRenderResponse>;
42
+ }
@@ -0,0 +1,7 @@
1
+ import { Conversation } from '../types/harmony-types';
2
+ export interface CodexSessionParseResult {
3
+ conversation: Conversation;
4
+ customLabels: string[][];
5
+ }
6
+ export declare const isCodexSessionJSONL: (raw: unknown[]) => boolean;
7
+ export declare const parseCodexSession: (raw: unknown[]) => CodexSessionParseResult | null;
@@ -0,0 +1,2 @@
1
+ export declare const allowedTags: string[];
2
+ export declare const allowedAttributes: string[];
@@ -0,0 +1,4 @@
1
+ import { HarmonyRenderResponse } from '../types/common-types';
2
+ export declare const HARMONY_RENDERER_NAME = "o200k_harmony";
3
+ export declare const renderHarmonyConversationForDisplay: (conversationJSON: string) => string;
4
+ export declare const renderHarmonyConversationInBrowser: (conversation: string, renderer: string) => HarmonyRenderResponse;
@@ -0,0 +1,22 @@
1
+ export interface MarkedKatexOptions {
2
+ nonStandard?: boolean;
3
+ [key: string]: unknown;
4
+ }
5
+ interface Token {
6
+ text: string;
7
+ displayMode: boolean;
8
+ }
9
+ export default function (options?: MarkedKatexOptions): {
10
+ extensions: {
11
+ name: string;
12
+ level: string;
13
+ tokenizer(src: string): {
14
+ type: string;
15
+ raw: string;
16
+ text: string;
17
+ displayMode: boolean;
18
+ } | undefined;
19
+ renderer: (token: Token) => string;
20
+ }[];
21
+ };
22
+ export {};
@@ -0,0 +1,2 @@
1
+ import { TemplateResult } from 'lit';
2
+ export declare function renderPatchPreview(text: string): TemplateResult | null;
@@ -0,0 +1,80 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ import { BlockContent } from '../types/common-types';
3
+ import { Conversation } from '../types/harmony-types';
4
+ /**
5
+ * Updates the position and appearance of a popper overlay tooltip.
6
+ * @param tooltip - The tooltip element.
7
+ * @param anchor - The anchor element to which the tooltip is attached.
8
+ * @param placement - The placement of the tooltip relative to the anchor
9
+ * ('bottom', 'left', 'top', 'right').
10
+ * @param withArrow - Indicates whether the tooltip should have an arrow.
11
+ * @param offsetAmount - The offset amount in pixels.
12
+ * @param maxWidth - The maximum width of the tooltip in pixels (optional).
13
+ */
14
+ export declare const updatePopperOverlay: (tooltip: HTMLElement, anchor: HTMLElement, placement: "bottom" | "left" | "top" | "right", withArrow: boolean, offsetAmount?: number, maxWidth?: number) => void;
15
+ /**
16
+ * Updates the position of a floating element relative to an anchor element.
17
+ * @param floatingElement - The floating element to be positioned.
18
+ * @param anchor - The anchor element to which the floating element is attached.
19
+ * @param placement - The placement of the floating element relative to the
20
+ * anchor ('bottom', 'left', 'top', 'right').
21
+ * @param offsetAmount - The y offset amount in pixels.
22
+ */
23
+ export declare const updateFloatPosition: (anchor: HTMLElement, floatingElement: HTMLElement, placement: "bottom" | "left" | "top" | "right", offsetAmount?: number) => void;
24
+ /**
25
+ * Generates an HTML template from a markdown string.
26
+ *
27
+ * @param content - The markdown content to be rendered.
28
+ * @param shouldRenderMarkdown - Whether to render the content as markdown.
29
+ * @returns The HTML template generated from the markdown content.
30
+ */
31
+ export declare const getMarkdownTemplate: (content: string, shouldRenderMarkdown: boolean, markdownAllowedTags: string[] | null, markdownAllowedAttributes: string[] | null) => TemplateResult<1>;
32
+ /**
33
+ * Creates a deferred promise that will be automatically rejected if not
34
+ * resolved within the specified wait time.
35
+ *
36
+ * @template T - The type of the value that the promise resolves with.
37
+ * @param waitTime - The time in milliseconds to wait before automatically
38
+ * rejecting the promise.
39
+ * @returns An object containing the promise, and wrapped resolve and reject
40
+ * functions.
41
+ */
42
+ export declare const getDeferredPromise: <T>(waitTime: number) => {
43
+ promise: Promise<T>;
44
+ resolve: (value: T) => void;
45
+ reject: (reason?: unknown) => void;
46
+ };
47
+ /**
48
+ * Converts a Blob to a base64 string.
49
+ * @param blob - The Blob to convert.
50
+ * @returns A promise that resolves to the base64 string.
51
+ */
52
+ export declare const blobToBase64: (blob: Blob) => Promise<string>;
53
+ /**
54
+ * Digests a message using SHA-256.
55
+ * @param message - The message to digest.
56
+ * @returns A promise that resolves to the digest of the message.
57
+ */
58
+ export declare const digestMessage: (message: string) => Promise<string>;
59
+ /**
60
+ * Converts a style object to a string.
61
+ * @param styles - The style object to convert.
62
+ * @returns The style string.
63
+ */
64
+ export declare const styleToString: (styles: Record<string, string>) => string;
65
+ export declare const arrayToTable: (data: unknown[][]) => TemplateResult;
66
+ /**
67
+ * Get custom convo labels and message labels from magic metadata field
68
+ * @param conversation - The conversation to get custom labels from
69
+ * @returns The custom labels
70
+ */
71
+ export declare const getCustomLabelsFromMagicMetadata: (conversation: Conversation) => {
72
+ customLabels: string[][];
73
+ customMessageLabels: ([string | number, string] | [string | number, string, string] | [string | number, string, string, string])[];
74
+ };
75
+ export declare class EuphonyLitElementWithBlockContents extends LitElement {
76
+ blockContents: BlockContent[];
77
+ }
78
+ export declare const sharedExpandBlockContents: (element: LitElement | EuphonyLitElementWithBlockContents) => void;
79
+ export declare const sharedCollapseBlockContents: (element: LitElement | EuphonyLitElementWithBlockContents) => void;
80
+ export declare const createBase64DataURL: (mimeType: string, dataBase64: string) => string;
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@wukazis/euphony",
3
+ "private": false,
4
+ "version": "0.1.45",
5
+ "type": "module",
6
+ "types": "./lib/euphony.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./lib/euphony.d.ts",
11
+ "default": "./lib/euphony.js"
12
+ }
13
+ }
14
+ },
15
+ "bin": {
16
+ "euphony": "bin/euphony.js"
17
+ },
18
+ "files": [
19
+ "bin",
20
+ "dist",
21
+ "server-dist",
22
+ "lib",
23
+ "README.md",
24
+ "LICENSE",
25
+ "NOTICE"
26
+ ],
27
+ "engines": {
28
+ "node": ">=20"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "dev": "vite --port 3000",
35
+ "build": "tsc && tsc -p tsconfig.server.json && vite build && vite build --mode server && vite build --mode library",
36
+ "build:app": "tsc && tsc -p tsconfig.server.json && vite build && vite build --mode server",
37
+ "build:frontend": "tsc && vite build",
38
+ "build:frontend-only": "tsc && VITE_EUPHONY_FRONTEND_ONLY=true vite build",
39
+ "build:github": "tsc && VITE_EUPHONY_FRONTEND_ONLY=true vite build --mode github",
40
+ "build:library": "tsc && vite build --mode library",
41
+ "build:server": "tsc -p tsconfig.server.json && vite build --mode server",
42
+ "start": "node server-dist/node-main.js",
43
+ "deploy:github": "pnpm run build:github && pnpm gh-pages -m \"Deploy $(git log '--format=format:%H' main -1)\" -d ./dist",
44
+ "deploy": "pnpm run deploy:github",
45
+ "preview": "vite preview"
46
+ },
47
+ "dependencies": {
48
+ "gpt-tokenizer": "^3.4.0",
49
+ "jmespath": "^0.16.0"
50
+ },
51
+ "devDependencies": {
52
+ "@datastructures-js/priority-queue": "^6.3.5",
53
+ "@floating-ui/dom": "^1.7.6",
54
+ "@shoelace-style/shoelace": "^2.20.1",
55
+ "@types/d3-format": "^3.0.4",
56
+ "@types/jmespath": "^0.15.2",
57
+ "@types/node": "^25.9.1",
58
+ "@types/prismjs": "1.26.6",
59
+ "@typescript-eslint/eslint-plugin": "8.58.2",
60
+ "@xiaohk/utils": "^0.1.0",
61
+ "async-mutex": "^0.5.0",
62
+ "d3-format": "^3.1.2",
63
+ "dompurify": "^3.4.0",
64
+ "eslint": "^9.39.4",
65
+ "eslint-config-prettier": "^10.1.8",
66
+ "eslint-plugin-lit": "^2.2.1",
67
+ "eslint-plugin-prettier": "^5.5.5",
68
+ "eslint-plugin-wc": "^3.1.0",
69
+ "gh-pages": "^6.3.0",
70
+ "globals": "^16.5.0",
71
+ "globby": "^14.1.0",
72
+ "lit": "^3.3.2",
73
+ "marked": "^15.0.12",
74
+ "prettier": "^3.8.3",
75
+ "prismjs": "^1.30.0",
76
+ "terser": "5.46.1",
77
+ "typescript": "^5.9.3",
78
+ "typescript-eslint": "8.58.2",
79
+ "vite": "^7.3.2",
80
+ "vite-plugin-dts": "^4.5.4",
81
+ "vite-plugin-web-components-hmr": "^0.1.3"
82
+ },
83
+ "packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501"
84
+ }