@ctliz/agent-intercom-claude 0.12.0-connect.3

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 (59) hide show
  1. package/.claude-plugin/plugin.json +26 -0
  2. package/.mcp.json +10 -0
  3. package/CHANGELOG.md +62 -0
  4. package/COPYRIGHT +6 -0
  5. package/LICENSE +661 -0
  6. package/LICENSE_TRANSITION.md +25 -0
  7. package/README.md +506 -0
  8. package/THIRD_PARTY_NOTICES.md +25 -0
  9. package/broker/access-credential.ts +76 -0
  10. package/broker/access-registry.ts +460 -0
  11. package/broker/audit.ts +60 -0
  12. package/broker/authorization.ts +125 -0
  13. package/broker/boss-contracts.ts +267 -0
  14. package/broker/broker.ts +2028 -0
  15. package/broker/client.ts +1048 -0
  16. package/broker/framing.ts +87 -0
  17. package/broker/ownership.ts +61 -0
  18. package/broker/paths.ts +161 -0
  19. package/broker/spawn.ts +463 -0
  20. package/broker/validation.ts +132 -0
  21. package/claude/cci.ts +512 -0
  22. package/claude/ccim.ts +31 -0
  23. package/claude/cli-runner.ts +220 -0
  24. package/claude/contact.ts +33 -0
  25. package/claude/inbox-monitor.ts +49 -0
  26. package/claude/inbox.ts +77 -0
  27. package/claude/mcp-protocol.ts +253 -0
  28. package/claude/native-bridge.ts +219 -0
  29. package/claude/native-protocol.ts +346 -0
  30. package/claude/permission-policy.ts +287 -0
  31. package/claude/runtime.ts +510 -0
  32. package/claude/server.ts +69 -0
  33. package/claude/team.ts +348 -0
  34. package/claude/transport.ts +97 -0
  35. package/claude/worker-config.ts +198 -0
  36. package/claude/worker-daemon.ts +418 -0
  37. package/commands/intercom-id.md +9 -0
  38. package/commands/intercom.md +8 -0
  39. package/config.ts +195 -0
  40. package/dist/broker.mjs +2530 -0
  41. package/dist/cci.mjs +3607 -0
  42. package/dist/ccim.mjs +3621 -0
  43. package/dist/claude-server.mjs +2730 -0
  44. package/dist/inbox-monitor.mjs +68 -0
  45. package/dist/worker-daemon.mjs +2797 -0
  46. package/durable-json.ts +25 -0
  47. package/licenses/MIT-pi-claude-link.txt +21 -0
  48. package/licenses/MIT-pi-intercom.txt +21 -0
  49. package/monitors/monitors.json +8 -0
  50. package/outbound-outbox.ts +116 -0
  51. package/package.json +93 -0
  52. package/protocol-v4/contract.ts +45 -0
  53. package/provider/protected-service.ts +162 -0
  54. package/provider/provider.mjs +34 -0
  55. package/scripts/build.mjs +71 -0
  56. package/scripts/verify-core-provenance.mjs +64 -0
  57. package/scripts/verify-packed-runtime.mjs +140 -0
  58. package/skills/claude-intercom/SKILL.md +90 -0
  59. package/types.ts +212 -0
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+
3
+ // claude/inbox-monitor.ts
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { setTimeout as delay } from "node:timers/promises";
6
+ import { basename } from "node:path";
7
+
8
+ // claude/inbox.ts
9
+ function formatInboxLine(entry) {
10
+ const who = entry.fromName ? `${entry.fromName} (${entry.fromId.slice(0, 8)})` : entry.fromId;
11
+ const kind = entry.expectsReply ? " [asking \u2014 awaiting your reply]" : "";
12
+ const oneLine = entry.text.replace(/\s+/g, " ").trim();
13
+ return `Intercom message from ${who}${kind}: ${oneLine}`;
14
+ }
15
+ function inboxBatchFrom(content, alreadyEmitted) {
16
+ const lines = content.split("\n").map((line) => line.trim()).filter(Boolean);
17
+ const total = lines.length;
18
+ const start = alreadyEmitted <= total ? alreadyEmitted : 0;
19
+ const entries = [];
20
+ for (let index = start; index < total; index += 1) {
21
+ try {
22
+ entries.push(JSON.parse(lines[index]));
23
+ } catch {
24
+ }
25
+ }
26
+ return { entries, total };
27
+ }
28
+
29
+ // claude/inbox-monitor.ts
30
+ var POLL_MS = 1e3;
31
+ function readContent(path) {
32
+ try {
33
+ return existsSync(path) ? readFileSync(path, "utf-8") : "";
34
+ } catch {
35
+ return "";
36
+ }
37
+ }
38
+ async function runInboxMonitor(path, signal) {
39
+ let emitted = inboxBatchFrom(readContent(path), 0).total;
40
+ for (; ; ) {
41
+ if (signal?.aborted) return;
42
+ const { entries, total } = inboxBatchFrom(readContent(path), emitted);
43
+ for (const entry of entries) {
44
+ process.stdout.write(`${formatInboxLine(entry)}
45
+ `);
46
+ }
47
+ emitted = total;
48
+ await delay(POLL_MS);
49
+ }
50
+ }
51
+ async function main() {
52
+ const path = process.env.CLAUDE_INTERCOM_INBOX || process.argv[2];
53
+ if (!path) {
54
+ process.stderr.write("inbox-monitor: no inbox path (set CLAUDE_INTERCOM_INBOX or pass a path)\n");
55
+ process.exit(1);
56
+ }
57
+ await runInboxMonitor(path);
58
+ }
59
+ if (process.argv[1] && (basename(process.argv[1]) === "inbox-monitor.ts" || basename(process.argv[1]) === "inbox-monitor.mjs")) {
60
+ void main().catch((error) => {
61
+ process.stderr.write(`inbox-monitor: ${error instanceof Error ? error.message : String(error)}
62
+ `);
63
+ process.exit(1);
64
+ });
65
+ }
66
+ export {
67
+ runInboxMonitor
68
+ };