@miller-tech/uap 1.7.1 → 1.8.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.
Files changed (53) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/analyzers/index.d.ts.map +1 -1
  3. package/dist/analyzers/index.js +17 -24
  4. package/dist/analyzers/index.js.map +1 -1
  5. package/dist/cli/init.d.ts.map +1 -1
  6. package/dist/cli/init.js +26 -1
  7. package/dist/cli/init.js.map +1 -1
  8. package/dist/coordination/adaptive-patterns.d.ts +31 -1
  9. package/dist/coordination/adaptive-patterns.d.ts.map +1 -1
  10. package/dist/coordination/adaptive-patterns.js +116 -1
  11. package/dist/coordination/adaptive-patterns.js.map +1 -1
  12. package/dist/dashboard/data-service.d.ts +65 -0
  13. package/dist/dashboard/data-service.d.ts.map +1 -1
  14. package/dist/dashboard/data-service.js.map +1 -1
  15. package/dist/dashboard/event-stream.d.ts +69 -0
  16. package/dist/dashboard/event-stream.d.ts.map +1 -0
  17. package/dist/dashboard/event-stream.js +120 -0
  18. package/dist/dashboard/event-stream.js.map +1 -0
  19. package/dist/dashboard/index.d.ts +3 -1
  20. package/dist/dashboard/index.d.ts.map +1 -1
  21. package/dist/dashboard/index.js +1 -0
  22. package/dist/dashboard/index.js.map +1 -1
  23. package/dist/dashboard/server.d.ts +1 -0
  24. package/dist/dashboard/server.d.ts.map +1 -1
  25. package/dist/dashboard/server.js +71 -0
  26. package/dist/dashboard/server.js.map +1 -1
  27. package/dist/mcp-router/executor/client.d.ts +11 -0
  28. package/dist/mcp-router/executor/client.d.ts.map +1 -1
  29. package/dist/mcp-router/executor/client.js +81 -5
  30. package/dist/mcp-router/executor/client.js.map +1 -1
  31. package/dist/memory/embeddings.d.ts +2 -0
  32. package/dist/memory/embeddings.d.ts.map +1 -1
  33. package/dist/memory/embeddings.js +23 -4
  34. package/dist/memory/embeddings.js.map +1 -1
  35. package/dist/models/index.d.ts +2 -0
  36. package/dist/models/index.d.ts.map +1 -1
  37. package/dist/models/index.js +2 -0
  38. package/dist/models/index.js.map +1 -1
  39. package/dist/models/profile-loader.d.ts +167 -0
  40. package/dist/models/profile-loader.d.ts.map +1 -0
  41. package/dist/models/profile-loader.js +133 -0
  42. package/dist/models/profile-loader.js.map +1 -0
  43. package/dist/models/router.d.ts +2 -1
  44. package/dist/models/router.d.ts.map +1 -1
  45. package/dist/models/router.js +32 -2
  46. package/dist/models/router.js.map +1 -1
  47. package/dist/telemetry/session-telemetry.d.ts +79 -0
  48. package/dist/telemetry/session-telemetry.d.ts.map +1 -1
  49. package/dist/telemetry/session-telemetry.js +7 -0
  50. package/dist/telemetry/session-telemetry.js.map +1 -1
  51. package/package.json +1 -1
  52. package/tools/agents/UAP/__init__.py +8 -1
  53. package/tools/agents/UAP/task_classifier.py +218 -0
@@ -0,0 +1,218 @@
1
+ """
2
+ Shared task classification and preamble building for UAP agents.
3
+
4
+ This module consolidates the duplicated CATEGORY_KEYWORDS and classify_task()
5
+ logic that was previously maintained separately in:
6
+ - tools/agents/opencode_uap_agent.py
7
+ - tools/uap_harbor/uap_agent.py
8
+
9
+ Both agents should import from here to stay in sync.
10
+ """
11
+
12
+ # Superset of all category keywords from both agent implementations.
13
+ # When adding new categories, add them here — both agents inherit automatically.
14
+ CATEGORY_KEYWORDS: dict[str, list[str]] = {
15
+ "git": [
16
+ "git",
17
+ ".git",
18
+ "commit",
19
+ "branch",
20
+ "reflog",
21
+ "fsck",
22
+ "recovery",
23
+ "leak",
24
+ "sanitize",
25
+ ],
26
+ "compression": [
27
+ "compress",
28
+ "decomp",
29
+ "encode",
30
+ "decoder",
31
+ "encoder",
32
+ "compressor",
33
+ "decompressor",
34
+ "codegolf",
35
+ "gzip",
36
+ "zlib",
37
+ ],
38
+ "chess": [
39
+ "chess",
40
+ "stockfish",
41
+ "fen",
42
+ "checkmate",
43
+ "best move",
44
+ "legal move",
45
+ ],
46
+ "polyglot": [
47
+ "polyglot",
48
+ "multi-language",
49
+ "compile in both",
50
+ "two languages",
51
+ "works as both",
52
+ ],
53
+ "service": [
54
+ "server",
55
+ "nginx",
56
+ "webserver",
57
+ "grpc",
58
+ "http service",
59
+ "listen on port",
60
+ "start a service",
61
+ "web server",
62
+ ],
63
+ "competitive": [
64
+ "corewars",
65
+ "warrior",
66
+ "pmars",
67
+ "redcode",
68
+ "win rate",
69
+ "opponent",
70
+ ],
71
+ "statistics": [
72
+ "mcmc",
73
+ "sampling",
74
+ "stan",
75
+ "pystan",
76
+ "rstan",
77
+ "ars",
78
+ "rejection sampler",
79
+ "bayesian",
80
+ "statistical",
81
+ ],
82
+ "c_systems": [
83
+ "segfault",
84
+ "buffer overflow",
85
+ ".c file",
86
+ "compile c",
87
+ "gcc",
88
+ "makefile",
89
+ "cython",
90
+ "mips",
91
+ "assembly",
92
+ ".pyx",
93
+ "build_ext",
94
+ "gcov",
95
+ "compile",
96
+ "from source",
97
+ ],
98
+ "binary_forensics": [
99
+ "elf",
100
+ "binary",
101
+ "extract",
102
+ "hexdump",
103
+ "readelf",
104
+ "forensic",
105
+ ],
106
+ "crypto": [
107
+ "7z",
108
+ "7zip",
109
+ "hash",
110
+ "crack",
111
+ "password",
112
+ "john",
113
+ "hashcat",
114
+ "encrypt",
115
+ "decrypt",
116
+ "brute",
117
+ ],
118
+ "database": [
119
+ "sqlite",
120
+ "wal",
121
+ "database",
122
+ "sql",
123
+ "db-wal",
124
+ "truncate",
125
+ ],
126
+ "testing_iteration": [
127
+ "test",
128
+ "pytest",
129
+ "verify",
130
+ "pass rate",
131
+ "threshold",
132
+ ],
133
+ "xss_filter": [
134
+ "xss",
135
+ "filter",
136
+ "javascript",
137
+ "sanitize html",
138
+ "html filter",
139
+ ],
140
+ "image_ocr": [
141
+ "ocr",
142
+ "screenshot",
143
+ "extract code from image",
144
+ "tesseract",
145
+ "image to text",
146
+ ],
147
+ "ml_recovery": [
148
+ "pytorch",
149
+ "torch",
150
+ "model recovery",
151
+ "corrupted model",
152
+ "state_dict",
153
+ "safetensors",
154
+ "hf model",
155
+ "huggingface",
156
+ ],
157
+ "webserver": [
158
+ "webserver",
159
+ "web server",
160
+ "git web",
161
+ "gitweb",
162
+ "instaweb",
163
+ "cgit",
164
+ "httpd",
165
+ "configure.*server",
166
+ "post-receive",
167
+ ],
168
+ "vulnerability": [
169
+ "vulnerability",
170
+ "vulnerabilities",
171
+ "cwe",
172
+ "crlf",
173
+ "injection",
174
+ "security fix",
175
+ "bottle.py",
176
+ ],
177
+ }
178
+
179
+
180
+ def classify_task(instruction: str) -> list[str]:
181
+ """Classify a task instruction into relevant pattern categories.
182
+
183
+ Uses keyword matching with a low threshold: any single keyword match
184
+ triggers inclusion. This is intentionally permissive because the cost
185
+ of a false positive (~60 extra tokens) is far less than the cost of
186
+ missing a relevant pattern.
187
+ """
188
+ lower = instruction.lower()
189
+ matched = []
190
+ for category, keywords in CATEGORY_KEYWORDS.items():
191
+ if any(kw in lower for kw in keywords):
192
+ matched.append(category)
193
+ return matched
194
+
195
+
196
+ def build_classified_preamble(
197
+ instruction: str,
198
+ core_prompt: str,
199
+ pattern_snippets: dict[str, str],
200
+ ) -> str:
201
+ """Build a minimal preamble with only relevant pattern snippets.
202
+
203
+ Args:
204
+ instruction: The task instruction to classify.
205
+ core_prompt: The base UAP_CORE prompt string.
206
+ pattern_snippets: Map of category -> snippet text.
207
+
208
+ Returns:
209
+ Combined preamble with core + matched snippets + task header.
210
+ """
211
+ categories = classify_task(instruction)
212
+ parts = [core_prompt]
213
+ for cat in categories:
214
+ snippet = pattern_snippets.get(cat)
215
+ if snippet:
216
+ parts.append(snippet)
217
+ parts.append("\n## YOUR TASK:\n\n")
218
+ return "\n".join(parts)