@spinabot/brigade 1.13.0 → 1.15.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/convex/logs.d.ts +9 -9
- package/convex/memory.d.ts +21 -21
- package/convex/schema.d.ts +11 -11
- package/convex/skills.d.ts +3 -3
- package/dist/buildstamp.json +1 -1
- package/dist/cli/commands/config-cmd.d.ts +12 -19
- package/dist/cli/commands/config-cmd.d.ts.map +1 -1
- package/dist/cli/commands/config-cmd.js +14 -197
- package/dist/cli/commands/config-cmd.js.map +1 -1
- package/dist/cli/commands/connect-transcript.d.ts +39 -0
- package/dist/cli/commands/connect-transcript.d.ts.map +1 -0
- package/dist/cli/commands/connect-transcript.js +60 -0
- package/dist/cli/commands/connect-transcript.js.map +1 -0
- package/dist/cli/commands/connect.d.ts.map +1 -1
- package/dist/cli/commands/connect.js +297 -169
- package/dist/cli/commands/connect.js.map +1 -1
- package/dist/core/agents-crud-ops.d.ts +15 -0
- package/dist/core/agents-crud-ops.d.ts.map +1 -0
- package/dist/core/agents-crud-ops.js +27 -0
- package/dist/core/agents-crud-ops.js.map +1 -0
- package/dist/core/agents-ops.d.ts +43 -0
- package/dist/core/agents-ops.d.ts.map +1 -0
- package/dist/core/agents-ops.js +117 -0
- package/dist/core/agents-ops.js.map +1 -0
- package/dist/core/channels-ops.d.ts +30 -0
- package/dist/core/channels-ops.d.ts.map +1 -0
- package/dist/core/channels-ops.js +52 -0
- package/dist/core/channels-ops.js.map +1 -0
- package/dist/core/config-ops.d.ts +77 -0
- package/dist/core/config-ops.d.ts.map +1 -0
- package/dist/core/config-ops.js +241 -0
- package/dist/core/config-ops.js.map +1 -0
- package/dist/core/exec-ops.d.ts +48 -0
- package/dist/core/exec-ops.d.ts.map +1 -0
- package/dist/core/exec-ops.js +101 -0
- package/dist/core/exec-ops.js.map +1 -0
- package/dist/core/integrations-ops.d.ts +25 -0
- package/dist/core/integrations-ops.d.ts.map +1 -0
- package/dist/core/integrations-ops.js +40 -0
- package/dist/core/integrations-ops.js.map +1 -0
- package/dist/core/memory-ops.d.ts +20 -0
- package/dist/core/memory-ops.d.ts.map +1 -0
- package/dist/core/memory-ops.js +40 -0
- package/dist/core/memory-ops.js.map +1 -0
- package/dist/core/pairing-ops.d.ts +33 -0
- package/dist/core/pairing-ops.d.ts.map +1 -0
- package/dist/core/pairing-ops.js +78 -0
- package/dist/core/pairing-ops.js.map +1 -0
- package/dist/core/provider-ops.d.ts +17 -0
- package/dist/core/provider-ops.d.ts.map +1 -0
- package/dist/core/provider-ops.js +29 -0
- package/dist/core/provider-ops.js.map +1 -0
- package/dist/core/server.d.ts.map +1 -1
- package/dist/core/server.js +261 -14
- package/dist/core/server.js.map +1 -1
- package/dist/core/sessions-ops.d.ts +25 -0
- package/dist/core/sessions-ops.d.ts.map +1 -0
- package/dist/core/sessions-ops.js +77 -0
- package/dist/core/sessions-ops.js.map +1 -0
- package/dist/core/skills-ops.d.ts +14 -0
- package/dist/core/skills-ops.d.ts.map +1 -0
- package/dist/core/skills-ops.js +28 -0
- package/dist/core/skills-ops.js.map +1 -0
- package/dist/protocol/errors.d.ts +14 -0
- package/dist/protocol/errors.d.ts.map +1 -1
- package/dist/protocol/errors.js +14 -0
- package/dist/protocol/errors.js.map +1 -1
- package/dist/protocol/handshake.d.ts +10 -0
- package/dist/protocol/handshake.d.ts.map +1 -1
- package/dist/protocol/methods.d.ts +478 -0
- package/dist/protocol/methods.d.ts.map +1 -1
- package/dist/protocol/stream-seq.d.ts +30 -0
- package/dist/protocol/stream-seq.d.ts.map +1 -0
- package/dist/protocol/stream-seq.js +38 -0
- package/dist/protocol/stream-seq.js.map +1 -0
- package/dist/protocol.d.ts +265 -6
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +95 -5
- package/dist/protocol.js.map +1 -1
- package/dist/tui/client.d.ts +67 -2
- package/dist/tui/client.d.ts.map +1 -1
- package/dist/tui/client.js +106 -2
- package/dist/tui/client.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration control behind the `composio` and `oauth` gateway RPCs — the
|
|
3
|
+
* Composio connector (1,000+ apps) and the DIY OAuth-2 authorize flow, reachable
|
|
4
|
+
* from a remote client.
|
|
5
|
+
*
|
|
6
|
+
* Both reuse the owner-scoped tools (ctx-free execute; owner-gating is a session
|
|
7
|
+
* wrapper). Operator-scoped (allowlisted in the guard-sweep). Action-based,
|
|
8
|
+
* mirroring the tools 1:1.
|
|
9
|
+
*
|
|
10
|
+
* REMOTE NOTES:
|
|
11
|
+
* - `composio` is fully remote-capable: Composio HOSTS the OAuth callback, so
|
|
12
|
+
* `connect` returns a click-link the operator opens anywhere and the gateway
|
|
13
|
+
* just polls `status` — no gateway loopback involved.
|
|
14
|
+
* - `oauth` is the DIY loopback flow: `start` opens a 127.0.0.1 listener ON THE
|
|
15
|
+
* GATEWAY HOST with a loopback redirect_uri, so the round-trip only completes
|
|
16
|
+
* when the operator's browser can reach the GATEWAY's loopback (local to the
|
|
17
|
+
* gateway, or tunneled). A pure-remote browser would hit its OWN loopback.
|
|
18
|
+
* `status`/`token` work remotely. For remote app integrations prefer
|
|
19
|
+
* `composio`.
|
|
20
|
+
*/
|
|
21
|
+
import { DEFAULT_AGENT_ID } from "../agents/routing/session-key.js";
|
|
22
|
+
import { makeComposioTool } from "../agents/tools/composio-tool.js";
|
|
23
|
+
import { makeOAuthAuthorizeTool } from "../agents/tools/oauth-authorize-tool.js";
|
|
24
|
+
/** `composio` — Composio connector: set-key/apps/connect/status/search/execute/disconnect/refresh. */
|
|
25
|
+
export async function handleComposio(params) {
|
|
26
|
+
const p = (params ?? {});
|
|
27
|
+
const agentId = (p.agentId ?? "").trim() || DEFAULT_AGENT_ID;
|
|
28
|
+
const tool = makeComposioTool({ agentId });
|
|
29
|
+
const res = await tool.execute("gateway", params);
|
|
30
|
+
return res.details;
|
|
31
|
+
}
|
|
32
|
+
/** `oauth` — DIY OAuth-2 authorize: start/await/cancel/status/token (see loopback caveat above). */
|
|
33
|
+
export async function handleOauth(params) {
|
|
34
|
+
const p = (params ?? {});
|
|
35
|
+
const agentId = (p.agentId ?? "").trim() || DEFAULT_AGENT_ID;
|
|
36
|
+
const tool = makeOAuthAuthorizeTool({ agentId });
|
|
37
|
+
const res = await tool.execute("gateway", params);
|
|
38
|
+
return res.details;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=integrations-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrations-ops.js","sourceRoot":"","sources":["../../src/core/integrations-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAe;IACnD,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAyB,CAAC;IACjD,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,gBAAgB,CAAC;IAC7D,MAAM,IAAI,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAe,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,OAAO,CAAC;AACpB,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAe;IAChD,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAyB,CAAC;IACjD,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,gBAAgB,CAAC;IAC7D,MAAM,IAAI,GAAG,sBAAsB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAe,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,OAAO,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory (Tideline) write + governance behind the `memory.*` gateway RPCs — the
|
|
3
|
+
* write_memory + manage_memory surface, reachable from a remote client.
|
|
4
|
+
*
|
|
5
|
+
* Memory lives in `facts.jsonl` (a store, NOT brigade.json), so `config.set`
|
|
6
|
+
* cannot reach it — these RPCs are the only typed remote path to MUTATE memory.
|
|
7
|
+
* READ is already covered by the `memory-query` (list/search/inspect/stats) and
|
|
8
|
+
* `memory-graph` RPCs.
|
|
9
|
+
*
|
|
10
|
+
* OPERATOR-SCOPED: operates on the OWNER origin over the agent's workspace,
|
|
11
|
+
* exactly like the tools (filesystem AND Convex modes). Reuses the SAME
|
|
12
|
+
* write_memory / manage_memory tool logic — their `execute()` is pure (owner-
|
|
13
|
+
* gating is a session wrapper, not inside execute), so invoking them with an
|
|
14
|
+
* owner scope from the gateway is correct and byte-identical to a turn.
|
|
15
|
+
*/
|
|
16
|
+
/** `memory.write` — persist a durable fact. Params mirror the write_memory tool. */
|
|
17
|
+
export declare function handleMemoryWrite(params: unknown): Promise<unknown>;
|
|
18
|
+
/** `memory.manage` — dream/purge/inspect/export/retention/vault/retract/restore/relink. */
|
|
19
|
+
export declare function handleMemoryManage(params: unknown): Promise<unknown>;
|
|
20
|
+
//# sourceMappingURL=memory-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-ops.d.ts","sourceRoot":"","sources":["../../src/core/memory-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,oFAAoF;AACpF,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAMzE;AAED,2FAA2F;AAC3F,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAM1E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory (Tideline) write + governance behind the `memory.*` gateway RPCs — the
|
|
3
|
+
* write_memory + manage_memory surface, reachable from a remote client.
|
|
4
|
+
*
|
|
5
|
+
* Memory lives in `facts.jsonl` (a store, NOT brigade.json), so `config.set`
|
|
6
|
+
* cannot reach it — these RPCs are the only typed remote path to MUTATE memory.
|
|
7
|
+
* READ is already covered by the `memory-query` (list/search/inspect/stats) and
|
|
8
|
+
* `memory-graph` RPCs.
|
|
9
|
+
*
|
|
10
|
+
* OPERATOR-SCOPED: operates on the OWNER origin over the agent's workspace,
|
|
11
|
+
* exactly like the tools (filesystem AND Convex modes). Reuses the SAME
|
|
12
|
+
* write_memory / manage_memory tool logic — their `execute()` is pure (owner-
|
|
13
|
+
* gating is a session wrapper, not inside execute), so invoking them with an
|
|
14
|
+
* owner scope from the gateway is correct and byte-identical to a turn.
|
|
15
|
+
*/
|
|
16
|
+
import { FactStore } from "../agents/memory/records.js";
|
|
17
|
+
import { makeManageMemoryTool } from "../agents/tools/manage-memory-tool.js";
|
|
18
|
+
import { makeWriteMemoryTool } from "../agents/tools/memory-tools.js";
|
|
19
|
+
import { DEFAULT_AGENT_ID, resolveAgentWorkspaceDir } from "../config/paths.js";
|
|
20
|
+
function workspaceFor(agentId) {
|
|
21
|
+
const id = (agentId ?? "").trim() || DEFAULT_AGENT_ID;
|
|
22
|
+
return resolveAgentWorkspaceDir(id);
|
|
23
|
+
}
|
|
24
|
+
/** `memory.write` — persist a durable fact. Params mirror the write_memory tool. */
|
|
25
|
+
export async function handleMemoryWrite(params) {
|
|
26
|
+
const p = (params ?? {});
|
|
27
|
+
const store = new FactStore(workspaceFor(p.agentId));
|
|
28
|
+
const tool = makeWriteMemoryTool(store, { senderIsOwner: true });
|
|
29
|
+
const res = await tool.execute("gateway", params);
|
|
30
|
+
return res.details;
|
|
31
|
+
}
|
|
32
|
+
/** `memory.manage` — dream/purge/inspect/export/retention/vault/retract/restore/relink. */
|
|
33
|
+
export async function handleMemoryManage(params) {
|
|
34
|
+
const p = (params ?? {});
|
|
35
|
+
const agentId = (p.agentId ?? "").trim() || DEFAULT_AGENT_ID;
|
|
36
|
+
const tool = makeManageMemoryTool(workspaceFor(agentId), { agentId });
|
|
37
|
+
const res = await tool.execute("gateway", params);
|
|
38
|
+
return res.details;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=memory-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-ops.js","sourceRoot":"","sources":["../../src/core/memory-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,SAAS,YAAY,CAAC,OAAgB;IACrC,MAAM,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,gBAAgB,CAAC;IACtD,OAAO,wBAAwB,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAe;IACtD,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAyB,CAAC;IACjD,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,mBAAmB,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAe,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,OAAO,CAAC;AACpB,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAe;IACvD,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAyB,CAAC;IACjD,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,gBAAgB,CAAC;IAC7D,MAAM,IAAI,GAAG,oBAAoB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAe,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,OAAO,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel pairing operations behind the `pairing.*` gateway RPCs — the
|
|
3
|
+
* `brigade pairing <list|approve|revoke>` surface, reachable from a remote
|
|
4
|
+
* client.
|
|
5
|
+
*
|
|
6
|
+
* OPERATOR-SCOPED channel access control (approve/deny strangers who DM the
|
|
7
|
+
* bot). Per-channel, never a per-session target, so no per-session guard. The
|
|
8
|
+
* RPCs REQUIRE an explicit `channel` (no CLI-style auto-pick) — a client knows
|
|
9
|
+
* the channel from `system.capabilities`. Reuses the SAME access-control
|
|
10
|
+
* primitives the CLI calls, including the owner-bootstrap + in-channel notify
|
|
11
|
+
* on approve.
|
|
12
|
+
*/
|
|
13
|
+
import { readPendingPairings } from "../agents/channels/access-control/index.js";
|
|
14
|
+
export type PairingListResult = {
|
|
15
|
+
channel: string;
|
|
16
|
+
pending: ReturnType<typeof readPendingPairings>;
|
|
17
|
+
};
|
|
18
|
+
export declare function handlePairingList(params: unknown): PairingListResult;
|
|
19
|
+
export interface PairingApproveResult {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
channel: string;
|
|
22
|
+
sender?: string;
|
|
23
|
+
owner?: boolean;
|
|
24
|
+
reason?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function handlePairingApprove(params: unknown): Promise<PairingApproveResult>;
|
|
27
|
+
export interface PairingRevokeResult {
|
|
28
|
+
ok: boolean;
|
|
29
|
+
channel: string;
|
|
30
|
+
reason?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function handlePairingRevoke(params: unknown): PairingRevokeResult;
|
|
33
|
+
//# sourceMappingURL=pairing-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing-ops.d.ts","sourceRoot":"","sources":["../../src/core/pairing-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAGN,mBAAmB,EAGnB,MAAM,4CAA4C,CAAC;AAqBpD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CAChD,CAAC;AACF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAKpE;AAED,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0BzF;AAED,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,mBAAmB,CAQxE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel pairing operations behind the `pairing.*` gateway RPCs — the
|
|
3
|
+
* `brigade pairing <list|approve|revoke>` surface, reachable from a remote
|
|
4
|
+
* client.
|
|
5
|
+
*
|
|
6
|
+
* OPERATOR-SCOPED channel access control (approve/deny strangers who DM the
|
|
7
|
+
* bot). Per-channel, never a per-session target, so no per-session guard. The
|
|
8
|
+
* RPCs REQUIRE an explicit `channel` (no CLI-style auto-pick) — a client knows
|
|
9
|
+
* the channel from `system.capabilities`. Reuses the SAME access-control
|
|
10
|
+
* primitives the CLI calls, including the owner-bootstrap + in-channel notify
|
|
11
|
+
* on approve.
|
|
12
|
+
*/
|
|
13
|
+
import { approvePairingCode, readChannelOwner, readPendingPairings, revokePairingCode, setChannelOwner, } from "../agents/channels/access-control/index.js";
|
|
14
|
+
import { BUNDLED_MODULES, loadModules } from "../agents/extensions/index.js";
|
|
15
|
+
import { DEFAULT_AGENT_ID, resolveAgentWorkspaceDir } from "../config/paths.js";
|
|
16
|
+
import { loadConfig } from "./config.js";
|
|
17
|
+
/** Best-effort adapter lookup — only `approve` needs it (owner-bootstrap + notify). */
|
|
18
|
+
async function resolveAdapter(channel) {
|
|
19
|
+
try {
|
|
20
|
+
const config = loadConfig();
|
|
21
|
+
const workspaceDir = resolveAgentWorkspaceDir(DEFAULT_AGENT_ID);
|
|
22
|
+
const registry = await loadModules({
|
|
23
|
+
modules: BUNDLED_MODULES,
|
|
24
|
+
meta: { agentId: DEFAULT_AGENT_ID, workspaceDir, cwd: workspaceDir, config: config },
|
|
25
|
+
});
|
|
26
|
+
return registry.channels.find((c) => c.id === channel);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function handlePairingList(params) {
|
|
33
|
+
const p = (params ?? {});
|
|
34
|
+
const channel = (p.channel ?? "").trim();
|
|
35
|
+
if (!channel)
|
|
36
|
+
throw new Error("pairing.list: missing 'channel'");
|
|
37
|
+
return { channel, pending: readPendingPairings(channel) };
|
|
38
|
+
}
|
|
39
|
+
export async function handlePairingApprove(params) {
|
|
40
|
+
const p = (params ?? {});
|
|
41
|
+
const channel = (p.channel ?? "").trim();
|
|
42
|
+
const code = (p.code ?? "").trim();
|
|
43
|
+
if (!channel || !code)
|
|
44
|
+
return { ok: false, channel, reason: "missing 'channel' or 'code'" };
|
|
45
|
+
const approved = approvePairingCode(channel, code);
|
|
46
|
+
if (!approved)
|
|
47
|
+
return { ok: false, channel, reason: "unknown or expired pairing code" };
|
|
48
|
+
// Owner bootstrap (bot-separate channels like Telegram): the first approved
|
|
49
|
+
// sender becomes the recorded owner so they can run admin commands. Reaching
|
|
50
|
+
// this RPC already proves operator access. Never overwrites an existing owner.
|
|
51
|
+
let becameOwner = false;
|
|
52
|
+
const adapter = await resolveAdapter(channel);
|
|
53
|
+
if (adapter?.pairing?.botIsSeparateFromOperator && !readChannelOwner(channel)) {
|
|
54
|
+
becameOwner = setChannelOwner(channel, approved.senderId);
|
|
55
|
+
}
|
|
56
|
+
// Best-effort in-channel "you're approved" reply when the adapter wires it.
|
|
57
|
+
const notify = adapter?.pairing?.notifyApproval;
|
|
58
|
+
if (notify) {
|
|
59
|
+
try {
|
|
60
|
+
await notify({ senderId: approved.senderId, senderName: approved.senderName });
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
/* non-fatal — the approval already landed in the allow-list */
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { ok: true, channel, sender: approved.senderId, owner: becameOwner };
|
|
67
|
+
}
|
|
68
|
+
export function handlePairingRevoke(params) {
|
|
69
|
+
const p = (params ?? {});
|
|
70
|
+
const channel = (p.channel ?? "").trim();
|
|
71
|
+
const code = (p.code ?? "").trim();
|
|
72
|
+
if (!channel || !code)
|
|
73
|
+
return { ok: false, channel, reason: "missing 'channel' or 'code'" };
|
|
74
|
+
return revokePairingCode(channel, code)
|
|
75
|
+
? { ok: true, channel }
|
|
76
|
+
: { ok: false, channel, reason: "no matching pending code" };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=pairing-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing-ops.js","sourceRoot":"","sources":["../../src/core/pairing-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GACf,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,uFAAuF;AACvF,KAAK,UAAU,cAAc,CAAC,OAAe;IAC5C,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC;YAClC,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAe,EAAE;SAC7F,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC;AAMD,MAAM,UAAU,iBA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-provider` adds a key, but there was NO way to REMOVE one
|
|
5
|
+
* over the gateway — keys live in `auth-profiles.json` (not config, so config.set
|
|
6
|
+
* can't reach them) and no tool exposes removal. This closes it. Operator-scoped
|
|
7
|
+
* per-agent (no per-session guard — allowlisted).
|
|
8
|
+
*/
|
|
9
|
+
export interface ProviderRemoveResult {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
providerId: string;
|
|
12
|
+
agentId: string;
|
|
13
|
+
removed: number;
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function handleProviderRemove(params: unknown): ProviderRemoveResult;
|
|
17
|
+
//# sourceMappingURL=provider-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-ops.d.ts","sourceRoot":"","sources":["../../src/core/provider-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,oBAAoB,CAe1E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-key removal behind the `provider.remove` gateway RPC.
|
|
3
|
+
*
|
|
4
|
+
* The genuine gap: `add-provider` adds a key, but there was NO way to REMOVE one
|
|
5
|
+
* over the gateway — keys live in `auth-profiles.json` (not config, so config.set
|
|
6
|
+
* can't reach them) and no tool exposes removal. This closes it. Operator-scoped
|
|
7
|
+
* per-agent (no per-session guard — allowlisted).
|
|
8
|
+
*/
|
|
9
|
+
import { readProfiles, writeProfiles } from "../auth/profiles.js";
|
|
10
|
+
import { DEFAULT_AGENT_ID } from "../config/paths.js";
|
|
11
|
+
export function handleProviderRemove(params) {
|
|
12
|
+
const p = (params ?? {});
|
|
13
|
+
const providerId = (p.providerId ?? "").trim().toLowerCase();
|
|
14
|
+
const agentId = (p.agentId ?? "").trim() || DEFAULT_AGENT_ID;
|
|
15
|
+
if (!providerId)
|
|
16
|
+
return { ok: false, providerId, agentId, removed: 0, reason: "missing 'providerId'" };
|
|
17
|
+
const file = readProfiles(agentId);
|
|
18
|
+
let removed = 0;
|
|
19
|
+
for (const [key, profile] of Object.entries(file.profiles)) {
|
|
20
|
+
if ((profile.provider ?? "").trim().toLowerCase() === providerId) {
|
|
21
|
+
delete file.profiles[key];
|
|
22
|
+
removed++;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (removed > 0)
|
|
26
|
+
writeProfiles(agentId, file);
|
|
27
|
+
return { ok: removed > 0, providerId, agentId, removed, ...(removed === 0 ? { reason: "no key found for that provider" } : {}) };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=provider-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-ops.js","sourceRoot":"","sources":["../../src/core/provider-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,MAAM,UAAU,oBAAoB,CAAC,MAAe;IACnD,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAA8C,CAAC;IACtE,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7D,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,gBAAgB,CAAC;IAC7D,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACvG,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE,CAAC;YAClE,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1B,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC;IACD,IAAI,OAAO,GAAG,CAAC;QAAE,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,gCAAgC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAClI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA8SH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAUzD,MAAM,WAAW,aAAa;IAC7B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AA8FD,wBAAsB,WAAW,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAwKjF"}
|