@sesamespace/hivemind 0.5.4 → 0.5.7

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 (86) hide show
  1. package/.github/workflows/memory-release.yml +89 -0
  2. package/config/default.toml +12 -0
  3. package/dist/{chunk-YHRGEWAZ.js → chunk-4U4GKI3X.js} +121 -34
  4. package/dist/chunk-4U4GKI3X.js.map +1 -0
  5. package/{packages/cli/src/commands/start.ts → dist/chunk-62S2NGMN.js} +39 -38
  6. package/dist/chunk-62S2NGMN.js.map +1 -0
  7. package/dist/{chunk-CGSXJVSS.js → chunk-7RTJSPMX.js} +2 -2
  8. package/dist/chunk-IJRAVHQC.js +327 -0
  9. package/dist/chunk-IJRAVHQC.js.map +1 -0
  10. package/dist/{chunk-MHDLSAJ3.js → chunk-JXLLCKMG.js} +102 -5
  11. package/dist/chunk-JXLLCKMG.js.map +1 -0
  12. package/dist/{chunk-SJI2KAIN.js → chunk-LJHJGDKY.js} +8 -2
  13. package/dist/chunk-LJHJGDKY.js.map +1 -0
  14. package/dist/{chunk-LNV373IF.js → chunk-LSOEUOTO.js} +2 -2
  15. package/dist/{chunk-S3RVZBPZ.js → chunk-PFN3BITA.js} +322 -2
  16. package/dist/chunk-PFN3BITA.js.map +1 -0
  17. package/dist/commands/fleet.js +3 -3
  18. package/dist/commands/init.js +1 -1
  19. package/dist/commands/service.js +1 -1
  20. package/dist/commands/start.js +3 -3
  21. package/dist/commands/upgrade.js +1 -1
  22. package/dist/commands/watchdog.js +10 -0
  23. package/dist/commands/watchdog.js.map +1 -0
  24. package/dist/index.js +6 -2
  25. package/dist/main.js +22 -12
  26. package/dist/main.js.map +1 -1
  27. package/dist/start.js +1 -1
  28. package/package.json +4 -3
  29. package/PLANNING.md +0 -383
  30. package/TASKS.md +0 -60
  31. package/dist/chunk-MHDLSAJ3.js.map +0 -1
  32. package/dist/chunk-PPQGQHXJ.js +0 -151
  33. package/dist/chunk-PPQGQHXJ.js.map +0 -1
  34. package/dist/chunk-S3RVZBPZ.js.map +0 -1
  35. package/dist/chunk-SJI2KAIN.js.map +0 -1
  36. package/dist/chunk-YHRGEWAZ.js.map +0 -1
  37. package/install.sh +0 -120
  38. package/npm-package.json +0 -26
  39. package/packages/cli/package.json +0 -23
  40. package/packages/cli/src/commands/fleet.ts +0 -206
  41. package/packages/cli/src/commands/init.ts +0 -252
  42. package/packages/cli/src/commands/service.ts +0 -159
  43. package/packages/cli/src/commands/upgrade.ts +0 -158
  44. package/packages/cli/src/main.ts +0 -64
  45. package/packages/cli/tsconfig.json +0 -8
  46. package/packages/memory/Cargo.lock +0 -6480
  47. package/packages/memory/Cargo.toml +0 -21
  48. package/packages/memory/src/context.rs +0 -179
  49. package/packages/memory/src/embeddings.rs +0 -51
  50. package/packages/memory/src/main.rs +0 -626
  51. package/packages/memory/src/promotion.rs +0 -637
  52. package/packages/memory/src/scoring.rs +0 -131
  53. package/packages/memory/src/store.rs +0 -460
  54. package/packages/memory/src/tasks.rs +0 -321
  55. package/packages/runtime/package.json +0 -24
  56. package/packages/runtime/src/__tests__/fleet-integration.test.ts +0 -235
  57. package/packages/runtime/src/__tests__/fleet.test.ts +0 -207
  58. package/packages/runtime/src/__tests__/integration.test.ts +0 -434
  59. package/packages/runtime/src/agent.ts +0 -255
  60. package/packages/runtime/src/config.ts +0 -130
  61. package/packages/runtime/src/context.ts +0 -192
  62. package/packages/runtime/src/fleet/fleet-manager.ts +0 -399
  63. package/packages/runtime/src/fleet/memory-sync.ts +0 -362
  64. package/packages/runtime/src/fleet/primary-client.ts +0 -285
  65. package/packages/runtime/src/fleet/worker-protocol.ts +0 -158
  66. package/packages/runtime/src/fleet/worker-server.ts +0 -246
  67. package/packages/runtime/src/index.ts +0 -57
  68. package/packages/runtime/src/llm-client.ts +0 -65
  69. package/packages/runtime/src/memory-client.ts +0 -309
  70. package/packages/runtime/src/pipeline.ts +0 -187
  71. package/packages/runtime/src/prompt.ts +0 -173
  72. package/packages/runtime/src/sesame.ts +0 -226
  73. package/packages/runtime/src/start.ts +0 -20
  74. package/packages/runtime/src/task-engine.ts +0 -113
  75. package/packages/runtime/src/worker.ts +0 -339
  76. package/packages/runtime/tsconfig.json +0 -8
  77. package/pnpm-workspace.yaml +0 -2
  78. package/run-aidan.sh +0 -23
  79. package/scripts/bootstrap.sh +0 -196
  80. package/scripts/build-npm.sh +0 -92
  81. package/scripts/com.hivemind.agent.plist +0 -44
  82. package/scripts/com.hivemind.memory.plist +0 -31
  83. package/tsconfig.json +0 -22
  84. package/tsup.config.ts +0 -27
  85. /package/dist/{chunk-CGSXJVSS.js.map → chunk-7RTJSPMX.js.map} +0 -0
  86. /package/dist/{chunk-LNV373IF.js.map → chunk-LSOEUOTO.js.map} +0 -0
@@ -1,21 +0,0 @@
1
- [package]
2
- name = "hivemind-memory"
3
- version = "0.1.0"
4
- edition = "2021"
5
-
6
- [dependencies]
7
- axum = "0.7"
8
- tokio = { version = "1", features = ["full"] }
9
- serde = { version = "1", features = ["derive"] }
10
- serde_json = "1"
11
- lancedb = "0.15"
12
- arrow-array = "53"
13
- arrow-schema = "53"
14
- reqwest = { version = "0.12", features = ["json"] }
15
- uuid = { version = "1", features = ["v4"] }
16
- chrono = { version = "0.4", features = ["serde"] }
17
- tracing = "0.1"
18
- tracing-subscriber = { version = "0.3", features = ["env-filter"] }
19
- tower-http = { version = "0.5", features = ["cors", "trace"] }
20
- anyhow = "1"
21
- futures = "0.3"
@@ -1,179 +0,0 @@
1
- use anyhow::Result;
2
- use arrow_array::{RecordBatch, RecordBatchIterator, StringArray};
3
- use arrow_schema::{DataType, Field, Schema};
4
- use chrono::Utc;
5
- use futures::stream::TryStreamExt;
6
- use lancedb::{connection::Connection, query::ExecutableQuery, query::QueryBase, Table};
7
- use serde::{Deserialize, Serialize};
8
- use std::sync::Arc;
9
- use uuid;
10
-
11
- const CONTEXTS_TABLE: &str = "contexts";
12
-
13
- #[derive(Debug, Serialize, Deserialize, Clone)]
14
- pub struct ContextMetadata {
15
- pub name: String,
16
- pub description: String,
17
- pub created_at: String,
18
- }
19
-
20
- pub struct ContextStore {
21
- db: Connection,
22
- }
23
-
24
- impl ContextStore {
25
- pub async fn new(db: Connection) -> Result<Self> {
26
- let store = Self { db };
27
- store.ensure_table().await?;
28
- Ok(store)
29
- }
30
-
31
- fn schema() -> Arc<Schema> {
32
- Arc::new(Schema::new(vec![
33
- Field::new("name", DataType::Utf8, false),
34
- Field::new("description", DataType::Utf8, false),
35
- Field::new("created_at", DataType::Utf8, false),
36
- ]))
37
- }
38
-
39
- async fn ensure_table(&self) -> Result<()> {
40
- let names = self.db.table_names().execute().await?;
41
- if !names.contains(&CONTEXTS_TABLE.to_string()) {
42
- let schema = Self::schema();
43
- let batch = RecordBatch::new_empty(schema.clone());
44
- let batches = RecordBatchIterator::new(vec![Ok(batch)], schema);
45
- self.db
46
- .create_table(CONTEXTS_TABLE, Box::new(batches))
47
- .execute()
48
- .await?;
49
- tracing::info!("Created contexts metadata table");
50
- }
51
- Ok(())
52
- }
53
-
54
- pub async fn create_context(&self, name: &str, description: &str) -> Result<ContextMetadata> {
55
- // Check if context already exists
56
- if let Some(existing) = self.get_context(name).await? {
57
- return Ok(existing);
58
- }
59
-
60
- let created_at = Utc::now().to_rfc3339();
61
-
62
- let metadata = ContextMetadata {
63
- name: name.to_string(),
64
- description: description.to_string(),
65
- created_at: created_at.clone(),
66
- };
67
-
68
- let schema = Self::schema();
69
- let batch = RecordBatch::try_new(
70
- schema.clone(),
71
- vec![
72
- Arc::new(StringArray::from(vec![name])),
73
- Arc::new(StringArray::from(vec![description])),
74
- Arc::new(StringArray::from(vec![created_at.as_str()])),
75
- ],
76
- )?;
77
-
78
- let table = self.db.open_table(CONTEXTS_TABLE).execute().await?;
79
- let batches = RecordBatchIterator::new(vec![Ok(batch)], schema);
80
- table.add(Box::new(batches)).execute().await?;
81
-
82
- tracing::info!("Created context: {}", name);
83
- Ok(metadata)
84
- }
85
-
86
- pub async fn get_context(&self, name: &str) -> Result<Option<ContextMetadata>> {
87
- let table = self.db.open_table(CONTEXTS_TABLE).execute().await?;
88
- let results = table
89
- .query()
90
- .only_if(format!("name = '{}'", name))
91
- .execute()
92
- .await?;
93
-
94
- let batches: Vec<RecordBatch> = results.try_collect().await?;
95
- for batch in &batches {
96
- if batch.num_rows() > 0 {
97
- let names = batch
98
- .column_by_name("name")
99
- .unwrap()
100
- .as_any()
101
- .downcast_ref::<StringArray>()
102
- .unwrap();
103
- let descriptions = batch
104
- .column_by_name("description")
105
- .unwrap()
106
- .as_any()
107
- .downcast_ref::<StringArray>()
108
- .unwrap();
109
- let created_ats = batch
110
- .column_by_name("created_at")
111
- .unwrap()
112
- .as_any()
113
- .downcast_ref::<StringArray>()
114
- .unwrap();
115
-
116
- return Ok(Some(ContextMetadata {
117
- name: names.value(0).to_string(),
118
- description: descriptions.value(0).to_string(),
119
- created_at: created_ats.value(0).to_string(),
120
- }));
121
- }
122
- }
123
-
124
- Ok(None)
125
- }
126
-
127
- pub async fn list_contexts(&self) -> Result<Vec<ContextMetadata>> {
128
- let table = self.db.open_table(CONTEXTS_TABLE).execute().await?;
129
- let results = table.query().execute().await?;
130
-
131
- let batches: Vec<RecordBatch> = results.try_collect().await?;
132
- let mut contexts = Vec::new();
133
-
134
- for batch in &batches {
135
- let names = batch
136
- .column_by_name("name")
137
- .unwrap()
138
- .as_any()
139
- .downcast_ref::<StringArray>()
140
- .unwrap();
141
- let descriptions = batch
142
- .column_by_name("description")
143
- .unwrap()
144
- .as_any()
145
- .downcast_ref::<StringArray>()
146
- .unwrap();
147
- let created_ats = batch
148
- .column_by_name("created_at")
149
- .unwrap()
150
- .as_any()
151
- .downcast_ref::<StringArray>()
152
- .unwrap();
153
-
154
- for i in 0..batch.num_rows() {
155
- contexts.push(ContextMetadata {
156
- name: names.value(i).to_string(),
157
- description: descriptions.value(i).to_string(),
158
- created_at: created_ats.value(i).to_string(),
159
- });
160
- }
161
- }
162
-
163
- Ok(contexts)
164
- }
165
-
166
- pub async fn delete_context(&self, name: &str) -> Result<bool> {
167
- if name == "global" {
168
- anyhow::bail!("Cannot delete global context");
169
- }
170
-
171
- let table = self.db.open_table(CONTEXTS_TABLE).execute().await?;
172
- table
173
- .delete(&format!("name = '{}'", name))
174
- .await?;
175
-
176
- tracing::info!("Deleted context metadata: {}", name);
177
- Ok(true)
178
- }
179
- }
@@ -1,51 +0,0 @@
1
- use anyhow::Result;
2
- use serde::{Deserialize, Serialize};
3
-
4
- pub struct OllamaClient {
5
- base_url: String,
6
- model: String,
7
- http: reqwest::Client,
8
- }
9
-
10
- #[derive(Serialize)]
11
- struct EmbedRequest {
12
- model: String,
13
- input: String,
14
- }
15
-
16
- #[derive(Deserialize)]
17
- struct EmbedResponse {
18
- embeddings: Vec<Vec<f32>>,
19
- }
20
-
21
- impl OllamaClient {
22
- pub fn new(base_url: &str, model: &str) -> Self {
23
- Self {
24
- base_url: base_url.to_string(),
25
- model: model.to_string(),
26
- http: reqwest::Client::new(),
27
- }
28
- }
29
-
30
- pub async fn embed(&self, text: &str) -> Result<Vec<f32>> {
31
- let url = format!("{}/api/embed", self.base_url);
32
- let req = EmbedRequest {
33
- model: self.model.clone(),
34
- input: text.to_string(),
35
- };
36
-
37
- let resp = self
38
- .http
39
- .post(&url)
40
- .json(&req)
41
- .send()
42
- .await?
43
- .error_for_status()?;
44
-
45
- let body: EmbedResponse = resp.json().await?;
46
- body.embeddings
47
- .into_iter()
48
- .next()
49
- .ok_or_else(|| anyhow::anyhow!("No embedding returned from Ollama"))
50
- }
51
- }