pi-tinychat 0.1.0 → 0.1.1
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 +21 -21
- package/README.md +139 -139
- package/bin/pi-tinychat.js +111 -111
- package/extension/plan.ts +281 -240
- package/package.json +68 -68
- package/public/app.js +3749 -3614
- package/public/favicon.svg +15 -15
- package/public/i18n.js +197 -169
- package/public/index.html +226 -226
- package/public/markdown.js +244 -244
- package/public/style.css +2814 -2762
- package/public/theme-init.js +18 -18
- package/src/compaction.js +139 -139
- package/src/errors.js +13 -13
- package/src/live.js +133 -133
- package/src/pi-path.js +70 -70
- package/src/pi-types.d.ts +85 -85
- package/src/pi.js +196 -196
- package/src/plan.js +91 -90
- package/src/server.js +910 -910
- package/src/sessions.js +256 -256
package/public/favicon.svg
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
-
<rect width="24" height="24" rx="6" fill="#cf4a22"/>
|
|
3
|
-
<path
|
|
4
|
-
d="M6.5 3.2H17.5Q21 3.2 21 6.7V15.3Q21 18.8 17.5 18.8H10L5.2 21V18Q3 17.2 3 14.8V6.7Q3 3.2 6.5 3.2Z"
|
|
5
|
-
fill="#fff"
|
|
6
|
-
/>
|
|
7
|
-
<path
|
|
8
|
-
d="M8 9L11 12L8 15M13 15H16.5"
|
|
9
|
-
fill="none"
|
|
10
|
-
stroke="#cf4a22"
|
|
11
|
-
stroke-width="2"
|
|
12
|
-
stroke-linecap="round"
|
|
13
|
-
stroke-linejoin="round"
|
|
14
|
-
/>
|
|
15
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
+
<rect width="24" height="24" rx="6" fill="#cf4a22"/>
|
|
3
|
+
<path
|
|
4
|
+
d="M6.5 3.2H17.5Q21 3.2 21 6.7V15.3Q21 18.8 17.5 18.8H10L5.2 21V18Q3 17.2 3 14.8V6.7Q3 3.2 6.5 3.2Z"
|
|
5
|
+
fill="#fff"
|
|
6
|
+
/>
|
|
7
|
+
<path
|
|
8
|
+
d="M8 9L11 12L8 15M13 15H16.5"
|
|
9
|
+
fill="none"
|
|
10
|
+
stroke="#cf4a22"
|
|
11
|
+
stroke-width="2"
|
|
12
|
+
stroke-linecap="round"
|
|
13
|
+
stroke-linejoin="round"
|
|
14
|
+
/>
|
|
15
|
+
</svg>
|
package/public/i18n.js
CHANGED
|
@@ -1,169 +1,197 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Only user-facing messages are translated: toasts, dialogs, banners, and
|
|
3
|
-
* errors. Static labels, buttons, and tooltips stay in English so the UI
|
|
4
|
-
* vocabulary and this file stay small.
|
|
5
|
-
*
|
|
6
|
-
* Pi model names, tool names, user/assistant text, and Pi/OS errors are not
|
|
7
|
-
* translated. `scripts/check-i18n.mjs` keeps the ja and en key sets aligned.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const LANGUAGES = [
|
|
11
|
-
{ value: "en", label: "English" },
|
|
12
|
-
{ value: "ja", label: "日本語" },
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
export const TRANSLATIONS = {
|
|
16
|
-
en: {
|
|
17
|
-
"common.delete": "Delete",
|
|
18
|
-
"common.untitled": "Untitled chat",
|
|
19
|
-
"history.deleteTitle": "Delete history",
|
|
20
|
-
"history.deleteAll": "Delete all {count} chats in this project permanently? This cannot be undone.",
|
|
21
|
-
"history.deleteOne": 'Delete "{name}" permanently? This cannot be undone.',
|
|
22
|
-
"history.deleteMany": "Delete {count} chats permanently? This cannot be undone.",
|
|
23
|
-
"history.deletedPartial": "{deleted} deleted, {failed} failed",
|
|
24
|
-
"history.deleted": "{deleted} chats deleted",
|
|
25
|
-
"cmd.noResponse": "There is no response to copy",
|
|
26
|
-
"cmd.copied": "Copied the last response",
|
|
27
|
-
"cmd.exportedPath": "Exported: {path}",
|
|
28
|
-
"cmd.exported": "Exported",
|
|
29
|
-
"cmd.nameRequired": "Enter a name (for example: /name my-task)",
|
|
30
|
-
"cmd.nameSet": "Session name updated",
|
|
31
|
-
"cmd.reloadRunning": "Cannot reload while running",
|
|
32
|
-
"error.extension": "An extension reported an error",
|
|
33
|
-
"error.notConnected": "Not connected to Pi",
|
|
34
|
-
"chat.newCancelled": "New chat cancelled",
|
|
35
|
-
"chat.previousBackground": "The previous chat continues in the background",
|
|
36
|
-
"chat.switchCancelled": "Switch cancelled",
|
|
37
|
-
"chat.cannotResume": "This chat cannot be resumed",
|
|
38
|
-
"compact.running": "Cannot compact while a run is in progress",
|
|
39
|
-
"compact.inProgress": "A compaction is already in progress",
|
|
40
|
-
"compact.done": "Context compacted",
|
|
41
|
-
"image.readFailed": "Could not read the image",
|
|
42
|
-
"image.max": "Up to {count} images",
|
|
43
|
-
"image.tooLarge": "The image is too large",
|
|
44
|
-
"context.saved": "Auto-compaction set to {percent}%",
|
|
45
|
-
"context.reset": "Auto-compaction reset to the Pi default",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"server.
|
|
67
|
-
"server.
|
|
68
|
-
"server.
|
|
69
|
-
"server.
|
|
70
|
-
"server.
|
|
71
|
-
"server.
|
|
72
|
-
"server.
|
|
73
|
-
"server.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Only user-facing messages are translated: toasts, dialogs, banners, and
|
|
3
|
+
* errors. Static labels, buttons, and tooltips stay in English so the UI
|
|
4
|
+
* vocabulary and this file stay small.
|
|
5
|
+
*
|
|
6
|
+
* Pi model names, tool names, user/assistant text, and Pi/OS errors are not
|
|
7
|
+
* translated. `scripts/check-i18n.mjs` keeps the ja and en key sets aligned.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const LANGUAGES = [
|
|
11
|
+
{ value: "en", label: "English" },
|
|
12
|
+
{ value: "ja", label: "日本語" },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export const TRANSLATIONS = {
|
|
16
|
+
en: {
|
|
17
|
+
"common.delete": "Delete",
|
|
18
|
+
"common.untitled": "Untitled chat",
|
|
19
|
+
"history.deleteTitle": "Delete history",
|
|
20
|
+
"history.deleteAll": "Delete all {count} chats in this project permanently? This cannot be undone.",
|
|
21
|
+
"history.deleteOne": 'Delete "{name}" permanently? This cannot be undone.',
|
|
22
|
+
"history.deleteMany": "Delete {count} chats permanently? This cannot be undone.",
|
|
23
|
+
"history.deletedPartial": "{deleted} deleted, {failed} failed",
|
|
24
|
+
"history.deleted": "{deleted} chats deleted",
|
|
25
|
+
"cmd.noResponse": "There is no response to copy",
|
|
26
|
+
"cmd.copied": "Copied the last response",
|
|
27
|
+
"cmd.exportedPath": "Exported: {path}",
|
|
28
|
+
"cmd.exported": "Exported",
|
|
29
|
+
"cmd.nameRequired": "Enter a name (for example: /name my-task)",
|
|
30
|
+
"cmd.nameSet": "Session name updated",
|
|
31
|
+
"cmd.reloadRunning": "Cannot reload while running",
|
|
32
|
+
"error.extension": "An extension reported an error",
|
|
33
|
+
"error.notConnected": "Not connected to Pi",
|
|
34
|
+
"chat.newCancelled": "New chat cancelled",
|
|
35
|
+
"chat.previousBackground": "The previous chat continues in the background",
|
|
36
|
+
"chat.switchCancelled": "Switch cancelled",
|
|
37
|
+
"chat.cannotResume": "This chat cannot be resumed",
|
|
38
|
+
"compact.running": "Cannot compact while a run is in progress",
|
|
39
|
+
"compact.inProgress": "A compaction is already in progress",
|
|
40
|
+
"compact.done": "Context compacted",
|
|
41
|
+
"image.readFailed": "Could not read the image",
|
|
42
|
+
"image.max": "Up to {count} images",
|
|
43
|
+
"image.tooLarge": "The image is too large",
|
|
44
|
+
"context.saved": "Auto-compaction set to {percent}%",
|
|
45
|
+
"context.reset": "Auto-compaction reset to the Pi default",
|
|
46
|
+
"run.next": "Next",
|
|
47
|
+
"run.thinking": "Thinking…",
|
|
48
|
+
"run.tools": "{count} tools",
|
|
49
|
+
"run.tool.read": "Reading",
|
|
50
|
+
"run.tool.edit": "Editing",
|
|
51
|
+
"run.tool.write": "Writing",
|
|
52
|
+
"run.tool.command": "Running",
|
|
53
|
+
"run.tool.web": "Fetching",
|
|
54
|
+
"run.tool.search": "Searching",
|
|
55
|
+
"run.tool.list": "Listing",
|
|
56
|
+
"run.tool.image": "Viewing",
|
|
57
|
+
"run.tool.plan": "Planning",
|
|
58
|
+
"run.tool.agent": "Delegating",
|
|
59
|
+
"run.tool.tool": "Running",
|
|
60
|
+
"banner.restart": "Restart",
|
|
61
|
+
"banner.connectingPi": "Connecting to Pi…",
|
|
62
|
+
"banner.reconnecting": "Reconnecting to the server…",
|
|
63
|
+
"banner.connectFailed": "Cannot connect to Pi: {message}",
|
|
64
|
+
"banner.retry": "Retry",
|
|
65
|
+
"banner.unauthorized": "Open this page from the launch URL printed in the terminal.",
|
|
66
|
+
"server.notConnected": "Not connected to Pi",
|
|
67
|
+
"server.invalidCommand": "Invalid command",
|
|
68
|
+
"server.sessionNotFound": "Session not found",
|
|
69
|
+
"server.deleteTargetMissing": "No sessions selected for deletion",
|
|
70
|
+
"server.sessionInUse": "A session in use cannot be deleted",
|
|
71
|
+
"server.sessionRunning": "A running session cannot be deleted",
|
|
72
|
+
"server.invalidPath": "Invalid path",
|
|
73
|
+
"server.invalidMessage": "The message is empty",
|
|
74
|
+
"server.invalidImages": "Invalid image",
|
|
75
|
+
"server.invalidModel": "Invalid model",
|
|
76
|
+
"server.invalidLevel": "Invalid reasoning effort",
|
|
77
|
+
"server.invalidName": "Invalid name",
|
|
78
|
+
"server.invalidId": "Invalid id",
|
|
79
|
+
"server.unsupportedCommand": "Unsupported command",
|
|
80
|
+
"server.requestTooLarge": "The request is too large",
|
|
81
|
+
"server.piTimeout": "Pi did not respond in time",
|
|
82
|
+
"server.piLaunch": "Pi is not available",
|
|
83
|
+
"server.noModel": "No model is selected",
|
|
84
|
+
"server.contextUnknown": "The context length is unknown for this model",
|
|
85
|
+
"server.percentRange": "The threshold must be between 1% and 99%",
|
|
86
|
+
"server.invalidSettings": "Invalid settings file",
|
|
87
|
+
"server.readSettings": "Could not read the settings file: {message}",
|
|
88
|
+
},
|
|
89
|
+
ja: {
|
|
90
|
+
"common.delete": "削除",
|
|
91
|
+
"common.untitled": "無題の会話",
|
|
92
|
+
"history.deleteTitle": "履歴を削除",
|
|
93
|
+
"history.deleteAll": "このプロジェクトの履歴 {count} 件を完全に削除します。元に戻せません。",
|
|
94
|
+
"history.deleteOne": "「{name}」を完全に削除します。元に戻せません。",
|
|
95
|
+
"history.deleteMany": "{count} 件の履歴を完全に削除します。元に戻せません。",
|
|
96
|
+
"history.deletedPartial": "{deleted} 件削除、{failed} 件失敗",
|
|
97
|
+
"history.deleted": "{deleted} 件の履歴を削除しました",
|
|
98
|
+
"cmd.noResponse": "コピーする応答がありません",
|
|
99
|
+
"cmd.copied": "最後の応答をコピーしました",
|
|
100
|
+
"cmd.exportedPath": "書き出しました: {path}",
|
|
101
|
+
"cmd.exported": "書き出しました",
|
|
102
|
+
"cmd.nameRequired": "名前を入力してください(例: /name 作業名)",
|
|
103
|
+
"cmd.nameSet": "セッション名を設定しました",
|
|
104
|
+
"cmd.reloadRunning": "実行中は再読み込みできません",
|
|
105
|
+
"error.extension": "拡張でエラーが発生しました",
|
|
106
|
+
"error.notConnected": "Pi に接続されていません",
|
|
107
|
+
"chat.newCancelled": "新しい会話はキャンセルされました",
|
|
108
|
+
"chat.previousBackground": "前の会話はバックグラウンドで継続します",
|
|
109
|
+
"chat.switchCancelled": "切り替えはキャンセルされました",
|
|
110
|
+
"chat.cannotResume": "この会話は再開できません",
|
|
111
|
+
"compact.running": "実行中は圧縮できません",
|
|
112
|
+
"compact.inProgress": "圧縮処理中です",
|
|
113
|
+
"compact.done": "コンテキストを圧縮しました",
|
|
114
|
+
"image.readFailed": "画像を読み込めません",
|
|
115
|
+
"image.max": "画像は {count} 枚までです",
|
|
116
|
+
"image.tooLarge": "画像が大きすぎます",
|
|
117
|
+
"context.saved": "自動圧縮を {percent}% に設定しました",
|
|
118
|
+
"context.reset": "自動圧縮を既定に戻しました",
|
|
119
|
+
"run.next": "次",
|
|
120
|
+
"run.thinking": "考え中…",
|
|
121
|
+
"run.tools": "{count} ツール",
|
|
122
|
+
"run.tool.read": "読み込み",
|
|
123
|
+
"run.tool.edit": "編集",
|
|
124
|
+
"run.tool.write": "書き込み",
|
|
125
|
+
"run.tool.command": "実行",
|
|
126
|
+
"run.tool.web": "取得",
|
|
127
|
+
"run.tool.search": "検索",
|
|
128
|
+
"run.tool.list": "一覧",
|
|
129
|
+
"run.tool.image": "画像",
|
|
130
|
+
"run.tool.plan": "計画",
|
|
131
|
+
"run.tool.agent": "委任",
|
|
132
|
+
"run.tool.tool": "実行",
|
|
133
|
+
"banner.restart": "再起動",
|
|
134
|
+
"banner.connectingPi": "Pi に接続しています…",
|
|
135
|
+
"banner.reconnecting": "サーバーに再接続しています…",
|
|
136
|
+
"banner.connectFailed": "Pi に接続できません: {message}",
|
|
137
|
+
"banner.retry": "再試行",
|
|
138
|
+
"banner.unauthorized":
|
|
139
|
+
"このページは起動用 URL から開く必要があります。ターミナルに表示された URL を開いてください。",
|
|
140
|
+
"server.notConnected": "Pi に接続されていません",
|
|
141
|
+
"server.invalidCommand": "コマンドが不正です",
|
|
142
|
+
"server.sessionNotFound": "セッションが見つかりません",
|
|
143
|
+
"server.deleteTargetMissing": "削除対象が指定されていません",
|
|
144
|
+
"server.sessionInUse": "使用中のセッションは削除できません",
|
|
145
|
+
"server.sessionRunning": "実行中のセッションは削除できません",
|
|
146
|
+
"server.invalidPath": "パスが不正です",
|
|
147
|
+
"server.invalidMessage": "メッセージが空です",
|
|
148
|
+
"server.invalidImages": "画像の形式が不正です",
|
|
149
|
+
"server.invalidModel": "モデルが不正です",
|
|
150
|
+
"server.invalidLevel": "level が不正です",
|
|
151
|
+
"server.invalidName": "name が不正です",
|
|
152
|
+
"server.invalidId": "id が不正です",
|
|
153
|
+
"server.unsupportedCommand": "未対応のコマンドです",
|
|
154
|
+
"server.requestTooLarge": "リクエストが大きすぎます",
|
|
155
|
+
"server.piTimeout": "Pi の起動がタイムアウトしました",
|
|
156
|
+
"server.piLaunch": "Pi を起動できません",
|
|
157
|
+
"server.noModel": "モデルが選択されていません",
|
|
158
|
+
"server.contextUnknown": "このモデルのコンテキスト長が不明です",
|
|
159
|
+
"server.percentRange": "圧縮しきい値は 1〜99% で指定してください",
|
|
160
|
+
"server.invalidSettings": "設定ファイルの形式が不正です",
|
|
161
|
+
"server.readSettings": "設定を読み込めません: {message}",
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
function detectLanguage() {
|
|
166
|
+
const language = typeof navigator === "object" ? navigator.language : "en";
|
|
167
|
+
return language.toLowerCase().startsWith("ja") ? "ja" : "en";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let language = detectLanguage();
|
|
171
|
+
|
|
172
|
+
export function normalizeLanguage(value) {
|
|
173
|
+
return value === "ja" || value === "en" ? value : null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function getLanguage() {
|
|
177
|
+
return language;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function t(key, params) {
|
|
181
|
+
const table = TRANSLATIONS[language] ?? TRANSLATIONS.en;
|
|
182
|
+
let value = table[key] ?? TRANSLATIONS.en[key] ?? key;
|
|
183
|
+
if (params && typeof value === "string") {
|
|
184
|
+
value = value.replace(/\{(\w+)\}/g, (match, name) =>
|
|
185
|
+
Object.hasOwn(params, name) ? String(params[name]) : match,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function setLanguage(value) {
|
|
192
|
+
language = normalizeLanguage(value) ?? detectLanguage();
|
|
193
|
+
if (typeof document === "object") {
|
|
194
|
+
document.documentElement.lang = language;
|
|
195
|
+
}
|
|
196
|
+
return language;
|
|
197
|
+
}
|