@rubytech/create-maxy-code 0.1.388 → 0.1.389

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 (100) hide show
  1. package/dist/__tests__/joblogic-excluded.test.js +39 -0
  2. package/dist/index.js +21 -0
  3. package/package.json +1 -1
  4. package/payload/platform/config/brand.json +1 -1
  5. package/payload/platform/plugins/.claude-plugin/marketplace.json +0 -5
  6. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +21 -2
  7. package/payload/platform/plugins/docs/references/admin-session.md +4 -0
  8. package/payload/platform/plugins/docs/references/admin-ui.md +18 -1
  9. package/payload/platform/plugins/docs/references/joblogic.md +2 -0
  10. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +2 -0
  11. package/payload/platform/plugins/work/PLUGIN.md +3 -0
  12. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.d.ts +2 -0
  13. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.d.ts.map +1 -0
  14. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.js +98 -0
  15. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.js.map +1 -0
  16. package/payload/platform/plugins/work/mcp/dist/index.js +16 -0
  17. package/payload/platform/plugins/work/mcp/dist/index.js.map +1 -1
  18. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.d.ts +53 -0
  19. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.d.ts.map +1 -0
  20. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.js +80 -0
  21. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.js.map +1 -0
  22. package/payload/platform/plugins/work/mcp/package.json +2 -1
  23. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  24. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -0
  25. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  26. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  27. package/payload/platform/services/claude-session-manager/dist/http-server.js +98 -8
  28. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  29. package/payload/platform/services/claude-session-manager/dist/pricing.d.ts +45 -0
  30. package/payload/platform/services/claude-session-manager/dist/pricing.d.ts.map +1 -0
  31. package/payload/platform/services/claude-session-manager/dist/pricing.js +57 -0
  32. package/payload/platform/services/claude-session-manager/dist/pricing.js.map +1 -0
  33. package/payload/platform/services/claude-session-manager/dist/session-metering.d.ts +38 -0
  34. package/payload/platform/services/claude-session-manager/dist/session-metering.d.ts.map +1 -0
  35. package/payload/platform/services/claude-session-manager/dist/session-metering.js +292 -0
  36. package/payload/platform/services/claude-session-manager/dist/session-metering.js.map +1 -0
  37. package/payload/platform/templates/specialists/agents/project-manager.md +1 -1
  38. package/payload/server/public/assets/{AdminLoginScreens-BejIjbmU.js → AdminLoginScreens-CerrEc_m.js} +1 -1
  39. package/payload/server/public/assets/AdminShell-cRTvNRbo.js +1 -0
  40. package/payload/server/public/assets/{Checkbox-1F1tzqca.js → Checkbox-Dh2pLMFN.js} +1 -1
  41. package/payload/server/public/assets/{Transcript-DkGa4CQH.js → Transcript-B_GVJujB.js} +1 -1
  42. package/payload/server/public/assets/{admin-DqQARkjy.js → admin-BXaYelnR.js} +1 -1
  43. package/payload/server/public/assets/{browser-nDtEK6RC.js → browser-fhjGE7fH.js} +1 -1
  44. package/payload/server/public/assets/calendar-PnZudAtc.js +1 -0
  45. package/payload/server/public/assets/chat-Dy_zrjKS.js +1 -0
  46. package/payload/server/public/assets/chevron-left-IB6TmMZ_.js +1 -0
  47. package/payload/server/public/assets/data-B2IcjAj6.js +1 -0
  48. package/payload/server/public/assets/{graph-DFyicKd7.js → graph-CycO3tkW.js} +2 -2
  49. package/payload/server/public/assets/{graph-labels-D3BQdcpD.js → graph-labels-DlSsSpBV.js} +1 -1
  50. package/payload/server/public/assets/{operator-BxrjWdT9.js → operator-L4kBC-zS.js} +1 -1
  51. package/payload/server/public/assets/page-D5E-Ng4D.js +1 -0
  52. package/payload/server/public/assets/page-M8sD9LOi.js +32 -0
  53. package/payload/server/public/assets/{public-DbdqfdYq.js → public-BmnajF3K.js} +1 -1
  54. package/payload/server/public/assets/{rotate-ccw-BkX8HODe.js → rotate-ccw-W5HhvAbo.js} +1 -1
  55. package/payload/server/public/assets/useSubAccountSwitcher-D1TI1xvd.css +1 -0
  56. package/payload/server/public/assets/useSubAccountSwitcher-UqZbmzYy.js +9 -0
  57. package/payload/server/public/browser.html +4 -4
  58. package/payload/server/public/calendar.html +5 -5
  59. package/payload/server/public/chat.html +8 -8
  60. package/payload/server/public/data.html +7 -7
  61. package/payload/server/public/graph.html +8 -8
  62. package/payload/server/public/index.html +10 -10
  63. package/payload/server/public/operator.html +10 -10
  64. package/payload/server/public/public.html +8 -8
  65. package/payload/server/server.js +275 -248
  66. package/payload/platform/plugins/joblogic/.claude-plugin/plugin.json +0 -21
  67. package/payload/platform/plugins/joblogic/PLUGIN.md +0 -182
  68. package/payload/platform/plugins/joblogic/lib/mcp-spawn-tee/index.js +0 -193
  69. package/payload/platform/plugins/joblogic/lib/mcp-spawn-tee/package.json +0 -3
  70. package/payload/platform/plugins/joblogic/mcp/dist/index.d.ts +0 -2
  71. package/payload/platform/plugins/joblogic/mcp/dist/index.d.ts.map +0 -1
  72. package/payload/platform/plugins/joblogic/mcp/dist/index.js +0 -229
  73. package/payload/platform/plugins/joblogic/mcp/dist/index.js.map +0 -1
  74. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.d.ts +0 -31
  75. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.d.ts.map +0 -1
  76. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.js +0 -78
  77. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.js.map +0 -1
  78. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.d.ts +0 -35
  79. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.d.ts.map +0 -1
  80. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.js +0 -106
  81. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.js.map +0 -1
  82. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.d.ts +0 -8
  83. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.d.ts.map +0 -1
  84. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.js +0 -41
  85. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.js.map +0 -1
  86. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.d.ts +0 -21
  87. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.d.ts.map +0 -1
  88. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.js +0 -47
  89. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.js.map +0 -1
  90. package/payload/platform/plugins/joblogic/mcp/package.json +0 -10
  91. package/payload/platform/plugins/joblogic/skills/joblogic/SKILL.md +0 -32
  92. package/payload/server/public/assets/AdminShell-D2-uBSB5.js +0 -1
  93. package/payload/server/public/assets/calendar-CO4Bwmho.js +0 -1
  94. package/payload/server/public/assets/chat-DeIge_bC.js +0 -1
  95. package/payload/server/public/assets/chevron-left-DhVdq0aN.js +0 -1
  96. package/payload/server/public/assets/data-B1GIdzHk.js +0 -1
  97. package/payload/server/public/assets/page-ByDLq_o1.js +0 -1
  98. package/payload/server/public/assets/page-D-Ep4bXd.js +0 -32
  99. package/payload/server/public/assets/useSubAccountSwitcher-DMbRhLPv.js +0 -9
  100. package/payload/server/public/assets/useSubAccountSwitcher-DS0iqSkP.css +0 -1
@@ -1,21 +0,0 @@
1
- {
2
- "name": "joblogic",
3
- "description": "JobLogic field-service connector (bespoke, one account) — OAuth client_credentials, tenant-scoped read/write across the job lifecycle.",
4
- "version": "0.1.0",
5
- "author": {
6
- "name": "Rubytech LLC"
7
- },
8
- "mcpServers": {
9
- "joblogic": {
10
- "type": "stdio",
11
- "command": "node",
12
- "args": [
13
- "${CLAUDE_PLUGIN_ROOT}/lib/mcp-spawn-tee/index.js",
14
- "${CLAUDE_PLUGIN_ROOT}/mcp/dist/index.js"
15
- ],
16
- "env": {
17
- "MCP_SPAWN_TEE_NAME": "joblogic"
18
- }
19
- }
20
- }
21
- }
@@ -1,182 +0,0 @@
1
- ---
2
- name: joblogic
3
- description: "JobLogic field-service connector (bespoke, one account) — OAuth client_credentials, tenant-scoped read/write across the job lifecycle."
4
- tools:
5
- - name: joblogic-credentials-set
6
- publicAllowlist: false
7
- adminAllowlist: true
8
- - name: joblogic-connection-status
9
- publicAllowlist: false
10
- adminAllowlist: true
11
- - name: joblogic-engineer-map-set
12
- publicAllowlist: false
13
- adminAllowlist: true
14
- - name: joblogic-engineer-map-list
15
- publicAllowlist: false
16
- adminAllowlist: true
17
- - name: joblogic-customer-list
18
- publicAllowlist: false
19
- adminAllowlist: true
20
- - name: joblogic-customer-get
21
- publicAllowlist: false
22
- adminAllowlist: true
23
- - name: joblogic-customer-create
24
- publicAllowlist: false
25
- adminAllowlist: true
26
- - name: joblogic-customer-update
27
- publicAllowlist: false
28
- adminAllowlist: true
29
- - name: joblogic-site-list
30
- publicAllowlist: false
31
- adminAllowlist: true
32
- - name: joblogic-site-get
33
- publicAllowlist: false
34
- adminAllowlist: true
35
- - name: joblogic-site-create
36
- publicAllowlist: false
37
- adminAllowlist: true
38
- - name: joblogic-site-update
39
- publicAllowlist: false
40
- adminAllowlist: true
41
- - name: joblogic-job-list
42
- publicAllowlist: false
43
- adminAllowlist: true
44
- - name: joblogic-job-get
45
- publicAllowlist: false
46
- adminAllowlist: true
47
- - name: joblogic-job-create
48
- publicAllowlist: false
49
- adminAllowlist: true
50
- - name: joblogic-job-update
51
- publicAllowlist: false
52
- adminAllowlist: true
53
- - name: joblogic-job-set-status
54
- publicAllowlist: false
55
- adminAllowlist: true
56
- - name: joblogic-job-approve
57
- publicAllowlist: false
58
- adminAllowlist: true
59
- - name: joblogic-engineer-list
60
- publicAllowlist: false
61
- adminAllowlist: true
62
- - name: joblogic-engineer-get
63
- publicAllowlist: false
64
- adminAllowlist: true
65
- - name: joblogic-visit-search-planner
66
- publicAllowlist: false
67
- adminAllowlist: true
68
- - name: joblogic-visit-get
69
- publicAllowlist: false
70
- adminAllowlist: true
71
- - name: joblogic-visit-create
72
- publicAllowlist: false
73
- adminAllowlist: true
74
- - name: joblogic-visit-update
75
- publicAllowlist: false
76
- adminAllowlist: true
77
- - name: joblogic-visit-deploy
78
- publicAllowlist: false
79
- adminAllowlist: true
80
- - name: joblogic-visit-cancel
81
- publicAllowlist: false
82
- adminAllowlist: true
83
- - name: joblogic-quote-list
84
- publicAllowlist: false
85
- adminAllowlist: true
86
- - name: joblogic-quote-get
87
- publicAllowlist: false
88
- adminAllowlist: true
89
- - name: joblogic-quote-create
90
- publicAllowlist: false
91
- adminAllowlist: true
92
- - name: joblogic-quote-approve
93
- publicAllowlist: false
94
- adminAllowlist: true
95
- - name: joblogic-invoice-list
96
- publicAllowlist: false
97
- adminAllowlist: true
98
- - name: joblogic-invoice-get
99
- publicAllowlist: false
100
- adminAllowlist: true
101
- - name: joblogic-invoice-create
102
- publicAllowlist: false
103
- adminAllowlist: true
104
- - name: joblogic-invoice-payment-create
105
- publicAllowlist: false
106
- adminAllowlist: true
107
- - name: joblogic-asset-list
108
- publicAllowlist: false
109
- adminAllowlist: true
110
- - name: joblogic-asset-get
111
- publicAllowlist: false
112
- adminAllowlist: true
113
- - name: joblogic-asset-create
114
- publicAllowlist: false
115
- adminAllowlist: true
116
- - name: joblogic-asset-update
117
- publicAllowlist: false
118
- adminAllowlist: true
119
- - name: joblogic-timesheet-list
120
- publicAllowlist: false
121
- adminAllowlist: true
122
- - name: joblogic-timesheet-create
123
- publicAllowlist: false
124
- adminAllowlist: true
125
- - name: joblogic-timesheet-update
126
- publicAllowlist: false
127
- adminAllowlist: true
128
- - name: joblogic-jobcost-create
129
- publicAllowlist: false
130
- adminAllowlist: true
131
- - name: joblogic-jobcost-update
132
- publicAllowlist: false
133
- adminAllowlist: true
134
- - name: joblogic-note-create
135
- publicAllowlist: false
136
- adminAllowlist: true
137
- - name: joblogic-attachment-url-generate
138
- publicAllowlist: false
139
- adminAllowlist: true
140
- skills:
141
- - skills/joblogic/SKILL.md
142
- metadata: {"platform":{"optional":true,"pluginKey":"joblogic"}}
143
- mcp:
144
- command: node
145
- args:
146
- - ${PLATFORM_ROOT}/lib/mcp-spawn-tee/dist/index.js
147
- - ${PLATFORM_ROOT}/plugins/joblogic/mcp/dist/index.js
148
- env:
149
- MCP_SPAWN_TEE_NAME: joblogic
150
- LOG_DIR: ${LOG_DIR}
151
- PLATFORM_ROOT: ${PLATFORM_ROOT}
152
- ACCOUNT_ID: ${ACCOUNT_ID}
153
- SESSION_ID: ${SESSION_ID}
154
- mcp-manifest: auto
155
- ---
156
-
157
- # JobLogic
158
-
159
- Connects to JobLogic, a cloud field-service management system (REST/JSON, OAuth 2.0). This is a bespoke connector for one account: it ships inert and does nothing on any other install, gated per-account by the account's `enabledPlugins` plus the presence of credentials in that account's secrets file. It is not part of any brand bundle.
160
-
161
- The intended use: field staff send a voice note or message to this install; the agent interprets it and makes the JobLogic write. Staff never call the API themselves, so only this install's outbound IP touches JobLogic.
162
-
163
- ## Capabilities
164
-
165
- - **joblogic-credentials-set** — store the OAuth client_credentials (client id + secret), company tenant id, and environment (uat or production).
166
- - **joblogic-connection-status** — acquire a token and confirm the environment, tenant, and source-IP whitelisting work.
167
- - **joblogic-engineer-map-set / -list** — map sender phone numbers to JobLogic engineer ids for write attribution.
168
- - **Reads** — list/get/search across customers, sites, jobs, engineers, visits (planner), quotes, invoices, assets, and timesheets.
169
- - **Writes** — create and update those records, plus lifecycle transitions: set a job status, approve a job or quote, deploy or cancel a visit, log job-cost lines, raise an invoice, record a payment, add a note or generate an attachment upload URL.
170
-
171
- ## Authorization and idempotency
172
-
173
- A write is authorized by the person who messaged the install requesting it; the agent does not add a second confirmation step. Every create takes an idempotency key, so a retry or a lost response never creates a duplicate record.
174
-
175
- ## Setup
176
-
177
- Connecting JobLogic runs through the `joblogic` skill (`skills/joblogic/SKILL.md`): the operator raises a JobLogic Support ticket, whitelists the install's outbound IP, and hands over the credentials. Use UAT for all testing before switching to production.
178
-
179
- ## Credentials and isolation
180
-
181
- Credentials live only in this account's secrets directory (`secrets/joblogic.json`, mode `0600`), inside the brand-isolated install. The bearer token is acquired on demand from the client credentials and refreshed automatically before it expires.
182
-
@@ -1,193 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- /**
4
- * MCP spawn-tee — in-process stderr capture + lifecycle observability.
5
- *
6
- * Claude Code spawns each MCP server itself; the platform never holds a
7
- * ChildProcess handle. This shim sits between Claude Code and the real MCP
8
- * server: Claude Code runs `node <this> <real-entry>`, and the shim runs the
9
- * real entry IN ITS OWN PROCESS via dynamic import() — one node runtime, not
10
- * two. Before importing, it replaces process.stderr.write with a tee so every
11
- * stderr byte the server writes is mirrored to the log sinks; stdin and stdout
12
- * (the JSON-RPC channel) are never touched.
13
- *
14
- * Claude Code CLI → shim (this file) = node running <real-entry> in-process
15
- * stdin/stdout : untouched (JSON-RPC channel)
16
- * stderr : process.stderr.write teed → per-date + per-session + passthrough
17
- *
18
- * Destinations (Task 706) — unchanged:
19
- * - `${LOG_DIR}/mcp-<name>-stderr-<date>.log` — per-date raw (back-compat;
20
- * the in-process mcp-stderr-tee and the [mcp-init-error] probe read it).
21
- * - `${LOG_DIR}/mcp-<name>-<SESSION_ID>.log` — per-session raw + lifecycle
22
- * lines. Authoritative sink. Absent when SESSION_ID is unset (enumeration
23
- * spawn) — then the per-date file is the fallback.
24
- * - `server.log` via the loopback log-ingest route — best-effort mirror of
25
- * the [mcp-helper] lifecycle lines.
26
- *
27
- * Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
28
- * [mcp-helper] op=spawn ... pid= entry=
29
- * [mcp-helper] op=boot ... head=<first stderr bytes>
30
- * [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
31
- *
32
- * Process model (Task 989): the shim IS the server's process. op=exit fires
33
- * from process.on("exit"), so it covers a normal exit, a non-zero exit, an
34
- * uncaught throw (code 1), and a catchable-signal exit (SIGTERM/SIGINT/SIGHUP,
35
- * whose handlers record the signal name). An external SIGKILL is uncatchable
36
- * and leaves no op=exit line — the per-session stderr tail already on disk and
37
- * Claude Code's own transport-drop are the evidence for that death mode.
38
- *
39
- * The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
40
- */
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- const node_fs_1 = require("node:fs");
43
- const node_path_1 = require("node:path");
44
- const node_url_1 = require("node:url");
45
- const SERVER_NAME = process.env.MCP_SPAWN_TEE_NAME ?? "unknown";
46
- const LOG_DIR = process.env.LOG_DIR;
47
- const SESSION_ID = process.env.SESSION_ID;
48
- const PLATFORM_PORT = process.env.PLATFORM_PORT;
49
- const ENTRY = process.argv[2];
50
- const SESSION_ID8 = SESSION_ID ? SESSION_ID.slice(0, 8) : "—";
51
- const spawnStamp = Date.now();
52
- // Per-session raw + lifecycle log (Task 706). Empty SESSION_ID (enumeration
53
- // spawn) → undefined, and the per-date file is the fallback.
54
- const perSessionPath = LOG_DIR && SESSION_ID
55
- ? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-${SESSION_ID}.log`)
56
- : undefined;
57
- const perDatePath = LOG_DIR
58
- ? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-stderr-${new Date(spawnStamp).toISOString().slice(0, 10)}.log`)
59
- : undefined;
60
- // Rolling tail of entry stderr for op=exit. Capped so a chatty server cannot
61
- // grow the buffer without bound.
62
- const TAIL_CAP = 2048;
63
- let stderrTail = "";
64
- let bootEmitted = false;
65
- let exitEmitted = false;
66
- let exitSignal;
67
- // The real stderr writer, captured before the tee replaces it. Lifecycle lines
68
- // and stderr passthrough both go through this so they are never re-teed into
69
- // the per-date sink nor recursed back into the patched writer.
70
- const rawStderrWrite = process.stderr.write.bind(process.stderr);
71
- // LOG_DIR is created once, lazily, on the first successful append — not per
72
- // chunk. teeWrite runs on the server's own stderr hot path now, so a per-call
73
- // mkdirSync would be two syscalls per log line for nothing.
74
- let logDirReady = false;
75
- function appendSafe(path, data) {
76
- if (!path || !LOG_DIR)
77
- return;
78
- try {
79
- if (!logDirReady) {
80
- (0, node_fs_1.mkdirSync)(LOG_DIR, { recursive: true });
81
- logDirReady = true;
82
- }
83
- (0, node_fs_1.appendFileSync)(path, data);
84
- }
85
- catch {
86
- /* unwritable destination — never mask primary output */
87
- }
88
- }
89
- // Best-effort mirror of a lifecycle line to server.log via the loopback
90
- // log-ingest route. Fire-and-forget: the per-session file is authoritative, so
91
- // a dropped POST loses nothing. On the "exit" event the loop is stopping, so
92
- // the op=exit mirror may not flush — the per-session line, written sync, holds.
93
- function postToServerLog(suffix, level) {
94
- if (!PLATFORM_PORT)
95
- return;
96
- try {
97
- const ctrl = new AbortController();
98
- const t = setTimeout(() => ctrl.abort(), 500);
99
- t.unref?.(); // never let the abort timer keep the shim's event loop alive
100
- void fetch(`http://127.0.0.1:${PLATFORM_PORT}/api/admin/log-ingest`, {
101
- method: "POST",
102
- headers: { "content-type": "application/json" },
103
- body: JSON.stringify({ tag: "mcp-helper", level, line: suffix }),
104
- signal: ctrl.signal,
105
- }).then(() => clearTimeout(t)).catch(() => clearTimeout(t));
106
- }
107
- catch {
108
- /* fetch threw synchronously — best-effort only */
109
- }
110
- }
111
- // Emit one [mcp-helper] lifecycle line: authoritative per-session file (sync,
112
- // survives process.exit), the shim's own stderr via the RAW writer (journald /
113
- // Claude Code visibility, never re-teed), and a best-effort server.log mirror.
114
- // `suffix` is the line body after the tag and carries no newline (the
115
- // log-ingest route rejects newlines).
116
- function emitLifecycle(suffix, level) {
117
- const line = `[mcp-helper] ${suffix}\n`;
118
- appendSafe(perSessionPath, line);
119
- try {
120
- rawStderrWrite(line);
121
- }
122
- catch { /* stderr closed */ }
123
- postToServerLog(suffix, level);
124
- }
125
- if (!ENTRY) {
126
- emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
127
- process.exit(2);
128
- }
129
- // Replace process.stderr.write with a tee: mirror every server stderr byte to
130
- // the per-date and per-session sinks, keep a rolling tail for op=exit, emit
131
- // op=boot on the first bytes, then pass the write through to the real stderr.
132
- const teeWrite = ((...args) => {
133
- const chunk = args[0];
134
- appendSafe(perDatePath, chunk); // per-date raw (back-compat)
135
- appendSafe(perSessionPath, chunk); // per-session raw (Task 706)
136
- const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
137
- stderrTail = (stderrTail + text).slice(-TAIL_CAP);
138
- if (!bootEmitted) {
139
- bootEmitted = true;
140
- const head = text.split("\n")[0].slice(0, 200);
141
- emitLifecycle(`op=boot session=${SESSION_ID8} server=${SERVER_NAME} head=${JSON.stringify(head)}`, "info");
142
- }
143
- return rawStderrWrite(...args); // passthrough
144
- });
145
- process.stderr.write = teeWrite;
146
- // Catchable-signal handling. The shim drives the exit ONLY when it is the sole
147
- // listener for the signal — i.e. the imported entry installed no handler of its
148
- // own. In that case it records the signal (so op=exit carries signal=<sig>) and
149
- // exits with 128+signum, mirroring the prior wrapper's exit-status convention.
150
- //
151
- // When the entry DID install a handler, the shim defers entirely and records
152
- // nothing: the entry's handler decides the exit code, and op=exit reflects that
153
- // exit verbatim. This matches the prior two-process model, where a child that
154
- // caught the signal and exited cleanly was observed as code=0 signal=— (a clean
155
- // self-exit), not as a signal death. Setting exitSignal here unconditionally
156
- // would mislabel every graceful signal-driven shutdown as a signal kill.
157
- function onSignal(sig, code) {
158
- return () => {
159
- if (process.listenerCount(sig) === 1) {
160
- exitSignal = sig;
161
- process.exit(code);
162
- }
163
- };
164
- }
165
- process.on("SIGTERM", onSignal("SIGTERM", 143));
166
- process.on("SIGINT", onSignal("SIGINT", 130));
167
- process.on("SIGHUP", onSignal("SIGHUP", 129));
168
- // op=exit, emitted once from the process "exit" event. Sync-only — the loop is
169
- // stopping. When a catchable signal caused the exit, report code=— signal=<sig>
170
- // to match the prior wrapper's format; otherwise code=<exit code> signal=—.
171
- process.on("exit", (code) => {
172
- if (exitEmitted)
173
- return;
174
- exitEmitted = true;
175
- const lifetimeMs = Date.now() - spawnStamp;
176
- const tail = stderrTail.slice(-200);
177
- const codeField = exitSignal ? "—" : String(code);
178
- const level = exitSignal || code !== 0 ? "error" : "info";
179
- emitLifecycle(`op=exit session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} ` +
180
- `code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level);
181
- });
182
- emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
183
- // Run the real MCP server in THIS process. Dynamic import() (not top-level
184
- // await — this file compiles to CommonJS) loads the ESM entry; a load-time
185
- // failure mirrors the old child spawn-error path (op=error, exit 127). The
186
- // op=exit handler is suppressed on this path so op=error stays the sole record.
187
- import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
188
- const msg = err instanceof Error ? err.message : String(err);
189
- exitEmitted = true;
190
- emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
191
- process.exit(127);
192
- });
193
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -1,229 +0,0 @@
1
- import { initStderrTee } from "../../../../lib/mcp-stderr-tee/dist/index.js";
2
- initStderrTee("joblogic");
3
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
- import { z } from "zod";
6
- import { lifelineTool } from "../../../../lib/mcp-lifeline/dist/index.js";
7
- import { readStore, setCredentials, setEngineerMap, resolveEngineer } from "./lib/secrets.js";
8
- import { getBearer } from "./lib/auth.js";
9
- import { jlRequest, jlCreate } from "./lib/client.js";
10
- // Plugin-system boot tolerance: module init must never throw; tools/list is
11
- // enumerated with empty env, so account context is resolved per call. Tools are
12
- // always registered (registering zero with empty env would hide them from the
13
- // admin allowlist entirely); each handler refuses per-call when context or creds
14
- // are absent.
15
- const ACCOUNT_ID = process.env.ACCOUNT_ID ?? null;
16
- const PLATFORM_ROOT = process.env.PLATFORM_ROOT ?? null;
17
- function creds() {
18
- if (!ACCOUNT_ID || !PLATFORM_ROOT)
19
- return "absent";
20
- return readStore(PLATFORM_ROOT, ACCOUNT_ID) ? "present" : "absent";
21
- }
22
- process.stderr.write(`[joblogic] op=init account=${ACCOUNT_ID ?? "null"} creds=${creds()}\n`);
23
- function refuseNoAccount(tool) {
24
- process.stderr.write(`[joblogic] tool=${tool} refuse reason=no-account-context\n`);
25
- return {
26
- content: [
27
- {
28
- type: "text",
29
- text: `${tool} cannot execute: launched without ACCOUNT_ID/PLATFORM_ROOT (metadata-only mode).`,
30
- },
31
- ],
32
- isError: true,
33
- };
34
- }
35
- function refuseNoCreds(tool) {
36
- process.stderr.write(`[joblogic] tool=${tool} refuse reason=no-creds\n`);
37
- return {
38
- content: [
39
- {
40
- type: "text",
41
- text: `${tool} cannot execute: no JobLogic credentials set for this account. Run joblogic-credentials-set.`,
42
- },
43
- ],
44
- isError: true,
45
- };
46
- }
47
- function ok(data) {
48
- return {
49
- content: [
50
- { type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) },
51
- ],
52
- };
53
- }
54
- function fail(msg) {
55
- return { content: [{ type: "text", text: msg }], isError: true };
56
- }
57
- function withStore(tool) {
58
- if (!ACCOUNT_ID || !PLATFORM_ROOT)
59
- return { refusal: refuseNoAccount(tool) };
60
- const store = readStore(PLATFORM_ROOT, ACCOUNT_ID);
61
- if (!store)
62
- return { refusal: refuseNoCreds(tool) };
63
- return { store };
64
- }
65
- const server = new McpServer({ name: "joblogic", version: "0.1.0" });
66
- const body = z.record(z.unknown());
67
- // --- Management ----------------------------------------------------------
68
- lifelineTool(server, "joblogic-credentials-set", "Store this account's JobLogic integration credentials (OAuth client_credentials) and company tenant id. environment is 'uat' (test) or 'production'. Get client_id/secret from a JobLogic Support ticket; the source IP must be whitelisted by JobLogic.", {
69
- clientId: z.string(),
70
- clientSecret: z.string(),
71
- tenantId: z.string().describe("Company tenant id, required on every call"),
72
- environment: z.enum(["uat", "production"]),
73
- }, async ({ clientId, clientSecret, tenantId, environment }) => {
74
- if (!ACCOUNT_ID || !PLATFORM_ROOT)
75
- return refuseNoAccount("joblogic-credentials-set");
76
- try {
77
- setCredentials(PLATFORM_ROOT, ACCOUNT_ID, { clientId, clientSecret, tenantId, environment });
78
- return ok(`Stored JobLogic ${environment} credentials for tenant ${tenantId}.`);
79
- }
80
- catch (e) {
81
- return fail(`joblogic-credentials-set failed: ${e.message}`);
82
- }
83
- });
84
- lifelineTool(server, "joblogic-connection-status", "Probe JobLogic auth: acquire a token and report environment + tenant. Use to confirm the credentials and source-IP whitelisting work before relying on the connector.", {}, async () => {
85
- const r = withStore("joblogic-connection-status");
86
- if ("refusal" in r)
87
- return r.refusal;
88
- try {
89
- await getBearer(r.store, ACCOUNT_ID, { force: true });
90
- return ok({ environment: r.store.environment, tenantId: r.store.tenantId, token: "acquired" });
91
- }
92
- catch (e) {
93
- return fail(`joblogic-connection-status failed: ${e.message}`);
94
- }
95
- });
96
- lifelineTool(server, "joblogic-engineer-map-set", "Map sender phone numbers (E.164) to JobLogic engineer ids, so a voice-noted write is attributed to the engineer who reported it. Merges with existing entries.", { entries: z.record(z.string()).describe('e.g. {"+447700900001":"eng-7"}') }, async ({ entries }) => {
97
- const r = withStore("joblogic-engineer-map-set");
98
- if ("refusal" in r)
99
- return r.refusal;
100
- try {
101
- setEngineerMap(PLATFORM_ROOT, ACCOUNT_ID, entries);
102
- return ok(`Stored ${Object.keys(entries).length} engineer mapping(s).`);
103
- }
104
- catch (e) {
105
- return fail(`joblogic-engineer-map-set failed: ${e.message}`);
106
- }
107
- });
108
- lifelineTool(server, "joblogic-engineer-map-list", "List the stored sender-phone → JobLogic engineer id mappings for this account.", {}, async () => {
109
- const r = withStore("joblogic-engineer-map-list");
110
- if ("refusal" in r)
111
- return r.refusal;
112
- return ok(r.store.engineerMap);
113
- });
114
- // --- Read factory --------------------------------------------------------
115
- function readTool(tool, entity, path, description) {
116
- lifelineTool(server, tool, description, { query: z.record(z.string()).optional().describe("Optional JobLogic query params, e.g. { id: '123' } or filters") }, async ({ query }) => {
117
- const r = withStore(tool);
118
- if ("refusal" in r)
119
- return r.refusal;
120
- try {
121
- return ok(await jlRequest({ store: r.store, accountId: ACCOUNT_ID, method: "GET", path, entity, tool, query }));
122
- }
123
- catch (e) {
124
- return fail(`${tool} failed: ${e.message}`);
125
- }
126
- });
127
- }
128
- // --- Write (create, idempotent) factory ---------------------------------
129
- function createToolFactory(tool, entity, path, description, attributable) {
130
- const schema = {
131
- idemKey: z
132
- .string()
133
- .describe("Idempotency key — a retry with the same key returns the first record and sends nothing. Derive it deterministically from the write's natural key."),
134
- body: body.describe(`${entity} body (fields per the JobLogic Postman reference; provisional until UAT-confirmed)`),
135
- };
136
- if (attributable) {
137
- schema.senderPhone = z
138
- .string()
139
- .optional()
140
- .describe("Sender phone (E.164); resolved to an engineer id via the engineer map and stamped on the write.");
141
- }
142
- lifelineTool(server, tool, description, schema, async (a) => {
143
- const r = withStore(tool);
144
- if ("refusal" in r)
145
- return r.refusal;
146
- let writeBody = a.body;
147
- if (attributable && a.senderPhone) {
148
- const eng = resolveEngineer(r.store, a.senderPhone);
149
- // The map is the trusted attribution source: a resolved engineerId wins
150
- // over any caller-supplied body.engineerId.
151
- if (eng)
152
- writeBody = { ...a.body, engineerId: eng };
153
- }
154
- try {
155
- return ok(await jlCreate({
156
- store: r.store,
157
- accountId: ACCOUNT_ID,
158
- platformRoot: PLATFORM_ROOT,
159
- path,
160
- entity,
161
- tool,
162
- idemKey: a.idemKey,
163
- body: writeBody,
164
- }));
165
- }
166
- catch (e) {
167
- return fail(`${tool} failed: ${e.message}`);
168
- }
169
- });
170
- }
171
- // --- Update / transition (POST, non-idempotent — caller supplies the id) --
172
- function postTool(tool, entity, path, description) {
173
- lifelineTool(server, tool, description, { body: body.describe(`${entity} body — MUST include the record id`) }, async ({ body: b }) => {
174
- const r = withStore(tool);
175
- if ("refusal" in r)
176
- return r.refusal;
177
- try {
178
- return ok(await jlRequest({ store: r.store, accountId: ACCOUNT_ID, method: "POST", path, entity, tool, body: b }));
179
- }
180
- catch (e) {
181
- return fail(`${tool} failed: ${e.message}`);
182
- }
183
- });
184
- }
185
- // --- Lifecycle registrations (paths provisional vs the Postman collection) -
186
- readTool("joblogic-customer-list", "Customer", "Customer/GetAll", "List JobLogic customers.");
187
- readTool("joblogic-customer-get", "Customer", "Customer/GetById", "Get one JobLogic customer by id (pass { id }).");
188
- createToolFactory("joblogic-customer-create", "Customer", "Customer/Create", "Create a JobLogic customer.", false);
189
- postTool("joblogic-customer-update", "Customer", "Customer/Update", "Update a JobLogic customer (body includes id).");
190
- readTool("joblogic-site-list", "Site", "Site/GetAll", "List JobLogic sites.");
191
- readTool("joblogic-site-get", "Site", "Site/GetById", "Get one JobLogic site by id.");
192
- createToolFactory("joblogic-site-create", "Site", "Site/Create", "Create a JobLogic site.", false);
193
- postTool("joblogic-site-update", "Site", "Site/Update", "Update a JobLogic site (body includes id).");
194
- readTool("joblogic-job-list", "Job", "Job/GetAll", "List JobLogic jobs.");
195
- readTool("joblogic-job-get", "Job", "Job/GetById", "Get one JobLogic job by id.");
196
- createToolFactory("joblogic-job-create", "Job", "Job/Create", "Create a JobLogic job.", false);
197
- postTool("joblogic-job-update", "Job", "Job/Update", "Update a JobLogic job (body includes id).");
198
- postTool("joblogic-job-set-status", "Job", "Job/SetStatus", "Set a job's status (body includes id + status).");
199
- postTool("joblogic-job-approve", "Job", "Job/Approve", "Approve a job (body includes id).");
200
- readTool("joblogic-engineer-list", "Engineer", "Engineer/GetAll", "List JobLogic engineers.");
201
- readTool("joblogic-engineer-get", "Engineer", "Engineer/GetById", "Get one JobLogic engineer by id.");
202
- readTool("joblogic-visit-search-planner", "Visit", "Visit/SearchPlanner", "Search the JobLogic visit planner (pass date/engineer filters in query).");
203
- readTool("joblogic-visit-get", "Visit", "Visit/GetById", "Get one JobLogic visit by id.");
204
- createToolFactory("joblogic-visit-create", "Visit", "Visit/Create", "Create a JobLogic visit.", true);
205
- postTool("joblogic-visit-update", "Visit", "Visit/Update", "Update a JobLogic visit (body includes id).");
206
- postTool("joblogic-visit-deploy", "Visit", "Visit/Deploy", "Deploy a JobLogic visit to an engineer (body includes id).");
207
- postTool("joblogic-visit-cancel", "Visit", "Visit/Cancel", "Cancel a JobLogic visit (body includes id).");
208
- readTool("joblogic-quote-list", "Quote", "Quote/GetAll", "List JobLogic quotes.");
209
- readTool("joblogic-quote-get", "Quote", "Quote/GetById", "Get one JobLogic quote by id.");
210
- createToolFactory("joblogic-quote-create", "Quote", "Quote/Create", "Create a JobLogic quote.", false);
211
- postTool("joblogic-quote-approve", "Quote", "Quote/Approve", "Approve a JobLogic quote (body includes id).");
212
- readTool("joblogic-invoice-list", "Invoice", "Invoice/GetAll", "List JobLogic invoices.");
213
- readTool("joblogic-invoice-get", "Invoice", "Invoice/GetById", "Get one JobLogic invoice by id.");
214
- createToolFactory("joblogic-invoice-create", "Invoice", "Invoice/Create", "Create (raise) a JobLogic invoice.", false);
215
- createToolFactory("joblogic-invoice-payment-create", "InvoicePayment", "Invoice/Payment/Create", "Record a payment against a JobLogic invoice.", false);
216
- readTool("joblogic-asset-list", "Asset", "Asset/GetAll", "List JobLogic assets.");
217
- readTool("joblogic-asset-get", "Asset", "Asset/GetById", "Get one JobLogic asset by id.");
218
- createToolFactory("joblogic-asset-create", "Asset", "Asset/Create", "Create a JobLogic asset.", false);
219
- postTool("joblogic-asset-update", "Asset", "Asset/Update", "Update a JobLogic asset (body includes id).");
220
- readTool("joblogic-timesheet-list", "Timesheet", "Timesheet/GetAll", "List JobLogic timesheets.");
221
- createToolFactory("joblogic-timesheet-create", "Timesheet", "Timesheet/Create", "Create a JobLogic timesheet entry.", true);
222
- postTool("joblogic-timesheet-update", "Timesheet", "Timesheet/Update", "Update a JobLogic timesheet entry (body includes id).");
223
- createToolFactory("joblogic-jobcost-create", "JobCost", "JobCost/Create", "Create a JobLogic job-cost line. Set body.kind to Labour|Material|Travel|Mileage|Expense.", true);
224
- postTool("joblogic-jobcost-update", "JobCost", "JobCost/Update", "Update a JobLogic job-cost line (body includes id).");
225
- createToolFactory("joblogic-note-create", "Note", "Note/Create", "Create a note on a job/visit (e.g. a voice-note transcript).", true);
226
- readTool("joblogic-attachment-url-generate", "Attachment", "Attachment/GenerateUrl", "Generate an upload URL for an attachment (field photo etc.).");
227
- const transport = new StdioServerTransport();
228
- await server.connect(transport);
229
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,aAAa,CAAC,UAAU,CAAC,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAgB,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM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