@llmguard/opencode 0.0.0-stage → 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.
Files changed (79) hide show
  1. package/MANUAL-TEST-G.md +167 -0
  2. package/README.md +334 -2
  3. package/RELEASE.md +122 -0
  4. package/bin/darwin-amd64/helper +0 -0
  5. package/bin/darwin-arm64/helper +0 -0
  6. package/bin/linux-amd64/helper +0 -0
  7. package/bin/linux-arm64/helper +0 -0
  8. package/bin/manifest.json +51 -0
  9. package/bin/windows-amd64/helper.exe +0 -0
  10. package/bin/windows-arm64/helper.exe +0 -0
  11. package/bridge/client.d.ts +55 -0
  12. package/bridge/client.js +425 -0
  13. package/bridge/framing.d.ts +19 -0
  14. package/bridge/framing.js +110 -0
  15. package/bridge/process.d.ts +38 -0
  16. package/bridge/process.js +378 -0
  17. package/bridge/protocol.d.ts +184 -0
  18. package/bridge/protocol.js +683 -0
  19. package/connection-catalog.d.ts +69 -0
  20. package/connection-catalog.js +287 -0
  21. package/connections-tui.d.ts +11 -0
  22. package/connections-tui.js +394 -0
  23. package/demasking.d.ts +2 -0
  24. package/demasking.js +445 -0
  25. package/gui-experimental.cjs +33 -0
  26. package/hook-trace.d.ts +2 -0
  27. package/hook-trace.js +35 -0
  28. package/index.d.ts +1 -0
  29. package/index.js +1 -0
  30. package/licenses/Go-LICENSE +27 -0
  31. package/messages.d.ts +230 -0
  32. package/messages.js +231 -0
  33. package/native/index.d.ts +1 -0
  34. package/native/index.js +1 -0
  35. package/native/tui.d.ts +1 -0
  36. package/native/tui.js +1 -0
  37. package/package.json +49 -4
  38. package/plugin-runtime.d.ts +3 -0
  39. package/plugin-runtime.js +3 -0
  40. package/plugin-settings.d.ts +77 -0
  41. package/plugin-settings.js +487 -0
  42. package/plugin.d.ts +41 -0
  43. package/plugin.js +10 -0
  44. package/response-diagnostics.d.ts +13 -0
  45. package/response-diagnostics.js +142 -0
  46. package/runtime/attachments.d.ts +4 -0
  47. package/runtime/attachments.js +19 -0
  48. package/runtime/errors.d.ts +18 -0
  49. package/runtime/errors.js +26 -0
  50. package/runtime/json.d.ts +14 -0
  51. package/runtime/json.js +243 -0
  52. package/runtime/limits.d.ts +2 -0
  53. package/runtime/limits.js +3 -0
  54. package/runtime/native-edit.d.ts +14 -0
  55. package/runtime/native-edit.js +73 -0
  56. package/runtime/runtime.d.ts +43 -0
  57. package/runtime/runtime.js +345 -0
  58. package/runtime/session-state.d.ts +13 -0
  59. package/runtime/session-state.js +73 -0
  60. package/runtime/text-layout.d.ts +9 -0
  61. package/runtime/text-layout.js +47 -0
  62. package/server.d.ts +1 -0
  63. package/server.js +1 -0
  64. package/settings-rpc.d.ts +511 -0
  65. package/settings-rpc.js +197 -0
  66. package/tui-messages.d.ts +1 -0
  67. package/tui-messages.js +84 -0
  68. package/tui.d.ts +17 -0
  69. package/tui.js +427 -0
  70. package/v1/hooks.d.ts +81 -0
  71. package/v1/hooks.js +97 -0
  72. package/v1/projection.d.ts +32 -0
  73. package/v1/projection.js +217 -0
  74. package/v1.d.ts +2 -0
  75. package/v1.js +2 -0
  76. package/v2/projection.d.ts +36 -0
  77. package/v2/projection.js +374 -0
  78. package/v2/server.d.ts +6 -0
  79. package/v2/server.js +633 -0
@@ -0,0 +1,197 @@
1
+ const empty = { type: "object", additionalProperties: false };
2
+ const status = {
3
+ type: "object",
4
+ properties: {
5
+ baseURL: { type: "string", maxLength: 2048 },
6
+ projectSID: { type: "string", maxLength: 36 },
7
+ allowLoopbackHTTP: { type: "boolean" },
8
+ configured: { type: "boolean" },
9
+ enabled: { type: "boolean" },
10
+ tokenPresent: { type: "boolean" },
11
+ environmentOverride: { type: "boolean" },
12
+ tokenSource: {
13
+ type: "string",
14
+ enum: ["environment", "session", "missing"],
15
+ },
16
+ },
17
+ required: [
18
+ "baseURL",
19
+ "projectSID",
20
+ "allowLoopbackHTTP",
21
+ "configured",
22
+ "enabled",
23
+ "tokenPresent",
24
+ "environmentOverride",
25
+ "tokenSource",
26
+ ],
27
+ additionalProperties: false,
28
+ };
29
+ const connectionFields = {
30
+ baseURL: { type: "string", maxLength: 2048 },
31
+ projectSID: { type: "string", maxLength: 36 },
32
+ allowLoopbackHTTP: { type: "boolean" },
33
+ };
34
+ const connectionList = {
35
+ type: "object",
36
+ additionalProperties: false,
37
+ properties: {
38
+ configured: { type: "boolean" },
39
+ activeLabel: { type: "string" },
40
+ revision: { type: "integer", minimum: 0 },
41
+ enabled: { type: "boolean" },
42
+ environmentOverride: { type: "boolean" },
43
+ items: {
44
+ type: "array",
45
+ maxItems: 100,
46
+ items: {
47
+ type: "object",
48
+ additionalProperties: false,
49
+ properties: {
50
+ ...connectionFields,
51
+ id: { type: "string" },
52
+ name: { type: "string" },
53
+ tokenPresent: { type: "boolean" },
54
+ tokenHint: { type: "string", maxLength: 7 },
55
+ active: { type: "boolean" },
56
+ },
57
+ required: [
58
+ "baseURL",
59
+ "projectSID",
60
+ "allowLoopbackHTTP",
61
+ "id",
62
+ "name",
63
+ "tokenPresent",
64
+ "active",
65
+ ],
66
+ },
67
+ },
68
+ },
69
+ required: [
70
+ "revision",
71
+ "enabled",
72
+ "configured",
73
+ "activeLabel",
74
+ "environmentOverride",
75
+ "items",
76
+ ],
77
+ };
78
+ const connectionTarget = {
79
+ type: "object",
80
+ additionalProperties: false,
81
+ properties: {
82
+ id: { type: "string", maxLength: 64 },
83
+ revision: { type: "integer", minimum: 0 },
84
+ },
85
+ required: ["id", "revision"],
86
+ };
87
+ const filesPolicy = {
88
+ type: "object",
89
+ properties: {
90
+ inspect: { type: "boolean" },
91
+ allowUninspectable: { type: "boolean" },
92
+ source: { type: "string", enum: ["default", "file", "env"] },
93
+ damaged: { type: "boolean" },
94
+ },
95
+ required: ["inspect", "allowUninspectable", "source", "damaged"],
96
+ additionalProperties: false,
97
+ };
98
+ const probeResult = {
99
+ type: "object",
100
+ additionalProperties: false,
101
+ properties: {
102
+ connected: { type: "boolean" },
103
+ code: { type: "string", maxLength: 64 },
104
+ decision: { enum: ["allow", "deny", "transform", null] },
105
+ },
106
+ required: ["connected", "code", "decision"],
107
+ };
108
+ export const settingsRPC = {
109
+ id: "llmguard.settings",
110
+ methods: {
111
+ connections: { input: empty, output: connectionList },
112
+ saveConnection: {
113
+ input: {
114
+ type: "object",
115
+ additionalProperties: false,
116
+ properties: {
117
+ ...connectionFields,
118
+ revision: { type: "integer", minimum: 0 },
119
+ id: { type: "string", maxLength: 64 },
120
+ name: { type: "string", minLength: 1, maxLength: 100 },
121
+ token: { type: "string", maxLength: 4096 },
122
+ },
123
+ required: [
124
+ "revision",
125
+ "name",
126
+ "baseURL",
127
+ "projectSID",
128
+ "allowLoopbackHTTP",
129
+ ],
130
+ },
131
+ output: connectionList,
132
+ },
133
+ testConnection: { input: connectionTarget, output: probeResult },
134
+ connect: { input: connectionTarget, output: probeResult },
135
+ status: { input: empty, output: status },
136
+ setEnabled: {
137
+ input: {
138
+ type: "object",
139
+ properties: { enabled: { type: "boolean" } },
140
+ required: ["enabled"],
141
+ additionalProperties: false,
142
+ },
143
+ output: status,
144
+ },
145
+ save: {
146
+ input: {
147
+ type: "object",
148
+ properties: {
149
+ baseURL: { type: "string", maxLength: 2048 },
150
+ projectSID: { type: "string", maxLength: 36 },
151
+ allowLoopbackHTTP: { type: "boolean" },
152
+ },
153
+ required: ["baseURL", "projectSID", "allowLoopbackHTTP"],
154
+ additionalProperties: false,
155
+ },
156
+ output: status,
157
+ },
158
+ setKey: {
159
+ input: {
160
+ type: "object",
161
+ properties: {
162
+ token: { type: "string", minLength: 1, maxLength: 4096 },
163
+ },
164
+ required: ["token"],
165
+ additionalProperties: false,
166
+ },
167
+ output: status,
168
+ },
169
+ files: { input: empty, output: filesPolicy },
170
+ setFiles: {
171
+ input: {
172
+ type: "object",
173
+ properties: {
174
+ inspect: { type: "boolean" },
175
+ allowUninspectable: { type: "boolean" },
176
+ },
177
+ required: ["inspect", "allowUninspectable"],
178
+ additionalProperties: false,
179
+ },
180
+ output: filesPolicy,
181
+ },
182
+ test: {
183
+ input: empty,
184
+ output: {
185
+ type: "object",
186
+ properties: {
187
+ connected: { type: "boolean" },
188
+ code: { type: "string", maxLength: 64 },
189
+ decision: { enum: ["allow", "deny", "transform", null] },
190
+ },
191
+ required: ["connected", "code", "decision"],
192
+ additionalProperties: false,
193
+ },
194
+ },
195
+ },
196
+ events: {},
197
+ };
@@ -0,0 +1 @@
1
+ export declare function tuiText(locale: string): (text: string) => string;
@@ -0,0 +1,84 @@
1
+ const english = {
2
+ "Вложения: не проверять": "Attachments: not inspected",
3
+ "Вложения: проверять, непроверяемые блокировать": "Attachments: inspect, block what cannot be inspected",
4
+ "Вложения: проверять, непроверяемые пропускать": "Attachments: inspect, let through what cannot be inspected",
5
+ "Файлы и изображения в запросах к модели": "Files and images in model requests",
6
+ "Задано переменными окружения сервера": "Set by the server environment variables",
7
+ "Файл настроек повреждён: действует строгий режим": "The settings file is damaged: strict mode is in effect",
8
+ Вложения: "Attachments",
9
+ "Проверка вложений задана переменными LLMGUARD_FILE_INSPECTION и LLMGUARD_FILE_UNINSPECTABLE; меню их не меняет.": "Attachment inspection is set by LLMGUARD_FILE_INSPECTION and LLMGUARD_FILE_UNINSPECTABLE; the menu does not change it.",
10
+ "Проверка файлов и изображений": "Inspection of files and images",
11
+ "Не проверять": "Do not inspect",
12
+ "Файлы и изображения проходят как раньше": "Files and images pass as before",
13
+ "Проверять, непроверяемые блокировать": "Inspect, block what cannot be inspected",
14
+ "Проблемный файл или срабатывание правила отклоняет запрос": "A problem file or a rule match rejects the request",
15
+ "Проверять, непроверяемые пропускать": "Inspect, let through what cannot be inspected",
16
+ "Неподдерживаемые типы, ссылки и идентификаторы файлов уходят без проверки": "Unsupported types, links and file ids go through uninspected",
17
+ "Настройки вложений сохранены": "Attachment settings saved",
18
+ Подключить: "Connect",
19
+ Подключён: "Connected",
20
+ " · окружение": " · environment",
21
+ "Guard доступен. Активное подключение не изменено.": "Guard is reachable. Active connection unchanged.",
22
+ "HTTP разрешён (без TLS)": "HTTP allowed (no TLS)",
23
+ "LLMGuard · Черновик подключения": "LLMGuard · Connection draft",
24
+ "LLMGuard: подключения": "LLMGuard: connections",
25
+ "SID проекта": "Project SID",
26
+ "Активное подключение останется прежним": "Active connection will stay unchanged",
27
+ Включить: "Enable",
28
+ "Выберите поле или сохраните": "Choose a field or save",
29
+ Добавить: "Add",
30
+ Закрыть: "Close",
31
+ "Заполните название, сервер и SID проекта.": "Enter a name, server and project SID.",
32
+ "Запросы всех сессий этого сервера будут проходить без проверки Guard.": "Requests in all sessions on this server will bypass Guard checks.",
33
+ "Защита включена.": "Protection enabled.",
34
+ "Защита выключена.": "Protection disabled.",
35
+ Изменить: "Edit",
36
+ "Изменить / черновик": "Edit / draft",
37
+ "Ключ Guard": "Guard key",
38
+ "Ключ виден при вводе; сохраняется локально на сервере OpenCode. Пусто — сохранить ключ этого подключения. Отмена возвращает к черновику.": "The key is visible while typing and saved locally on the OpenCode server. Leave blank to keep this connection's key. Cancel returns to the draft.",
39
+ "Ключ сохранён": "Key saved",
40
+ Назад: "Back",
41
+ Название: "Name",
42
+ "Название, сервер или SID": "Name, server or SID",
43
+ "Не задан": "Not set",
44
+ "Не задано": "Not set",
45
+ "Нужен ключ": "Key required",
46
+ "Нужен ключ: выберите «Изменить», затем «Сохранить».": "Key required: choose Edit, then Save.",
47
+ Отбросить: "Discard",
48
+ "Отбросить другой черновик?": "Discard the other draft?",
49
+ "Отбросить черновик?": "Discard draft?",
50
+ "Отбросить черновик…": "Discard draft…",
51
+ Отключить: "Disable",
52
+ "Отключить защиту?": "Disable protection?",
53
+ "Отключить…": "Disable…",
54
+ Отмена: "Cancel",
55
+ Повторить: "Retry",
56
+ "Подключение задано окружением сервера.": "Connection is managed by the server environment.",
57
+ "Подключение применено. Защита включена.": "Connection applied. Protection enabled.",
58
+ "Подключение сохранено. Активный проект не изменён.": "Connection saved. Active project unchanged.",
59
+ "Подключён · ": "Connected · ",
60
+ Проверить: "Check",
61
+ "Проверка выбранного подключения…": "Checking selected connection…",
62
+ "Проверка не пройдена. Проверьте сервер, SID и ключ.": "Check failed. Verify server, SID and key.",
63
+ "Проверка перед подключением…": "Checking before connecting…",
64
+ Продолжить: "Continue",
65
+ Протокол: "Protocol",
66
+ "Разрешить HTTP (без TLS)": "Allow HTTP (no TLS)",
67
+ "Результат действия неизвестен. Проверьте обновлённый список перед повтором.": "Action outcome unknown. Review the refreshed list before retrying.",
68
+ Сервер: "Server",
69
+ "Сервер Guard": "Guard server",
70
+ "Состояние подключения неизвестно. Проверьте серверный плагин.": "Connection state unknown. Check the server plugin.",
71
+ "Сохранение не подтверждено. Черновик сохранён; обновите список перед повтором.": "Save not confirmed. Draft kept; refresh the list before retrying.",
72
+ Сохранить: "Save",
73
+ "Сохранённые подключения не изменятся.": "Saved connections will stay unchanged.",
74
+ "Список недоступен": "Connection list unavailable",
75
+ Черновик: "Draft",
76
+ "защита включена": "protection enabled",
77
+ "защита выключена": "protection disabled",
78
+ "операции блокируются": "operations blocked",
79
+ };
80
+ // TUI SDK 2.2.5 has no locale API; use the client terminal locale, never server locale.
81
+ export function tuiText(locale) {
82
+ const russian = /^ru(?:[_.-]|$)/i.test(locale);
83
+ return (text) => (russian ? text : (english[text] ?? text));
84
+ }
package/tui.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { Plugin } from "@opencode/plugin/tui";
2
+ type Context = Plugin.Context;
3
+ type API = {
4
+ status(): Promise<unknown>;
5
+ setEnabled(input: unknown): Promise<unknown>;
6
+ save(input: unknown): Promise<unknown>;
7
+ setKey(input: unknown): Promise<unknown>;
8
+ test(): Promise<unknown>;
9
+ files?(): Promise<unknown>;
10
+ setFiles?(input: unknown): Promise<unknown>;
11
+ };
12
+ export declare function registerSettingsTUI(context: Pick<Context, "keymap" | "ui">, api: API): () => void;
13
+ declare const _default: {
14
+ id: string;
15
+ setup(context: Plugin.Context): () => void;
16
+ };
17
+ export default _default;