@dmsdc-ai/aigentry-deliberation 0.0.39 → 0.0.41
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/README.md +136 -218
- package/examples/README.md +25 -0
- package/examples/basic-deliberation.md +99 -0
- package/examples/browser-automation.md +120 -0
- package/examples/code-review.md +78 -0
- package/examples/structured-synthesis.md +96 -0
- package/index.js +440 -4050
- package/install.js +1 -1
- package/lib/entitlement.js +120 -0
- package/lib/session.js +651 -0
- package/lib/speaker-discovery.js +1575 -0
- package/lib/telepty.js +911 -0
- package/lib/transport.js +1355 -0
- package/package.json +9 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Browser Automation — Include ChatGPT / Gemini via CDP
|
|
2
|
+
|
|
3
|
+
Use `deliberation_browser_llm_tabs` and `deliberation_browser_auto_turn` to pull browser-based
|
|
4
|
+
LLMs (ChatGPT, Gemini, Claude.ai) into a deliberation session without manual copy-paste.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
- Chrome / Chromium launched with remote debugging enabled:
|
|
11
|
+
```bash
|
|
12
|
+
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/cdp-profile
|
|
13
|
+
```
|
|
14
|
+
- Target LLM tabs open and logged in (e.g., chatgpt.com, gemini.google.com)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Step 1 — Discover Open Browser Tabs
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
// Tool: deliberation_browser_llm_tabs
|
|
22
|
+
{}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Response:**
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"tabs": [
|
|
29
|
+
{ "id": "tab-001", "url": "https://chatgpt.com", "title": "ChatGPT", "provider": "chatgpt" },
|
|
30
|
+
{ "id": "tab-002", "url": "https://gemini.google.com", "title": "Gemini", "provider": "gemini" }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Step 2 — Confirm Speakers Including Browser Tabs
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
// Tool: deliberation_confirm_speakers
|
|
41
|
+
{
|
|
42
|
+
"speaker_ids": ["claude-opus", "tab-001", "tab-002"]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Step 3 — Start the Session
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
// Tool: deliberation_start
|
|
52
|
+
{
|
|
53
|
+
"topic": "Best caching strategy for a high-traffic e-commerce product page",
|
|
54
|
+
"context": "~50k requests/min, product data changes every 15 minutes, personalization per user.",
|
|
55
|
+
"max_turns": 6
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Step 4 — Route a Turn to a Browser Tab
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
// Tool: deliberation_browser_auto_turn
|
|
65
|
+
{
|
|
66
|
+
"deliberation_id": "delib-b7c8d9",
|
|
67
|
+
"tab_id": "tab-001",
|
|
68
|
+
"prompt": "Given the context above, what caching strategy would you recommend and why?"
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**What happens:** The server injects the prompt into the ChatGPT tab via CDP, waits for the
|
|
73
|
+
response to stream to completion, then captures the text and stores it as a deliberation turn.
|
|
74
|
+
|
|
75
|
+
**Response:**
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"speaker_id": "tab-001",
|
|
79
|
+
"content": "I recommend a two-layer cache: CDN edge cache (TTL 60s) for the static product shell, plus a Redis read-through cache (TTL 900s) for product data. For personalization, serve a generic cached page and hydrate user-specific sections client-side via a lightweight /api/personalize call.",
|
|
80
|
+
"transport": "browser_auto"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Step 5 — Run All Remaining Turns Automatically
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
// Tool: deliberation_run_until_blocked
|
|
90
|
+
{
|
|
91
|
+
"deliberation_id": "delib-b7c8d9"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The server routes each pending turn to its assigned transport (`browser_auto` for tabs,
|
|
96
|
+
`cli_respond` for CLI speakers) and blocks only when manual input is required.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Step 6 — Synthesize
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
// Tool: deliberation_synthesize
|
|
104
|
+
{
|
|
105
|
+
"deliberation_id": "delib-b7c8d9"
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Response:**
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"verdict": "Two-layer cache: CDN (60s TTL) + Redis (900s TTL) with client-side personalization hydration",
|
|
113
|
+
"confidence": 0.88,
|
|
114
|
+
"actionable_tasks": [
|
|
115
|
+
{ "id": 1, "task": "Configure CDN cache rules with 60s TTL and stale-while-revalidate", "priority": "high" },
|
|
116
|
+
{ "id": 2, "task": "Add Redis read-through cache for product data with 15-min TTL", "priority": "high" },
|
|
117
|
+
{ "id": 3, "task": "Build /api/personalize endpoint for client-side hydration", "priority": "medium" }
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Multi-AI Code Review
|
|
2
|
+
|
|
3
|
+
Use `deliberation_request_review` to route a code snippet to multiple AI speakers for parallel review.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Scenario
|
|
8
|
+
|
|
9
|
+
You have a new authentication middleware and want independent review from Claude and Gemini before merging.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Step 1 — Start a Review Session
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
// Tool: deliberation_request_review
|
|
17
|
+
{
|
|
18
|
+
"topic": "Security review: JWT authentication middleware",
|
|
19
|
+
"code": "function authMiddleware(req, res, next) {\n const token = req.headers['authorization']?.split(' ')[1];\n if (!token) return res.status(401).json({ error: 'No token' });\n try {\n const payload = jwt.verify(token, process.env.JWT_SECRET);\n req.user = payload;\n next();\n } catch (err) {\n res.status(403).json({ error: 'Invalid token' });\n }\n}",
|
|
20
|
+
"language": "javascript",
|
|
21
|
+
"focus": ["security", "error handling", "edge cases"]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Response:**
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"deliberation_id": "delib-review-x9z1",
|
|
29
|
+
"status": "active",
|
|
30
|
+
"assigned_speakers": ["claude-opus", "gemini-pro"]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Step 2 — Collect Reviews
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
// Tool: deliberation_respond (speaker: claude-opus)
|
|
40
|
+
{
|
|
41
|
+
"deliberation_id": "delib-review-x9z1",
|
|
42
|
+
"speaker_id": "claude-opus",
|
|
43
|
+
"content": "Issues found:\n1. JWT_SECRET missing guard — if env var is undefined, jwt.verify accepts any token signed with 'undefined'.\n2. No token expiry enforcement beyond jwt.verify defaults.\n3. Leaking error type in 403 response could aid attackers.\nRecommend: validate JWT_SECRET at startup, use a dedicated error logger, return generic 403 message."
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
// Tool: deliberation_respond (speaker: gemini-pro)
|
|
49
|
+
{
|
|
50
|
+
"deliberation_id": "delib-review-x9z1",
|
|
51
|
+
"speaker_id": "gemini-pro",
|
|
52
|
+
"content": "Concur on the JWT_SECRET risk. Additional concern: no algorithm pinning — `jwt.verify` without `algorithms` option is vulnerable to algorithm confusion (e.g., HS256 vs RS256 swap). Add `{ algorithms: ['HS256'] }` as third argument."
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Step 3 — Synthesize Review Findings
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
// Tool: deliberation_synthesize
|
|
62
|
+
{
|
|
63
|
+
"deliberation_id": "delib-review-x9z1"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Response:**
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"verdict": "Block merge — 2 critical security issues",
|
|
71
|
+
"confidence": 0.95,
|
|
72
|
+
"actionable_tasks": [
|
|
73
|
+
{ "id": 1, "task": "Guard JWT_SECRET at startup with process.exit on missing value", "priority": "high" },
|
|
74
|
+
{ "id": 2, "task": "Pin algorithm: jwt.verify(token, secret, { algorithms: ['HS256'] })", "priority": "high" },
|
|
75
|
+
{ "id": 3, "task": "Replace detailed error message in 403 with generic 'Forbidden'", "priority": "medium" }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Structured Synthesis & ExecutionContractV2
|
|
2
|
+
|
|
3
|
+
`deliberation_synthesize` returns an `ExecutionContractV2` — a machine-readable handoff
|
|
4
|
+
that downstream automation (brain inbox, CI pipelines, executor agents) can consume directly.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Triggering Synthesis
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
// Tool: deliberation_synthesize
|
|
12
|
+
{
|
|
13
|
+
"deliberation_id": "delib-a1b2c3"
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Full ExecutionContractV2 Schema
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"schema_version": 2,
|
|
24
|
+
"source_session_id": "aigentry-orchestrator-claude",
|
|
25
|
+
"deliberation_id": "delib-a1b2c3",
|
|
26
|
+
"summary": "GraphQL chosen over REST for the new API due to multi-client flexibility and nested data requirements.",
|
|
27
|
+
"decisions": [
|
|
28
|
+
"Use GraphQL with Apollo Server",
|
|
29
|
+
"Schema-first design with code generation",
|
|
30
|
+
"Maintain REST shim for legacy mobile clients during 90-day transition"
|
|
31
|
+
],
|
|
32
|
+
"actionable_tasks": [
|
|
33
|
+
{
|
|
34
|
+
"id": 1,
|
|
35
|
+
"task": "Set up Apollo Server with schema-first design",
|
|
36
|
+
"priority": "high",
|
|
37
|
+
"files": ["src/server.js", "src/schema/index.graphql"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": 2,
|
|
41
|
+
"task": "Define GraphQL types for User, Order, and Product entities",
|
|
42
|
+
"priority": "high",
|
|
43
|
+
"files": ["src/schema/types.graphql"]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": 3,
|
|
47
|
+
"task": "Add REST compatibility shim for /api/v1 routes",
|
|
48
|
+
"priority": "medium",
|
|
49
|
+
"files": ["src/routes/v1.js"]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"experiment_outcome": {
|
|
53
|
+
"verdict": "keep",
|
|
54
|
+
"confidence": 0.82
|
|
55
|
+
},
|
|
56
|
+
"generated_from": "deliberation_synthesize"
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Brain Inbox Handoff
|
|
63
|
+
|
|
64
|
+
The contract is automatically written to:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
~/.aigentry/inbox/handoff-{deliberation_id}.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
An executor agent (or `inbox-watcher.mjs`) picks it up and starts implementation:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
node inbox-watcher.mjs
|
|
74
|
+
# => Detected handoff: delib-a1b2c3
|
|
75
|
+
# => Dispatching 3 tasks to executor...
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Consuming the Contract in Code
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
import { readFileSync } from 'fs';
|
|
84
|
+
import { homedir } from 'os';
|
|
85
|
+
import path from 'path';
|
|
86
|
+
|
|
87
|
+
const contract = JSON.parse(
|
|
88
|
+
readFileSync(path.join(homedir(), '.aigentry/inbox/handoff-delib-a1b2c3.json'), 'utf8')
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
for (const task of contract.actionable_tasks) {
|
|
92
|
+
if (task.priority === 'high') {
|
|
93
|
+
console.log(`[HIGH] ${task.task} → files: ${task.files.join(', ')}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|