@stackwright-pro/mcp 0.2.0-alpha.97 → 0.2.0-alpha.98

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/server.js CHANGED
@@ -2905,6 +2905,7 @@ function loadPipelineGraph() {
2905
2905
  }
2906
2906
 
2907
2907
  // src/tools/pipeline.ts
2908
+ var import_telemetry = require("@stackwright-pro/telemetry");
2908
2909
  var PHASE_ORDER = [
2909
2910
  "designer",
2910
2911
  "theme",
@@ -3119,6 +3120,28 @@ function handleSetPipelineState(input) {
3119
3120
  }
3120
3121
  }
3121
3122
  writeState(cwd, state);
3123
+ try {
3124
+ const completedPhases = Object.entries(state.phases).filter(([, ps]) => ps.artifactWritten).map(([p]) => p);
3125
+ (0, import_telemetry.emit)(
3126
+ {
3127
+ type: "pipeline_state_change",
3128
+ state: state.status,
3129
+ phases: { ready: [], completed: completedPhases, blocked: [] }
3130
+ },
3131
+ { cwd }
3132
+ );
3133
+ if (input.field === "artifactWritten" && input.value === true && input.phase) {
3134
+ (0, import_telemetry.emit)({ type: "phase_complete", phase: input.phase }, { cwd });
3135
+ }
3136
+ if (input.updates) {
3137
+ for (const update of input.updates) {
3138
+ if (update.field === "artifactWritten" && update.value === true) {
3139
+ (0, import_telemetry.emit)({ type: "phase_complete", phase: update.phase }, { cwd });
3140
+ }
3141
+ }
3142
+ }
3143
+ } catch {
3144
+ }
3122
3145
  return { text: JSON.stringify(state), isError: false };
3123
3146
  } catch (err) {
3124
3147
  return { text: JSON.stringify({ error: true, message: String(err) }), isError: true };
@@ -3824,7 +3847,7 @@ var PHASE_ARTIFACT_SCHEMA = {
3824
3847
  2
3825
3848
  )
3826
3849
  };
3827
- function handleValidateArtifact(input) {
3850
+ function _validateArtifactInner(input) {
3828
3851
  const cwd = input._cwd ?? process.cwd();
3829
3852
  const { phase, responseText, artifact: directArtifact } = input;
3830
3853
  if (!isValidPhase2(phase)) {
@@ -4046,6 +4069,32 @@ function handleValidateArtifact(input) {
4046
4069
  return { text: JSON.stringify({ error: true, phase, message }), isError: true };
4047
4070
  }
4048
4071
  }
4072
+ function handleValidateArtifact(input) {
4073
+ const cwd = input._cwd ?? process.cwd();
4074
+ const { phase } = input;
4075
+ (0, import_telemetry.emit)(
4076
+ { type: "tool_call", toolName: "stackwright_pro_validate_artifact", args: { phase }, phase },
4077
+ { cwd }
4078
+ );
4079
+ const result = _validateArtifactInner(input);
4080
+ try {
4081
+ const parsed = JSON.parse(result.text);
4082
+ if (parsed.valid === true && parsed.artifactPath) {
4083
+ (0, import_telemetry.emit)({ type: "file_write", path: parsed.artifactPath, phase }, { cwd });
4084
+ }
4085
+ (0, import_telemetry.emit)(
4086
+ {
4087
+ type: "tool_complete",
4088
+ toolName: "stackwright_pro_validate_artifact",
4089
+ success: parsed.valid === true,
4090
+ phase
4091
+ },
4092
+ { cwd }
4093
+ );
4094
+ } catch {
4095
+ }
4096
+ return result;
4097
+ }
4049
4098
  function registerPipelineTools(server2) {
4050
4099
  const DESC = "Writes state to .stackwright/ \u2014 the filesystem is the state machine.";
4051
4100
  const res = (r) => ({
@@ -4182,12 +4231,70 @@ function registerPipelineTools(server2) {
4182
4231
  return res(handleValidateArtifact({ phase, responseText: responseText ?? "" }));
4183
4232
  }
4184
4233
  );
4234
+ server2.tool(
4235
+ "stackwright_pro_emit_event",
4236
+ `Emit a telemetry event to .stackwright/pipeline-events.ndjson. Foreman calls this at phase boundaries and agent-invoke boundaries. Best-effort: failures are silent and never block. ${DESC}`,
4237
+ {
4238
+ type: import_zod13.z.enum(["phase_start", "phase_complete", "agent_invoke_start", "agent_invoke_complete"]).describe("Event type to emit"),
4239
+ phase: import_zod13.z.string().optional().describe("Current phase name"),
4240
+ targetOtter: import_zod13.z.string().optional().describe("For agent_invoke_* events: which otter is being invoked"),
4241
+ success: import_zod13.z.boolean().optional().describe("For agent_invoke_complete: did the invocation succeed?"),
4242
+ otter: import_zod13.z.string().optional().describe('Which otter is emitting (defaults to "foreman")'),
4243
+ durationSec: import_zod13.z.number().optional().describe("Duration in seconds (for *_complete events)")
4244
+ },
4245
+ async ({ type, phase, targetOtter, success, otter, durationSec }) => {
4246
+ let emitted = false;
4247
+ try {
4248
+ if (type === "phase_start") {
4249
+ if (!phase) {
4250
+ return res({
4251
+ text: JSON.stringify({ emitted: false, reason: "phase required for phase_start" }),
4252
+ isError: false
4253
+ });
4254
+ }
4255
+ emitted = (0, import_telemetry.emit)({ type: "phase_start", phase, otter: otter ?? "foreman" });
4256
+ } else if (type === "phase_complete") {
4257
+ if (!phase) {
4258
+ return res({
4259
+ text: JSON.stringify({ emitted: false, reason: "phase required for phase_complete" }),
4260
+ isError: false
4261
+ });
4262
+ }
4263
+ emitted = (0, import_telemetry.emit)({
4264
+ type: "phase_complete",
4265
+ phase,
4266
+ otter: otter ?? "foreman",
4267
+ ...durationSec != null ? { durationSec } : {}
4268
+ });
4269
+ } else if (type === "agent_invoke_start") {
4270
+ emitted = (0, import_telemetry.emit)({
4271
+ type: "agent_invoke_start",
4272
+ targetOtter: targetOtter ?? "",
4273
+ phase,
4274
+ otter: otter ?? "foreman"
4275
+ });
4276
+ } else if (type === "agent_invoke_complete") {
4277
+ emitted = (0, import_telemetry.emit)({
4278
+ type: "agent_invoke_complete",
4279
+ targetOtter: targetOtter ?? "",
4280
+ success: success ?? true,
4281
+ phase,
4282
+ otter: otter ?? "foreman",
4283
+ ...durationSec != null ? { durationSec } : {}
4284
+ });
4285
+ }
4286
+ } catch {
4287
+ }
4288
+ return res({ text: JSON.stringify({ emitted }), isError: false });
4289
+ }
4290
+ );
4185
4291
  }
4186
4292
 
4187
4293
  // src/tools/safe-write.ts
4188
4294
  var import_zod14 = require("zod");
4189
4295
  var import_fs7 = require("fs");
4190
4296
  var import_path7 = require("path");
4297
+ var import_telemetry2 = require("@stackwright-pro/telemetry");
4191
4298
  var OTTER_WRITE_ALLOWLISTS = {
4192
4299
  "stackwright-pro-designer-otter": [
4193
4300
  { prefix: ".stackwright/artifacts/", suffix: ".json", description: "Design language artifact" }
@@ -4515,7 +4622,7 @@ function validateContent(filePath, content) {
4515
4622
  if (filePath === ".env" || filePath.startsWith(".env")) return validateEnvContent(content);
4516
4623
  return null;
4517
4624
  }
4518
- function handleSafeWrite(input) {
4625
+ function _safeWriteInner(input) {
4519
4626
  const cwd = input._cwd ?? process.cwd();
4520
4627
  const { callerOtter, filePath, content, createDirectories = true } = input;
4521
4628
  const check = checkPathAllowed(callerOtter, filePath);
@@ -4623,6 +4730,31 @@ function handleSafeWrite(input) {
4623
4730
  return { text: JSON.stringify(result), isError: true };
4624
4731
  }
4625
4732
  }
4733
+ function handleSafeWrite(input) {
4734
+ const cwd = input._cwd ?? process.cwd();
4735
+ const { filePath, callerOtter } = input;
4736
+ (0, import_telemetry2.emit)(
4737
+ { type: "tool_call", toolName: "stackwright_pro_safe_write", args: { callerOtter, filePath } },
4738
+ { cwd }
4739
+ );
4740
+ const result = _safeWriteInner(input);
4741
+ try {
4742
+ const parsed = JSON.parse(result.text);
4743
+ if (parsed.success === true && parsed.path) {
4744
+ (0, import_telemetry2.emit)({ type: "file_write", path: parsed.path, bytes: parsed.bytesWritten }, { cwd });
4745
+ }
4746
+ (0, import_telemetry2.emit)(
4747
+ {
4748
+ type: "tool_complete",
4749
+ toolName: "stackwright_pro_safe_write",
4750
+ success: parsed.success === true
4751
+ },
4752
+ { cwd }
4753
+ );
4754
+ } catch {
4755
+ }
4756
+ return result;
4757
+ }
4626
4758
  function registerSafeWriteTools(server2) {
4627
4759
  const DESC = "Controlled file-write chokepoint. Every write from specialist otters goes through this tool with per-otter path allowlists. The LLM cannot write to arbitrary filesystem paths.";
4628
4760
  server2.tool(
@@ -5564,63 +5696,63 @@ var import_path9 = require("path");
5564
5696
  var _checksums = /* @__PURE__ */ new Map([
5565
5697
  [
5566
5698
  "stackwright-pro-api-otter.json",
5567
- "822b35d7a330ed8ac0b42a63b0f70a41885aa9b5ea23cc5b8b998b549da4c05c"
5699
+ "b3ad28c4404af9fb3c2cfce258c707dadd37bc59ac236e1f46d6163cd8d5dc9b"
5568
5700
  ],
5569
5701
  [
5570
5702
  "stackwright-pro-auth-otter.json",
5571
- "d6cd5732667018d99456be77d5955e454da7a0999a0330b5f03a483aa1b9b33f"
5703
+ "1a21d9f23e250f23291124307e5a2a32af5a716566319a3290372dae3d02e637"
5572
5704
  ],
5573
5705
  [
5574
5706
  "stackwright-pro-dashboard-otter.json",
5575
- "19268b1ab423bfbb628ebfbc9f6767d5c0bfedd03963c6d445a2724a8bb78f9c"
5707
+ "d9277616db5680ce3d598908fa3a1b0d0f626e33948785a4c64703b85e463b31"
5576
5708
  ],
5577
5709
  [
5578
5710
  "stackwright-pro-data-otter.json",
5579
- "bb66eaab31c6872536dca4d3ff145724a46356946dd0665cc4f0346714d3bacb"
5711
+ "536cba95f32667e81ae4b6335378a095f91095598defff0de00af231ebdbc488"
5580
5712
  ],
5581
5713
  [
5582
5714
  "stackwright-pro-designer-otter.json",
5583
- "b54121c6a2ab5b1ad68c1262c58b2e04e6315feacd6bb8de8e78eb36f2fa6be6"
5715
+ "69a6c09fbb54f971c48eae7fd52faa63cf79be2923e435aca9ff802e8d541d0f"
5584
5716
  ],
5585
5717
  [
5586
5718
  "stackwright-pro-domain-expert-otter.json",
5587
- "1f21b8ff3450bdae29a4d31b31462ba22583995a448af3c11ab0a5071f46bd72"
5719
+ "14d77cade020f44d1b5a2b406e2599501f3466ee90ca4248500a441d419bc59c"
5588
5720
  ],
5589
5721
  [
5590
5722
  "stackwright-pro-foreman-otter.json",
5591
- "abb1cc5e40a8c5ff98057273f43a9e90e2791a15951090cd4d98407c0c3618e3"
5723
+ "4db4639e618cdd008d86c416bbc88bd4b2a7965e4bfcf01ec54b828f04ccb816"
5592
5724
  ],
5593
5725
  [
5594
5726
  "stackwright-pro-form-wizard-otter.json",
5595
- "975ad68e8fb6fe5a10373be278946fa4d9d7ec2238a0b2bd9e4a412e5b1fdd6d"
5727
+ "7f6f94192f26face57dc8b2e22e0a49d23ceeeb356ca4ebde05492f1b25e3c47"
5596
5728
  ],
5597
5729
  [
5598
5730
  "stackwright-pro-geo-otter.json",
5599
- "eef152e5b58947c8eb1ffec2c37acffc39f84b61be4c6cb827310f052221935b"
5731
+ "15f2327b69f75a9c772c2acad5a5d6d3daefb7b55a079aca3205ecd4f33ae349"
5600
5732
  ],
5601
5733
  [
5602
5734
  "stackwright-pro-page-otter.json",
5603
- "ddfa497a4d4980080fa2918aec4d6dfd78d5c28ec6426b4b52f4f26fccaddabb"
5735
+ "c467c5d03b69d87fb1efa9482674a25e2f63782189db74b65309928d47456176"
5604
5736
  ],
5605
5737
  [
5606
5738
  "stackwright-pro-polish-otter.json",
5607
- "5e6532c1fe0737ed83b1f46dd55642e1076adb6ef23d4de636523eb3d88d3087"
5739
+ "1cfea28e121e30181b0a7c8bda0700ffc892a6f919a0ec64996a4cf3f7735b51"
5608
5740
  ],
5609
5741
  [
5610
5742
  "stackwright-pro-qa-otter.json",
5611
- "ecb1e76170723fce43f515044e304d9da32253dadecbf29bf08c90bb8f375f77"
5743
+ "822075893bb4f8496f3dca7b0e68eda460a6fbde87480c13c194582eb7744318"
5612
5744
  ],
5613
5745
  [
5614
5746
  "stackwright-pro-scaffold-otter.json",
5615
- "96ac7754b54c15732206cd4d8043b558d0c465757a0bc70fae6b498d6f02f22a"
5747
+ "341d74ff2be24893ed174e869dc40c090f82e25e11d412d63519944512c37f15"
5616
5748
  ],
5617
5749
  [
5618
5750
  "stackwright-pro-theme-otter.json",
5619
- "fb62e56642f7f94c50ce173f3e1ce978b3f20ab1567e87403b901d6dd991a7db"
5751
+ "b0eccc1945e30b80a0f9a3209c5428e8e32cd09063bd9b2ef7ecb891343774f2"
5620
5752
  ],
5621
5753
  [
5622
5754
  "stackwright-services-otter.json",
5623
- "0a5dac670482871c718099767b30bf23d8ec57e942bd40a00ce295926d82c6bd"
5755
+ "8997bdd9a6fd3e6e02563578a1649480bc21acf919534ae41f73e70ade7cf500"
5624
5756
  ]
5625
5757
  ]);
5626
5758
  Object.freeze(_checksums);
@@ -7059,6 +7191,7 @@ var package_default = {
7059
7191
  "@stackwright-pro/cli-data-explorer": "workspace:*",
7060
7192
  "@stackwright-pro/openapi": "workspace:*",
7061
7193
  "@stackwright-pro/pulse": "workspace:*",
7194
+ "@stackwright-pro/telemetry": "workspace:*",
7062
7195
  "@stackwright-pro/types": "workspace:*",
7063
7196
  "@stackwright/mcp": "0.6.0-alpha.1",
7064
7197
  "@types/js-yaml": "^4.0.9",
@@ -7080,7 +7213,7 @@ var package_default = {
7080
7213
  "test:coverage": "vitest run --coverage"
7081
7214
  },
7082
7215
  name: "@stackwright-pro/mcp",
7083
- version: "0.2.0-alpha.97",
7216
+ version: "0.2.0-alpha.98",
7084
7217
  description: "MCP tools for Stackwright Pro - Data Explorer, Security, ISR, and Dashboard generation",
7085
7218
  license: "SEE LICENSE IN LICENSE",
7086
7219
  main: "./dist/server.js",