zerochat 7.3.0__py3-none-any.whl

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 (130) hide show
  1. zerochat-7.3.0.dist-info/METADATA +70 -0
  2. zerochat-7.3.0.dist-info/RECORD +130 -0
  3. zerochat-7.3.0.dist-info/WHEEL +5 -0
  4. zerochat-7.3.0.dist-info/entry_points.txt +2 -0
  5. zerochat-7.3.0.dist-info/licenses/LICENSE +34 -0
  6. zerochat-7.3.0.dist-info/top_level.txt +2 -0
  7. zerochat.py +2004 -0
  8. zerochat_runtime/__init__.py +1 -0
  9. zerochat_runtime/assets/css/base.css +199 -0
  10. zerochat_runtime/assets/css/components/composer.css +1258 -0
  11. zerochat_runtime/assets/css/components/debug.css +777 -0
  12. zerochat_runtime/assets/css/components/header.css +97 -0
  13. zerochat_runtime/assets/css/components/icons.css +39 -0
  14. zerochat_runtime/assets/css/components/markdown.css +685 -0
  15. zerochat_runtime/assets/css/components/messages.css +473 -0
  16. zerochat_runtime/assets/css/components/modals.css +1319 -0
  17. zerochat_runtime/assets/css/components/sidebar.css +622 -0
  18. zerochat_runtime/assets/css/components/tools.css +1223 -0
  19. zerochat_runtime/assets/css/layout.css +171 -0
  20. zerochat_runtime/assets/css/print.css +120 -0
  21. zerochat_runtime/assets/css/styles.css +18 -0
  22. zerochat_runtime/assets/css/theme-overrides.css +555 -0
  23. zerochat_runtime/assets/css/tokens.css +165 -0
  24. zerochat_runtime/assets/help/architecture.html +247 -0
  25. zerochat_runtime/assets/help/composer.html +134 -0
  26. zerochat_runtime/assets/help/conversations.html +105 -0
  27. zerochat_runtime/assets/help/debug.html +108 -0
  28. zerochat_runtime/assets/help/en/architecture.html +247 -0
  29. zerochat_runtime/assets/help/en/composer.html +134 -0
  30. zerochat_runtime/assets/help/en/conversations.html +104 -0
  31. zerochat_runtime/assets/help/en/debug.html +105 -0
  32. zerochat_runtime/assets/help/en/gemini-free.html +39 -0
  33. zerochat_runtime/assets/help/en/index.html +191 -0
  34. zerochat_runtime/assets/help/en/learning.html +71 -0
  35. zerochat_runtime/assets/help/en/mcp.html +143 -0
  36. zerochat_runtime/assets/help/en/openrouter-free.html +39 -0
  37. zerochat_runtime/assets/help/en/profiles.html +173 -0
  38. zerochat_runtime/assets/help/en/rag.html +130 -0
  39. zerochat_runtime/assets/help/en/reasoning-telemetry.html +108 -0
  40. zerochat_runtime/assets/help/en/tools-agent.html +133 -0
  41. zerochat_runtime/assets/help/en/webllm.html +355 -0
  42. zerochat_runtime/assets/help/gemini-free.html +39 -0
  43. zerochat_runtime/assets/help/help.css +604 -0
  44. zerochat_runtime/assets/help/help.js +51 -0
  45. zerochat_runtime/assets/help/index.html +194 -0
  46. zerochat_runtime/assets/help/learning.html +71 -0
  47. zerochat_runtime/assets/help/mcp.html +143 -0
  48. zerochat_runtime/assets/help/openrouter-free.html +39 -0
  49. zerochat_runtime/assets/help/profiles.html +174 -0
  50. zerochat_runtime/assets/help/rag.html +130 -0
  51. zerochat_runtime/assets/help/reasoning-telemetry.html +111 -0
  52. zerochat_runtime/assets/help/tools-agent.html +133 -0
  53. zerochat_runtime/assets/help/webllm.html +359 -0
  54. zerochat_runtime/assets/js/agent-core.js +1553 -0
  55. zerochat_runtime/assets/js/api.js +844 -0
  56. zerochat_runtime/assets/js/app.js +2558 -0
  57. zerochat_runtime/assets/js/attachments.js +220 -0
  58. zerochat_runtime/assets/js/charts.js +338 -0
  59. zerochat_runtime/assets/js/chat-engine.js +566 -0
  60. zerochat_runtime/assets/js/config-store.js +207 -0
  61. zerochat_runtime/assets/js/context-manager.js +584 -0
  62. zerochat_runtime/assets/js/conversation-service.js +484 -0
  63. zerochat_runtime/assets/js/cookies.js +688 -0
  64. zerochat_runtime/assets/js/data-reset-service.js +136 -0
  65. zerochat_runtime/assets/js/debug.js +508 -0
  66. zerochat_runtime/assets/js/defaults.js +16 -0
  67. zerochat_runtime/assets/js/export.js +179 -0
  68. zerochat_runtime/assets/js/file-parser.js +2088 -0
  69. zerochat_runtime/assets/js/generation-controller.js +417 -0
  70. zerochat_runtime/assets/js/i18n.js +1483 -0
  71. zerochat_runtime/assets/js/icons.js +156 -0
  72. zerochat_runtime/assets/js/ingestionEngine.js +436 -0
  73. zerochat_runtime/assets/js/markdown.js +588 -0
  74. zerochat_runtime/assets/js/mcp.js +1271 -0
  75. zerochat_runtime/assets/js/message-turns.js +62 -0
  76. zerochat_runtime/assets/js/profile-backup.js +118 -0
  77. zerochat_runtime/assets/js/profile-export-bundle.js +481 -0
  78. zerochat_runtime/assets/js/profile-repository.js +213 -0
  79. zerochat_runtime/assets/js/providers-webllm.js +486 -0
  80. zerochat_runtime/assets/js/providers.js +1560 -0
  81. zerochat_runtime/assets/js/rag-index.js +295 -0
  82. zerochat_runtime/assets/js/rag-service.js +530 -0
  83. zerochat_runtime/assets/js/rag-ui.js +997 -0
  84. zerochat_runtime/assets/js/ragStorage.js +676 -0
  85. zerochat_runtime/assets/js/sandbox.js +449 -0
  86. zerochat_runtime/assets/js/state.js +704 -0
  87. zerochat_runtime/assets/js/storage-db.js +144 -0
  88. zerochat_runtime/assets/js/tool-cards.js +330 -0
  89. zerochat_runtime/assets/js/tool-security.js +653 -0
  90. zerochat_runtime/assets/js/tools/README.md +50 -0
  91. zerochat_runtime/assets/js/tools/builtin/agent-checkpoint.tool.js +212 -0
  92. zerochat_runtime/assets/js/tools/builtin/download-pdf.tool.js +111 -0
  93. zerochat_runtime/assets/js/tools/builtin/execute-javascript.tool.js +219 -0
  94. zerochat_runtime/assets/js/tools/builtin/fetch-web-page.tool.js +112 -0
  95. zerochat_runtime/assets/js/tools/builtin/list-documents.tool.js +117 -0
  96. zerochat_runtime/assets/js/tools/builtin/read-knowledge-chunk.tool.js +129 -0
  97. zerochat_runtime/assets/js/tools/builtin/read-knowledge-image.tool.js +95 -0
  98. zerochat_runtime/assets/js/tools/builtin/render-chart.tool.js +90 -0
  99. zerochat_runtime/assets/js/tools/builtin/search-knowledge-base.tool.js +124 -0
  100. zerochat_runtime/assets/js/tools/builtin/search-web.tool.js +125 -0
  101. zerochat_runtime/assets/js/tools/tool-manifest.js +53 -0
  102. zerochat_runtime/assets/js/tools/tool-runtime.js +77 -0
  103. zerochat_runtime/assets/js/ui-composer.js +319 -0
  104. zerochat_runtime/assets/js/ui-conversation.js +655 -0
  105. zerochat_runtime/assets/js/ui-dialogs.js +132 -0
  106. zerochat_runtime/assets/js/ui-generation-status.js +119 -0
  107. zerochat_runtime/assets/js/ui-inspector.js +804 -0
  108. zerochat_runtime/assets/js/ui-mcp.js +604 -0
  109. zerochat_runtime/assets/js/ui-profiles.js +824 -0
  110. zerochat_runtime/assets/js/ui-reasoning.js +146 -0
  111. zerochat_runtime/assets/js/ui-settings.js +825 -0
  112. zerochat_runtime/assets/js/ui-shell.js +215 -0
  113. zerochat_runtime/assets/js/ui-sidebar.js +429 -0
  114. zerochat_runtime/assets/js/ui-telemetry.js +404 -0
  115. zerochat_runtime/assets/js/ui-transfer.js +262 -0
  116. zerochat_runtime/assets/js/utils.js +216 -0
  117. zerochat_runtime/assets/js/vendor/orama.browser.js +11 -0
  118. zerochat_runtime/assets/js/web-browser.js +569 -0
  119. zerochat_runtime/assets/js/web-search.js +519 -0
  120. zerochat_runtime/assets/manifest.webmanifest +20 -0
  121. zerochat_runtime/assets/services/dummy_mcp/dummy_mcp_server.py +47 -0
  122. zerochat_runtime/assets/services/dummy_mcp/service.json +22 -0
  123. zerochat_runtime/assets/services/lsp/installer.json +9 -0
  124. zerochat_runtime/assets/services/lsp/service.json +22 -0
  125. zerochat_runtime/assets/services/memory/installer.json +9 -0
  126. zerochat_runtime/assets/services/memory/service.json +24 -0
  127. zerochat_runtime/assets/services/playwright/installer.json +10 -0
  128. zerochat_runtime/assets/services/playwright/service.json +39 -0
  129. zerochat_runtime/assets/sw.js +164 -0
  130. zerochat_runtime/assets/zerochat.html +671 -0
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Sole runtime configuration boundary. UI and execution must read this store,
3
+ * never the editable profile repository or browser storage directly.
4
+ */
5
+ (function (root, factory) {
6
+ if (typeof exports === 'object' && typeof module !== 'undefined') {
7
+ module.exports = factory(require('./state.js'), require('./cookies.js'), require('./profile-repository.js'), require('./defaults.js'));
8
+ } else {
9
+ root.ChatConfig = factory(root.ChatState, root.ChatStorage, root.ChatProfileRepository, root.ChatDefaults);
10
+ }
11
+ }(typeof self !== 'undefined' ? self : this, function (State, Storage, Profiles, Defaults) {
12
+ 'use strict';
13
+
14
+ const SCHEMA_VERSION = 2;
15
+ const DEFAULT_THEME = Defaults.DEFAULT_THEME;
16
+ const PROFILE_FIELDS = Profiles?.PROFILE_FIELDS || [];
17
+ const DEFAULT_SYSTEM_DATA_PROMPT = '[Format: Always use standard Markdown and plain text. Never use LaTeX syntax or delimiters ($ or $$); write mathematics, formulas, and numbers directly in readable text using standard symbols (+, -, ×, /, =).]';
18
+ const DEFAULTS = Object.freeze({
19
+ schemaVersion: SCHEMA_VERSION,
20
+ activeProfile: null,
21
+ apiUrl: 'http://localhost:1234/v1', apiType: 'openai', model: '', modelContextLimit: null, contextLimitOverride: null,
22
+ systemPrompt: '', systemDataPrompt: DEFAULT_SYSTEM_DATA_PROMPT, temperature: '0.7', reasoningEffort: 'medium', reasoningTransport: 'auto',
23
+ maxAgentTurns: 15,
24
+ modelReasoningConfig: null,
25
+ enabledTools: { execute_javascript: true, search_web: true, fetch_web_page: true, download_pdf: true, render_chart: true },
26
+ enableRawLogs: false, enableContextCache: true,
27
+ apiKeyLocked: false,
28
+ theme: DEFAULT_THEME, language: 'es', enableDebugMessages: false,
29
+ activeRagBranchId: '', activeRagBranchIds: [],
30
+ mcpHost: '127.0.0.1', mcpPort: 6388, mcpAutoConnect: false,
31
+ webllmConfig: {
32
+ context_window_size: 'default',
33
+ prefill_chunk_size: 'default'
34
+ }
35
+ });
36
+
37
+ function clone(value) {
38
+ return JSON.parse(JSON.stringify(value));
39
+ }
40
+
41
+ function normalizeBranchIds(value, fallback) {
42
+ const values = Array.isArray(value) ? value : (value ? [value] : fallback || []);
43
+ return values.map(String).map(id => id.trim()).filter(Boolean);
44
+ }
45
+
46
+ function normalize(config = {}) {
47
+ const next = { ...clone(DEFAULTS), ...clone(config), schemaVersion: SCHEMA_VERSION };
48
+ delete next.activeProfileName;
49
+ delete next.enableAgentJs;
50
+ delete next.enableAgentWeb;
51
+ delete next.enableAgentSearch;
52
+ delete next.enableAgentChart;
53
+ delete next.sendDateTime;
54
+ next.apiUrl = String(next.apiUrl || DEFAULTS.apiUrl).trim() || DEFAULTS.apiUrl;
55
+ next.apiType = String(next.apiType || DEFAULTS.apiType).trim() || DEFAULTS.apiType;
56
+ delete next.apiKey;
57
+ next.model = String(next.model || '').trim();
58
+ const contextLimit = Number(next.modelContextLimit);
59
+ next.modelContextLimit = Number.isFinite(contextLimit) && contextLimit > 0 ? Math.floor(contextLimit) : null;
60
+ const contextLimitOverride = Number(next.contextLimitOverride);
61
+ next.contextLimitOverride = Number.isFinite(contextLimitOverride) && contextLimitOverride > 0 ? Math.floor(contextLimitOverride) : null;
62
+ next.systemPrompt = String(next.systemPrompt || '').trim();
63
+ next.systemDataPrompt = String(next.systemDataPrompt || '').trim();
64
+ next.temperature = String(next.temperature ?? DEFAULTS.temperature);
65
+ next.reasoningEffort = ['off', 'none'].includes(String(next.reasoningEffort).toLowerCase()) ? 'none' : String(next.reasoningEffort || DEFAULTS.reasoningEffort);
66
+ next.reasoningTransport = ['omit', 'send-none'].includes(next.reasoningTransport) ? next.reasoningTransport : 'auto';
67
+ const parsedTurns = Number(next.maxAgentTurns);
68
+ next.maxAgentTurns = Number.isInteger(parsedTurns) && parsedTurns >= 1 ? Math.min(50, Math.max(1, parsedTurns)) : 15;
69
+ next.theme = next.theme === 'dark' ? 'dark' : 'light';
70
+ next.language = next.language === 'en' ? 'en' : 'es';
71
+ next.enabledTools = next.enabledTools && typeof next.enabledTools === 'object' ? clone(next.enabledTools) : clone(DEFAULTS.enabledTools);
72
+ next.enableRawLogs = next.enableRawLogs === true;
73
+ next.enableDebugMessages = next.enableDebugMessages === true;
74
+ next.enableContextCache = next.enableContextCache !== false;
75
+ next.mcpHost = String(next.mcpHost || DEFAULTS.mcpHost).trim() || DEFAULTS.mcpHost;
76
+ const parsedMcpPort = Number(next.mcpPort);
77
+ next.mcpPort = Number.isInteger(parsedMcpPort) && parsedMcpPort >= 1024 && parsedMcpPort <= 65535 ? parsedMcpPort : DEFAULTS.mcpPort;
78
+ next.mcpAutoConnect = next.mcpAutoConnect === true;
79
+ next.activeRagBranchIds = normalizeBranchIds(next.activeRagBranchIds, next.activeRagBranchId ? [next.activeRagBranchId] : []);
80
+ next.activeRagBranchId = next.activeRagBranchIds[0] || '';
81
+ next.modelReasoningConfig = next.modelReasoningConfig && typeof next.modelReasoningConfig === 'object' ? clone(next.modelReasoningConfig) : null;
82
+ if (!next.activeProfile || typeof next.activeProfile !== 'object') next.activeProfile = null;
83
+ return next;
84
+ }
85
+
86
+ function profileMetadata(profile) {
87
+ return { id: profile.id, name: profile.name, version: profile.version, appliedAt: Date.now() };
88
+ }
89
+
90
+ function createConfigStore(options = {}) {
91
+ const state = options.state || State;
92
+ const storage = options.storage || Storage;
93
+ const profiles = options.profiles || Profiles;
94
+
95
+ function persist(next) {
96
+ if (!storage?.saveRuntimeConfigV2) throw new Error('El almacenamiento de configuración no está disponible.');
97
+ storage.saveRuntimeConfigV2({ ...next, modelContextLimit: null });
98
+ }
99
+
100
+ function commit(next) {
101
+ const normalized = normalize(next);
102
+ persist(normalized);
103
+ state.set('config', normalized);
104
+ return state.get('config');
105
+ }
106
+
107
+ function initialize() {
108
+ try {
109
+ profiles?.initialize?.();
110
+ } catch (error) {
111
+ console.warn('No se pudo inicializar el repositorio de perfiles:', error);
112
+ }
113
+ const stored = storage?.loadRuntimeConfigV2?.();
114
+ let fallbackProfile = null;
115
+ try {
116
+ fallbackProfile = profiles?.get?.(profiles?.READONLY_PROFILE_ID) || profiles?.list?.()[0] || null;
117
+ } catch (_) {}
118
+ if (stored) {
119
+ const config = { ...stored, modelContextLimit: null };
120
+ try {
121
+ if (!profiles?.get?.(config.activeProfile?.id) && fallbackProfile) {
122
+ return commit(applyProfile(config, fallbackProfile));
123
+ }
124
+ } catch (_) {}
125
+ return commit(config);
126
+ }
127
+
128
+ try {
129
+ return fallbackProfile ? activateProfile(fallbackProfile.id) : commit(DEFAULTS);
130
+ } catch (_) {
131
+ return commit(DEFAULTS);
132
+ }
133
+ }
134
+
135
+ function getActive() {
136
+ return normalize(state.get('config') || DEFAULTS);
137
+ }
138
+
139
+ function updateRuntime(patch = {}) {
140
+ const current = getActive();
141
+ const safePatch = { ...patch };
142
+ delete safePatch.schemaVersion;
143
+ delete safePatch.activeProfile;
144
+ const connectionChanged = ['apiUrl', 'apiType', 'model'].some(key => Object.prototype.hasOwnProperty.call(safePatch, key)
145
+ && safePatch[key] !== current[key]);
146
+ if (connectionChanged && !Object.prototype.hasOwnProperty.call(safePatch, 'modelContextLimit')) {
147
+ safePatch.modelContextLimit = null;
148
+ }
149
+ return commit({ ...current, ...safePatch });
150
+ }
151
+
152
+ function updateGeneral(patch = {}) {
153
+ return updateRuntime(patch);
154
+ }
155
+
156
+ function activateProfile(profileId) {
157
+ const profile = profiles?.get?.(profileId);
158
+ if (!profile) throw new Error('El perfil seleccionado no existe.');
159
+ return commit(applyProfile(getActive(), profile));
160
+ }
161
+
162
+ function applyProfile(config, profile) {
163
+ const patch = {};
164
+ PROFILE_FIELDS.forEach(field => {
165
+ patch[field] = clone(profile.settings[field] !== undefined ? profile.settings[field] : DEFAULTS[field]);
166
+ });
167
+ return {
168
+ ...config,
169
+ ...patch,
170
+ modelContextLimit: null,
171
+ contextLimitOverride: profile.settings.contextLimitOverride ?? null,
172
+ activeProfile: profileMetadata(profile)
173
+ };
174
+ }
175
+
176
+ function activateFallbackProfile() {
177
+ const fallbackProfile = profiles?.get?.(profiles?.READONLY_PROFILE_ID) || profiles?.list?.()[0] || null;
178
+ return fallbackProfile ? activateProfile(fallbackProfile.id) : commit(DEFAULTS);
179
+ }
180
+
181
+ function subscribe(listener) {
182
+ if (!state?.subscribe) throw new Error('El estado global no está disponible.');
183
+ return state.subscribe('config', listener);
184
+ }
185
+
186
+ function resetRuntime() {
187
+ const mirror = profiles?.get?.(profiles?.READONLY_PROFILE_ID);
188
+ return commit(mirror ? applyProfile(DEFAULTS, mirror) : DEFAULTS);
189
+ }
190
+
191
+ return {
192
+ initialize,
193
+ getActive,
194
+ get: getActive,
195
+ updateRuntime,
196
+ updateGeneral,
197
+ update: updateRuntime,
198
+ activateProfile,
199
+ activateFallbackProfile,
200
+ subscribe,
201
+ resetRuntime
202
+ };
203
+ }
204
+
205
+ const defaultStore = createConfigStore();
206
+ return { SCHEMA_VERSION, DEFAULT_SYSTEM_DATA_PROMPT, DEFAULTS: clone(DEFAULTS), normalize, createConfigStore, ...defaultStore };
207
+ }));