@rubytech/create-maxy-code 0.1.302 → 0.1.304
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/dist/__tests__/install-immutability.test.js +55 -0
- package/dist/index.js +46 -1
- package/dist/install-immutability.js +59 -0
- package/package.json +1 -1
- package/payload/platform/plugins/admin/hooks/__tests__/prompt-optimiser-compliance.test.sh +12 -0
- package/payload/platform/plugins/admin/hooks/prompt-optimiser-compliance.sh +10 -6
- package/payload/platform/plugins/admin/skills/access-manager/SKILL.md +1 -0
- package/payload/platform/plugins/admin/skills/access-manager/references/operations.md +22 -0
- package/payload/platform/plugins/docs/references/admin-session.md +2 -0
- package/payload/platform/plugins/whatsapp/skills/connect-whatsapp/SKILL.md +4 -4
- package/payload/platform/scripts/__tests__/check-no-task-id-leaks.test.sh +28 -0
- package/payload/platform/scripts/check-no-task-id-leaks.mjs +43 -8
- package/payload/platform/services/claude-session-manager/dist/channel-mcp.d.ts +15 -0
- package/payload/platform/services/claude-session-manager/dist/channel-mcp.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/channel-mcp.js +34 -0
- package/payload/platform/services/claude-session-manager/dist/channel-mcp.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/channel-targets.d.ts +26 -0
- package/payload/platform/services/claude-session-manager/dist/channel-targets.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/channel-targets.js +19 -0
- package/payload/platform/services/claude-session-manager/dist/channel-targets.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +80 -51
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +15 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.js +13 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.d.ts +8 -0
- package/payload/platform/services/whatsapp-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.js +183 -21
- package/payload/platform/services/whatsapp-channel/dist/server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts +82 -0
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts.map +1 -0
- package/payload/platform/services/whatsapp-channel/dist/targets.js +131 -0
- package/payload/platform/services/whatsapp-channel/dist/targets.js.map +1 -0
- package/payload/premium-plugins/venture-studio/skills/prototype-host/SKILL.md +1 -1
- package/payload/premium-plugins/writer-craft/PLUGIN.md +4 -4
- package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +4 -4
- package/payload/server/{chunk-JHSF5VPE.js → chunk-TUY3RB5G.js} +4 -0
- package/payload/server/maxy-edge.js +2 -2
- package/payload/server/public/assets/AdminLoginScreens-BXKCagZn.js +1 -0
- package/payload/server/public/assets/AdminShell-CxKd_V3O.js +1 -0
- package/payload/server/public/assets/{Checkbox-CTB1YICm.js → Checkbox-BHmeAgrw.js} +1 -1
- package/payload/server/public/assets/Transcript-DPDJitcb.js +1 -0
- package/payload/server/public/assets/admin-DHLuBUtk.js +1 -0
- package/payload/server/public/assets/{audio-attachment-mime-B6GLbrSj.js → audio-attachment-mime-BxI3Kl4_.js} +1 -1
- package/payload/server/public/assets/{browser-Df57jxpr.js → browser-DgtLMsM1.js} +1 -1
- package/payload/server/public/assets/chat-Ib78Kdhg.js +1 -0
- package/payload/server/public/assets/data-C317FUk4.js +1 -0
- package/payload/server/public/assets/file-download-DXFcVkh6.js +1 -0
- package/payload/server/public/assets/{graph-BqdF9YLX.js → graph-CHf_9bmD.js} +2 -2
- package/payload/server/public/assets/{graph-labels-Bv6MHqfG.js → graph-labels-BbiX-sz-.js} +1 -1
- package/payload/server/public/assets/{jsx-runtime-DuiIXAPx.css → jsx-runtime-BkXvvpkS.css} +1 -1
- package/payload/server/public/assets/operator-BJ5tN5vl.js +1 -0
- package/payload/server/public/assets/page-CjuqiMAQ.js +1 -0
- package/payload/server/public/assets/{public-B3qyifbI.js → public-D3G4tgFu.js} +1 -1
- package/payload/server/public/assets/{useSelectionMode-FzQBlPMx.js → useSelectionMode-DcgaoBP6.js} +1 -1
- package/payload/server/public/browser.html +6 -6
- package/payload/server/public/chat.html +9 -9
- package/payload/server/public/data.html +5 -5
- package/payload/server/public/graph.html +8 -8
- package/payload/server/public/index.html +10 -9
- package/payload/server/public/operator.html +12 -10
- package/payload/server/public/public.html +6 -6
- package/payload/server/server.js +777 -571
- package/payload/server/public/assets/AdminShell-CKQFuyG1.js +0 -1
- package/payload/server/public/assets/Transcript-ClvmtDzk.js +0 -1
- package/payload/server/public/assets/admin-STC3C8ed.js +0 -1
- package/payload/server/public/assets/chat-B9ZI_e8i.js +0 -1
- package/payload/server/public/assets/data-BYiwvhSl.js +0 -1
- package/payload/server/public/assets/file-download-CU0xHXGF.js +0 -1
- package/payload/server/public/assets/operator-lvmlNtX0.js +0 -1
- package/payload/server/public/assets/page-lv61ROf4.js +0 -1
- /package/payload/server/public/assets/{500-CWMpccrR.css → AdminLoginScreens-CWMpccrR.css} +0 -0
- /package/payload/server/public/assets/{jsx-runtime-Brvwqc85.js → jsx-runtime-BabLCDgS.js} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Task 848 — acceptance grid for install-immutability.ts.
|
|
2
|
+
//
|
|
3
|
+
// Pure command-emission module: protectCommands/unprotectCommands return the
|
|
4
|
+
// privileged `chattr` argv that makes the deployed platform source immutable to
|
|
5
|
+
// the agent's user. The caller injects the DetectedPlatform value so tests run
|
|
6
|
+
// identically on Linux CI and Mac developer boxes — no process.platform reads
|
|
7
|
+
// inside the module under test. Three roots are frozen (server, platform,
|
|
8
|
+
// premium-plugins); platform/config is the sole runtime-writable exclusion.
|
|
9
|
+
import test from "node:test";
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import { protectCommands, unprotectCommands, lsattrShowsImmutable, } from "../install-immutability.js";
|
|
12
|
+
const INSTALL = "/home/admin/maxy-code";
|
|
13
|
+
const SERVER = "/home/admin/maxy-code/server";
|
|
14
|
+
const PLATFORM = "/home/admin/maxy-code/platform";
|
|
15
|
+
const PREMIUM = "/home/admin/maxy-code/premium-plugins";
|
|
16
|
+
const CONFIG = "/home/admin/maxy-code/platform/config";
|
|
17
|
+
test("protect freezes the three roots then un-freezes config, in order, on linux", () => {
|
|
18
|
+
assert.deepEqual(protectCommands(INSTALL, "linux"), [
|
|
19
|
+
{ command: "chattr", args: ["-R", "+i", SERVER] },
|
|
20
|
+
{ command: "chattr", args: ["-R", "+i", PLATFORM] },
|
|
21
|
+
{ command: "chattr", args: ["-R", "+i", PREMIUM] },
|
|
22
|
+
{ command: "chattr", args: ["-R", "-i", CONFIG] },
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
test("unprotect emits chattr -R -i on the three roots for linux", () => {
|
|
26
|
+
assert.deepEqual(unprotectCommands(INSTALL, "linux"), [
|
|
27
|
+
{ command: "chattr", args: ["-R", "-i", SERVER] },
|
|
28
|
+
{ command: "chattr", args: ["-R", "-i", PLATFORM] },
|
|
29
|
+
{ command: "chattr", args: ["-R", "-i", PREMIUM] },
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
test("config exclusion is un-frozen last, after its parent platform is frozen", () => {
|
|
33
|
+
const cmds = protectCommands(INSTALL, "linux");
|
|
34
|
+
const platformIdx = cmds.findIndex((c) => c.args[2] === PLATFORM && c.args[1] === "+i");
|
|
35
|
+
const configIdx = cmds.findIndex((c) => c.args[2] === CONFIG && c.args[1] === "-i");
|
|
36
|
+
assert.ok(platformIdx >= 0 && configIdx >= 0);
|
|
37
|
+
assert.ok(platformIdx < configIdx);
|
|
38
|
+
});
|
|
39
|
+
test("emits nothing on darwin", () => {
|
|
40
|
+
assert.deepEqual(protectCommands(INSTALL, "darwin"), []);
|
|
41
|
+
assert.deepEqual(unprotectCommands(INSTALL, "darwin"), []);
|
|
42
|
+
});
|
|
43
|
+
test("emits nothing on unsupported", () => {
|
|
44
|
+
assert.deepEqual(protectCommands(INSTALL, "unsupported"), []);
|
|
45
|
+
assert.deepEqual(unprotectCommands(INSTALL, "unsupported"), []);
|
|
46
|
+
});
|
|
47
|
+
test("lsattrShowsImmutable reads the immutable flag from an lsattr -d line", () => {
|
|
48
|
+
// `lsattr -d <path>` → "<flags> <path>"; the immutable 'i' sits in the flag field.
|
|
49
|
+
assert.equal(lsattrShowsImmutable("----i---------e---- /home/admin/maxy-code/platform"), true);
|
|
50
|
+
assert.equal(lsattrShowsImmutable("-------------e---- /home/admin/maxy-code/platform/config"), false);
|
|
51
|
+
// 'i' only ever occupies the immutable position; a capital 'I' (indexed dir) is distinct.
|
|
52
|
+
assert.equal(lsattrShowsImmutable("---------------I--- /home/admin/maxy-code/platform"), false);
|
|
53
|
+
// empty / malformed output is not immutable.
|
|
54
|
+
assert.equal(lsattrShowsImmutable(""), false);
|
|
55
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,8 @@ import { validateTierFlag, validateEntitlementBase64, applyTierToAccountConfig,
|
|
|
10
10
|
import { parseOsRelease, isUbuntuLike as isUbuntuLikePure, parseAptCacheCandidate, decideAptResolution, } from "./apt-resolve.js";
|
|
11
11
|
import { findPeerBrandOnDefaultNeo4jPort } from "./peer-brand-detect.js";
|
|
12
12
|
import { runInitLogging } from "./init-logging.js";
|
|
13
|
-
import { requireSupportedPlatform } from "./platform-detect.js";
|
|
13
|
+
import { requireSupportedPlatform, detectPlatform } from "./platform-detect.js";
|
|
14
|
+
import { protectCommands, unprotectCommands, lsattrShowsImmutable } from "./install-immutability.js";
|
|
14
15
|
import { renderPlist } from "./launchd-plist.js";
|
|
15
16
|
import { installAllBrewPackages } from "./brew-install.js";
|
|
16
17
|
import { parseSwVers, isSupportedMacosVersion } from "./macos-version.js";
|
|
@@ -1855,6 +1856,21 @@ function deployPayload() {
|
|
|
1855
1856
|
// User data lives at {installDir}/data/ — outside the platform/ wipe zone.
|
|
1856
1857
|
// Install path creates this fresh; runtime writers populate it on demand.
|
|
1857
1858
|
mkdirSync(join(INSTALL_DIR, "data"), { recursive: true });
|
|
1859
|
+
// Task 848 — on upgrade the prior server/, platform/, premium-plugins/ trees are
|
|
1860
|
+
// immutable (chattr +i). Clear all three BEFORE the wipe loop, or the rmSync of
|
|
1861
|
+
// those dirs below fails with EPERM. Gate on INSTALL_DIR existence (any prior
|
|
1862
|
+
// install), not server/ alone — a partial state where server/ was removed but
|
|
1863
|
+
// platform/ stayed frozen must still be unprotected. Fresh install: INSTALL_DIR
|
|
1864
|
+
// not yet created (mkdirSync below), so skip. Linux-only (emits nothing
|
|
1865
|
+
// elsewhere). bestEffort: a missing root chattr-errors harmlessly.
|
|
1866
|
+
const guardPlatform = detectPlatform(process.platform);
|
|
1867
|
+
if (existsSync(INSTALL_DIR)) {
|
|
1868
|
+
for (const c of unprotectCommands(INSTALL_DIR, guardPlatform)) {
|
|
1869
|
+
const target = c.args[c.args.length - 1];
|
|
1870
|
+
console.log(` [agent-guard] op=unprotect target=${target}`);
|
|
1871
|
+
shell(c.command, c.args, { sudo: true, bestEffort: true });
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1858
1874
|
// Wipe deployment directories to prevent stale files.
|
|
1859
1875
|
// data/ is NOT wiped — it contains user data (accounts, uploads) that must survive.
|
|
1860
1876
|
for (const dir of ["platform", "server", "maxy", "premium-plugins", "docs", ".claude"]) {
|
|
@@ -1869,6 +1885,11 @@ function deployPayload() {
|
|
|
1869
1885
|
recursive: true,
|
|
1870
1886
|
force: true,
|
|
1871
1887
|
});
|
|
1888
|
+
// Task 848 — the platform source trees are frozen immutable as the final install
|
|
1889
|
+
// action (see main()), not here: the installer keeps writing under platform/
|
|
1890
|
+
// after this deploy (buildPlatform's npm install, service builds, plugin
|
|
1891
|
+
// registration), so an early freeze would EPERM those writes. The pre-wipe
|
|
1892
|
+
// unprotect above is the matching half on upgrade.
|
|
1872
1893
|
// Link persistent config into install directory
|
|
1873
1894
|
const configDir = join(INSTALL_DIR, "platform/config");
|
|
1874
1895
|
mkdirSync(configDir, { recursive: true });
|
|
@@ -4068,6 +4089,30 @@ try {
|
|
|
4068
4089
|
// step. The smbpasswd `user` step is deferred at install time and synced
|
|
4069
4090
|
// by the platform's /set-pin route when the operator sets a PIN.
|
|
4070
4091
|
provisionSamba();
|
|
4092
|
+
// Task 848 — freeze the platform source trees as the final install action, after
|
|
4093
|
+
// every install-time write under platform/ (buildPlatform's npm install →
|
|
4094
|
+
// platform/node_modules, the service builds under platform/services/*/dist, and
|
|
4095
|
+
// plugin registration). server/, platform/, premium-plugins/ become immutable to
|
|
4096
|
+
// the agent's user; platform/config/ is excluded by protectCommands (it is
|
|
4097
|
+
// runtime-writable). Load-bearing, so the outcome is verified positively: `chattr
|
|
4098
|
+
// -R` exits nonzero on the benign symlinks/special files an npm tree always
|
|
4099
|
+
// contains, so its aggregate exit code is not a reliable signal — instead
|
|
4100
|
+
// re-read each target's own immutable bit with `lsattr -d`. A freeze command
|
|
4101
|
+
// (+i) succeeded iff the target is now immutable; the config exclusion (-i)
|
|
4102
|
+
// succeeded iff it is now mutable. A failed protect does not abort the install;
|
|
4103
|
+
// the drift detector remains the backstop. Linux-only (emits nothing elsewhere).
|
|
4104
|
+
const guardPlatformProtect = detectPlatform(process.platform);
|
|
4105
|
+
for (const c of protectCommands(INSTALL_DIR, guardPlatformProtect)) {
|
|
4106
|
+
const target = c.args[c.args.length - 1];
|
|
4107
|
+
const freezing = c.args.includes("+i");
|
|
4108
|
+
const op = freezing ? "protect" : "protect-exclude";
|
|
4109
|
+
logFile(`> sudo ${c.command} ${c.args.join(" ")}`);
|
|
4110
|
+
spawnSync("sudo", [c.command, ...c.args], { stdio: "pipe", timeout: 30_000 });
|
|
4111
|
+
const probe = spawnSync("lsattr", ["-d", target], { stdio: "pipe", timeout: 10_000 });
|
|
4112
|
+
const immutable = probe.status === 0 && lsattrShowsImmutable(probe.stdout?.toString() ?? "");
|
|
4113
|
+
const ok = freezing ? immutable : !immutable;
|
|
4114
|
+
console.log(` [agent-guard] op=${ok ? op : `${op}-failed`} target=${target}`);
|
|
4115
|
+
}
|
|
4071
4116
|
console.log("");
|
|
4072
4117
|
console.log("================================================================");
|
|
4073
4118
|
console.log("");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Task 848 — OS-level platform boundary. After the installer deploys the
|
|
2
|
+
// platform, three trees are made immutable with `chattr +i` so a
|
|
3
|
+
// confused-but-compliant agent (same user, running under `bypassPermissions`)
|
|
4
|
+
// cannot hand-edit platform code — writes fail with EPERM and the agent reports
|
|
5
|
+
// the platform defect instead of patching the box:
|
|
6
|
+
// - server/ the built server bundle (Task 843, the incident target)
|
|
7
|
+
// - platform/ plugin code, scripts, templates, channel-service dist
|
|
8
|
+
// - premium-plugins/ premium bundle source
|
|
9
|
+
//
|
|
10
|
+
// platform/config/ is the sole runtime-writable subpath under a frozen root
|
|
11
|
+
// (the booting server writes .<hostname>-version there; it also holds brand.json,
|
|
12
|
+
// the chromium path, and the neo4j password), so it is un-frozen last — after its
|
|
13
|
+
// `+i` parent, since immutability is per-inode and a `-i` child dir stays
|
|
14
|
+
// writable. Linux/ext4 only — `chattr` does not exist on darwin, so off-Linux
|
|
15
|
+
// platforms emit nothing and the deploy step is a no-op. This module is pure: it
|
|
16
|
+
// returns the privileged argv but never executes it; the caller runs unprotect
|
|
17
|
+
// before the deploy wipe on upgrade and protect as the final install action.
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
/** Install-relative roots frozen immutable, in apply order. */
|
|
20
|
+
const PROTECTED_ROOTS = ["server", "platform", "premium-plugins"];
|
|
21
|
+
/** Install-relative subpaths under a frozen root that the running platform
|
|
22
|
+
* writes to, so they are un-frozen after the roots are frozen. */
|
|
23
|
+
const WRITABLE_EXCLUSIONS = ["platform/config"];
|
|
24
|
+
/** `chattr -R +i` each protected root, then `chattr -R -i` each writable
|
|
25
|
+
* exclusion; [] on any non-Linux platform. */
|
|
26
|
+
export function protectCommands(installDir, platform) {
|
|
27
|
+
if (platform !== "linux")
|
|
28
|
+
return [];
|
|
29
|
+
const cmds = PROTECTED_ROOTS.map((root) => ({
|
|
30
|
+
command: "chattr",
|
|
31
|
+
args: ["-R", "+i", join(installDir, root)],
|
|
32
|
+
}));
|
|
33
|
+
for (const sub of WRITABLE_EXCLUSIONS) {
|
|
34
|
+
cmds.push({ command: "chattr", args: ["-R", "-i", join(installDir, sub)] });
|
|
35
|
+
}
|
|
36
|
+
return cmds;
|
|
37
|
+
}
|
|
38
|
+
/** `chattr -R -i` each protected root; [] on any non-Linux platform.
|
|
39
|
+
* A writable exclusion needs no separate entry: the recursive `-i` on its
|
|
40
|
+
* parent root descends into it and clears the flag. */
|
|
41
|
+
export function unprotectCommands(installDir, platform) {
|
|
42
|
+
if (platform !== "linux")
|
|
43
|
+
return [];
|
|
44
|
+
return PROTECTED_ROOTS.map((root) => ({
|
|
45
|
+
command: "chattr",
|
|
46
|
+
args: ["-R", "-i", join(installDir, root)],
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
/** True iff an `lsattr -d <path>` output line shows the immutable ('i') flag.
|
|
50
|
+
* `lsattr -d` prints "<flags> <path>"; the immutable attribute uniquely
|
|
51
|
+
* occupies the lowercase-'i' position in the flag field, so a substring test on
|
|
52
|
+
* the first whitespace-delimited token is exact. Used to verify a freeze took:
|
|
53
|
+
* `chattr -R` exits nonzero on the benign symlinks/special files an npm tree
|
|
54
|
+
* always contains, so its aggregate exit code is not a reliable success signal —
|
|
55
|
+
* re-reading the target's own immutable bit is. */
|
|
56
|
+
export function lsattrShowsImmutable(lsattrLine) {
|
|
57
|
+
const flags = lsattrLine.trim().split(/\s+/)[0] ?? "";
|
|
58
|
+
return flags.includes("i");
|
|
59
|
+
}
|
package/package.json
CHANGED
|
@@ -56,6 +56,10 @@ CHANNEL_REFRAME='{"type":"user","isMeta":true,"message":{"role":"user","content"
|
|
|
56
56
|
# payload, not the wrapper (the always-present instruction text would otherwise
|
|
57
57
|
# make every reframed turn look non-trivial).
|
|
58
58
|
CHANNEL_REFRAME_TRIVIAL='{"type":"user","isMeta":true,"message":{"role":"user","content":"<channel source=\"whatsapp-channel\">## Context\nyes\n\n## Instruction\nChoose the installed specialist that owns this request and dispatch it with the Agent tool.</channel>"}}'
|
|
59
|
+
# Task 853 — multi-target (unified server) shape: the harness wraps with the
|
|
60
|
+
# registration key `channel`, and the server embeds an inner source tag, so the
|
|
61
|
+
# reframe arrives DOUBLE-wrapped. The strip must iterate to reach ## Context.
|
|
62
|
+
CHANNEL_REFRAME_MULTI='{"type":"user","isMeta":true,"message":{"role":"user","content":"<channel source=\"channel\">\n<channel source=\"whatsapp\">\n## Context\nplease draft the works order PDF for order 926\n\n## Instruction\nChoose the installed specialist that owns this request and dispatch it with the Agent tool.\n</channel>\n</channel>"}}'
|
|
59
63
|
|
|
60
64
|
assert_flagged() {
|
|
61
65
|
local name="$1" t="$2" out
|
|
@@ -169,6 +173,14 @@ assert_not_flagged "reframe turn + Agent dispatch -> not flagged" \
|
|
|
169
173
|
# even though the wrapper text is long.
|
|
170
174
|
assert_not_flagged "reframe turn with one-word Context payload -> not flagged (trivial)" \
|
|
171
175
|
"$(mk_transcript "$CHANNEL_REFRAME_TRIVIAL" "$ASSISTANT_TEXT")"
|
|
176
|
+
# 18b. Task 853 — double-wrapped multi-target reframe + inline authoring, no
|
|
177
|
+
# marker -> flagged. A single-strip would leave the inner tag and never see
|
|
178
|
+
# ## Context (the Task 805 re-blinding class).
|
|
179
|
+
assert_flagged "multi-target double-wrapped reframe + inline authoring -> flagged" \
|
|
180
|
+
"$(mk_transcript "$CHANNEL_REFRAME_MULTI" "$ASSISTANT_REPLY" "$ASSISTANT_BASH" "$ASSISTANT_WRITE")"
|
|
181
|
+
# 18c. Same double-wrapped reframe with an Agent dispatch -> not flagged.
|
|
182
|
+
assert_not_flagged "multi-target double-wrapped reframe + Agent dispatch -> not flagged" \
|
|
183
|
+
"$(mk_transcript "$CHANNEL_REFRAME_MULTI" "$ASSISTANT_REPLY" "$ASSISTANT_AGENT")"
|
|
172
184
|
# 19. Channel-wrapped NON-reframe turn (no ## Instruction section — webchat
|
|
173
185
|
# today, Task 776) with no marker -> not directive-equivalent, not flagged.
|
|
174
186
|
assert_not_flagged "channel-wrapped non-reframe turn, no marker -> not flagged" \
|
|
@@ -129,16 +129,20 @@ if boundary is None:
|
|
|
129
129
|
|
|
130
130
|
slice_rows = rows[boundary:]
|
|
131
131
|
|
|
132
|
-
# Strip
|
|
133
|
-
#
|
|
132
|
+
# Strip leading <channel ...>...</channel> wrapper(s) to reach the inner
|
|
133
|
+
# prompt. WhatsApp/native-channel prompts arrive wrapped once; a multi-target
|
|
134
|
+
# (unified-server, Task 853) prompt arrives DOUBLE-wrapped — the harness wraps
|
|
135
|
+
# with the registration key `channel` and the server embeds an inner
|
|
136
|
+
# <channel source="<door>"> tag — so iterate until the payload surfaces.
|
|
134
137
|
inner = prompt_text
|
|
135
138
|
is_channel = False
|
|
136
|
-
|
|
139
|
+
while inner.startswith("<channel"):
|
|
137
140
|
end = inner.find(">")
|
|
138
141
|
close = inner.rfind("</channel>")
|
|
139
|
-
if end
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
if end == -1 or close == -1 or close <= end:
|
|
143
|
+
break
|
|
144
|
+
inner = inner[end + 1:close].strip()
|
|
145
|
+
is_channel = True
|
|
142
146
|
|
|
143
147
|
# Task 805 — a channel-wrapped reframe turn (the ## Context / ## Instruction
|
|
144
148
|
# sections of composeAdminContent) is directive-equivalent: the directive hook suppresses
|
|
@@ -16,6 +16,7 @@ Applies when the business owner wants to control who can access a gated public a
|
|
|
16
16
|
- Admin asks to revoke or extend someone's access
|
|
17
17
|
- Admin asks to set an agent's access mode (open or gated)
|
|
18
18
|
- Admin asks to resend an invitation
|
|
19
|
+
- Admin asks to enrol a worker with both a phone and an email (one person, two contact doors)
|
|
19
20
|
|
|
20
21
|
## Constraints
|
|
21
22
|
|
|
@@ -126,6 +126,28 @@ The endpoint is loopback-only; it accepts the element ID returned from the cyphe
|
|
|
126
126
|
|
|
127
127
|
Present a `confirm` component before the revocation lands. Explain that the visitor is logged out immediately and must wait for a fresh invitation to re-access.
|
|
128
128
|
|
|
129
|
+
## Enrol a Phone+Email Worker
|
|
130
|
+
|
|
131
|
+
**Outcome:** One `Person` node carries both the worker's phone (E.164) and an email `AccessGrant` for the target agent, so the WhatsApp phone door and the email magic-link door resolve to the same person. Returns the `personId` and a grant summary.
|
|
132
|
+
|
|
133
|
+
Do NOT write this via cypher — the UI server owns the enrolment write. After confirming, run:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
curl -s -X POST http://localhost:19200/api/admin/enrol-person \
|
|
137
|
+
-H 'Content-Type: application/json' \
|
|
138
|
+
-d '{"phone": "+447700900123", "email": "worker@example.com", "agentSlug": "<slug>"}'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The endpoint is loopback-only. It normalises the phone to E.164 digits, lowercases the email, resolves the `accountId` server-side, and MERGEs — re-enrolling the same (account, phone) is idempotent. The response is `{"personId": "...", "grant": {"grantId": "...", "status": "...", "contactValue": "..."}}`; present both to the admin. A 400 names the malformed field (`invalid-phone` / `invalid-email`).
|
|
142
|
+
|
|
143
|
+
The returned `status` is the grant's true state. Enrolling never un-revokes: if `status` is `"revoked"`, the worker stays locked out until the admin explicitly re-invites (the grant was deliberately revoked, and enrolment must not silently undo that). Tell the admin and offer the invite flow.
|
|
144
|
+
|
|
145
|
+
No invite email is sent. If the worker needs web access, they request a magic link themselves from the agent's gate page (the request-magic-link flow), or the admin runs the normal invite/resend operation against the same email — it lands on the same person.
|
|
146
|
+
|
|
147
|
+
This does not touch WhatsApp `dmPolicy` / `allowFrom` — whether the phone may message the agent stays operator config.
|
|
148
|
+
|
|
149
|
+
Present a `confirm` component before enrolling, showing: the worker's phone, email, and the target agent.
|
|
150
|
+
|
|
129
151
|
## Extend Access
|
|
130
152
|
|
|
131
153
|
**Outcome:** Grant's `expiresAt` is pushed forward by the requested duration.
|
|
@@ -26,6 +26,8 @@ The HMAC secret lives at `~/.${brand}/credentials/admin-session-secret` (mode `0
|
|
|
26
26
|
|
|
27
27
|
**Observability.** `[session-rehydrate-from-token] sessionKey=… accountId=… userId=… ageMs=…` fires once per successful rehydrate in `server.log`. A tampered token fails HMAC and returns `invalid-token` silently (no log line — would otherwise be a noise/attack-amplifier surface); the request's downstream `[session] middleware-reject status=401 code=session-not-registered` is sufficient.
|
|
28
28
|
|
|
29
|
+
**Adjacent 401 surface — remote-auth gate.** The PIN-session reject-code taxonomy (`session-missing`, `session-not-registered`, `session-expired-age`, `grant-expired` — the `AdminRejectCode` union in `platform/ui/app/lib/useAdminFetch.ts`) shares its 401 transport with one code from a different security domain: the remote-auth gate (`server/index.ts`, the `__remote_session` cookie's 24h TTL) answers an expired/missing/invalid remote-auth token on any `/api/*` path with `401 {"code":"remote-auth-required"}` — document navigations keep getting the login HTML with a redirect. Client handling is deliberately split: the PIN codes route to enter-pin recovery, while `remote-auth-required` triggers a full page reload (the gate then serves the login page for the current path), because a PIN screen behind an expired remote-auth token cannot reach its own API. The gate's log line is `[remote-auth] login required … respond=401|html`.
|
|
30
|
+
|
|
29
31
|
## SDK-resume contract on PIN-rebind
|
|
30
32
|
|
|
31
33
|
The Anthropic SDK is stateless against its own JSONL: every cold-create with `resume: <agentSessionId>` reads `${CLAUDE_CONFIG_DIR}/projects/<encoded-cwd>/<agentSessionId>.jsonl` verbatim. The Maxy graph (`Conversation.agentSessionId`) is just the pointer into the JSONL, not a parallel transcript. The PIN-rebind contract preserves this:
|
|
@@ -47,7 +47,7 @@ The self phone from Phase 1 is automatically registered as an admin phone. If th
|
|
|
47
47
|
|
|
48
48
|
### Phase 3: Public Agent Selection
|
|
49
49
|
|
|
50
|
-
WhatsApp inbound from non-admin phones routes
|
|
50
|
+
WhatsApp inbound from non-admin phones routes only for **authenticated-public** senders: the sender must be allowed by the DM policy **and** resolve to an enrolled `:Person` (their phone is on a Person record for this account). An allowed-but-unenrolled sender is dropped with `[whatsapp:route] op=dropped reason=public-unresolved`. Each routed sender gets their own per-person, reply-only session. The public-agent setting below is the WhatsApp config's designated public agent; it does not change how an authenticated-public sender is routed.
|
|
51
51
|
|
|
52
52
|
1. **Check current state** — Call `whatsapp-config` with `action: "get-public-agent"` to see if one is already set. Also call `account-manage` to list the available public agents.
|
|
53
53
|
|
|
@@ -55,11 +55,11 @@ WhatsApp inbound from non-admin phones routes to a public agent configured in th
|
|
|
55
55
|
|
|
56
56
|
3. **Set the public agent** — Call `whatsapp-config` with `action: "set-public-agent"` and `slug: "{chosen-slug}"`.
|
|
57
57
|
|
|
58
|
-
4. **
|
|
58
|
+
4. **Set the DM policy** — Call `whatsapp-config` with `action: "update-config"`, `dmPolicy: "allowlist"`, and the enrolled customers' phones in `allowFrom`. Without a policy that allows the sender, all non-admin messages are silently dropped regardless of which public agent is configured. Even an allowed sender only routes once enrolled as a `:Person` carrying that phone.
|
|
59
59
|
|
|
60
|
-
5. **Confirm** — "
|
|
60
|
+
5. **Confirm** — "Enrolled customers on the allowlist will get their own WhatsApp conversation with the agent."
|
|
61
61
|
|
|
62
|
-
If only one public agent exists, confirm it as the choice rather than asking. If no public agents exist,
|
|
62
|
+
If only one public agent exists, confirm it as the choice rather than asking. If no public agents exist, the public-agent setting can be skipped — it does not gate authenticated-public routing.
|
|
63
63
|
|
|
64
64
|
## Relinking
|
|
65
65
|
|
|
@@ -13,6 +13,7 @@ ROOT=$(mktemp -d)
|
|
|
13
13
|
trap 'rm -rf "$ROOT"' EXIT
|
|
14
14
|
mkdir -p "$ROOT/platform/plugins/demo/skills/demo" \
|
|
15
15
|
"$ROOT/platform/templates/specialists" \
|
|
16
|
+
"$ROOT/premium-plugins/demo-bundle/skills/demo" \
|
|
16
17
|
"$ROOT/.docs"
|
|
17
18
|
|
|
18
19
|
clean_skill() { printf '# Demo skill\n\nDoes a thing.\n' > "$ROOT/platform/plugins/demo/skills/demo/SKILL.md"; }
|
|
@@ -48,6 +49,19 @@ else
|
|
|
48
49
|
fi
|
|
49
50
|
rm -f "$ROOT/platform/templates/specialists/AGENT.md"
|
|
50
51
|
|
|
52
|
+
# 3b. `(Task 999)` under a shipped premium bundle -> gate fails + names it.
|
|
53
|
+
# Premium bundles are copied verbatim into the client payload, so any
|
|
54
|
+
# citation in their markdown leaks to paying clients the same as core.
|
|
55
|
+
printf '# Demo skill\n\nDoes a thing (Task 999).\n' > "$ROOT/premium-plugins/demo-bundle/skills/demo/SKILL.md"
|
|
56
|
+
out=$(TASK_ID_LEAK_ROOT="$ROOT" node "$GATE" 2>&1); rc=$?
|
|
57
|
+
if [[ "$rc" -ne 0 ]] \
|
|
58
|
+
&& printf '%s' "$out" | grep -q '\[task-id-leak\] file=premium-plugins/demo-bundle/skills/demo/SKILL.md'; then
|
|
59
|
+
echo "PASS: (Task 999) in shipped premium bundle fails the gate"; PASS=$((PASS+1))
|
|
60
|
+
else
|
|
61
|
+
echo "FAIL: premium citation not caught (rc=$rc): $out" >&2; FAIL=$((FAIL+1))
|
|
62
|
+
fi
|
|
63
|
+
rm -f "$ROOT/premium-plugins/demo-bundle/skills/demo/SKILL.md"
|
|
64
|
+
|
|
51
65
|
# 4. `Tasks 12 and 34` plural form under a shipped skill -> gate fails.
|
|
52
66
|
printf '# Demo skill\n\nMerged behaviour (Tasks 12 and 34).\n' > "$ROOT/platform/plugins/demo/skills/demo/SKILL.md"
|
|
53
67
|
out=$(TASK_ID_LEAK_ROOT="$ROOT" node "$GATE" 2>&1); rc=$?
|
|
@@ -102,6 +116,20 @@ else
|
|
|
102
116
|
fi
|
|
103
117
|
clean_skill
|
|
104
118
|
|
|
119
|
+
# 4f. A `(Task NNN)` citation a soft line-wrap split across two source lines ->
|
|
120
|
+
# gate fails + names it. Markdown rejoins the lines, so the client agent
|
|
121
|
+
# still reads `(Task 900)`; a per-line scan sees `Task` and `900` separately
|
|
122
|
+
# and misses it. printf emits a real newline between `Task` and `900`.
|
|
123
|
+
printf '# Demo skill\n\nThe method-capture flow (Task\n900) fills it in later.\n' > "$ROOT/platform/plugins/demo/skills/demo/SKILL.md"
|
|
124
|
+
out=$(TASK_ID_LEAK_ROOT="$ROOT" node "$GATE" 2>&1); rc=$?
|
|
125
|
+
if [[ "$rc" -ne 0 ]] \
|
|
126
|
+
&& printf '%s' "$out" | grep -q '\[task-id-leak\] file=platform/plugins/demo/skills/demo/SKILL.md'; then
|
|
127
|
+
echo "PASS: line-wrapped (Task\\n900) citation fails the gate"; PASS=$((PASS+1))
|
|
128
|
+
else
|
|
129
|
+
echo "FAIL: line-wrapped citation not caught (rc=$rc): $out" >&2; FAIL=$((FAIL+1))
|
|
130
|
+
fi
|
|
131
|
+
clean_skill
|
|
132
|
+
|
|
105
133
|
# 5. A hex colour `#999` in a shipped .md -> gate does NOT trip (not a citation).
|
|
106
134
|
printf '# Demo skill\n\nUse colour `#999` for labels.\n' > "$ROOT/platform/plugins/demo/skills/demo/SKILL.md"
|
|
107
135
|
out=$(TASK_ID_LEAK_ROOT="$ROOT" node "$GATE" 2>&1); rc=$?
|
|
@@ -67,6 +67,10 @@ const MD_TASK_ID_RE = /\bTasks?[\s-]+\d{2,4}|\btasks?\s+\d{2,4}/
|
|
|
67
67
|
const MD_SCAN_ROOTS = [
|
|
68
68
|
join(REPO_ROOT, 'platform', 'plugins'),
|
|
69
69
|
join(REPO_ROOT, 'platform', 'templates'),
|
|
70
|
+
// Premium bundles are copied verbatim into the client payload
|
|
71
|
+
// (`payload/premium-plugins/<bundle>/`), so their shipped markdown loads into
|
|
72
|
+
// the client agent the same as core plugins — any citation form leaks.
|
|
73
|
+
join(REPO_ROOT, 'premium-plugins'),
|
|
70
74
|
]
|
|
71
75
|
|
|
72
76
|
function isCommentLine(line) {
|
|
@@ -130,9 +134,31 @@ for (const root of SCAN_ROOTS) {
|
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
// Markdown scan — shipped operator-loadable docs. Reuses `walk` (which already
|
|
133
|
-
// skips node_modules/dist/build/.next/payload/__tests__) and matches
|
|
134
|
-
//
|
|
137
|
+
// skips node_modules/dist/build/.next/payload/__tests__) and matches against
|
|
138
|
+
// MD_TASK_ID_RE with no comment skip: the whole doc is agent content.
|
|
135
139
|
// .docs/ and .tasks/ are not under MD_SCAN_ROOTS, so they stay citation-rich.
|
|
140
|
+
//
|
|
141
|
+
// Scanned per paragraph, not per line: a markdown soft-wrap can split a single
|
|
142
|
+
// citation across two source lines (`... (Task\n659) ...`), which renders as
|
|
143
|
+
// `(Task 659)` but matches neither line in isolation. Consecutive non-blank
|
|
144
|
+
// lines are joined with a space (the soft-break a renderer would insert) and
|
|
145
|
+
// scanned as one string; a blank line ends the paragraph, so the join never
|
|
146
|
+
// crosses a paragraph break. Every match in the paragraph is reported, mapped
|
|
147
|
+
// back to the source line where the match starts, preserving exact-line and
|
|
148
|
+
// multi-citation reporting.
|
|
149
|
+
const MD_TASK_ID_RE_G = new RegExp(MD_TASK_ID_RE.source, 'g')
|
|
150
|
+
|
|
151
|
+
function flushParagraph(file, joined, lineStarts) {
|
|
152
|
+
if (joined === '') return
|
|
153
|
+
for (const m of joined.matchAll(MD_TASK_ID_RE_G)) {
|
|
154
|
+
let lineNo = lineStarts[0].lineNo
|
|
155
|
+
for (const ls of lineStarts) {
|
|
156
|
+
if (ls.offset <= m.index) lineNo = ls.lineNo
|
|
157
|
+
}
|
|
158
|
+
leaks.push({ file: relative(REPO_ROOT, file), line: lineNo, content: m[0] })
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
136
162
|
for (const root of MD_SCAN_ROOTS) {
|
|
137
163
|
for (const file of walk(root)) {
|
|
138
164
|
if (!file.endsWith('.md')) continue
|
|
@@ -143,11 +169,20 @@ for (const root of MD_SCAN_ROOTS) {
|
|
|
143
169
|
continue
|
|
144
170
|
}
|
|
145
171
|
const lines = content.split('\n')
|
|
172
|
+
let joined = ''
|
|
173
|
+
let lineStarts = []
|
|
146
174
|
for (let i = 0; i < lines.length; i++) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
if (lines[i].trim() === '') {
|
|
176
|
+
flushParagraph(file, joined, lineStarts)
|
|
177
|
+
joined = ''
|
|
178
|
+
lineStarts = []
|
|
179
|
+
continue
|
|
180
|
+
}
|
|
181
|
+
if (joined !== '') joined += ' '
|
|
182
|
+
lineStarts.push({ offset: joined.length, lineNo: i + 1 })
|
|
183
|
+
joined += lines[i]
|
|
150
184
|
}
|
|
185
|
+
flushParagraph(file, joined, lineStarts)
|
|
151
186
|
}
|
|
152
187
|
}
|
|
153
188
|
|
|
@@ -159,8 +194,8 @@ if (leaks.length > 0) {
|
|
|
159
194
|
console.error('')
|
|
160
195
|
console.error('Code files: citations belong in inline comments only, never in operator-visible')
|
|
161
196
|
console.error('strings (stderr/stdout, logs, systemd --description=, error messages, console.*).')
|
|
162
|
-
console.error('Shipped markdown (platform/plugins, platform/templates): no task
|
|
163
|
-
console.error('form — the whole doc loads into a client-facing agent. Dev docs
|
|
164
|
-
console.error('are exempt and keep their citations.')
|
|
197
|
+
console.error('Shipped markdown (platform/plugins, platform/templates, premium-plugins): no task')
|
|
198
|
+
console.error('citation in any form — the whole doc loads into a client-facing agent. Dev docs')
|
|
199
|
+
console.error('(.docs/, .tasks/) are exempt and keep their citations.')
|
|
165
200
|
process.exit(1)
|
|
166
201
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChannelTargetSet } from './channel-targets.js';
|
|
2
|
+
export declare const CHANNEL_SERVER_NAME = "channel";
|
|
3
|
+
export interface ChannelMcpServerEntry {
|
|
4
|
+
command: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
env: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildChannelMcpServers(p: {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
targets: ChannelTargetSet;
|
|
11
|
+
}): Record<string, ChannelMcpServerEntry>;
|
|
12
|
+
export declare function channelDevChannelsArgv(): string[];
|
|
13
|
+
export declare function channelMcpConfigPath(sessionId: string, dir: string): string;
|
|
14
|
+
export declare function buildChannelArgv(mcpConfigPath: string): string[];
|
|
15
|
+
//# sourceMappingURL=channel-mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-mcp.d.ts","sourceRoot":"","sources":["../src/channel-mcp.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,eAAO,MAAM,mBAAmB,YAAY,CAAA;AAE5C,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC5B;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EAAE;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAexC;AAED,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Task 850 — attach builder for the UNIFIED channel server. Registered (in
|
|
2
|
+
// place of the per-kind wa/webchat servers) only when a session is bound to ≥2
|
|
3
|
+
// channel kinds. The agent sees exactly one `reply` tool; the server reads the
|
|
4
|
+
// whole target set from `CHANNEL_TARGETS` and fans each reply to every bound
|
|
5
|
+
// target's existing gateway reply endpoint. Pure (no fs) like wa-channel-mcp.ts.
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
export const CHANNEL_SERVER_NAME = 'channel';
|
|
8
|
+
export function buildChannelMcpServers(p) {
|
|
9
|
+
// Every target carries the same built server path (the generalized
|
|
10
|
+
// whatsapp-channel dist). Pick whichever kind is bound.
|
|
11
|
+
const anyTarget = p.targets.whatsapp ?? p.targets.webchat;
|
|
12
|
+
if (!anyTarget)
|
|
13
|
+
throw new Error('buildChannelMcpServers: empty target set');
|
|
14
|
+
return {
|
|
15
|
+
[CHANNEL_SERVER_NAME]: {
|
|
16
|
+
command: 'node',
|
|
17
|
+
args: [anyTarget.serverPath],
|
|
18
|
+
env: {
|
|
19
|
+
CHANNEL_SESSION_ID: p.sessionId,
|
|
20
|
+
CHANNEL_TARGETS: JSON.stringify(p.targets),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function channelDevChannelsArgv() {
|
|
26
|
+
return ['--dangerously-load-development-channels', `server:${CHANNEL_SERVER_NAME}`];
|
|
27
|
+
}
|
|
28
|
+
export function channelMcpConfigPath(sessionId, dir) {
|
|
29
|
+
return join(dir, `maxy-channel-${sessionId.replace(/[^A-Za-z0-9_-]/g, '_')}.json`);
|
|
30
|
+
}
|
|
31
|
+
export function buildChannelArgv(mcpConfigPath) {
|
|
32
|
+
return ['--mcp-config', mcpConfigPath, ...channelDevChannelsArgv()];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=channel-mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-mcp.js","sourceRoot":"","sources":["../src/channel-mcp.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,+EAA+E;AAC/E,6EAA6E;AAC7E,iFAAiF;AAEjF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAQ5C,MAAM,UAAU,sBAAsB,CAAC,CAGtC;IACC,mEAAmE;IACnE,wDAAwD;IACxD,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACzD,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC3E,OAAO;QACL,CAAC,mBAAmB,CAAC,EAAE;YACrB,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC;YAC5B,GAAG,EAAE;gBACH,kBAAkB,EAAE,CAAC,CAAC,SAAS;gBAC/B,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;aAC3C;SACF;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,CAAC,yCAAyC,EAAE,UAAU,mBAAmB,EAAE,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAE,GAAW;IACjE,OAAO,IAAI,CAAC,GAAG,EAAE,gBAAgB,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;AACpF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,aAAqB;IACpD,OAAO,CAAC,cAAc,EAAE,aAAa,EAAE,GAAG,sBAAsB,EAAE,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface WhatsAppTarget {
|
|
2
|
+
kind: 'whatsapp';
|
|
3
|
+
senderId: string;
|
|
4
|
+
gatewayUrl: string;
|
|
5
|
+
serverPath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WebchatTarget {
|
|
8
|
+
kind: 'webchat';
|
|
9
|
+
key: string;
|
|
10
|
+
gatewayUrl: string;
|
|
11
|
+
serverPath: string;
|
|
12
|
+
}
|
|
13
|
+
export type ChannelTarget = WhatsAppTarget | WebchatTarget;
|
|
14
|
+
/** Per-session bound targets, at most one per kind. */
|
|
15
|
+
export interface ChannelTargetSet {
|
|
16
|
+
whatsapp?: WhatsAppTarget;
|
|
17
|
+
webchat?: WebchatTarget;
|
|
18
|
+
}
|
|
19
|
+
/** Add (or replace) a target of its kind. Pure. */
|
|
20
|
+
export declare function mergeTarget(set: ChannelTargetSet, t: ChannelTarget): ChannelTargetSet;
|
|
21
|
+
/** The kinds currently bound, in no guaranteed order. */
|
|
22
|
+
export declare function targetKinds(set: ChannelTargetSet): Array<ChannelTarget['kind']>;
|
|
23
|
+
/** True when ≥2 distinct kinds are bound — the case that needs the unified
|
|
24
|
+
* server (one reply tool fanning to every target). */
|
|
25
|
+
export declare function isMultiTarget(set: ChannelTargetSet): boolean;
|
|
26
|
+
//# sourceMappingURL=channel-targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-targets.d.ts","sourceRoot":"","sources":["../src/channel-targets.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AACD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AACD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,aAAa,CAAA;AAE1D,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB;AAED,mDAAmD;AACnD,wBAAgB,WAAW,CAAC,GAAG,EAAE,gBAAgB,EAAE,CAAC,EAAE,aAAa,GAAG,gBAAgB,CAErF;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,GAAG,EAAE,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAE/E;AAED;uDACuD;AACvD,wBAAgB,aAAa,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAE5D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Task 850 — a session's outbound binding is a SET of channel targets, at most
|
|
2
|
+
// one per kind, replacing the whatsapp-XOR-webchat single binding. The manager
|
|
3
|
+
// assembles this set from the per-kind binding stores and decides whether to
|
|
4
|
+
// register the unified `channel` server (≥2 kinds) or the existing per-kind
|
|
5
|
+
// server (1 kind).
|
|
6
|
+
/** Add (or replace) a target of its kind. Pure. */
|
|
7
|
+
export function mergeTarget(set, t) {
|
|
8
|
+
return { ...set, [t.kind]: t };
|
|
9
|
+
}
|
|
10
|
+
/** The kinds currently bound, in no guaranteed order. */
|
|
11
|
+
export function targetKinds(set) {
|
|
12
|
+
return Object.keys(set).filter((k) => set[k]);
|
|
13
|
+
}
|
|
14
|
+
/** True when ≥2 distinct kinds are bound — the case that needs the unified
|
|
15
|
+
* server (one reply tool fanning to every target). */
|
|
16
|
+
export function isMultiTarget(set) {
|
|
17
|
+
return targetKinds(set).length >= 2;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=channel-targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-targets.js","sourceRoot":"","sources":["../src/channel-targets.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,mBAAmB;AAsBnB,mDAAmD;AACnD,MAAM,UAAU,WAAW,CAAC,GAAqB,EAAE,CAAgB;IACjE,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;AAChC,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,WAAW,CAAC,GAAqB;IAC/C,OAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAkC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACjF,CAAC;AAED;uDACuD;AACvD,MAAM,UAAU,aAAa,CAAC,GAAqB;IACjD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAA;AACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAY3B,OAAO,EAgBL,KAAK,SAAS,EAEf,MAAM,kBAAkB,CAAA;AAqBzB,OAAO,KAAK,EAAE,SAAS,EAAyB,MAAM,iBAAiB,CAAA;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAgFhE,eAAO,MAAM,kBAAkB,QAA2B,CAAA;AAS1D,eAAO,MAAM,4BAA4B,QAAS,CAAA;AAIlD,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC7E;;qEAEiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,SAAS,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,WAAW,CAAA;IAC/B,eAAe,EAAE,aAAa,CAAA;IAC9B;kFAC8E;IAC9E,cAAc,EAAE,cAAc,CAAA;IAC9B;;gFAE4E;IAC5E,cAAc,EAAE,cAAc,CAAA;IAC9B;;;6BAGyB;IACzB,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC;;gFAE4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAoND;;;kEAGkE;AAClE,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG;IAC3B,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACpD;;;+CAG2C;IAC3C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAChD,CAAA;AAmBD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CA6/DpD"}
|