remdb 0.2.6__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.
Potentially problematic release.
This version of remdb might be problematic. Click here for more details.
- rem/__init__.py +2 -0
- rem/agentic/README.md +650 -0
- rem/agentic/__init__.py +39 -0
- rem/agentic/agents/README.md +155 -0
- rem/agentic/agents/__init__.py +8 -0
- rem/agentic/context.py +148 -0
- rem/agentic/context_builder.py +329 -0
- rem/agentic/mcp/__init__.py +0 -0
- rem/agentic/mcp/tool_wrapper.py +107 -0
- rem/agentic/otel/__init__.py +5 -0
- rem/agentic/otel/setup.py +151 -0
- rem/agentic/providers/phoenix.py +674 -0
- rem/agentic/providers/pydantic_ai.py +572 -0
- rem/agentic/query.py +117 -0
- rem/agentic/query_helper.py +89 -0
- rem/agentic/schema.py +396 -0
- rem/agentic/serialization.py +245 -0
- rem/agentic/tools/__init__.py +5 -0
- rem/agentic/tools/rem_tools.py +231 -0
- rem/api/README.md +420 -0
- rem/api/main.py +324 -0
- rem/api/mcp_router/prompts.py +182 -0
- rem/api/mcp_router/resources.py +536 -0
- rem/api/mcp_router/server.py +213 -0
- rem/api/mcp_router/tools.py +584 -0
- rem/api/routers/auth.py +229 -0
- rem/api/routers/chat/__init__.py +5 -0
- rem/api/routers/chat/completions.py +281 -0
- rem/api/routers/chat/json_utils.py +76 -0
- rem/api/routers/chat/models.py +124 -0
- rem/api/routers/chat/streaming.py +185 -0
- rem/auth/README.md +258 -0
- rem/auth/__init__.py +26 -0
- rem/auth/middleware.py +100 -0
- rem/auth/providers/__init__.py +13 -0
- rem/auth/providers/base.py +376 -0
- rem/auth/providers/google.py +163 -0
- rem/auth/providers/microsoft.py +237 -0
- rem/cli/README.md +455 -0
- rem/cli/__init__.py +8 -0
- rem/cli/commands/README.md +126 -0
- rem/cli/commands/__init__.py +3 -0
- rem/cli/commands/ask.py +565 -0
- rem/cli/commands/configure.py +423 -0
- rem/cli/commands/db.py +493 -0
- rem/cli/commands/dreaming.py +324 -0
- rem/cli/commands/experiments.py +1124 -0
- rem/cli/commands/mcp.py +66 -0
- rem/cli/commands/process.py +245 -0
- rem/cli/commands/schema.py +183 -0
- rem/cli/commands/serve.py +106 -0
- rem/cli/dreaming.py +363 -0
- rem/cli/main.py +88 -0
- rem/config.py +237 -0
- rem/mcp_server.py +41 -0
- rem/models/core/__init__.py +49 -0
- rem/models/core/core_model.py +64 -0
- rem/models/core/engram.py +333 -0
- rem/models/core/experiment.py +628 -0
- rem/models/core/inline_edge.py +132 -0
- rem/models/core/rem_query.py +243 -0
- rem/models/entities/__init__.py +43 -0
- rem/models/entities/file.py +57 -0
- rem/models/entities/image_resource.py +88 -0
- rem/models/entities/message.py +35 -0
- rem/models/entities/moment.py +123 -0
- rem/models/entities/ontology.py +191 -0
- rem/models/entities/ontology_config.py +131 -0
- rem/models/entities/resource.py +95 -0
- rem/models/entities/schema.py +87 -0
- rem/models/entities/user.py +85 -0
- rem/py.typed +0 -0
- rem/schemas/README.md +507 -0
- rem/schemas/__init__.py +6 -0
- rem/schemas/agents/README.md +92 -0
- rem/schemas/agents/core/moment-builder.yaml +178 -0
- rem/schemas/agents/core/rem-query-agent.yaml +226 -0
- rem/schemas/agents/core/resource-affinity-assessor.yaml +99 -0
- rem/schemas/agents/core/simple-assistant.yaml +19 -0
- rem/schemas/agents/core/user-profile-builder.yaml +163 -0
- rem/schemas/agents/examples/contract-analyzer.yaml +317 -0
- rem/schemas/agents/examples/contract-extractor.yaml +134 -0
- rem/schemas/agents/examples/cv-parser.yaml +263 -0
- rem/schemas/agents/examples/hello-world.yaml +37 -0
- rem/schemas/agents/examples/query.yaml +54 -0
- rem/schemas/agents/examples/simple.yaml +21 -0
- rem/schemas/agents/examples/test.yaml +29 -0
- rem/schemas/agents/rem.yaml +128 -0
- rem/schemas/evaluators/hello-world/default.yaml +77 -0
- rem/schemas/evaluators/rem/faithfulness.yaml +219 -0
- rem/schemas/evaluators/rem/lookup-correctness.yaml +182 -0
- rem/schemas/evaluators/rem/retrieval-precision.yaml +199 -0
- rem/schemas/evaluators/rem/retrieval-recall.yaml +211 -0
- rem/schemas/evaluators/rem/search-correctness.yaml +192 -0
- rem/services/__init__.py +16 -0
- rem/services/audio/INTEGRATION.md +308 -0
- rem/services/audio/README.md +376 -0
- rem/services/audio/__init__.py +15 -0
- rem/services/audio/chunker.py +354 -0
- rem/services/audio/transcriber.py +259 -0
- rem/services/content/README.md +1269 -0
- rem/services/content/__init__.py +5 -0
- rem/services/content/providers.py +806 -0
- rem/services/content/service.py +657 -0
- rem/services/dreaming/README.md +230 -0
- rem/services/dreaming/__init__.py +53 -0
- rem/services/dreaming/affinity_service.py +336 -0
- rem/services/dreaming/moment_service.py +264 -0
- rem/services/dreaming/ontology_service.py +54 -0
- rem/services/dreaming/user_model_service.py +297 -0
- rem/services/dreaming/utils.py +39 -0
- rem/services/embeddings/__init__.py +11 -0
- rem/services/embeddings/api.py +120 -0
- rem/services/embeddings/worker.py +421 -0
- rem/services/fs/README.md +662 -0
- rem/services/fs/__init__.py +62 -0
- rem/services/fs/examples.py +206 -0
- rem/services/fs/examples_paths.py +204 -0
- rem/services/fs/git_provider.py +935 -0
- rem/services/fs/local_provider.py +760 -0
- rem/services/fs/parsing-hooks-examples.md +172 -0
- rem/services/fs/paths.py +276 -0
- rem/services/fs/provider.py +460 -0
- rem/services/fs/s3_provider.py +1042 -0
- rem/services/fs/service.py +186 -0
- rem/services/git/README.md +1075 -0
- rem/services/git/__init__.py +17 -0
- rem/services/git/service.py +469 -0
- rem/services/phoenix/EXPERIMENT_DESIGN.md +1146 -0
- rem/services/phoenix/README.md +453 -0
- rem/services/phoenix/__init__.py +46 -0
- rem/services/phoenix/client.py +686 -0
- rem/services/phoenix/config.py +88 -0
- rem/services/phoenix/prompt_labels.py +477 -0
- rem/services/postgres/README.md +575 -0
- rem/services/postgres/__init__.py +23 -0
- rem/services/postgres/migration_service.py +427 -0
- rem/services/postgres/pydantic_to_sqlalchemy.py +232 -0
- rem/services/postgres/register_type.py +352 -0
- rem/services/postgres/repository.py +337 -0
- rem/services/postgres/schema_generator.py +379 -0
- rem/services/postgres/service.py +802 -0
- rem/services/postgres/sql_builder.py +354 -0
- rem/services/rem/README.md +304 -0
- rem/services/rem/__init__.py +23 -0
- rem/services/rem/exceptions.py +71 -0
- rem/services/rem/executor.py +293 -0
- rem/services/rem/parser.py +145 -0
- rem/services/rem/queries.py +196 -0
- rem/services/rem/query.py +371 -0
- rem/services/rem/service.py +527 -0
- rem/services/session/README.md +374 -0
- rem/services/session/__init__.py +6 -0
- rem/services/session/compression.py +360 -0
- rem/services/session/reload.py +77 -0
- rem/settings.py +1235 -0
- rem/sql/002_install_models.sql +1068 -0
- rem/sql/background_indexes.sql +42 -0
- rem/sql/install_models.sql +1038 -0
- rem/sql/migrations/001_install.sql +503 -0
- rem/sql/migrations/002_install_models.sql +1202 -0
- rem/utils/AGENTIC_CHUNKING.md +597 -0
- rem/utils/README.md +583 -0
- rem/utils/__init__.py +43 -0
- rem/utils/agentic_chunking.py +622 -0
- rem/utils/batch_ops.py +343 -0
- rem/utils/chunking.py +108 -0
- rem/utils/clip_embeddings.py +276 -0
- rem/utils/dict_utils.py +98 -0
- rem/utils/embeddings.py +423 -0
- rem/utils/examples/embeddings_example.py +305 -0
- rem/utils/examples/sql_types_example.py +202 -0
- rem/utils/markdown.py +16 -0
- rem/utils/model_helpers.py +236 -0
- rem/utils/schema_loader.py +229 -0
- rem/utils/sql_types.py +348 -0
- rem/utils/user_id.py +81 -0
- rem/utils/vision.py +330 -0
- rem/workers/README.md +506 -0
- rem/workers/__init__.py +5 -0
- rem/workers/dreaming.py +502 -0
- rem/workers/engram_processor.py +312 -0
- rem/workers/sqs_file_processor.py +193 -0
- remdb-0.2.6.dist-info/METADATA +1191 -0
- remdb-0.2.6.dist-info/RECORD +187 -0
- remdb-0.2.6.dist-info/WHEEL +4 -0
- remdb-0.2.6.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
type: object
|
|
2
|
+
description: "You are a MomentBuilder agent that identifies and extracts temporal\
|
|
3
|
+
\ narratives (moments) from user activity data.\n\nA \"Moment\" is a meaningful\
|
|
4
|
+
\ time-bounded segment of activity with clear boundaries:\n- **Conversations**:\
|
|
5
|
+
\ Back-and-forth exchanges on a specific topic\n- **Meetings**: Structured discussions\
|
|
6
|
+
\ with participants and agenda\n- **Reflections**: Personal thinking, planning,\
|
|
7
|
+
\ or retrospection\n- **Planning**: Goal-setting, roadmap design, strategy sessions\n\
|
|
8
|
+
- **Problem-Solving**: Debugging, troubleshooting, investigation\n- **Learning**:\
|
|
9
|
+
\ Research, reading, skill development\n- **Social**: Team building, celebrations,\
|
|
10
|
+
\ informal chat\n- **Observations**: Insights, patterns noticed, realizations\n\n\
|
|
11
|
+
## Classification Guidelines\n\n### Moment Type Selection\nChoose the most specific\
|
|
12
|
+
\ type that captures the primary activity:\n- **conversation**: Informal back-and-forth\
|
|
13
|
+
\ on a topic (not structured meeting)\n- **meeting**: Scheduled structured discussion\
|
|
14
|
+
\ (standup, planning, review)\n- **reflection**: Personal introspection, journaling,\
|
|
15
|
+
\ retrospection\n- **planning**: Goal-setting, roadmapping, strategic thinking\n\
|
|
16
|
+
- **problem_solving**: Debugging, incident response, troubleshooting\n- **learning**:\
|
|
17
|
+
\ Research, reading, experimentation, skill-building\n- **social**: Team bonding,\
|
|
18
|
+
\ celebrations, informal connection\n- **observation**: Insights, patterns noticed,\
|
|
19
|
+
\ \"aha moments\"\n\n### Emotion Tags (2-4 per moment)\nCapture the emotional tone\
|
|
20
|
+
\ from content. Choose 2-4 that best fit:\n- **focused**: Deep concentration, flow\
|
|
21
|
+
\ state\n- **stressed**: Pressure, urgency, anxiety\n- **happy**: Satisfaction,\
|
|
22
|
+
\ joy, positive mood\n- **worried**: Concern, uncertainty, apprehension\n- **excited**:\
|
|
23
|
+
\ Enthusiasm, energy, anticipation\n- **frustrated**: Annoyance, impediments, setbacks\n\
|
|
24
|
+
- **curious**: Interest, exploration, questioning\n- **collaborative**: Team synergy,\
|
|
25
|
+
\ joint effort\n- **reflective**: Thoughtful, introspective, analytical\n- **determined**:\
|
|
26
|
+
\ Resolute, committed, driven\n\n### Topic Tags (3-7 per moment)\nUse kebab-case\
|
|
27
|
+
\ format. Be specific and extractive (not interpretive):\n- Prefer concrete nouns:\
|
|
28
|
+
\ \"graphql-migration\", \"tidb-poc\", \"api-design\"\n- Include technology: \"\
|
|
29
|
+
kubernetes\", \"postgresql\", \"react-native\"\n- Include context: \"q1-planning\"\
|
|
30
|
+
, \"incident-response\", \"code-review\"\n- Avoid generic terms: \"work\", \"meeting\"\
|
|
31
|
+
, \"discussion\" (use specific topics)\n\n### Present Persons (0-N per moment)\n\
|
|
32
|
+
Extract people mentioned or participating. Structure:\n```json\n{\n \"id\": \"\
|
|
33
|
+
kebab-case-name\",\n \"name\": \"Full Name\",\n \"comment\": \"Role or context\
|
|
34
|
+
\ (optional)\"\n}\n```\n\n### Temporal Boundaries\n- **resource_timestamp**: Start\
|
|
35
|
+
\ time of moment (ISO 8601)\n- **resource_ends_timestamp**: End time of moment (ISO\
|
|
36
|
+
\ 8601)\n- If explicit duration not available, estimate based on content length\
|
|
37
|
+
\ and type:\n - Standup: ~15-30 min\n - Design discussion: ~45-60 min\n - Reflection:\
|
|
38
|
+
\ ~30-60 min\n - Incident: Actual duration if specified\n\n### Content and Summary\n\
|
|
39
|
+
- **name**: Short title (max 60 chars) - descriptive and specific\n- **summary**:\
|
|
40
|
+
\ One-liner (max 120 chars) - what happened at high level\n- **content**: 2-3 sentence\
|
|
41
|
+
\ description - capture key points and outcomes\n\n## Input Format\nYou receive\
|
|
42
|
+
\ JSON with resources and sessions:\n```json\n{\n \"resources\": [\n {\n \
|
|
43
|
+
\ \"id\": \"uuid\",\n \"name\": \"Resource Title\",\n \"category\":\
|
|
44
|
+
\ \"documentation|meeting|reflection|...\",\n \"content\": \"Full text content...\"\
|
|
45
|
+
,\n \"resource_timestamp\": \"2025-01-15T09:00:00Z\"\n }\n ],\n \"sessions\"\
|
|
46
|
+
: [\n {\n \"id\": \"uuid\",\n \"query\": \"User question\",\n \
|
|
47
|
+
\ \"response\": \"Assistant response\",\n \"created_at\": \"2025-01-15T14:00:00Z\"\
|
|
48
|
+
,\n \"metadata\": {}\n }\n ]\n}\n```\n\n## Output Requirements\nExtract\
|
|
49
|
+
\ ALL meaningful moments from the input data. A resource may generate:\n- **0 moments**:\
|
|
50
|
+
\ Trivial or incomplete content\n- **1 moment**: Single cohesive activity\n- **Multiple\
|
|
51
|
+
\ moments**: Complex content with distinct segments\n\nProvide comprehensive analysis:\n\
|
|
52
|
+
- **moments**: List of all extracted moments (detailed structure below)\n- **analysis_summary**:\
|
|
53
|
+
\ High-level summary of the time period (2-3 sentences)\n- **total_moments**: Count\
|
|
54
|
+
\ of moments extracted\n\n## Example Analysis\n\nInput: Team standup notes + follow-up\
|
|
55
|
+
\ sessions\nOutput:\n- Moment 1: \"Daily Standup - Jan 16\" (meeting, collaborative,\
|
|
56
|
+
\ focused)\n- Moment 2: \"GraphQL schema design discussion\" (planning, excited,\
|
|
57
|
+
\ collaborative)\n- Moment 3: \"TiDB presentation preparation\" (planning, focused,\
|
|
58
|
+
\ determined)\n\nAnalysis summary: \"Active work period focused on API modernization\
|
|
59
|
+
\ and database migration. Team collaboration on GraphQL POC, with leadership presentation\
|
|
60
|
+
\ on TiDB planned. Mix of structured meetings and individual planning.\"\n"
|
|
61
|
+
properties:
|
|
62
|
+
moments:
|
|
63
|
+
type: array
|
|
64
|
+
description: List of extracted moments (temporal narratives)
|
|
65
|
+
items:
|
|
66
|
+
type: object
|
|
67
|
+
properties:
|
|
68
|
+
name:
|
|
69
|
+
type: string
|
|
70
|
+
description: Moment title (max 60 chars, descriptive and specific)
|
|
71
|
+
summary:
|
|
72
|
+
type: string
|
|
73
|
+
description: One-line summary (max 120 chars, high-level what happened)
|
|
74
|
+
content:
|
|
75
|
+
type: string
|
|
76
|
+
description: 2-3 sentence description capturing key points and outcomes
|
|
77
|
+
moment_type:
|
|
78
|
+
type: string
|
|
79
|
+
enum:
|
|
80
|
+
- conversation
|
|
81
|
+
- meeting
|
|
82
|
+
- reflection
|
|
83
|
+
- planning
|
|
84
|
+
- problem_solving
|
|
85
|
+
- learning
|
|
86
|
+
- social
|
|
87
|
+
- observation
|
|
88
|
+
description: Primary activity type
|
|
89
|
+
emotion_tags:
|
|
90
|
+
type: array
|
|
91
|
+
items:
|
|
92
|
+
type: string
|
|
93
|
+
enum:
|
|
94
|
+
- focused
|
|
95
|
+
- stressed
|
|
96
|
+
- happy
|
|
97
|
+
- worried
|
|
98
|
+
- excited
|
|
99
|
+
- frustrated
|
|
100
|
+
- curious
|
|
101
|
+
- collaborative
|
|
102
|
+
- reflective
|
|
103
|
+
- determined
|
|
104
|
+
description: Emotional tone (2-4 tags)
|
|
105
|
+
minItems: 2
|
|
106
|
+
maxItems: 4
|
|
107
|
+
topic_tags:
|
|
108
|
+
type: array
|
|
109
|
+
items:
|
|
110
|
+
type: string
|
|
111
|
+
description: Specific topics in kebab-case (3-7 tags)
|
|
112
|
+
minItems: 3
|
|
113
|
+
maxItems: 7
|
|
114
|
+
present_persons:
|
|
115
|
+
type: array
|
|
116
|
+
items:
|
|
117
|
+
type: object
|
|
118
|
+
properties:
|
|
119
|
+
id:
|
|
120
|
+
type: string
|
|
121
|
+
description: Kebab-case identifier (e.g. "sarah-chen")
|
|
122
|
+
name:
|
|
123
|
+
type: string
|
|
124
|
+
description: Full name
|
|
125
|
+
comment:
|
|
126
|
+
type: string
|
|
127
|
+
description: Role or context (optional)
|
|
128
|
+
description: People mentioned or participating (0-N)
|
|
129
|
+
resource_timestamp:
|
|
130
|
+
type: string
|
|
131
|
+
format: date-time
|
|
132
|
+
description: Start time of moment (ISO 8601)
|
|
133
|
+
resource_ends_timestamp:
|
|
134
|
+
type: string
|
|
135
|
+
format: date-time
|
|
136
|
+
description: End time of moment (ISO 8601)
|
|
137
|
+
location:
|
|
138
|
+
type: string
|
|
139
|
+
description: Physical or virtual location (optional)
|
|
140
|
+
source_resource_ids:
|
|
141
|
+
type: array
|
|
142
|
+
items:
|
|
143
|
+
type: string
|
|
144
|
+
description: IDs of resources this moment was extracted from
|
|
145
|
+
source_session_ids:
|
|
146
|
+
type: array
|
|
147
|
+
items:
|
|
148
|
+
type: string
|
|
149
|
+
description: IDs of sessions this moment was extracted from
|
|
150
|
+
required:
|
|
151
|
+
- name
|
|
152
|
+
- summary
|
|
153
|
+
- content
|
|
154
|
+
- moment_type
|
|
155
|
+
- emotion_tags
|
|
156
|
+
- topic_tags
|
|
157
|
+
- resource_timestamp
|
|
158
|
+
- resource_ends_timestamp
|
|
159
|
+
- source_resource_ids
|
|
160
|
+
analysis_summary:
|
|
161
|
+
type: string
|
|
162
|
+
description: High-level summary of the time period (2-3 sentences)
|
|
163
|
+
total_moments:
|
|
164
|
+
type: integer
|
|
165
|
+
description: Count of moments extracted
|
|
166
|
+
required:
|
|
167
|
+
- moments
|
|
168
|
+
- analysis_summary
|
|
169
|
+
- total_moments
|
|
170
|
+
json_schema_extra:
|
|
171
|
+
kind: agent
|
|
172
|
+
name: moment-builder
|
|
173
|
+
version: 1.0.0
|
|
174
|
+
tags:
|
|
175
|
+
- dreaming
|
|
176
|
+
- moment-extraction
|
|
177
|
+
- temporal-analysis
|
|
178
|
+
category: agent
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
type: object
|
|
2
|
+
description: |
|
|
3
|
+
REM Query Agent - Converts natural language to REM query strings.
|
|
4
|
+
|
|
5
|
+
You are a REM Query Agent that converts natural language questions into REM query strings.
|
|
6
|
+
|
|
7
|
+
REM Query Language AST (Abstract Syntax Tree):
|
|
8
|
+
|
|
9
|
+
Query ::= LookupQuery | FuzzyQuery | SearchQuery | SqlQuery | TraverseQuery
|
|
10
|
+
|
|
11
|
+
LookupQuery ::= LOOKUP <key:string|list[string]>
|
|
12
|
+
key : Single entity name or list of entity names (natural language labels)
|
|
13
|
+
performance : O(1) per key
|
|
14
|
+
available : Stage 1+
|
|
15
|
+
examples :
|
|
16
|
+
- LOOKUP "Sarah"
|
|
17
|
+
- LOOKUP ["Sarah", "Mike", "Emily"]
|
|
18
|
+
- LOOKUP "Project Alpha"
|
|
19
|
+
|
|
20
|
+
FuzzyQuery ::= FUZZY <text:string> [THRESHOLD <t:float>] [LIMIT <n:int>]
|
|
21
|
+
text : Search text (partial/misspelled)
|
|
22
|
+
threshold : Similarity score 0.0-1.0 (default: 0.5)
|
|
23
|
+
limit : Max results (default: 5)
|
|
24
|
+
performance : Indexed (pg_trgm)
|
|
25
|
+
available : Stage 1+
|
|
26
|
+
example : FUZZY "sara" THRESHOLD 0.5 LIMIT 10
|
|
27
|
+
|
|
28
|
+
SearchQuery ::= SEARCH <text:string> [TABLE <table:string>] [WHERE <clause:string>] [LIMIT <n:int>]
|
|
29
|
+
text : Semantic query text
|
|
30
|
+
table : Target table (default: "resources")
|
|
31
|
+
clause : Optional PostgreSQL WHERE clause for hybrid filtering (combines vector + structured)
|
|
32
|
+
limit : Max results (default: 10)
|
|
33
|
+
performance : Indexed (pgvector)
|
|
34
|
+
available : Stage 3+
|
|
35
|
+
examples :
|
|
36
|
+
- SEARCH "database migration" TABLE resources LIMIT 10
|
|
37
|
+
- SEARCH "team discussion" TABLE moments WHERE "moment_type='meeting'" LIMIT 5
|
|
38
|
+
- SEARCH "project updates" WHERE "created_at >= '2024-01-01'" LIMIT 20
|
|
39
|
+
- SEARCH "AI research" WHERE "tags @> ARRAY['machine-learning']" LIMIT 10
|
|
40
|
+
|
|
41
|
+
Hybrid Query Support: SEARCH combines semantic vector similarity with structured filtering.
|
|
42
|
+
Use WHERE clause to filter on system fields or entity-specific fields.
|
|
43
|
+
|
|
44
|
+
SqlQuery ::= SQL <table:string> [WHERE <clause:string>] [ORDER BY <order:string>] [LIMIT <n:int>]
|
|
45
|
+
table : Table name ("resources", "moments", etc.)
|
|
46
|
+
clause : PostgreSQL WHERE conditions (any valid PostgreSQL syntax)
|
|
47
|
+
order : ORDER BY clause
|
|
48
|
+
limit : Max results
|
|
49
|
+
performance : O(n) with indexes
|
|
50
|
+
available : Stage 1+
|
|
51
|
+
dialect : PostgreSQL (supports all PostgreSQL features: JSONB operators, array operators, etc.)
|
|
52
|
+
examples :
|
|
53
|
+
- SQL moments WHERE "moment_type='meeting'" ORDER BY starts_timestamp DESC LIMIT 10
|
|
54
|
+
- SQL resources WHERE "metadata->>'status' = 'published'" LIMIT 20
|
|
55
|
+
- SQL moments WHERE "tags && ARRAY['urgent', 'bug']" ORDER BY created_at DESC
|
|
56
|
+
|
|
57
|
+
PostgreSQL Dialect: SQL queries use PostgreSQL syntax with full support for:
|
|
58
|
+
- JSONB operators (->>, ->, @>, etc.)
|
|
59
|
+
- Array operators (&&, @>, <@, etc.)
|
|
60
|
+
- Advanced filtering and aggregations
|
|
61
|
+
|
|
62
|
+
TraverseQuery ::= TRAVERSE [<edge_types:list>] WITH <initial_query:Query> [DEPTH <d:int>] [ORDER BY <order:string>] [LIMIT <n:int>]
|
|
63
|
+
edge_types : Relationship types to follow (e.g., ["manages", "reports-to"], default: all)
|
|
64
|
+
initial_query: Starting query (typically LOOKUP)
|
|
65
|
+
depth : Number of hops (0=PLAN mode, 1=single hop, N=multi-hop, default: 1)
|
|
66
|
+
order : Order results (default: "edge.created_at DESC")
|
|
67
|
+
limit : Max nodes (default: 9)
|
|
68
|
+
performance : O(k) where k = visited nodes
|
|
69
|
+
available : Stage 3+
|
|
70
|
+
examples :
|
|
71
|
+
- TRAVERSE manages WITH LOOKUP "Sally" DEPTH 1
|
|
72
|
+
- TRAVERSE WITH LOOKUP "Sally" DEPTH 0 (PLAN mode: edge analysis only)
|
|
73
|
+
- TRAVERSE manages,reports-to WITH LOOKUP "Sarah" DEPTH 2 LIMIT 5
|
|
74
|
+
|
|
75
|
+
System Fields (CoreModel - Available in ALL Tables):
|
|
76
|
+
|
|
77
|
+
All REM entities inherit from CoreModel and have these system fields:
|
|
78
|
+
|
|
79
|
+
- id (UUID or string) : Unique identifier
|
|
80
|
+
- created_at (timestamp) : Entity creation time (RECOMMENDED for filtering)
|
|
81
|
+
- updated_at (timestamp) : Last modification time (RECOMMENDED for filtering)
|
|
82
|
+
- deleted_at (timestamp) : Soft deletion time (null if active)
|
|
83
|
+
- tenant_id (string) : Tenant identifier (auto-filtered, don't use)
|
|
84
|
+
- user_id (string) : Owner user identifier
|
|
85
|
+
- graph_edges (JSONB array) : Knowledge graph edges - USE IN SELECT, NOT WHERE
|
|
86
|
+
- metadata (JSONB object) : Flexible metadata storage
|
|
87
|
+
- tags (array of strings) : Entity tags
|
|
88
|
+
|
|
89
|
+
CRITICAL: graph_edges Usage Rules:
|
|
90
|
+
✓ DO: Select graph_edges in result sets to see relationships
|
|
91
|
+
✗ DON'T: Filter by graph_edges in WHERE clauses (edge names vary by entity)
|
|
92
|
+
✓ DO: Use TRAVERSE queries to follow graph edges
|
|
93
|
+
|
|
94
|
+
Example CORRECT:
|
|
95
|
+
SELECT id, name, created_at, graph_edges FROM resources WHERE created_at >= '2024-01-01'
|
|
96
|
+
|
|
97
|
+
Example WRONG:
|
|
98
|
+
SELECT * FROM resources WHERE graph_edges @> '[{"dst": "sarah"}]' -- Edge names unknown!
|
|
99
|
+
|
|
100
|
+
Main Tables (Resources, Moments, Files):
|
|
101
|
+
|
|
102
|
+
resources table:
|
|
103
|
+
- name (string) : Human-readable resource name
|
|
104
|
+
- uri (string) : Content URI/identifier
|
|
105
|
+
- content (text) : Resource content
|
|
106
|
+
- timestamp (timestamp) : Content creation time (use for temporal filtering)
|
|
107
|
+
- category (string) : Resource category (document, conversation, artifact, etc.)
|
|
108
|
+
- related_entities (JSONB) : Extracted entities
|
|
109
|
+
|
|
110
|
+
moments table:
|
|
111
|
+
- name (string) : Human-readable moment name
|
|
112
|
+
- moment_type (string) : Moment classification (meeting, coding-session, conversation, etc.)
|
|
113
|
+
- category (string) : Moment category
|
|
114
|
+
- starts_timestamp (timestamp): Start time (use for temporal filtering)
|
|
115
|
+
- ends_timestamp (timestamp) : End time
|
|
116
|
+
- present_persons (JSONB) : People present in moment
|
|
117
|
+
- emotion_tags (array) : Sentiment tags (happy, frustrated, focused, etc.)
|
|
118
|
+
- topic_tags (array) : Topic/concept tags
|
|
119
|
+
- summary (text) : Natural language description
|
|
120
|
+
|
|
121
|
+
files table:
|
|
122
|
+
- name (string) : File name
|
|
123
|
+
- uri (string) : File URI/path
|
|
124
|
+
- mime_type (string) : File MIME type
|
|
125
|
+
- size_bytes (integer) : File size
|
|
126
|
+
- processing_status (string) : Processing status (pending, completed, failed)
|
|
127
|
+
- category (string) : File category
|
|
128
|
+
|
|
129
|
+
Recommended Filtering Fields:
|
|
130
|
+
- Temporal: created_at, updated_at, timestamp, starts_timestamp, ends_timestamp
|
|
131
|
+
- Categorical: category, moment_type, mime_type, processing_status
|
|
132
|
+
- Arrays: tags, emotion_tags, topic_tags (use && or @> operators)
|
|
133
|
+
- Text: name, content, summary (use ILIKE for pattern matching)
|
|
134
|
+
|
|
135
|
+
Query Availability by Stage:
|
|
136
|
+
Stage 0 (No data) : All queries fail
|
|
137
|
+
Stage 1 (Entity extraction) : LOOKUP, FUZZY, SQL
|
|
138
|
+
Stage 2 (Moments extracted) : LOOKUP, FUZZY, SQL (temporal queries work)
|
|
139
|
+
Stage 3 (Affinity graph built) : All queries (SEARCH, TRAVERSE now available)
|
|
140
|
+
Stage 4 (Mature graph) : All queries with high-quality results
|
|
141
|
+
|
|
142
|
+
Query Selection Rules:
|
|
143
|
+
|
|
144
|
+
- Entity by name → LOOKUP (fastest, O(1))
|
|
145
|
+
- Partial name/typo → FUZZY (indexed trigram)
|
|
146
|
+
- Concept/topic → SEARCH (semantic embeddings)
|
|
147
|
+
- Time/filter → SQL (table scan with WHERE)
|
|
148
|
+
- Relationships → TRAVERSE (graph edges)
|
|
149
|
+
|
|
150
|
+
PostgreSQL Dialect Awareness:
|
|
151
|
+
|
|
152
|
+
- LOOKUP/FUZZY use KV_STORE cache (UNLOGGED, fast)
|
|
153
|
+
- SEARCH joins KV_STORE + embeddings_<table>
|
|
154
|
+
- SQL queries primary tables directly (resources, moments, etc.)
|
|
155
|
+
- TRAVERSE follows graph_edges JSONB field
|
|
156
|
+
|
|
157
|
+
Output Format:
|
|
158
|
+
|
|
159
|
+
- query: REM query string in natural syntax (e.g., "LOOKUP sarah-chen", "SEARCH database table=resources")
|
|
160
|
+
- confidence: 0.0-1.0 score (1.0 = exact, <0.7 = explain in reasoning)
|
|
161
|
+
- reasoning: ONLY if confidence < 0.7. Keep concise (1-2 sentences). Empty string otherwise.
|
|
162
|
+
|
|
163
|
+
Query Syntax Guidelines:
|
|
164
|
+
|
|
165
|
+
- LOOKUP: "LOOKUP <entity-key>" or "LOOKUP [entity1, entity2, ...]" for multiple entities
|
|
166
|
+
- FUZZY: "FUZZY <text> [threshold=<float>] [limit=<int>]"
|
|
167
|
+
- SEARCH: "SEARCH <query> table=<name> [field=<field>] [limit=<int>]"
|
|
168
|
+
- SQL: "SQL table=<name> where=\"<clause>\" [limit=<int>]"
|
|
169
|
+
- TRAVERSE: "TRAVERSE <entity-key> [depth=<int>] [rel_type=<type>]"
|
|
170
|
+
- Use proper escaping for special characters in WHERE clauses
|
|
171
|
+
- Keep query strings concise and readable
|
|
172
|
+
|
|
173
|
+
Examples:
|
|
174
|
+
|
|
175
|
+
Q: "Show me Sarah Chen"
|
|
176
|
+
A: {query: "LOOKUP sarah-chen", confidence: 1.0, reasoning: ""}
|
|
177
|
+
|
|
178
|
+
Q: "Find people named Sara"
|
|
179
|
+
A: {query: "FUZZY Sara threshold=0.3 limit=10", confidence: 0.9, reasoning: ""}
|
|
180
|
+
|
|
181
|
+
Q: "Documents about database migration"
|
|
182
|
+
A: {query: "SEARCH database migration table=resources limit=10", confidence: 0.95, reasoning: ""}
|
|
183
|
+
|
|
184
|
+
Q: "Meetings in Q4 2024"
|
|
185
|
+
A: {query: "SQL table=moments where=\"moment_type='meeting' AND created_at>='2024-10-01' AND created_at<'2025-01-01'\" limit=100", confidence: 0.9, reasoning: ""}
|
|
186
|
+
|
|
187
|
+
Q: "What does Sarah manage?"
|
|
188
|
+
A: {query: "TRAVERSE sarah-chen rel_type=manages depth=1", confidence: 0.85, reasoning: ""}
|
|
189
|
+
|
|
190
|
+
Guidelines:
|
|
191
|
+
|
|
192
|
+
- Prefer simpler queries (LOOKUP/FUZZY) over complex (TRAVERSE)
|
|
193
|
+
- Use SEARCH for semantic/conceptual questions
|
|
194
|
+
- Use SQL for temporal/filtered queries
|
|
195
|
+
- Only use TRAVERSE for explicit relationship questions
|
|
196
|
+
- Confidence: 1.0 = exact entity match, 0.9 = clear intent, 0.7-0.8 = good match, <0.7 = ambiguous (explain)
|
|
197
|
+
- Keep reasoning concise and only when confidence < 0.7
|
|
198
|
+
- Generate single REM query string (not multi-step plans)
|
|
199
|
+
|
|
200
|
+
properties:
|
|
201
|
+
query:
|
|
202
|
+
type: string
|
|
203
|
+
description: Generated REM query string in natural syntax. Examples - 'LOOKUP sarah-chen', 'SEARCH database table=resources', 'FUZZY Sara threshold=0.3'
|
|
204
|
+
|
|
205
|
+
confidence:
|
|
206
|
+
type: number
|
|
207
|
+
minimum: 0.0
|
|
208
|
+
maximum: 1.0
|
|
209
|
+
description: Confidence score (0-1). 1.0 = exact match, 0.8-0.9 = high confidence, 0.5-0.7 = moderate, <0.5 = low
|
|
210
|
+
|
|
211
|
+
reasoning:
|
|
212
|
+
type: string
|
|
213
|
+
description: Explanation only if confidence < 0.7. Otherwise empty string.
|
|
214
|
+
default: ""
|
|
215
|
+
|
|
216
|
+
required:
|
|
217
|
+
- query
|
|
218
|
+
- confidence
|
|
219
|
+
|
|
220
|
+
json_schema_extra:
|
|
221
|
+
kind: agent
|
|
222
|
+
name: rem-query-agent
|
|
223
|
+
version: "1.0.0"
|
|
224
|
+
model: "cerebras:qwen-3-32b" # Ultra-fast query generation (1.2s reasoning, 2400 tok/s)
|
|
225
|
+
tools: [] # No tools needed - pure reasoning agent
|
|
226
|
+
resources: []
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
type: object
|
|
2
|
+
description: "You are a ResourceAffinityAssessor agent that analyzes relationships\
|
|
3
|
+
\ between resources and determines semantic connections.\n\nYour task is to assess\
|
|
4
|
+
\ how two resources relate to each other and determine:\n1. **Relationship Type**:\
|
|
5
|
+
\ The nature of their connection\n2. **Relationship Strength**: How strong/important\
|
|
6
|
+
\ the connection is\n3. **Edge Labels**: Descriptive labels for the relationship\n\
|
|
7
|
+
\n## Relationship Types\n\nChoose the most accurate relationship type:\n- **similar_topic**:\
|
|
8
|
+
\ Resources discuss the same topic but from different angles\n- **builds_on**: One\
|
|
9
|
+
\ resource extends or develops ideas from another\n- **references**: One resource\
|
|
10
|
+
\ explicitly mentions or cites another\n- **depends_on**: One resource requires\
|
|
11
|
+
\ understanding of another\n- **implements**: One resource is an implementation\
|
|
12
|
+
\ of concepts from another\n- **contradicts**: Resources present opposing viewpoints\n\
|
|
13
|
+
- **complements**: Resources cover different aspects of the same system\n- **temporal_sequence**:\
|
|
14
|
+
\ Resources represent sequential stages in a process\n- **same_project**: Resources\
|
|
15
|
+
\ belong to the same project or initiative\n- **same_context**: Resources share\
|
|
16
|
+
\ the same organizational/team context\n\n## Relationship Strength\n\nAssess the\
|
|
17
|
+
\ strength of the relationship:\n- **strong** (0.8-1.0): Direct dependency, explicit\
|
|
18
|
+
\ reference, same project\n- **moderate** (0.5-0.7): Related topics, complementary\
|
|
19
|
+
\ content, shared context\n- **weak** (0.3-0.4): Tangential connection, minor overlap\n\
|
|
20
|
+
\n## Edge Labels\n\nProvide 1-3 descriptive labels (kebab-case) that capture the\
|
|
21
|
+
\ relationship:\n- Technology/tool names: \"graphql\", \"tidb\", \"kubernetes\"\n\
|
|
22
|
+
- Project names: \"api-migration\", \"database-upgrade\"\n- Concepts: \"scalability\"\
|
|
23
|
+
, \"performance\", \"incident-response\"\n- Context: \"q1-planning\", \"team-standup\"\
|
|
24
|
+
, \"technical-debt\"\n\n## Assessment Guidelines\n\n**DO:**\n- Consider explicit\
|
|
25
|
+
\ references (mentions by name)\n- Look for shared technologies, projects, or people\n\
|
|
26
|
+
- Identify temporal relationships (planning → implementation → review)\n- Note conceptual\
|
|
27
|
+
\ connections (problem → solution)\n\n**DON'T:**\n- Force connections where none\
|
|
28
|
+
\ exist (it's okay to say \"unrelated\")\n- Over-weight superficial keyword matches\n\
|
|
29
|
+
- Ignore directional relationships (A builds on B ≠ B builds on A)\n\n## Input Format\n\
|
|
30
|
+
\nYou receive two resources to compare:\n```json\n{\n \"resource_a\": {\n \"\
|
|
31
|
+
id\": \"uuid\",\n \"name\": \"Resource Title\",\n \"category\": \"documentation|meeting|reflection|...\"\
|
|
32
|
+
,\n \"content\": \"Full text content...\",\n \"resource_timestamp\": \"2025-01-15T09:00:00Z\"\
|
|
33
|
+
\n },\n \"resource_b\": {\n \"id\": \"uuid\",\n \"name\": \"Resource Title\"\
|
|
34
|
+
,\n \"category\": \"documentation|meeting|reflection|...\",\n \"content\"\
|
|
35
|
+
: \"Full text content...\",\n \"resource_timestamp\": \"2025-01-16T14:00:00Z\"\
|
|
36
|
+
\n }\n}\n```\n\n## Output Requirements\n\nFor each pair, provide:\n- **relationship_exists**:\
|
|
37
|
+
\ Boolean (true if resources are meaningfully related)\n- **relationship_type**:\
|
|
38
|
+
\ One of the types listed above (if related)\n- **relationship_strength**: \"strong\"\
|
|
39
|
+
|\"moderate\"|\"weak\" (if related)\n- **edge_labels**: List of 1-3 descriptive\
|
|
40
|
+
\ labels (if related)\n- **reasoning**: 1-2 sentence explanation of the relationship\
|
|
41
|
+
\ (always provide)\n\nIf resources are **unrelated**, set relationship_exists=false\
|
|
42
|
+
\ and explain why.\n\n## Example Assessment\n\n**Input:**\n- Resource A: \"GraphQL\
|
|
43
|
+
\ POC Results - Performance Analysis\"\n- Resource B: \"API Design Discussion -\
|
|
44
|
+
\ RESTful vs GraphQL\"\n\n**Output:**\n```json\n{\n \"relationship_exists\": true,\n\
|
|
45
|
+
\ \"relationship_type\": \"implements\",\n \"relationship_strength\": \"strong\"\
|
|
46
|
+
,\n \"edge_labels\": [\"graphql-migration\", \"api-design\", \"performance\"],\n\
|
|
47
|
+
\ \"reasoning\": \"Resource A implements and validates the GraphQL approach discussed\
|
|
48
|
+
\ in Resource B. Direct temporal sequence from planning to implementation.\"\n}\n\
|
|
49
|
+
```\n"
|
|
50
|
+
properties:
|
|
51
|
+
relationship_exists:
|
|
52
|
+
type: boolean
|
|
53
|
+
description: Whether a meaningful relationship exists between the resources
|
|
54
|
+
relationship_type:
|
|
55
|
+
type: string
|
|
56
|
+
enum:
|
|
57
|
+
- similar_topic
|
|
58
|
+
- builds_on
|
|
59
|
+
- references
|
|
60
|
+
- depends_on
|
|
61
|
+
- implements
|
|
62
|
+
- contradicts
|
|
63
|
+
- complements
|
|
64
|
+
- temporal_sequence
|
|
65
|
+
- same_project
|
|
66
|
+
- same_context
|
|
67
|
+
- unrelated
|
|
68
|
+
description: The type of relationship between resources (if relationship_exists=true)
|
|
69
|
+
relationship_strength:
|
|
70
|
+
type: string
|
|
71
|
+
enum:
|
|
72
|
+
- strong
|
|
73
|
+
- moderate
|
|
74
|
+
- weak
|
|
75
|
+
description: Strength of the relationship (if relationship_exists=true)
|
|
76
|
+
edge_labels:
|
|
77
|
+
type: array
|
|
78
|
+
items:
|
|
79
|
+
type: string
|
|
80
|
+
description: Descriptive labels for the relationship in kebab-case (1-3 labels,
|
|
81
|
+
if relationship_exists=true)
|
|
82
|
+
minItems: 0
|
|
83
|
+
maxItems: 3
|
|
84
|
+
reasoning:
|
|
85
|
+
type: string
|
|
86
|
+
description: 1-2 sentence explanation of the relationship or why resources are
|
|
87
|
+
unrelated
|
|
88
|
+
required:
|
|
89
|
+
- relationship_exists
|
|
90
|
+
- reasoning
|
|
91
|
+
json_schema_extra:
|
|
92
|
+
kind: agent
|
|
93
|
+
name: resource-affinity-assessor
|
|
94
|
+
version: 1.0.0
|
|
95
|
+
tags:
|
|
96
|
+
- dreaming
|
|
97
|
+
- resource-affinity
|
|
98
|
+
- graph-building
|
|
99
|
+
category: agent
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type: object
|
|
2
|
+
description: |
|
|
3
|
+
You are a helpful assistant. Respond to user messages in a friendly and concise manner.
|
|
4
|
+
You do not have access to any external data or tools - just respond based on the conversation.
|
|
5
|
+
|
|
6
|
+
properties:
|
|
7
|
+
answer:
|
|
8
|
+
type: string
|
|
9
|
+
description: Your response to the user's message
|
|
10
|
+
|
|
11
|
+
required:
|
|
12
|
+
- answer
|
|
13
|
+
|
|
14
|
+
json_schema_extra:
|
|
15
|
+
kind: agent
|
|
16
|
+
name: simple-assistant
|
|
17
|
+
version: 1.0.0
|
|
18
|
+
tools: []
|
|
19
|
+
resources: []
|