@rubytech/create-maxy-code 0.1.498 → 0.1.499

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.
Files changed (41) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/active-rules/dist/index.d.ts +3 -7
  3. package/payload/platform/lib/active-rules/dist/index.d.ts.map +1 -1
  4. package/payload/platform/lib/active-rules/dist/index.js +20 -52
  5. package/payload/platform/lib/active-rules/dist/index.js.map +1 -1
  6. package/payload/platform/lib/active-rules/src/index.test.ts +35 -69
  7. package/payload/platform/lib/active-rules/src/index.ts +17 -58
  8. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +3 -3
  9. package/payload/platform/plugins/docs/references/internals.md +2 -2
  10. package/payload/platform/plugins/email/mcp/dist/__tests__/compose-signature.test.d.ts +2 -0
  11. package/payload/platform/plugins/email/mcp/dist/__tests__/compose-signature.test.d.ts.map +1 -0
  12. package/payload/platform/plugins/email/mcp/dist/__tests__/compose-signature.test.js +53 -0
  13. package/payload/platform/plugins/email/mcp/dist/__tests__/compose-signature.test.js.map +1 -0
  14. package/payload/platform/plugins/email/mcp/dist/__tests__/signature.test.d.ts +2 -0
  15. package/payload/platform/plugins/email/mcp/dist/__tests__/signature.test.d.ts.map +1 -0
  16. package/payload/platform/plugins/email/mcp/dist/__tests__/signature.test.js +50 -0
  17. package/payload/platform/plugins/email/mcp/dist/__tests__/signature.test.js.map +1 -0
  18. package/payload/platform/plugins/email/mcp/dist/lib/compose.d.ts.map +1 -1
  19. package/payload/platform/plugins/email/mcp/dist/lib/compose.js +15 -2
  20. package/payload/platform/plugins/email/mcp/dist/lib/compose.js.map +1 -1
  21. package/payload/platform/plugins/email/mcp/dist/lib/signature.d.ts +29 -0
  22. package/payload/platform/plugins/email/mcp/dist/lib/signature.d.ts.map +1 -0
  23. package/payload/platform/plugins/email/mcp/dist/lib/signature.js +55 -0
  24. package/payload/platform/plugins/email/mcp/dist/lib/signature.js.map +1 -0
  25. package/payload/platform/plugins/email/references/email-reference.md +10 -0
  26. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-read-active-rules.test.js +10 -9
  27. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-read-active-rules.test.js.map +1 -1
  28. package/payload/platform/plugins/memory/skills/conversational-memory/SKILL.md +2 -0
  29. package/payload/platform/plugins/memory/skills/preference-audit/SKILL.md +16 -0
  30. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.d.ts +19 -19
  31. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.d.ts.map +1 -1
  32. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.js +28 -34
  33. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.js.map +1 -1
  34. package/payload/server/public/assets/{chat-qtOiJX-Y.js → chat-MvnxPJZ5.js} +1 -1
  35. package/payload/server/public/assets/{operator-icJwMkZF.js → operator-DCNWUKP_.js} +1 -1
  36. package/payload/server/public/assets/{page-iG57nKOg.js → page-C4TrTU6r.js} +1 -1
  37. package/payload/server/public/assets/{public-CkOumzpf.js → public-DXJXQPwe.js} +1 -1
  38. package/payload/server/public/chat.html +2 -2
  39. package/payload/server/public/operator.html +2 -2
  40. package/payload/server/public/public.html +2 -2
  41. package/payload/server/server.js +47 -57
@@ -144,47 +144,18 @@ var require_dist = __commonJS({
144
144
  "../lib/active-rules/dist/index.js"(exports) {
145
145
  "use strict";
146
146
  Object.defineProperty(exports, "__esModule", { value: true });
147
- exports.ACTIVE_CANDIDATE_LIMIT = exports.ACTIVE_CANDIDATE_FLOOR = exports.INJECTION_RULE_CAP = exports.SAME_SUBJECT_COSINE = void 0;
148
- exports.cosine = cosine;
149
- exports.deconflictBySubject = deconflictBySubject;
147
+ exports.ACTIVE_CANDIDATE_FLOOR = exports.SAME_SUBJECT_COSINE = void 0;
150
148
  exports.formatStandingRulesBlock = formatStandingRulesBlock2;
151
149
  exports.resolveOwnerUserId = resolveOwnerUserId2;
152
150
  exports.queryActiveRuleCandidates = queryActiveRuleCandidates;
153
151
  exports.resolveActiveRules = resolveActiveRules2;
154
152
  exports.activeRuleSet = activeRuleSet;
155
153
  exports.SAME_SUBJECT_COSINE = 0.85;
156
- exports.INJECTION_RULE_CAP = 12;
157
154
  exports.ACTIVE_CANDIDATE_FLOOR = 0.4;
158
- exports.ACTIVE_CANDIDATE_LIMIT = 30;
159
- function cosine(a, b) {
160
- if (!a.length || !b.length || a.length !== b.length)
161
- return 0;
162
- let dot = 0;
163
- let na = 0;
164
- let nb = 0;
165
- for (let i = 0; i < a.length; i++) {
166
- dot += a[i] * b[i];
167
- na += a[i] * a[i];
168
- nb += b[i] * b[i];
169
- }
170
- if (na === 0 || nb === 0)
171
- return 0;
172
- return dot / (Math.sqrt(na) * Math.sqrt(nb));
173
- }
174
- function deconflictBySubject(records, cosineThreshold = exports.SAME_SUBJECT_COSINE) {
175
- const winners = [];
176
- for (const r of records) {
177
- const emb = r.embedding;
178
- const isDup = Array.isArray(emb) && emb.length > 0 && winners.some((w) => Array.isArray(w.embedding) && w.embedding.length > 0 && cosine(emb, w.embedding) >= cosineThreshold);
179
- if (!isDup)
180
- winners.push(r);
181
- }
182
- return winners.map(({ embedding: _embedding, ...rest }) => rest);
183
- }
184
- function formatStandingRulesBlock2(rules, cap = exports.INJECTION_RULE_CAP) {
155
+ function formatStandingRulesBlock2(rules) {
185
156
  if (rules.length === 0)
186
157
  return "";
187
- const lines = rules.slice(0, cap).map((r) => `- ${r.value}`);
158
+ const lines = rules.map((r) => `- ${r.value}`);
188
159
  return `## Standing rules
189
160
  ${lines.join("\n")}`;
190
161
  }
@@ -209,7 +180,6 @@ ${lines.join("\n")}`;
209
180
  pref.key AS key, pref.value AS value, pref.confidence AS confidence,
210
181
  pref.observedAt AS observedAt, pref.embedding AS embedding
211
182
  ORDER BY pref.confidence DESC, pref.observedAt DESC
212
- LIMIT ${exports.ACTIVE_CANDIDATE_LIMIT}
213
183
  `, { accountId, ownerUserId, floor: exports.ACTIVE_CANDIDATE_FLOOR });
214
184
  return result.records.map((r) => ({
215
185
  preferenceId: r.get("preferenceId"),
@@ -236,12 +206,13 @@ ${lines.join("\n")}`;
236
206
  async function queryActiveRuleCandidates(session, accountId) {
237
207
  return (await resolveCandidates(session, accountId)).candidates;
238
208
  }
239
- async function resolveActiveRules2(session, accountId, cap = exports.INJECTION_RULE_CAP) {
209
+ async function resolveActiveRules2(session, accountId) {
240
210
  const { candidates, ownerUserId, source } = await resolveCandidates(session, accountId);
241
- return { rules: deconflictBySubject(candidates).slice(0, cap), ownerUserId, source };
211
+ const rules = candidates.map(({ embedding: _embedding, ...rest }) => rest);
212
+ return { rules, ownerUserId, source };
242
213
  }
243
- async function activeRuleSet(session, accountId, cap = exports.INJECTION_RULE_CAP) {
244
- return (await resolveActiveRules2(session, accountId, cap)).rules;
214
+ async function activeRuleSet(session, accountId) {
215
+ return (await resolveActiveRules2(session, accountId)).rules;
245
216
  }
246
217
  }
247
218
  });
@@ -7581,7 +7552,7 @@ function createScheduleInjectRoutes(deps) {
7581
7552
  }
7582
7553
 
7583
7554
  // server/index.ts
7584
- var import_dist11 = __toESM(require_dist(), 1);
7555
+ var import_dist8 = __toESM(require_dist(), 1);
7585
7556
 
7586
7557
  // app/lib/whatsapp/socket-resolution-error.ts
7587
7558
  function formatPresentKeys(presentKeys) {
@@ -11651,7 +11622,7 @@ function unwrapChannel(text) {
11651
11622
  }
11652
11623
  return source ? { text: inner, source } : { text: inner };
11653
11624
  }
11654
- var COMPOSED_ADMIN_FRAME = /^(?:## Standing rules\n[\s\S]*?\n\n)?## Context\n([\s\S]*)\n\n## Instruction\n[\s\S]*$/;
11625
+ var COMPOSED_ADMIN_FRAME = /^(?:## Scheduled automation \(platform-verified\)\n[\s\S]*?\n\n)?(?:## Standing rules\n[\s\S]*?\n\n)?## Context\n([\s\S]*)\n\n## Instruction\n[\s\S]*$/;
11655
11626
  var UPLOAD_ANNOTATION = /(?:\n\n)?\[The operator uploaded \d+ file\(s\): [\s\S]*\]$/;
11656
11627
  function rawFromComposedAdminFrame(text) {
11657
11628
  const context = text.match(COMPOSED_ADMIN_FRAME)?.[1];
@@ -12200,6 +12171,23 @@ function tagAndMergeInstallConversations(perAccount) {
12200
12171
  }
12201
12172
  return all.sort((x, y) => (y.lastMessageAt ?? "").localeCompare(x.lastMessageAt ?? ""));
12202
12173
  }
12174
+ function dropHouseRowsOwnedBySubAccount(rows, subManagerPhones) {
12175
+ return rows.filter((r) => {
12176
+ if (r.isHouse !== true || r.source !== "store" || r.senderId == null) return true;
12177
+ let owner = null;
12178
+ for (const [subId, phones] of subManagerPhones) {
12179
+ if (counterpartyBoundToSubAccount(phones, r.senderId)) {
12180
+ owner = subId;
12181
+ break;
12182
+ }
12183
+ }
12184
+ if (owner === null) return true;
12185
+ const subHasOwnRow = rows.some(
12186
+ (o) => o.isHouse !== true && o.accountId === owner && o.source === "store" && o.senderId != null && counterpartyBoundToSubAccount([o.senderId], r.senderId)
12187
+ );
12188
+ return !subHasOwnRow;
12189
+ });
12190
+ }
12203
12191
  app5.get("/conversations-all", requireAdminSession, async (c) => {
12204
12192
  const cacheKey = c.var.cacheKey;
12205
12193
  const caller2 = getAccountIdForSession(cacheKey) ?? null;
@@ -12273,10 +12261,21 @@ app5.get("/conversations-all", requireAdminSession, async (c) => {
12273
12261
  const storeRows = buildStoreConversationRows(account.accountId, readConversationSummaries(account.accountId));
12274
12262
  perAccount.push({ isHouse, rows: [...named, ...storeRows] });
12275
12263
  }
12276
- const conversations = tagAndMergeInstallConversations(perAccount);
12264
+ const houseAccount = validAccounts.find((a) => a.accountId === houseId) ?? null;
12265
+ const subManagerPhones = /* @__PURE__ */ new Map();
12266
+ if (houseAccount) {
12267
+ const managers = readAccountManagers(houseAccount.accountDir);
12268
+ for (const a of validAccounts) {
12269
+ if (houseIds.has(a.accountId)) continue;
12270
+ const phones = managerPhonesForAccount(managers, a.accountId);
12271
+ if (phones.length > 0) subManagerPhones.set(a.accountId, phones);
12272
+ }
12273
+ }
12274
+ const merged = tagAndMergeInstallConversations(perAccount);
12275
+ const conversations = dropHouseRowsOwnedBySubAccount(merged, subManagerPhones);
12277
12276
  const houseRows = conversations.filter((r) => r.isHouse).length;
12278
12277
  console.log(
12279
- `[wa-reader] op=conversations-all accounts=${validAccounts.length} rows=${conversations.length} house=${houseRows} sub=${conversations.length - houseRows}`
12278
+ `[wa-reader] op=conversations-all accounts=${validAccounts.length} rows=${conversations.length} house=${houseRows} sub=${conversations.length - houseRows} deduped=${merged.length - conversations.length}`
12280
12279
  );
12281
12280
  return c.json({ conversations });
12282
12281
  });
@@ -26642,9 +26641,6 @@ var InboundHub = class {
26642
26641
  }
26643
26642
  };
26644
26643
 
26645
- // app/lib/whatsapp/gateway/wa-gateway.ts
26646
- var import_dist7 = __toESM(require_dist(), 1);
26647
-
26648
26644
  // node_modules/hono/dist/utils/stream.js
26649
26645
  var StreamingApi = class {
26650
26646
  writer;
@@ -27060,7 +27056,7 @@ var WaGateway = class {
27060
27056
  const injected = res.block ? (res.block.match(/^- /gm) ?? []).length : 0;
27061
27057
  const owner8 = res.ownerUserId ? res.ownerUserId.slice(0, 8) : "-";
27062
27058
  console.error(
27063
- `[preference-inject] op=inject channel=wa accountId=${input.effectiveAccountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >= import_dist7.INJECTION_RULE_CAP}`
27059
+ `[preference-inject] op=inject channel=wa accountId=${input.effectiveAccountId} injected=${injected} owner=${owner8} source=${res.source}`
27064
27060
  );
27065
27061
  }
27066
27062
  this.hub.deliver(
@@ -27340,9 +27336,6 @@ var InboundHub2 = class {
27340
27336
  }
27341
27337
  };
27342
27338
 
27343
- // app/lib/webchat/gateway/webchat-gateway.ts
27344
- var import_dist8 = __toESM(require_dist(), 1);
27345
-
27346
27339
  // app/lib/webchat/gateway/routes.ts
27347
27340
  function createWebchatChannelRoutes(deps) {
27348
27341
  const app66 = new Hono();
@@ -27821,7 +27814,7 @@ var WebchatGateway = class _WebchatGateway {
27821
27814
  const injected = res.block ? (res.block.match(/^- /gm) ?? []).length : 0;
27822
27815
  const owner8 = res.ownerUserId ? res.ownerUserId.slice(0, 8) : "-";
27823
27816
  console.error(
27824
- `[preference-inject] op=inject channel=web accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >= import_dist8.INJECTION_RULE_CAP}`
27817
+ `[preference-inject] op=inject channel=web accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source}`
27825
27818
  );
27826
27819
  }
27827
27820
  this.hub.deliver(
@@ -28525,9 +28518,6 @@ var InboundHub3 = class {
28525
28518
  }
28526
28519
  };
28527
28520
 
28528
- // app/lib/telegram/gateway/telegram-gateway.ts
28529
- var import_dist9 = __toESM(require_dist(), 1);
28530
-
28531
28521
  // app/lib/telegram/gateway/routes.ts
28532
28522
  function createTelegramChannelRoutes(deps) {
28533
28523
  const app66 = new Hono();
@@ -28701,7 +28691,7 @@ var TelegramGateway = class {
28701
28691
  const injected = res.block ? (res.block.match(/^- /gm) ?? []).length : 0;
28702
28692
  const owner8 = res.ownerUserId ? res.ownerUserId.slice(0, 8) : "-";
28703
28693
  console.error(
28704
- `[preference-inject] op=inject channel=tg accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >= import_dist9.INJECTION_RULE_CAP}`
28694
+ `[preference-inject] op=inject channel=tg accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source}`
28705
28695
  );
28706
28696
  }
28707
28697
  this.hub.deliver(
@@ -29070,11 +29060,11 @@ async function firePublicSessionEndReview(input) {
29070
29060
  }
29071
29061
 
29072
29062
  // app/lib/whatsapp/inbound/resolve-client-graph-owner.ts
29073
- var import_dist10 = __toESM(require_dist(), 1);
29063
+ var import_dist7 = __toESM(require_dist(), 1);
29074
29064
  async function resolveClientOwnerUserId(accountId, deps = {}) {
29075
29065
  const listAccounts = deps.listAccounts ?? listValidAccounts;
29076
29066
  const getSession4 = deps.getSession ?? getSession;
29077
- const resolveOwner2 = deps.resolveOwner ?? import_dist10.resolveOwnerUserId;
29067
+ const resolveOwner2 = deps.resolveOwner ?? import_dist7.resolveOwnerUserId;
29078
29068
  const role = listAccounts().find((a) => a.accountId === accountId)?.config.role;
29079
29069
  if (role !== "client") return null;
29080
29070
  const session = getSession4();
@@ -29536,8 +29526,8 @@ var webchatFileFollowers = /* @__PURE__ */ new Map();
29536
29526
  async function fetchAccountStandingRules(accountId) {
29537
29527
  const session = getSession();
29538
29528
  try {
29539
- const res = await (0, import_dist11.resolveActiveRules)(session, accountId);
29540
- return { block: (0, import_dist11.formatStandingRulesBlock)(res.rules), ownerUserId: res.ownerUserId, source: res.source };
29529
+ const res = await (0, import_dist8.resolveActiveRules)(session, accountId);
29530
+ return { block: (0, import_dist8.formatStandingRulesBlock)(res.rules), ownerUserId: res.ownerUserId, source: res.source };
29541
29531
  } catch (err) {
29542
29532
  console.error(
29543
29533
  `[preference-inject] op=fetch-failed accountId=${accountId} error=${err instanceof Error ? err.message : String(err)}`