@chatpanel/bridge 0.11.23 → 0.11.25
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 +7 -7
- package/package.json +1 -13
- package/scripts/sync-channels.mjs +8 -90
- package/scripts/sync-events.mjs +7 -78
- package/scripts/sync-pii.mjs +7 -68
- package/src/api-compat.js +5 -294
- package/src/channels/adapters/telegram.js +3 -298
- package/src/channels/bridge.js +1 -59
- package/src/channels/eventlog.js +3 -57
- package/src/channels/gateway.js +1 -114
- package/src/channels/invoke.js +1 -172
- package/src/channels/normalize.js +1 -58
- package/src/channels/pairing.js +1 -95
- package/src/channels/service.js +1 -329
- package/src/channels/stream.js +5 -104
- package/src/cli-errors.js +3 -136
- package/src/connections.js +1 -160
- package/src/connectors.js +1 -100
- package/src/engines/antigravity.js +5 -235
- package/src/engines/args.js +1 -47
- package/src/engines/claude.js +6 -586
- package/src/engines/cli-agents.js +7 -312
- package/src/engines/codex.js +6 -463
- package/src/engines/custom.js +17 -577
- package/src/engines/prompt.js +6 -32
- package/src/engines/stream-formats.js +2 -222
- package/src/entitlement.js +1 -77
- package/src/env.js +3 -628
- package/src/events/capability.js +1 -134
- package/src/events/event.js +1 -183
- package/src/events/reach.js +1 -31
- package/src/events/ref.js +1 -63
- package/src/events/scm-connection.js +1 -188
- package/src/events/scopes.js +1 -20
- package/src/events/skill-manifest.js +1 -338
- package/src/events/skill-scan.js +3 -217
- package/src/events/view.js +1 -96
- package/src/mcp-capabilities.js +2 -139
- package/src/mcp-local.js +0 -0
- package/src/mcp-quarantine.js +1 -110
- package/src/net.js +1 -107
- package/src/pii/index.js +1 -29
- package/src/pii/net.js +1 -111
- package/src/pii/pii-detect.js +2 -296
- package/src/pii/pii-redact.js +1 -470
- package/src/pii/pipeline.js +1 -137
- package/src/pii/sanitize.js +2 -179
- package/src/pii/tool-harness.js +1 -184
- package/src/pii/tool-rank.js +1 -110
- package/src/proc.js +2 -91
- package/src/relay-timeout.js +1 -21
- package/src/runs.js +1 -49
- package/src/sanitize.js +1 -7
- package/src/scm.js +1 -76
- package/src/server.js +10 -1492
- package/src/service.js +11 -176
- package/src/sign-in.js +1 -91
- package/src/skills.js +1 -399
- package/src/ssrf.js +1 -70
- package/src/update.js +1 -216
- package/src/workdir.js +1 -108
- package/src/worktree.js +3 -125
package/src/runs.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// Cancellation used to depend on Node noticing the client's socket close and firing
|
|
4
|
-
// `req.on('close')`. That is a signal about a socket, not about intent: it can arrive late,
|
|
5
|
-
// and on a request whose body was already consumed it does not reliably arrive at all — so
|
|
6
|
-
// a codex `shell:` step ran on for minutes after Stop with nothing left listening to it.
|
|
7
|
-
//
|
|
8
|
-
// A run registered here can be cancelled by name. The socket-close path stays as a safety
|
|
9
|
-
// net for a panel that is closed or crashes, but the button no longer depends on it.
|
|
10
|
-
const runs = new Map();
|
|
11
|
-
|
|
12
|
-
export function startRun(id) {
|
|
13
|
-
const ac = new AbortController();
|
|
14
|
-
const children = new Set();
|
|
15
|
-
const run = {
|
|
16
|
-
id,
|
|
17
|
-
signal: ac.signal,
|
|
18
|
-
// Children are tracked as well as signalled, because an agent that spawns sub-agents
|
|
19
|
-
// spawns processes this module never sees at spawn time. Whoever creates one registers
|
|
20
|
-
// it, and Stop reaches all of them.
|
|
21
|
-
track(child) { if (child?.pid) { children.add(child); child.once?.('exit', () => children.delete(child)); } },
|
|
22
|
-
cancel(reason = 'stopped') {
|
|
23
|
-
if (run.cancelled) return false;
|
|
24
|
-
run.cancelled = reason;
|
|
25
|
-
ac.abort();
|
|
26
|
-
return true;
|
|
27
|
-
},
|
|
28
|
-
cancelled: null,
|
|
29
|
-
children,
|
|
30
|
-
};
|
|
31
|
-
runs.set(id, run);
|
|
32
|
-
return run;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function endRun(id) { runs.delete(id); }
|
|
36
|
-
|
|
37
|
-
export function cancelRun(id, reason = 'stopped') {
|
|
38
|
-
const run = runs.get(id);
|
|
39
|
-
return run ? run.cancel(reason) : false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Used on shutdown: leaving a CLI running after the bridge exits is how orphans are made. */
|
|
43
|
-
export function cancelAll(reason = 'shutdown') {
|
|
44
|
-
let n = 0;
|
|
45
|
-
for (const run of runs.values()) if (run.cancel(reason)) n += 1;
|
|
46
|
-
return n;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const activeRuns = () => runs.size;
|
|
1
|
+
const r=new Map;function l(n){const t=new AbortController,e=new Set,o={id:n,signal:t.signal,track(c){c?.pid&&(e.add(c),c.once?.("exit",()=>e.delete(c)))},cancel(c="stopped"){return o.cancelled?!1:(o.cancelled=c,t.abort(),!0)},cancelled:null,children:e};return r.set(n,o),o}function u(n){r.delete(n)}function a(n,t="stopped"){const e=r.get(n);return e?e.cancel(t):!1}function s(n="shutdown"){let t=0;for(const e of r.values())e.cancel(n)&&(t+=1);return t}const f=()=>r.size;export{f as activeRuns,s as cancelAll,a as cancelRun,u as endRun,l as startRun};
|
package/src/sanitize.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// This file used to be a HAND copy of chatpanel-pii/sanitize.js, kept in step by memory — the
|
|
4
|
-
// exact drift the vendoring scripts exist to prevent. The engine is now vendored properly under
|
|
5
|
-
// src/pii/ (npm run sync:pii, with a --check drift guard), so this is a re-export and there is
|
|
6
|
-
// only one copy in the repo to diverge from. Existing importers are unchanged.
|
|
7
|
-
export { hasHiddenChars, sanitizeUnicode, stripHidden, SANITIZE_RANGES } from './pii/sanitize.js';
|
|
1
|
+
import{hasHiddenChars as e,sanitizeUnicode as n,stripHidden as r,SANITIZE_RANGES as s}from"./pii/sanitize.js";export{s as SANITIZE_RANGES,e as hasHiddenChars,n as sanitizeUnicode,r as stripHidden};
|
package/src/scm.js
CHANGED
|
@@ -1,76 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// The repository is the source of truth for a project that is code (architecture-pillars.md
|
|
4
|
-
// §14): the board holds the conversation, the job board the intent, but what an agent DID
|
|
5
|
-
// lives in branches and commits in the hub the organisation already uses. The bridge adds
|
|
6
|
-
// no git client — the coding agents know `git` — but it is the one process that knows
|
|
7
|
-
// where the agent worked and can look before and after, so it reports: which repo, which
|
|
8
|
-
// branch, HEAD when the run started, HEAD when it ended, and how many commits lie between.
|
|
9
|
-
// The runner puts that on the task and on the agent's scorecard, where a merged PR will be
|
|
10
|
-
// the one outcome fact that does not come from a judge.
|
|
11
|
-
//
|
|
12
|
-
// Read-only, never writes, never fails a run: a directory that is not a checkout, or a
|
|
13
|
-
// machine without git, is `null` and nothing is announced. Every call is bounded by a short
|
|
14
|
-
// timeout — `git` on a network filesystem must not stall a chat.
|
|
15
|
-
|
|
16
|
-
import { execFile } from 'node:child_process';
|
|
17
|
-
|
|
18
|
-
const GIT_TIMEOUT_MS = 2500;
|
|
19
|
-
|
|
20
|
-
/** One git query; '' on any failure (no git, not a repo, timed out). */
|
|
21
|
-
function git(dir, args, { exec = execFile } = {}) {
|
|
22
|
-
return new Promise((resolve) => {
|
|
23
|
-
let done = false;
|
|
24
|
-
const finish = (v) => { if (!done) { done = true; resolve(v); } };
|
|
25
|
-
try {
|
|
26
|
-
exec('git', ['-C', dir, ...args], { timeout: GIT_TIMEOUT_MS, windowsHide: true, maxBuffer: 1 << 20 }, (err, stdout) => finish(err ? '' : String(stdout || '').trim()));
|
|
27
|
-
} catch { finish(''); }
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The checkout at `dir`, or null. `{ repo, remote, branch, head, dirty }` — `repo` is the
|
|
33
|
-
* worktree's top level, `remote` the origin URL when there is one (with any credential
|
|
34
|
-
* stripped: a token in a URL is not something to put on a record), `branch` the current one
|
|
35
|
-
* ('HEAD' when detached), `head` the full commit, `dirty` whether anything is uncommitted.
|
|
36
|
-
*/
|
|
37
|
-
export async function gitState(dir, opts = {}) {
|
|
38
|
-
if (!dir) return null;
|
|
39
|
-
const repo = await git(dir, ['rev-parse', '--show-toplevel'], opts);
|
|
40
|
-
if (!repo) return null;
|
|
41
|
-
const [branch, head, remote, status] = await Promise.all([
|
|
42
|
-
git(dir, ['rev-parse', '--abbrev-ref', 'HEAD'], opts),
|
|
43
|
-
git(dir, ['rev-parse', 'HEAD'], opts),
|
|
44
|
-
git(dir, ['remote', 'get-url', 'origin'], opts),
|
|
45
|
-
git(dir, ['status', '--porcelain', '--untracked-files=no'], opts),
|
|
46
|
-
]);
|
|
47
|
-
return {
|
|
48
|
-
repo,
|
|
49
|
-
...(remote ? { remote: stripCredential(remote) } : {}),
|
|
50
|
-
branch: branch || 'HEAD',
|
|
51
|
-
...(head ? { head } : {}),
|
|
52
|
-
dirty: status.length > 0,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** `https://user:token@host/…` → `https://host/…`. */
|
|
57
|
-
export function stripCredential(url) {
|
|
58
|
-
return String(url || '').replace(/^([a-z][a-z0-9+.-]*:\/\/)[^@/]+@/i, '$1');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* What the run changed: the state after, plus `commits` — how many lie between the HEAD it
|
|
63
|
-
* started at and the HEAD it ended at (0 when unchanged or unknowable). `before` is what
|
|
64
|
-
* `gitState` returned at the start; a run that began outside a checkout can still end in
|
|
65
|
-
* one (an agent that cloned), so `after` is read regardless.
|
|
66
|
-
*/
|
|
67
|
-
export async function gitDelta(dir, before, opts = {}) {
|
|
68
|
-
const after = await gitState(dir, opts);
|
|
69
|
-
if (!after) return null;
|
|
70
|
-
let commits = 0;
|
|
71
|
-
if (before?.head && after.head && before.head !== after.head) {
|
|
72
|
-
const n = await git(dir, ['rev-list', '--count', `${before.head}..${after.head}`], opts);
|
|
73
|
-
commits = Number(n) || 0;
|
|
74
|
-
}
|
|
75
|
-
return { ...after, ...(before?.head ? { headBefore: before.head } : {}), commits };
|
|
76
|
-
}
|
|
1
|
+
import{execFile as l}from"node:child_process";const s=2500;function u(e,t,{exec:a=l}={}){return new Promise(r=>{let n=!1;const i=o=>{n||(n=!0,r(o))};try{a("git",["-C",e,...t],{timeout:s,windowsHide:!0,maxBuffer:1<<20},(o,c)=>i(o?"":String(c||"").trim()))}catch{i("")}})}async function h(e,t={}){if(!e)return null;const a=await u(e,["rev-parse","--show-toplevel"],t);if(!a)return null;const[r,n,i,o]=await Promise.all([u(e,["rev-parse","--abbrev-ref","HEAD"],t),u(e,["rev-parse","HEAD"],t),u(e,["remote","get-url","origin"],t),u(e,["status","--porcelain","--untracked-files=no"],t)]);return{repo:a,...i?{remote:f(i)}:{},branch:r||"HEAD",...n?{head:n}:{},dirty:o.length>0}}function f(e){return String(e||"").replace(/^([a-z][a-z0-9+.-]*:\/\/)[^@/]+@/i,"$1")}async function d(e,t,a={}){const r=await h(e,a);if(!r)return null;let n=0;if(t?.head&&r.head&&t.head!==r.head){const i=await u(e,["rev-list","--count",`${t.head}..${r.head}`],a);n=Number(i)||0}return{...r,...t?.head?{headBefore:t.head}:{},commits:n}}export{d as gitDelta,h as gitState,f as stripCredential};
|