@lumifai/harness-tool-pack-postgres 0.0.1 → 0.1.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/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@lumifai/harness-tool-pack-postgres",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "license": "UNLICENSED",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Lumif-ai/lumif-harness.git",
8
+ "directory": "packages/tool-packs/postgres"
9
+ },
5
10
  "engines": {
6
11
  "node": ">=22.13.0"
7
12
  },
@@ -22,12 +27,12 @@
22
27
  "skills"
23
28
  ],
24
29
  "dependencies": {
30
+ "@lumifai/harness-tool-packs": "0.1.0",
25
31
  "@mastra/core": "1.50.1",
26
32
  "csv-parse": "^7.0.0",
27
33
  "pg": "^8.16.3",
28
34
  "pg-cursor": "^2.21.0",
29
- "pg-sql2": "^5.0.1",
30
- "@lumifai/harness-tool-packs": "0.0.1"
35
+ "pg-sql2": "^5.0.1"
31
36
  },
32
37
  "devDependencies": {
33
38
  "@types/pg": "^8.15.5",
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: postgres-write
3
+ description: Deterministic PostgreSQL insert and update tools that read JSON from the workspace
4
+ version: 1.1.0
5
+ tags:
6
+ - database
7
+ - postgres
8
+ - write
9
+ ---
10
+
11
+ # PostgreSQL Write Tools
12
+
13
+ Use the `postgres` tool pack to persist workspace JSON files into PostgreSQL deterministically.
14
+ Pair these tools with the `postgres` discovery workflow before unfamiliar tables.
15
+
16
+ These tools do **not** run arbitrary SQL. Boot config must set `allowedTables` (and optionally `allowedColumns`).
17
+
18
+ ## Tools
19
+
20
+ | Tool | Purpose |
21
+ | --------------------------- | ------------------------------------------- |
22
+ | `postgres_insert_from_file` | JSON file → `INSERT` rows (optional upsert) |
23
+ | `postgres_update_from_file` | JSON patch → `UPDATE` one row |
24
+
25
+ ## Insert file format
26
+
27
+ Path is **workspace-relative** (no leading `/`), e.g. `campaigns/123/brief.json`.
28
+
29
+ Single row:
30
+
31
+ ```json
32
+ {
33
+ "id": "campaign-123",
34
+ "name": "Fintech outreach",
35
+ "metadata": { "region": "US" }
36
+ }
37
+ ```
38
+
39
+ Multiple rows (every row must have the **same keys**):
40
+
41
+ ```json
42
+ [
43
+ { "id": "c1", "name": "Campaign A", "metadata": {} },
44
+ { "id": "c2", "name": "Campaign B", "metadata": {} }
45
+ ]
46
+ ```
47
+
48
+ Tool args:
49
+
50
+ - `conflictColumns` — e.g. `["id"]` for idempotent saves
51
+ - `onConflict` — `ignore` (default when conflictColumns set) or `update` (upsert non-key columns)
52
+
53
+ Empty arrays are rejected.
54
+
55
+ ## Update file format
56
+
57
+ Flat object — **only columns to change**:
58
+
59
+ ```json
60
+ {
61
+ "name": "Updated campaign name",
62
+ "metadata": { "region": "EU", "status": "confirmed" }
63
+ }
64
+ ```
65
+
66
+ Lookup via tool args (not in the file):
67
+
68
+ - `whereColumn` — defaults to `id`
69
+ - `whereValue` — required unless `resolveWhereValue` is configured at server boot
70
+
71
+ ## Workflow
72
+
73
+ 1. Optionally inspect the table with `postgres_describe_table`.
74
+ 2. Write JSON to the workspace (`write_file`).
75
+ 3. Call `postgres_insert_from_file` or `postgres_update_from_file`.
76
+
77
+ ## Safety rules
78
+
79
+ - Only write to tables/columns allowed in boot config.
80
+ - Do not include the lookup column in update JSON files.
81
+ - Writes require user approval by default.