agentdb 1.0.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 +38 -0
- package/LICENSE-APACHE +190 -0
- package/LICENSE-MIT +21 -0
- package/README.md +953 -0
- package/bin/agentdb.js +485 -0
- package/bin/plugin-cli-wrapper.mjs +21 -0
- package/dist/cache/query-cache.d.ts +105 -0
- package/dist/cache/query-cache.d.ts.map +1 -0
- package/dist/cache/query-cache.js +224 -0
- package/dist/cache/query-cache.js.map +1 -0
- package/dist/cache/query-cache.mjs +219 -0
- package/dist/cli/cache/query-cache.d.ts +104 -0
- package/dist/cli/cache/query-cache.js +244 -0
- package/dist/cli/cli/db-commands.d.ts +48 -0
- package/dist/cli/cli/db-commands.js +613 -0
- package/dist/cli/commands.d.ts +7 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +113 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/commands.mjs +104 -0
- package/dist/cli/core/backend-interface.d.ts +70 -0
- package/dist/cli/core/backend-interface.js +15 -0
- package/dist/cli/core/native-backend.d.ts +140 -0
- package/dist/cli/core/native-backend.js +432 -0
- package/dist/cli/core/vector-db.d.ts +126 -0
- package/dist/cli/core/vector-db.js +338 -0
- package/dist/cli/core/wasm-backend.d.ts +95 -0
- package/dist/cli/core/wasm-backend.js +418 -0
- package/dist/cli/db-commands.d.ts +49 -0
- package/dist/cli/db-commands.d.ts.map +1 -0
- package/dist/cli/db-commands.js +533 -0
- package/dist/cli/db-commands.js.map +1 -0
- package/dist/cli/db-commands.mjs +522 -0
- package/dist/cli/generator.d.ts +11 -0
- package/dist/cli/generator.d.ts.map +1 -0
- package/dist/cli/generator.js +567 -0
- package/dist/cli/generator.js.map +1 -0
- package/dist/cli/generator.mjs +527 -0
- package/dist/cli/help.d.ts +18 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +676 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/help.mjs +667 -0
- package/dist/cli/index/hnsw.d.ts +164 -0
- package/dist/cli/index/hnsw.js +558 -0
- package/dist/cli/plugin-cli.d.ts +7 -0
- package/dist/cli/plugin-cli.d.ts.map +1 -0
- package/dist/cli/plugin-cli.js +295 -0
- package/dist/cli/plugin-cli.js.map +1 -0
- package/dist/cli/plugin-cli.mjs +289 -0
- package/dist/cli/quantization/product-quantization.d.ts +108 -0
- package/dist/cli/quantization/product-quantization.js +350 -0
- package/dist/cli/query/query-builder.d.ts +322 -0
- package/dist/cli/query/query-builder.js +600 -0
- package/dist/cli/templates.d.ts +14 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +182 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/cli/templates.mjs +176 -0
- package/dist/cli/types/index.d.ts +116 -0
- package/dist/cli/types/index.js +5 -0
- package/dist/cli/types.d.ts +91 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +6 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/types.mjs +4 -0
- package/dist/cli/wizard/index.d.ts +6 -0
- package/dist/cli/wizard/index.d.ts.map +1 -0
- package/dist/cli/wizard/index.js +138 -0
- package/dist/cli/wizard/index.js.map +1 -0
- package/dist/cli/wizard/index.mjs +131 -0
- package/dist/cli/wizard/prompts.d.ts +11 -0
- package/dist/cli/wizard/prompts.d.ts.map +1 -0
- package/dist/cli/wizard/prompts.js +482 -0
- package/dist/cli/wizard/prompts.js.map +1 -0
- package/dist/cli/wizard/prompts.mjs +470 -0
- package/dist/cli/wizard/validator.d.ts +13 -0
- package/dist/cli/wizard/validator.d.ts.map +1 -0
- package/dist/cli/wizard/validator.js +234 -0
- package/dist/cli/wizard/validator.js.map +1 -0
- package/dist/cli/wizard/validator.mjs +224 -0
- package/dist/core/backend-interface.d.ts +71 -0
- package/dist/core/backend-interface.d.ts.map +1 -0
- package/dist/core/backend-interface.js +16 -0
- package/dist/core/backend-interface.js.map +1 -0
- package/dist/core/backend-interface.mjs +12 -0
- package/dist/core/native-backend.d.ts +141 -0
- package/dist/core/native-backend.d.ts.map +1 -0
- package/dist/core/native-backend.js +457 -0
- package/dist/core/native-backend.js.map +1 -0
- package/dist/core/native-backend.mjs +449 -0
- package/dist/core/vector-db.d.ts +127 -0
- package/dist/core/vector-db.d.ts.map +1 -0
- package/dist/core/vector-db.js +266 -0
- package/dist/core/vector-db.js.map +1 -0
- package/dist/core/vector-db.mjs +261 -0
- package/dist/core/wasm-backend.d.ts +96 -0
- package/dist/core/wasm-backend.d.ts.map +1 -0
- package/dist/core/wasm-backend.js +393 -0
- package/dist/core/wasm-backend.js.map +1 -0
- package/dist/core/wasm-backend.mjs +385 -0
- package/dist/index/hnsw-optimized.d.ts +75 -0
- package/dist/index/hnsw-optimized.d.ts.map +1 -0
- package/dist/index/hnsw-optimized.js +412 -0
- package/dist/index/hnsw-optimized.js.map +1 -0
- package/dist/index/hnsw-optimized.mjs +407 -0
- package/dist/index/hnsw.d.ts +165 -0
- package/dist/index/hnsw.d.ts.map +1 -0
- package/dist/index/hnsw.js +521 -0
- package/dist/index/hnsw.js.map +1 -0
- package/dist/index/hnsw.mjs +516 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +63 -0
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +789 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp-server.mjs +784 -0
- package/dist/plugins/base-plugin.d.ts +114 -0
- package/dist/plugins/base-plugin.d.ts.map +1 -0
- package/dist/plugins/base-plugin.js +313 -0
- package/dist/plugins/base-plugin.js.map +1 -0
- package/dist/plugins/base-plugin.mjs +275 -0
- package/dist/plugins/implementations/active-learning.d.ts +135 -0
- package/dist/plugins/implementations/active-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/active-learning.js +372 -0
- package/dist/plugins/implementations/active-learning.js.map +1 -0
- package/dist/plugins/implementations/active-learning.mjs +367 -0
- package/dist/plugins/implementations/actor-critic.d.ts +64 -0
- package/dist/plugins/implementations/actor-critic.d.ts.map +1 -0
- package/dist/plugins/implementations/actor-critic.js +363 -0
- package/dist/plugins/implementations/actor-critic.js.map +1 -0
- package/dist/plugins/implementations/actor-critic.mjs +358 -0
- package/dist/plugins/implementations/adversarial-training.d.ts +133 -0
- package/dist/plugins/implementations/adversarial-training.d.ts.map +1 -0
- package/dist/plugins/implementations/adversarial-training.js +409 -0
- package/dist/plugins/implementations/adversarial-training.js.map +1 -0
- package/dist/plugins/implementations/adversarial-training.mjs +404 -0
- package/dist/plugins/implementations/curriculum-learning.d.ts +132 -0
- package/dist/plugins/implementations/curriculum-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/curriculum-learning.js +354 -0
- package/dist/plugins/implementations/curriculum-learning.js.map +1 -0
- package/dist/plugins/implementations/curriculum-learning.mjs +349 -0
- package/dist/plugins/implementations/decision-transformer.d.ts +77 -0
- package/dist/plugins/implementations/decision-transformer.d.ts.map +1 -0
- package/dist/plugins/implementations/decision-transformer.js +422 -0
- package/dist/plugins/implementations/decision-transformer.js.map +1 -0
- package/dist/plugins/implementations/decision-transformer.mjs +417 -0
- package/dist/plugins/implementations/federated-learning.d.ts +126 -0
- package/dist/plugins/implementations/federated-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/federated-learning.js +436 -0
- package/dist/plugins/implementations/federated-learning.js.map +1 -0
- package/dist/plugins/implementations/federated-learning.mjs +431 -0
- package/dist/plugins/implementations/index.d.ts +30 -0
- package/dist/plugins/implementations/index.d.ts.map +1 -0
- package/dist/plugins/implementations/index.js +45 -0
- package/dist/plugins/implementations/index.js.map +1 -0
- package/dist/plugins/implementations/index.mjs +31 -0
- package/dist/plugins/implementations/multi-task-learning.d.ts +115 -0
- package/dist/plugins/implementations/multi-task-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/multi-task-learning.js +369 -0
- package/dist/plugins/implementations/multi-task-learning.js.map +1 -0
- package/dist/plugins/implementations/multi-task-learning.mjs +364 -0
- package/dist/plugins/implementations/neural-architecture-search.d.ts +148 -0
- package/dist/plugins/implementations/neural-architecture-search.d.ts.map +1 -0
- package/dist/plugins/implementations/neural-architecture-search.js +379 -0
- package/dist/plugins/implementations/neural-architecture-search.js.map +1 -0
- package/dist/plugins/implementations/neural-architecture-search.mjs +374 -0
- package/dist/plugins/implementations/q-learning.d.ts +98 -0
- package/dist/plugins/implementations/q-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/q-learning.js +435 -0
- package/dist/plugins/implementations/q-learning.js.map +1 -0
- package/dist/plugins/implementations/q-learning.mjs +430 -0
- package/dist/plugins/implementations/sarsa.d.ts +103 -0
- package/dist/plugins/implementations/sarsa.d.ts.map +1 -0
- package/dist/plugins/implementations/sarsa.js +347 -0
- package/dist/plugins/implementations/sarsa.js.map +1 -0
- package/dist/plugins/implementations/sarsa.mjs +342 -0
- package/dist/plugins/index.d.ts +107 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +179 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/index.mjs +168 -0
- package/dist/plugins/interface.d.ts +439 -0
- package/dist/plugins/interface.d.ts.map +1 -0
- package/dist/plugins/interface.js +12 -0
- package/dist/plugins/interface.js.map +1 -0
- package/dist/plugins/interface.mjs +10 -0
- package/dist/plugins/learning-plugin.interface.d.ts +257 -0
- package/dist/plugins/learning-plugin.interface.d.ts.map +1 -0
- package/dist/plugins/learning-plugin.interface.js +7 -0
- package/dist/plugins/learning-plugin.interface.js.map +1 -0
- package/dist/plugins/learning-plugin.interface.mjs +5 -0
- package/dist/plugins/plugin-exports.d.ts +71 -0
- package/dist/plugins/plugin-exports.d.ts.map +1 -0
- package/dist/plugins/plugin-exports.js +78 -0
- package/dist/plugins/plugin-exports.js.map +1 -0
- package/dist/plugins/plugin-exports.mjs +69 -0
- package/dist/plugins/registry.d.ts +206 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +365 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/registry.mjs +356 -0
- package/dist/plugins/validator.d.ts +63 -0
- package/dist/plugins/validator.d.ts.map +1 -0
- package/dist/plugins/validator.js +464 -0
- package/dist/plugins/validator.js.map +1 -0
- package/dist/plugins/validator.mjs +458 -0
- package/dist/quantization/binary-quantization.d.ts +104 -0
- package/dist/quantization/binary-quantization.d.ts.map +1 -0
- package/dist/quantization/binary-quantization.js +246 -0
- package/dist/quantization/binary-quantization.js.map +1 -0
- package/dist/quantization/binary-quantization.mjs +240 -0
- package/dist/quantization/optimized-pq.d.ts +138 -0
- package/dist/quantization/optimized-pq.d.ts.map +1 -0
- package/dist/quantization/optimized-pq.js +320 -0
- package/dist/quantization/optimized-pq.js.map +1 -0
- package/dist/quantization/optimized-pq.mjs +313 -0
- package/dist/quantization/product-quantization.d.ts +109 -0
- package/dist/quantization/product-quantization.d.ts.map +1 -0
- package/dist/quantization/product-quantization.js +287 -0
- package/dist/quantization/product-quantization.js.map +1 -0
- package/dist/quantization/product-quantization.mjs +282 -0
- package/dist/quantization/scalar-quantization.d.ts +100 -0
- package/dist/quantization/scalar-quantization.d.ts.map +1 -0
- package/dist/quantization/scalar-quantization.js +324 -0
- package/dist/quantization/scalar-quantization.js.map +1 -0
- package/dist/quantization/scalar-quantization.mjs +319 -0
- package/dist/query/index.d.ts +6 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +9 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/index.mjs +4 -0
- package/dist/query/query-builder.d.ts +323 -0
- package/dist/query/query-builder.d.ts.map +1 -0
- package/dist/query/query-builder.js +524 -0
- package/dist/query/query-builder.js.map +1 -0
- package/dist/query/query-builder.mjs +519 -0
- package/dist/reasoning/context-synthesizer.d.ts +57 -0
- package/dist/reasoning/context-synthesizer.d.ts.map +1 -0
- package/dist/reasoning/context-synthesizer.js +224 -0
- package/dist/reasoning/context-synthesizer.js.map +1 -0
- package/dist/reasoning/context-synthesizer.mjs +219 -0
- package/dist/reasoning/experience-curator.d.ts +66 -0
- package/dist/reasoning/experience-curator.d.ts.map +1 -0
- package/dist/reasoning/experience-curator.js +288 -0
- package/dist/reasoning/experience-curator.js.map +1 -0
- package/dist/reasoning/experience-curator.mjs +283 -0
- package/dist/reasoning/memory-optimizer.d.ts +69 -0
- package/dist/reasoning/memory-optimizer.d.ts.map +1 -0
- package/dist/reasoning/memory-optimizer.js +331 -0
- package/dist/reasoning/memory-optimizer.js.map +1 -0
- package/dist/reasoning/memory-optimizer.mjs +326 -0
- package/dist/reasoning/pattern-matcher.d.ts +59 -0
- package/dist/reasoning/pattern-matcher.d.ts.map +1 -0
- package/dist/reasoning/pattern-matcher.js +229 -0
- package/dist/reasoning/pattern-matcher.js.map +1 -0
- package/dist/reasoning/pattern-matcher.mjs +224 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts +118 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts.map +1 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.js +477 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.js.map +1 -0
- package/dist/reasoningbank/adapter/types.d.ts +113 -0
- package/dist/reasoningbank/adapter/types.d.ts.map +1 -0
- package/dist/reasoningbank/adapter/types.js +9 -0
- package/dist/reasoningbank/adapter/types.js.map +1 -0
- package/dist/reasoningbank/cli/commands.d.ts +16 -0
- package/dist/reasoningbank/cli/commands.d.ts.map +1 -0
- package/dist/reasoningbank/cli/commands.js +272 -0
- package/dist/reasoningbank/cli/commands.js.map +1 -0
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts +319 -0
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts.map +1 -0
- package/dist/reasoningbank/mcp/agentdb-tools.js +301 -0
- package/dist/reasoningbank/mcp/agentdb-tools.js.map +1 -0
- package/dist/reasoningbank/migration/migrate.d.ts +25 -0
- package/dist/reasoningbank/migration/migrate.d.ts.map +1 -0
- package/dist/reasoningbank/migration/migrate.js +178 -0
- package/dist/reasoningbank/migration/migrate.js.map +1 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts +37 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.js +114 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.js.map +1 -0
- package/dist/reasoningbank/reasoning/experience-curator.d.ts +39 -0
- package/dist/reasoningbank/reasoning/experience-curator.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/experience-curator.js +98 -0
- package/dist/reasoningbank/reasoning/experience-curator.js.map +1 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts +44 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.js +184 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.js.map +1 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts +40 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.js +87 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.js.map +1 -0
- package/dist/reasoningbank/sync/quic-sync.d.ts +77 -0
- package/dist/reasoningbank/sync/quic-sync.d.ts.map +1 -0
- package/dist/reasoningbank/sync/quic-sync.js +165 -0
- package/dist/reasoningbank/sync/quic-sync.js.map +1 -0
- package/dist/sync/conflict.d.ts +78 -0
- package/dist/sync/conflict.d.ts.map +1 -0
- package/dist/sync/conflict.js +202 -0
- package/dist/sync/conflict.js.map +1 -0
- package/dist/sync/conflict.mjs +196 -0
- package/dist/sync/coordinator.d.ts +111 -0
- package/dist/sync/coordinator.d.ts.map +1 -0
- package/dist/sync/coordinator.js +256 -0
- package/dist/sync/coordinator.js.map +1 -0
- package/dist/sync/coordinator.mjs +250 -0
- package/dist/sync/delta.d.ts +81 -0
- package/dist/sync/delta.d.ts.map +1 -0
- package/dist/sync/delta.js +245 -0
- package/dist/sync/delta.js.map +1 -0
- package/dist/sync/delta.mjs +238 -0
- package/dist/sync/index.d.ts +11 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +22 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/index.mjs +9 -0
- package/dist/sync/quic-sync.d.ts +81 -0
- package/dist/sync/quic-sync.d.ts.map +1 -0
- package/dist/sync/quic-sync.js +329 -0
- package/dist/sync/quic-sync.js.map +1 -0
- package/dist/sync/quic-sync.mjs +323 -0
- package/dist/sync/types.d.ts +168 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +8 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/sync/types.mjs +6 -0
- package/dist/types/index.d.ts +117 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +4 -0
- package/dist/wasm-loader.d.ts +32 -0
- package/dist/wasm-loader.d.ts.map +1 -0
- package/dist/wasm-loader.js +75 -0
- package/dist/wasm-loader.js.map +1 -0
- package/dist/wasm-loader.mjs +64 -0
- package/examples/adaptive-learning.ts +284 -0
- package/examples/browser/README.md +732 -0
- package/examples/browser/adaptive-recommendations/index.html +427 -0
- package/examples/browser/collaborative-filtering/index.html +310 -0
- package/examples/browser/continual-learning/index.html +736 -0
- package/examples/browser/experience-replay/index.html +616 -0
- package/examples/browser/index.html +369 -0
- package/examples/browser/meta-learning/index.html +789 -0
- package/examples/browser/neuro-symbolic/index.html +692 -0
- package/examples/browser/pattern-learning/index.html +620 -0
- package/examples/browser/quantum-inspired/index.html +728 -0
- package/examples/browser/rag/index.html +624 -0
- package/examples/browser/swarm-intelligence/index.html +811 -0
- package/examples/browser-basic.html +170 -0
- package/examples/hnsw-example.ts +148 -0
- package/examples/node-basic.js +70 -0
- package/examples/quic-sync-example.ts +310 -0
- package/examples/quick-start.js +68 -0
- package/examples/wasm-example.ts +222 -0
- package/package.json +118 -0
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Pattern-Based Learning - AgentDB</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
|
|
10
|
+
body {
|
|
11
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
12
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
13
|
+
min-height: 100vh;
|
|
14
|
+
padding: 2rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.container { max-width: 1200px; margin: 0 auto; }
|
|
18
|
+
|
|
19
|
+
header {
|
|
20
|
+
background: white;
|
|
21
|
+
border-radius: 12px;
|
|
22
|
+
padding: 2rem;
|
|
23
|
+
margin-bottom: 2rem;
|
|
24
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 { color: #333; margin-bottom: 0.5rem; }
|
|
28
|
+
.subtitle { color: #666; }
|
|
29
|
+
|
|
30
|
+
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
|
|
31
|
+
|
|
32
|
+
.card {
|
|
33
|
+
background: white;
|
|
34
|
+
border-radius: 12px;
|
|
35
|
+
padding: 2rem;
|
|
36
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.card h2 { color: #333; margin-bottom: 1rem; }
|
|
40
|
+
|
|
41
|
+
.task-grid {
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
|
44
|
+
gap: 1rem;
|
|
45
|
+
margin-top: 1rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.task-btn {
|
|
49
|
+
padding: 2rem 1rem;
|
|
50
|
+
background: #f8f9fa;
|
|
51
|
+
border: 2px solid #e0e0e0;
|
|
52
|
+
border-radius: 8px;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
transition: all 0.2s ease;
|
|
55
|
+
text-align: center;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.task-btn:hover {
|
|
59
|
+
border-color: #667eea;
|
|
60
|
+
transform: translateY(-2px);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.task-btn .icon { font-size: 2rem; margin-bottom: 0.5rem; }
|
|
64
|
+
.task-btn .label { font-weight: 600; color: #333; }
|
|
65
|
+
|
|
66
|
+
.pattern-list {
|
|
67
|
+
max-height: 400px;
|
|
68
|
+
overflow-y: auto;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.pattern-item {
|
|
72
|
+
background: #f8f9fa;
|
|
73
|
+
border-radius: 6px;
|
|
74
|
+
padding: 1rem;
|
|
75
|
+
margin-bottom: 0.5rem;
|
|
76
|
+
border-left: 4px solid #667eea;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.pattern-header {
|
|
80
|
+
display: flex;
|
|
81
|
+
justify-content: space-between;
|
|
82
|
+
margin-bottom: 0.5rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.pattern-title { font-weight: 600; color: #333; }
|
|
86
|
+
.pattern-score {
|
|
87
|
+
background: #667eea;
|
|
88
|
+
color: white;
|
|
89
|
+
padding: 0.25rem 0.75rem;
|
|
90
|
+
border-radius: 12px;
|
|
91
|
+
font-size: 0.85rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.pattern-details {
|
|
95
|
+
color: #666;
|
|
96
|
+
font-size: 0.9rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.stat-grid {
|
|
100
|
+
display: grid;
|
|
101
|
+
grid-template-columns: repeat(2, 1fr);
|
|
102
|
+
gap: 1rem;
|
|
103
|
+
margin-bottom: 1rem;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.stat {
|
|
107
|
+
background: #f8f9fa;
|
|
108
|
+
padding: 1rem;
|
|
109
|
+
border-radius: 6px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.stat-label { color: #666; font-size: 0.9rem; }
|
|
113
|
+
.stat-value {
|
|
114
|
+
color: #333;
|
|
115
|
+
font-size: 1.8rem;
|
|
116
|
+
font-weight: bold;
|
|
117
|
+
margin-top: 0.25rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.btn {
|
|
121
|
+
padding: 0.75rem 1.5rem;
|
|
122
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
123
|
+
color: white;
|
|
124
|
+
border: none;
|
|
125
|
+
border-radius: 6px;
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
transition: opacity 0.3s ease;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.btn:hover { opacity: 0.9; }
|
|
132
|
+
|
|
133
|
+
.prediction-box {
|
|
134
|
+
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
|
|
135
|
+
border: 2px solid #667eea;
|
|
136
|
+
border-radius: 8px;
|
|
137
|
+
padding: 1.5rem;
|
|
138
|
+
margin-top: 1rem;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.prediction-title {
|
|
142
|
+
font-weight: 600;
|
|
143
|
+
color: #667eea;
|
|
144
|
+
margin-bottom: 0.5rem;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.prediction-text {
|
|
148
|
+
color: #333;
|
|
149
|
+
line-height: 1.6;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.timeline {
|
|
153
|
+
position: relative;
|
|
154
|
+
padding-left: 2rem;
|
|
155
|
+
margin-top: 1rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.timeline-item {
|
|
159
|
+
position: relative;
|
|
160
|
+
padding-bottom: 1rem;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.timeline-item::before {
|
|
164
|
+
content: '';
|
|
165
|
+
position: absolute;
|
|
166
|
+
left: -1.5rem;
|
|
167
|
+
top: 0.5rem;
|
|
168
|
+
width: 10px;
|
|
169
|
+
height: 10px;
|
|
170
|
+
background: #667eea;
|
|
171
|
+
border-radius: 50%;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.timeline-item::after {
|
|
175
|
+
content: '';
|
|
176
|
+
position: absolute;
|
|
177
|
+
left: -1.25rem;
|
|
178
|
+
top: 1rem;
|
|
179
|
+
width: 2px;
|
|
180
|
+
height: calc(100% - 0.5rem);
|
|
181
|
+
background: #e0e0e0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.timeline-item:last-child::after { display: none; }
|
|
185
|
+
|
|
186
|
+
.timeline-time {
|
|
187
|
+
color: #999;
|
|
188
|
+
font-size: 0.85rem;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.timeline-action {
|
|
192
|
+
color: #333;
|
|
193
|
+
font-weight: 500;
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
196
|
+
</head>
|
|
197
|
+
<body>
|
|
198
|
+
<div class="container">
|
|
199
|
+
<header>
|
|
200
|
+
<h1>🎯 Pattern-Based Learning</h1>
|
|
201
|
+
<p class="subtitle">Learn from user behavior and predict next actions</p>
|
|
202
|
+
</header>
|
|
203
|
+
|
|
204
|
+
<div class="grid">
|
|
205
|
+
<div class="card">
|
|
206
|
+
<h2>Perform Tasks</h2>
|
|
207
|
+
<p style="color: #666; margin-bottom: 1rem;">
|
|
208
|
+
Click on tasks below. The system will learn your patterns and predict your next action!
|
|
209
|
+
</p>
|
|
210
|
+
|
|
211
|
+
<div class="task-grid">
|
|
212
|
+
<button class="task-btn" data-task="email">
|
|
213
|
+
<div class="icon">📧</div>
|
|
214
|
+
<div class="label">Check Email</div>
|
|
215
|
+
</button>
|
|
216
|
+
<button class="task-btn" data-task="calendar">
|
|
217
|
+
<div class="icon">📅</div>
|
|
218
|
+
<div class="label">View Calendar</div>
|
|
219
|
+
</button>
|
|
220
|
+
<button class="task-btn" data-task="notes">
|
|
221
|
+
<div class="icon">📝</div>
|
|
222
|
+
<div class="label">Take Notes</div>
|
|
223
|
+
</button>
|
|
224
|
+
<button class="task-btn" data-task="tasks">
|
|
225
|
+
<div class="icon">✅</div>
|
|
226
|
+
<div class="label">Manage Tasks</div>
|
|
227
|
+
</button>
|
|
228
|
+
<button class="task-btn" data-task="chat">
|
|
229
|
+
<div class="icon">💬</div>
|
|
230
|
+
<div class="label">Team Chat</div>
|
|
231
|
+
</button>
|
|
232
|
+
<button class="task-btn" data-task="files">
|
|
233
|
+
<div class="icon">📁</div>
|
|
234
|
+
<div class="label">Browse Files</div>
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<div id="prediction" class="prediction-box" style="display: none;">
|
|
239
|
+
<div class="prediction-title">🔮 Next Action Prediction</div>
|
|
240
|
+
<div class="prediction-text" id="predictionText"></div>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
<div style="margin-top: 2rem;">
|
|
244
|
+
<button class="btn" id="clearBtn">Clear History</button>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<div class="card">
|
|
249
|
+
<h2>Learning Analytics</h2>
|
|
250
|
+
|
|
251
|
+
<div class="stat-grid">
|
|
252
|
+
<div class="stat">
|
|
253
|
+
<div class="stat-label">Actions Performed</div>
|
|
254
|
+
<div class="stat-value" id="actionCount">0</div>
|
|
255
|
+
</div>
|
|
256
|
+
<div class="stat">
|
|
257
|
+
<div class="stat-label">Patterns Detected</div>
|
|
258
|
+
<div class="stat-value" id="patternCount">0</div>
|
|
259
|
+
</div>
|
|
260
|
+
<div class="stat">
|
|
261
|
+
<div class="stat-label">Prediction Accuracy</div>
|
|
262
|
+
<div class="stat-value" id="accuracy">-</div>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="stat">
|
|
265
|
+
<div class="stat-label">Confidence Level</div>
|
|
266
|
+
<div class="stat-value" id="confidence">-</div>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<h3 style="margin-top: 1.5rem; margin-bottom: 0.5rem;">Recent Activity</h3>
|
|
271
|
+
<div class="timeline" id="timeline">
|
|
272
|
+
<p style="color: #666; padding: 1rem;">No activity yet</p>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
<div class="card">
|
|
278
|
+
<h2>Discovered Patterns</h2>
|
|
279
|
+
<div class="pattern-list" id="patternList">
|
|
280
|
+
<p style="color: #666; text-align: center; padding: 2rem;">
|
|
281
|
+
Perform some tasks to discover patterns!
|
|
282
|
+
</p>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<script type="module">
|
|
288
|
+
/**
|
|
289
|
+
* Pattern-Based Learning Example
|
|
290
|
+
*
|
|
291
|
+
* This system learns from user interaction patterns:
|
|
292
|
+
* 1. Tracks task sequences and timing
|
|
293
|
+
* 2. Discovers frequent patterns using vector similarity
|
|
294
|
+
* 3. Predicts next actions based on current context
|
|
295
|
+
* 4. Adapts UI/UX based on learned behaviors
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
let db = null;
|
|
299
|
+
let actionHistory = [];
|
|
300
|
+
let patterns = [];
|
|
301
|
+
let predictions = [];
|
|
302
|
+
|
|
303
|
+
async function initDB() {
|
|
304
|
+
console.log('Initializing pattern learning database...');
|
|
305
|
+
|
|
306
|
+
db = {
|
|
307
|
+
patterns: [],
|
|
308
|
+
sequences: [],
|
|
309
|
+
|
|
310
|
+
async storePattern(pattern) {
|
|
311
|
+
const embedding = this.generateSequenceEmbedding(pattern.sequence);
|
|
312
|
+
|
|
313
|
+
this.patterns.push({
|
|
314
|
+
id: Date.now().toString(),
|
|
315
|
+
sequence: pattern.sequence,
|
|
316
|
+
embedding: embedding,
|
|
317
|
+
frequency: pattern.frequency,
|
|
318
|
+
avgDuration: pattern.avgDuration,
|
|
319
|
+
confidence: pattern.confidence,
|
|
320
|
+
lastSeen: Date.now()
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
return this.patterns[this.patterns.length - 1];
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
async findSimilarPatterns(currentSequence, k = 3) {
|
|
327
|
+
if (currentSequence.length === 0) return [];
|
|
328
|
+
|
|
329
|
+
const queryEmbedding = this.generateSequenceEmbedding(currentSequence);
|
|
330
|
+
|
|
331
|
+
const scored = this.patterns.map(pattern => ({
|
|
332
|
+
...pattern,
|
|
333
|
+
similarity: cosineSimilarity(queryEmbedding, pattern.embedding)
|
|
334
|
+
}));
|
|
335
|
+
|
|
336
|
+
return scored
|
|
337
|
+
.sort((a, b) => b.similarity - a.similarity)
|
|
338
|
+
.slice(0, k);
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
generateSequenceEmbedding(sequence) {
|
|
342
|
+
// Generate embedding for action sequence
|
|
343
|
+
const embedding = new Array(128).fill(0);
|
|
344
|
+
|
|
345
|
+
sequence.forEach((action, index) => {
|
|
346
|
+
const actionHash = simpleHash(action);
|
|
347
|
+
const positionWeight = 1 / (index + 1); // Recent actions weighted more
|
|
348
|
+
|
|
349
|
+
for (let i = 0; i < embedding.length; i++) {
|
|
350
|
+
embedding[i] += Math.sin(actionHash * (i + 1)) * positionWeight;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// Normalize
|
|
355
|
+
const norm = Math.sqrt(embedding.reduce((sum, val) => sum + val * val, 0));
|
|
356
|
+
return embedding.map(val => val / (norm || 1));
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function simpleHash(str) {
|
|
362
|
+
let hash = 0;
|
|
363
|
+
for (let i = 0; i < str.length; i++) {
|
|
364
|
+
hash = ((hash << 5) - hash) + str.charCodeAt(i);
|
|
365
|
+
hash = hash & hash;
|
|
366
|
+
}
|
|
367
|
+
return hash;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function cosineSimilarity(a, b) {
|
|
371
|
+
let dot = 0, normA = 0, normB = 0;
|
|
372
|
+
for (let i = 0; i < a.length; i++) {
|
|
373
|
+
dot += a[i] * b[i];
|
|
374
|
+
normA += a[i] * a[i];
|
|
375
|
+
normB += b[i] * b[i];
|
|
376
|
+
}
|
|
377
|
+
return dot / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async function handleTaskClick(task) {
|
|
381
|
+
const action = {
|
|
382
|
+
task: task,
|
|
383
|
+
timestamp: Date.now()
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
actionHistory.push(action);
|
|
387
|
+
|
|
388
|
+
// Update timeline
|
|
389
|
+
addToTimeline(task);
|
|
390
|
+
|
|
391
|
+
// Detect patterns (use last 5 actions)
|
|
392
|
+
if (actionHistory.length >= 3) {
|
|
393
|
+
await detectPatterns();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Predict next action
|
|
397
|
+
if (actionHistory.length >= 2) {
|
|
398
|
+
await predictNextAction();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
updateStats();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
async function detectPatterns() {
|
|
405
|
+
const recentActions = actionHistory.slice(-5).map(a => a.task);
|
|
406
|
+
|
|
407
|
+
// Check for sequential patterns
|
|
408
|
+
for (let len = 2; len <= Math.min(recentActions.length, 4); len++) {
|
|
409
|
+
const sequence = recentActions.slice(-len);
|
|
410
|
+
|
|
411
|
+
// Count occurrences of this pattern in history
|
|
412
|
+
const occurrences = countPatternOccurrences(sequence);
|
|
413
|
+
|
|
414
|
+
if (occurrences >= 2) { // Pattern appeared at least twice
|
|
415
|
+
const existing = patterns.find(p =>
|
|
416
|
+
JSON.stringify(p.sequence) === JSON.stringify(sequence)
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
if (existing) {
|
|
420
|
+
existing.frequency++;
|
|
421
|
+
existing.lastSeen = Date.now();
|
|
422
|
+
} else {
|
|
423
|
+
const pattern = {
|
|
424
|
+
sequence: sequence,
|
|
425
|
+
frequency: occurrences,
|
|
426
|
+
avgDuration: calculateAvgDuration(sequence),
|
|
427
|
+
confidence: Math.min(occurrences / 10, 1)
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
patterns.push(pattern);
|
|
431
|
+
await db.storePattern(pattern);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
renderPatterns();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function countPatternOccurrences(pattern) {
|
|
440
|
+
let count = 0;
|
|
441
|
+
const history = actionHistory.map(a => a.task);
|
|
442
|
+
|
|
443
|
+
for (let i = 0; i <= history.length - pattern.length; i++) {
|
|
444
|
+
const slice = history.slice(i, i + pattern.length);
|
|
445
|
+
if (JSON.stringify(slice) === JSON.stringify(pattern)) {
|
|
446
|
+
count++;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return count;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function calculateAvgDuration(sequence) {
|
|
454
|
+
const occurrences = [];
|
|
455
|
+
const history = actionHistory.map(a => a.task);
|
|
456
|
+
|
|
457
|
+
for (let i = 0; i <= history.length - sequence.length; i++) {
|
|
458
|
+
const slice = history.slice(i, i + sequence.length);
|
|
459
|
+
if (JSON.stringify(slice) === JSON.stringify(sequence)) {
|
|
460
|
+
const start = actionHistory[i].timestamp;
|
|
461
|
+
const end = actionHistory[i + sequence.length - 1].timestamp;
|
|
462
|
+
occurrences.push(end - start);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return occurrences.length > 0
|
|
467
|
+
? occurrences.reduce((a, b) => a + b, 0) / occurrences.length
|
|
468
|
+
: 0;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
async function predictNextAction() {
|
|
472
|
+
const recent = actionHistory.slice(-3).map(a => a.task);
|
|
473
|
+
const similar = await db.findSimilarPatterns(recent, 3);
|
|
474
|
+
|
|
475
|
+
if (similar.length > 0 && similar[0].similarity > 0.7) {
|
|
476
|
+
const topPattern = similar[0];
|
|
477
|
+
const matchLength = Math.min(recent.length, topPattern.sequence.length - 1);
|
|
478
|
+
|
|
479
|
+
// Find where current sequence matches pattern
|
|
480
|
+
let matchIndex = -1;
|
|
481
|
+
for (let i = 0; i <= topPattern.sequence.length - matchLength; i++) {
|
|
482
|
+
const slice = topPattern.sequence.slice(i, i + matchLength);
|
|
483
|
+
if (JSON.stringify(slice) === JSON.stringify(recent.slice(-matchLength))) {
|
|
484
|
+
matchIndex = i;
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (matchIndex >= 0 && matchIndex + matchLength < topPattern.sequence.length) {
|
|
490
|
+
const nextTask = topPattern.sequence[matchIndex + matchLength];
|
|
491
|
+
const confidence = (topPattern.similarity * topPattern.confidence * 100).toFixed(0);
|
|
492
|
+
|
|
493
|
+
showPrediction(nextTask, confidence);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
hidePrediction();
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function showPrediction(task, confidence) {
|
|
502
|
+
const taskNames = {
|
|
503
|
+
email: 'Check Email 📧',
|
|
504
|
+
calendar: 'View Calendar 📅',
|
|
505
|
+
notes: 'Take Notes 📝',
|
|
506
|
+
tasks: 'Manage Tasks ✅',
|
|
507
|
+
chat: 'Team Chat 💬',
|
|
508
|
+
files: 'Browse Files 📁'
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
document.getElementById('prediction').style.display = 'block';
|
|
512
|
+
document.getElementById('predictionText').textContent =
|
|
513
|
+
`Based on your patterns, you might want to: ${taskNames[task]} (${confidence}% confidence)`;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function hidePrediction() {
|
|
517
|
+
document.getElementById('prediction').style.display = 'none';
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function addToTimeline(task) {
|
|
521
|
+
const taskNames = {
|
|
522
|
+
email: 'Checked Email',
|
|
523
|
+
calendar: 'Viewed Calendar',
|
|
524
|
+
notes: 'Took Notes',
|
|
525
|
+
tasks: 'Managed Tasks',
|
|
526
|
+
chat: 'Used Team Chat',
|
|
527
|
+
files: 'Browsed Files'
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const timeline = document.getElementById('timeline');
|
|
531
|
+
|
|
532
|
+
if (actionHistory.length === 1) {
|
|
533
|
+
timeline.innerHTML = '';
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const item = document.createElement('div');
|
|
537
|
+
item.className = 'timeline-item';
|
|
538
|
+
item.innerHTML = `
|
|
539
|
+
<div class="timeline-time">${new Date().toLocaleTimeString()}</div>
|
|
540
|
+
<div class="timeline-action">${taskNames[task]}</div>
|
|
541
|
+
`;
|
|
542
|
+
|
|
543
|
+
timeline.insertBefore(item, timeline.firstChild);
|
|
544
|
+
|
|
545
|
+
// Keep only last 10 items
|
|
546
|
+
while (timeline.children.length > 10) {
|
|
547
|
+
timeline.removeChild(timeline.lastChild);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function renderPatterns() {
|
|
552
|
+
const listEl = document.getElementById('patternList');
|
|
553
|
+
|
|
554
|
+
if (patterns.length === 0) {
|
|
555
|
+
listEl.innerHTML = '<p style="color: #666; text-align: center; padding: 2rem;">Perform some tasks to discover patterns!</p>';
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const taskNames = {
|
|
560
|
+
email: '📧', calendar: '📅', notes: '📝',
|
|
561
|
+
tasks: '✅', chat: '💬', files: '📁'
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
const sorted = [...patterns].sort((a, b) => b.frequency - a.frequency);
|
|
565
|
+
|
|
566
|
+
listEl.innerHTML = sorted.map(pattern => `
|
|
567
|
+
<div class="pattern-item">
|
|
568
|
+
<div class="pattern-header">
|
|
569
|
+
<div class="pattern-title">
|
|
570
|
+
${pattern.sequence.map(t => taskNames[t]).join(' → ')}
|
|
571
|
+
</div>
|
|
572
|
+
<div class="pattern-score">${pattern.frequency}x</div>
|
|
573
|
+
</div>
|
|
574
|
+
<div class="pattern-details">
|
|
575
|
+
Confidence: ${(pattern.confidence * 100).toFixed(0)}% •
|
|
576
|
+
Avg. Duration: ${(pattern.avgDuration / 1000).toFixed(1)}s
|
|
577
|
+
</div>
|
|
578
|
+
</div>
|
|
579
|
+
`).join('');
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function updateStats() {
|
|
583
|
+
document.getElementById('actionCount').textContent = actionHistory.length;
|
|
584
|
+
document.getElementById('patternCount').textContent = patterns.length;
|
|
585
|
+
|
|
586
|
+
if (patterns.length > 0) {
|
|
587
|
+
const avgConfidence = patterns.reduce((sum, p) => sum + p.confidence, 0) / patterns.length;
|
|
588
|
+
document.getElementById('confidence').textContent = `${(avgConfidence * 100).toFixed(0)}%`;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function clearHistory() {
|
|
593
|
+
if (confirm('Clear all history and patterns?')) {
|
|
594
|
+
actionHistory = [];
|
|
595
|
+
patterns = [];
|
|
596
|
+
db.patterns = [];
|
|
597
|
+
|
|
598
|
+
document.getElementById('timeline').innerHTML = '<p style="color: #666; padding: 1rem;">No activity yet</p>';
|
|
599
|
+
document.getElementById('prediction').style.display = 'none';
|
|
600
|
+
|
|
601
|
+
renderPatterns();
|
|
602
|
+
updateStats();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// Event listeners
|
|
607
|
+
document.querySelectorAll('.task-btn').forEach(btn => {
|
|
608
|
+
btn.addEventListener('click', () => {
|
|
609
|
+
const task = btn.getAttribute('data-task');
|
|
610
|
+
handleTaskClick(task);
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
document.getElementById('clearBtn').addEventListener('click', clearHistory);
|
|
615
|
+
|
|
616
|
+
// Initialize
|
|
617
|
+
initDB();
|
|
618
|
+
</script>
|
|
619
|
+
</body>
|
|
620
|
+
</html>
|