@chatpanel/gateway 0.6.97 → 0.6.99
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 +2 -2
- package/src/server.js +1 -1
- package/src/team-board.js +15 -8
- package/src/team-record.js +25 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/gateway",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.99",
|
|
4
4
|
"description": "Local privacy gateway — redacts PII out of OpenAI/Anthropic API traffic before it reaches a model, then restores it in the reply. Point opencode, codex, aider, Claude Code, etc. at it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"node": ">=18"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@chatpanel/bridge": "^0.11.
|
|
30
|
+
"@chatpanel/bridge": "^0.11.23",
|
|
31
31
|
"@chatpanel/pii": "^0.7.4",
|
|
32
32
|
"@huggingface/transformers": "^4.2.0",
|
|
33
33
|
"onnxruntime-web": "1.26.0-dev.20260416-b7804b056c",
|
package/src/server.js
CHANGED
|
@@ -63,7 +63,7 @@ import * as openai from './openai.js';
|
|
|
63
63
|
import * as responses from './responses.js';
|
|
64
64
|
import * as anthropic from './anthropic.js';
|
|
65
65
|
|
|
66
|
-
export const VERSION = '0.6.
|
|
66
|
+
export const VERSION = '0.6.99';
|
|
67
67
|
|
|
68
68
|
// WARM search tier — SQLite + FTS5 record store (falls back to an encrypted-JSON
|
|
69
69
|
// store if SQLite can't load), fed by the extension's ingest sync + backup-ingest.
|
package/src/team-board.js
CHANGED
|
@@ -75,8 +75,12 @@ export function parseFindings(text, { role, taskId } = {}) {
|
|
|
75
75
|
// ── threads, posts, asks ────────────────────────────────────────────────────────────────
|
|
76
76
|
|
|
77
77
|
export const THREAD_KINDS = Object.freeze(['task', 'ask', 'discussion', 'proposal']);
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
// `failed`: the task behind the thread ended without an answer (every model on the roster
|
|
79
|
+
// tried, or a hard error) — not `resolved`, which read as "done" on the board.
|
|
80
|
+
export const THREAD_STATUSES = Object.freeze(['open', 'waiting', 'resolved', 'failed', 'approved', 'rejected']);
|
|
81
|
+
// `request`: a member asks for a piece of its task to be done by someone else — the runner
|
|
82
|
+
// turns it into a sub-task with its own thread (team-subtask.js).
|
|
83
|
+
export const POST_KINDS = Object.freeze(['finding', 'note', 'question', 'answer', 'draft', 'decision', 'request']);
|
|
80
84
|
export const POST_STATUSES = Object.freeze(['open', 'proposed', 'approved', 'rejected']);
|
|
81
85
|
export const ASK_TYPES = Object.freeze(['info', 'budget', 'permission', 'direction']);
|
|
82
86
|
export const RUNNER = 'runner';
|
|
@@ -109,7 +113,7 @@ export function foldBoard(state, ev) {
|
|
|
109
113
|
if (x) { x.status = p.status; x.decidedBy = p.by; x.decidedAt = p.at ?? ev?.at; }
|
|
110
114
|
} else if (type === 'board.thread-status' && p.threadId) {
|
|
111
115
|
const t = s.threads.find((x) => x.id === p.threadId);
|
|
112
|
-
if (t) { t.status = p.status; if (p.status !== 'waiting') t.waitingOn = null; }
|
|
116
|
+
if (t) { t.status = p.status; if (p.status !== 'waiting') t.waitingOn = null; if (p.holder) t.holder = p.holder; }
|
|
113
117
|
}
|
|
114
118
|
return s;
|
|
115
119
|
}
|
|
@@ -131,22 +135,25 @@ export function createBoard({ now = () => Date.now(), newId = null, state = null
|
|
|
131
135
|
|
|
132
136
|
const api = {
|
|
133
137
|
/** Open a thread. A task's thread is opened once; asking for it again returns it. */
|
|
134
|
-
openThread({ id = null, taskId = null, kind = 'discussion', title = '', by = RUNNER, status = 'open', ask = null } = {}) {
|
|
138
|
+
openThread({ id = null, taskId = null, kind = 'discussion', title = '', by = RUNNER, status = 'open', ask = null, parent = null, holder = null } = {}) {
|
|
135
139
|
if (kind === 'task' && taskId) { const had = threadForTask(taskId); if (had) return had; }
|
|
136
|
-
|
|
140
|
+
// `parent`: the task this one was requested from (a sub-task's thread hangs under its
|
|
141
|
+
// parent's on the board); `holder`: the member that took it.
|
|
142
|
+
const thread = { id: id || mk('th'), kind: THREAD_KINDS.includes(kind) ? kind : 'discussion', taskId, title: clip(title, 200), by, status: THREAD_STATUSES.includes(status) ? status : 'open', at: now(), posts: 0, ...(ask ? { ask } : {}), ...(parent ? { parent } : {}), ...(holder ? { holder } : {}) };
|
|
137
143
|
st.threads.push(thread);
|
|
138
144
|
say('board.thread', { thread: { ...thread } });
|
|
139
145
|
return thread;
|
|
140
146
|
},
|
|
141
147
|
/** A post in a thread; `replyTo` makes it a reply. */
|
|
142
|
-
|
|
148
|
+
/** `proposal` rides on a draft a person decides on — `{ kind: 'agent', agent, jobId }` (§15.2): the card the host creates when the post is approved. */
|
|
149
|
+
post({ id = null, threadId, by, kind = 'note', text = '', refs = [], replyTo = null, status = 'open', finding = null, ask = null, proposal = null } = {}) {
|
|
143
150
|
const t = threadOf(threadId);
|
|
144
151
|
if (!t) throw new Error(`no thread ${threadId}`);
|
|
145
152
|
if (id && postOf(id)) return postOf(id);
|
|
146
153
|
const post = {
|
|
147
154
|
id: id || mk('p'), threadId, by: String(by || RUNNER), kind: POST_KINDS.includes(kind) ? kind : 'note',
|
|
148
155
|
text: clip(text, MAX_POST_TEXT), refs: refsOf(refs), replyTo, status: POST_STATUSES.includes(status) ? status : 'open', at: now(),
|
|
149
|
-
...(finding ? { finding } : {}), ...(ask ? { ask } : {}),
|
|
156
|
+
...(finding ? { finding } : {}), ...(ask ? { ask } : {}), ...(proposal && typeof proposal === 'object' ? { proposal } : {}),
|
|
150
157
|
};
|
|
151
158
|
st.posts.push(post);
|
|
152
159
|
t.lastAt = post.at; t.lastBy = post.by; t.posts = (t.posts || 0) + 1;
|
|
@@ -282,7 +289,7 @@ function threadedLines(state, { taskIds, role }) {
|
|
|
282
289
|
for (const t of threads) {
|
|
283
290
|
const own = posts.filter((x) => x.threadId === t.id && x.status !== 'rejected');
|
|
284
291
|
if (!own.length) continue;
|
|
285
|
-
out.push(`## ${t.kind}${t.by && t.by !== RUNNER ? ` by ${t.by}` : ''}: ${t.title}${t.status === 'resolved' && t.kind === 'ask' ? ' (answered)' : ''}`);
|
|
292
|
+
out.push(`## ${t.kind}${t.by && t.by !== RUNNER ? ` by ${t.by}` : ''}: ${t.title}${t.holder ? ` (held by ${t.holder})` : ''}${t.status === 'resolved' && t.kind === 'ask' ? ' (answered)' : ''}`);
|
|
286
293
|
const line = (x, depth) => {
|
|
287
294
|
const tag = [x.kind === 'finding' ? (x.finding?.kind || 'claim') : x.kind, x.by, x.finding?.confidence != null ? `${Math.round(x.finding.confidence * 100)}%` : null, x.status === 'approved' ? 'APPROVED' : x.status === 'proposed' ? 'proposed' : null, x.kind === 'decision' || x.by === PERSON ? 'SETTLED' : null].filter(Boolean).join(' · ');
|
|
288
295
|
out.push(`${' '.repeat(depth)}- [${tag}] ${x.text}${x.refs?.length ? ` (refs: ${x.refs.join(', ')})` : ''}`);
|
package/src/team-record.js
CHANGED
|
@@ -15,7 +15,7 @@ export const RESUMABLE_RUN_STATUSES = Object.freeze(['waiting', 'stopped', 'fail
|
|
|
15
15
|
const TASK_TEXT_MAX = 20_000;
|
|
16
16
|
|
|
17
17
|
export function emptyRun({ id, client = '', now = Date.now() } = {}) {
|
|
18
|
-
return { id, client: String(client || '').slice(0, 40), createdAt: now, lastEventAt: now, status: 'planning', team: '', request: '', roles: [], plan: null, tasks: [], board: [], threads: emptyBoardState(), checkpoint: null, proposal: null, usage: null, stopRequested: null, startedAt: null, endedAt: null };
|
|
18
|
+
return { id, client: String(client || '').slice(0, 40), createdAt: now, lastEventAt: now, status: 'planning', team: '', request: '', roles: [], plan: null, tasks: [], jobs: [], board: [], threads: emptyBoardState(), checkpoint: null, proposal: null, usage: null, stopRequested: null, startedAt: null, endedAt: null };
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const taskOf = (run, id) => run.tasks.find((x) => x.id === id);
|
|
@@ -36,9 +36,24 @@ export function foldRun(run, ev) {
|
|
|
36
36
|
case 'plan.ready':
|
|
37
37
|
run.plan = { by: p.by || 'fixed', tasks: Array.isArray(p.tasks) ? p.tasks : [] };
|
|
38
38
|
// A resume replays the plan: keep what the tasks already hold (transcripts, attempts).
|
|
39
|
-
run.tasks = run.plan.tasks.map((t) => ({ ...(taskOf(run, t.id) || {}), id: t.id, role: t.role, title: t.title, status: taskOf(run, t.id)?.status === 'ok' ? 'ok' : 'pending', findings: taskOf(run, t.id)?.findings || 0 }));
|
|
39
|
+
run.tasks = run.plan.tasks.map((t) => ({ ...(taskOf(run, t.id) || {}), id: t.id, role: t.role, title: t.title, status: taskOf(run, t.id)?.status === 'ok' ? 'ok' : (t.parent && !t.role ? 'unassigned' : 'pending'), findings: taskOf(run, t.id)?.findings || 0, ...(t.parent ? { parent: t.parent, requestedBy: t.requestedBy || null } : {}), ...(t.grants ? { grants: t.grants, why: t.why || '' } : {}) }));
|
|
40
40
|
run.status = 'running';
|
|
41
41
|
break;
|
|
42
|
+
// A SUB-TASK (§15.2): requested by a member mid-run, it joins the plan under its parent;
|
|
43
|
+
// taken by a member, recruited from the pool, created on a person's approval — or not.
|
|
44
|
+
case 'task.requested':
|
|
45
|
+
if (p.taskId && !taskOf(run, p.taskId)) {
|
|
46
|
+
const task = { id: p.taskId, role: null, title: p.title || p.taskId, prompt: p.prompt || '', dependsOn: Array.isArray(p.dependsOn) ? p.dependsOn : [], parent: p.parent || null, requestedBy: p.by || null, needs: p.needs || null, depth: p.depth || 1, wait: p.wait !== false };
|
|
47
|
+
if (run.plan) run.plan.tasks = [...(run.plan.tasks || []), task];
|
|
48
|
+
run.tasks.push({ id: task.id, role: null, title: task.title, status: 'requested', findings: 0, parent: task.parent, requestedBy: task.requestedBy, needs: task.needs, requestedAt: at });
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case 'task.taken': { const t = taskOf(run, p.taskId); if (t) { t.role = p.role; t.status = 'pending'; t.takenBy = { by: p.by || 'fit', role: p.role, fit: p.fit ?? null, reasons: p.reasons || [], agentId: p.agentId || null, engine: p.engine || null, why: p.why || '', at }; } const pt = run.plan?.tasks?.find((x) => x.id === p.taskId); if (pt) pt.role = p.role; break; }
|
|
52
|
+
case 'task.posted': { const t = taskOf(run, p.taskId); if (t) t.job = p.job || null; if (p.job && !run.jobs.some((j) => j.id === p.job.id)) run.jobs.push({ ...p.job, taskId: p.taskId, at }); break; }
|
|
53
|
+
case 'task.proposed': { const t = taskOf(run, p.taskId); if (t) t.proposal = { agent: p.agent || null, threadId: p.threadId || null, postId: p.postId || null, why: p.why || '', at }; break; }
|
|
54
|
+
case 'task.unassigned': { const t = taskOf(run, p.taskId); if (t) { t.status = 'unassigned'; t.error = p.why || null; t.endedAt = at; } const j = run.jobs.find((x) => x.taskId === p.taskId); if (j) j.status = 'failed'; break; }
|
|
55
|
+
case 'task.nudged': { const t = taskOf(run, p.taskId); if (t) t.nudged = [...(t.nudged || []), { grants: p.grants || [], at }]; break; }
|
|
56
|
+
case 'run.role-added': if (p.role?.id && !run.roles.includes(p.role.id)) { run.roles.push(p.role.id); run.recruited = [...(run.recruited || []), { ...p.role, jobId: p.jobId || null, at }]; const j = run.jobs.find((x) => x.id === p.jobId); if (j) { j.status = 'recruited'; j.recruited = { agentId: p.role.agent || p.role.id, engine: p.role.engine || null, at }; } } break;
|
|
42
57
|
case 'task.started': { const t = taskOf(run, p.taskId); if (t) { t.status = 'running'; t.startedAt = at; t.error = null; } run.status = 'running'; break; }
|
|
43
58
|
case 'task.model': { const t = taskOf(run, p.taskId); if (t) { t.model = p.model; t.attempts = [...(t.attempts || []), { model: p.model, at, attempt: p.attempt }]; } break; }
|
|
44
59
|
case 'task.step': { const t = taskOf(run, p.taskId); if (t && Array.isArray(p.steps)) t.transcript = [...(t.transcript || []), ...p.steps]; break; }
|
|
@@ -50,7 +65,14 @@ export function foldRun(run, ev) {
|
|
|
50
65
|
break;
|
|
51
66
|
case 'task.waiting': { const t = taskOf(run, p.taskId); if (t) { t.status = 'waiting'; t.waitingOn = p.threadId; } break; }
|
|
52
67
|
case 'task.done':
|
|
53
|
-
case 'task.failed': {
|
|
68
|
+
case 'task.failed': {
|
|
69
|
+
const t = taskOf(run, p.taskId);
|
|
70
|
+
if (t) { t.status = p.status || (type === 'task.done' ? 'ok' : 'failed'); t.error = p.error || null; t.ms = p.ms; t.endedAt = at; }
|
|
71
|
+
// A job posting's outcome is the sub-task's (§15.2.5): taken by, finished how.
|
|
72
|
+
const j = run.jobs.find((x) => x.taskId === p.taskId);
|
|
73
|
+
if (j) { j.status = type === 'task.done' ? 'done' : 'failed'; j.endedAt = at; }
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
54
76
|
case 'run.merging': run.status = 'merging'; break;
|
|
55
77
|
case 'run.waiting': run.status = 'running'; break;
|
|
56
78
|
case 'run.usage': run.usage = p.usage || run.usage; break;
|