ummaya 0.2.3 → 0.2.4

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 (111) hide show
  1. package/README.md +2 -1
  2. package/npm-shrinkwrap.json +2 -2
  3. package/package.json +1 -1
  4. package/prompts/manifest.yaml +2 -2
  5. package/prompts/session_guidance_v1.md +3 -1
  6. package/prompts/system_v1.md +8 -7
  7. package/pyproject.toml +2 -7
  8. package/src/ummaya/context/builder.py +17 -11
  9. package/src/ummaya/engine/engine.py +27 -7
  10. package/src/ummaya/engine/query.py +20 -0
  11. package/src/ummaya/evidence/__init__.py +25 -0
  12. package/src/ummaya/evidence/__main__.py +7 -0
  13. package/src/ummaya/evidence/models.py +58 -0
  14. package/src/ummaya/evidence/runner.py +308 -0
  15. package/src/ummaya/evidence/task_registry.py +264 -0
  16. package/src/ummaya/ipc/frame_schema.py +47 -0
  17. package/src/ummaya/ipc/stdio.py +1287 -54
  18. package/src/ummaya/llm/client.py +132 -56
  19. package/src/ummaya/llm/reasoning.py +84 -0
  20. package/src/ummaya/tools/discovery_bridge.py +17 -1
  21. package/src/ummaya/tools/executor.py +32 -12
  22. package/src/ummaya/tools/geocoding/kakao_client.py +1 -2
  23. package/src/ummaya/tools/kma/apihub_catalog.py +984 -1
  24. package/src/ummaya/tools/kma/apihub_structured_adapter.py +86 -6
  25. package/src/ummaya/tools/kma/apihub_url_adapter.py +593 -0
  26. package/src/ummaya/tools/kma/apihub_url_catalog.py +296 -0
  27. package/src/ummaya/tools/location_adapters.py +8 -6
  28. package/src/ummaya/tools/manifest_metadata.py +16 -3
  29. package/src/ummaya/tools/mvp_surface.py +2 -2
  30. package/src/ummaya/tools/nmc/emergency_search.py +8 -6
  31. package/src/ummaya/tools/register_all.py +9 -0
  32. package/src/ummaya/tools/resolve_location.py +4 -4
  33. package/src/ummaya/tools/search.py +664 -18
  34. package/src/ummaya/tools/verified_data_go_kr/_manifest.py +115 -25
  35. package/src/ummaya/tools/verified_data_go_kr/airkorea_air_quality.py +109 -4
  36. package/src/ummaya/tools/verified_data_go_kr/nmc_aed_site.py +108 -2
  37. package/src/ummaya/tools/verified_data_go_kr/pps_bid_public_info.py +174 -9
  38. package/src/ummaya/tools/verified_data_go_kr/tago_bus_arrival.py +66 -3
  39. package/src/ummaya/tools/verified_data_go_kr/tago_bus_location.py +12 -2
  40. package/src/ummaya/tools/verified_data_go_kr/tago_bus_route.py +8 -2
  41. package/src/ummaya/tools/verified_data_go_kr/tago_bus_route_station.py +114 -0
  42. package/src/ummaya/tools/verified_data_go_kr/tago_bus_station.py +14 -3
  43. package/src/ummaya/tools/verify_canonical_map.py +21 -0
  44. package/tui/package.json +1 -2
  45. package/tui/src/QueryEngine.ts +4 -0
  46. package/tui/src/cli/handlers/auth.ts +1 -1
  47. package/tui/src/cli/handlers/mcp.tsx +3 -3
  48. package/tui/src/cli/print.ts +69 -18
  49. package/tui/src/cli/update.ts +13 -13
  50. package/tui/src/commands/copy/index.ts +1 -1
  51. package/tui/src/commands/cost/cost.ts +2 -2
  52. package/tui/src/commands/init-verifiers.ts +5 -5
  53. package/tui/src/commands/init.ts +30 -30
  54. package/tui/src/commands/insights.ts +43 -43
  55. package/tui/src/commands/install-github-app/install-github-app.tsx +2 -2
  56. package/tui/src/commands/install-github-app/setupGitHubActions.ts +3 -3
  57. package/tui/src/commands/install.tsx +5 -5
  58. package/tui/src/commands/mcp/addCommand.ts +5 -5
  59. package/tui/src/commands/mcp/xaaIdpCommand.ts +2 -2
  60. package/tui/src/commands/plugin/ManageMarketplaces.tsx +2 -2
  61. package/tui/src/commands/reasoning/index.ts +13 -0
  62. package/tui/src/commands/reasoning/reasoning.tsx +177 -0
  63. package/tui/src/commands/thinkback/thinkback.tsx +3 -3
  64. package/tui/src/commands.ts +2 -0
  65. package/tui/src/components/Messages.tsx +2 -1
  66. package/tui/src/components/Spinner.tsx +2 -2
  67. package/tui/src/components/design-system/LoadingState.tsx +2 -2
  68. package/tui/src/ipc/codec.ts +26 -0
  69. package/tui/src/ipc/frames.generated.ts +398 -303
  70. package/tui/src/ipc/llmClient.ts +130 -51
  71. package/tui/src/ipc/llmTypes.ts +16 -1
  72. package/tui/src/ipc/schema/frame.schema.json +1 -3475
  73. package/tui/src/main.tsx +3 -0
  74. package/tui/src/query.ts +467 -2
  75. package/tui/src/screens/REPL.tsx +3 -3
  76. package/tui/src/services/api/claude.ts +48 -18
  77. package/tui/src/services/api/client.ts +33 -12
  78. package/tui/src/services/api/ummaya.ts +70 -16
  79. package/tui/src/skills/bundled/stuck.ts +12 -12
  80. package/tui/src/state/AppStateStore.ts +7 -0
  81. package/tui/src/tools/AdapterTool/AdapterTool.ts +590 -7
  82. package/tui/src/tools/LookupPrimitive/LookupPrimitive.ts +43 -17
  83. package/tui/src/tools/LookupPrimitive/prompt.ts +7 -6
  84. package/tui/src/tools/ResolveLocationPrimitive/ResolveLocationPrimitive.ts +40 -19
  85. package/tui/src/tools/SubmitPrimitive/SubmitPrimitive.ts +25 -9
  86. package/tui/src/tools/VerifyPrimitive/VerifyPrimitive.ts +25 -9
  87. package/tui/src/tools/_shared/citizenUserText.ts +49 -0
  88. package/tui/src/tools/_shared/directPublicDataGuard.ts +362 -0
  89. package/tui/src/tools/_shared/kmaAnalysisGuard.ts +197 -0
  90. package/tui/src/tools/_shared/kmaAviationGuard.ts +70 -0
  91. package/tui/src/tools/_shared/locationInputRepair.ts +112 -0
  92. package/tui/src/tools/_shared/nmcAedGuard.ts +234 -0
  93. package/tui/src/tools/_shared/protectedCheckGuard.ts +207 -0
  94. package/tui/src/tools/_shared/rootPrimitiveInput.ts +67 -0
  95. package/tui/src/tools/_shared/textToolCallGuard.ts +91 -0
  96. package/tui/src/tools/_shared/toolChoiceRepair.ts +866 -0
  97. package/tui/src/utils/attachments.ts +1 -1
  98. package/tui/src/utils/kExaoneReasoning.ts +138 -0
  99. package/tui/src/utils/messages.ts +1 -0
  100. package/tui/src/utils/multiToolLayout.ts +13 -0
  101. package/tui/src/utils/processUserInput/processSlashCommand.tsx +2 -2
  102. package/tui/src/utils/processUserInput/processUserInput.ts +26 -0
  103. package/tui/src/utils/settings/applySettingsChange.ts +4 -0
  104. package/tui/src/utils/settings/types.ts +9 -3
  105. package/tui/src/utils/stats.ts +1 -1
  106. package/uv.lock +1 -15
  107. package/assets/copilot-gate-logo.svg +0 -58
  108. package/assets/govon-logo.svg +0 -40
  109. package/src/ummaya/eval/__init__.py +0 -5
  110. package/src/ummaya/eval/retrieval.py +0 -713
  111. package/tui/src/utils/messageStream.ts +0 -186
@@ -0,0 +1,91 @@
1
+ import { textFromContent } from './nmcAedGuard.js'
2
+
3
+ const TEXT_TOOL_CALL_RE =
4
+ /<tool_call>|<\/tool_call>|"name"\s*:\s*"[^"]+"[\s\S]*"arguments"\s*:\s*\{/iu
5
+ const TEXT_TOOL_CALL_BLOCK_RE = /\s*<tool_call>[\s\S]*?<\/tool_call>\s*/giu
6
+ const TEXT_TOOL_CALL_REPAIR_MARKER = 'Textual tool-call final-answer repair'
7
+ const TEXT_TOOL_CALL_REPAIR_PROMPT =
8
+ 'Textual tool-call final-answer repair: the previous assistant message was invalid because it printed a tool call as text. Never emit <tool_call> text, JSON tool-call text, or a JSON object with name/arguments in prose. If a tool is still needed, call it only through the native structured tool_use interface. If the needed tool has already been attempted, do not call or print any tool; write one Korean prose answer from the actual tool results already in this conversation. If the available result is no-data, upstream failure, approval-required, or insufficient for the requested detail, state that directly and give the official handoff or next action.'
9
+
10
+ function asRecord(value: unknown): Record<string, unknown> | undefined {
11
+ return typeof value === 'object' && value !== null
12
+ ? (value as Record<string, unknown>)
13
+ : undefined
14
+ }
15
+
16
+ function messageRecord(message: unknown): Record<string, unknown> | undefined {
17
+ return asRecord(asRecord(message)?.message)
18
+ }
19
+
20
+ function messageRole(message: unknown): string | undefined {
21
+ const outer = asRecord(message)
22
+ const inner = messageRecord(message)
23
+ if (typeof inner?.role === 'string') return inner.role
24
+ if (typeof outer?.role === 'string') return outer.role
25
+ return typeof outer?.type === 'string' ? outer.type : undefined
26
+ }
27
+
28
+ function messageContent(message: unknown): unknown {
29
+ return messageRecord(message)?.content ?? asRecord(message)?.content
30
+ }
31
+
32
+ function contentBlocks(message: unknown): readonly unknown[] {
33
+ const content = messageContent(message)
34
+ return Array.isArray(content) ? content : []
35
+ }
36
+
37
+ function hasToolUseBlock(message: unknown): boolean {
38
+ return contentBlocks(message).some(block => asRecord(block)?.type === 'tool_use')
39
+ }
40
+
41
+ function assistantTextContainsToolCall(message: unknown): boolean {
42
+ if (messageRole(message) !== 'assistant') return false
43
+ if (hasToolUseBlock(message)) return false
44
+ return TEXT_TOOL_CALL_RE.test(textFromContent(messageContent(message)))
45
+ }
46
+
47
+ function hasRepairPrompt(messages: readonly unknown[]): boolean {
48
+ return messages.some(message =>
49
+ textFromContent(messageContent(message)).includes(TEXT_TOOL_CALL_REPAIR_MARKER),
50
+ )
51
+ }
52
+
53
+ function latestAssistantMessage(messages: readonly unknown[]): unknown | undefined {
54
+ for (let idx = messages.length - 1; idx >= 0; idx -= 1) {
55
+ if (messageRole(messages[idx]) === 'assistant') return messages[idx]
56
+ }
57
+ return undefined
58
+ }
59
+
60
+ export function buildTextToolCallFinalAnswerRepairPromptIfNeeded({
61
+ messages,
62
+ }: {
63
+ messages: readonly unknown[]
64
+ }): string | undefined {
65
+ if (hasRepairPrompt(messages)) return undefined
66
+ const latestAssistant = latestAssistantMessage(messages)
67
+ if (!assistantTextContainsToolCall(latestAssistant)) return undefined
68
+ return TEXT_TOOL_CALL_REPAIR_PROMPT
69
+ }
70
+
71
+ export function shouldWithholdTextToolCallFinalAnswer({
72
+ messages,
73
+ candidate,
74
+ }: {
75
+ messages: readonly unknown[]
76
+ candidate: unknown
77
+ }): boolean {
78
+ if (hasRepairPrompt(messages)) return false
79
+ return assistantTextContainsToolCall(candidate)
80
+ }
81
+
82
+ export function textContainsToolCall(text: string): boolean {
83
+ return TEXT_TOOL_CALL_RE.test(text)
84
+ }
85
+
86
+ export function stripTextToolCallBlocks(text: string): string {
87
+ return text
88
+ .replace(TEXT_TOOL_CALL_BLOCK_RE, '\n')
89
+ .replace(/\n{3,}/gu, '\n\n')
90
+ .trim()
91
+ }