@stackwright-pro/mcp 0.2.0-alpha.100 → 0.2.0-alpha.101

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
@@ -4117,6 +4117,67 @@ function handleValidateArtifact(input) {
4117
4117
  }
4118
4118
  return result;
4119
4119
  }
4120
+ function handleEmitEvent(input) {
4121
+ const emitFn = input._emit ?? import_telemetry.emit;
4122
+ try {
4123
+ const caller = input.otter ?? "foreman";
4124
+ if (caller !== "foreman") {
4125
+ return {
4126
+ text: JSON.stringify({
4127
+ emitted: false,
4128
+ reason: `AUTHORIZATION: only the foreman otter may emit lifecycle events. Specialist otters should signal completion via their response text and the artifact write \u2014 not by emitting phase events. Caller was "${caller}". This is informational, not a failure.`
4129
+ }),
4130
+ isError: false
4131
+ };
4132
+ }
4133
+ let emitted = false;
4134
+ if (input.type === "phase_start") {
4135
+ if (!input.phase) {
4136
+ return {
4137
+ text: JSON.stringify({ emitted: false, reason: "phase required for phase_start" }),
4138
+ isError: false
4139
+ };
4140
+ }
4141
+ emitted = emitFn({ type: "phase_start", phase: input.phase, otter: caller });
4142
+ } else if (input.type === "phase_complete") {
4143
+ if (!input.phase) {
4144
+ return {
4145
+ text: JSON.stringify({ emitted: false, reason: "phase required for phase_complete" }),
4146
+ isError: false
4147
+ };
4148
+ }
4149
+ emitted = emitFn({
4150
+ type: "phase_complete",
4151
+ phase: input.phase,
4152
+ otter: caller,
4153
+ ...input.durationSec != null ? { durationSec: input.durationSec } : {}
4154
+ });
4155
+ } else if (input.type === "agent_invoke_start") {
4156
+ emitted = emitFn({
4157
+ type: "agent_invoke_start",
4158
+ targetOtter: input.targetOtter ?? "",
4159
+ phase: input.phase,
4160
+ otter: caller
4161
+ });
4162
+ } else if (input.type === "agent_invoke_complete") {
4163
+ emitted = emitFn({
4164
+ type: "agent_invoke_complete",
4165
+ targetOtter: input.targetOtter ?? "",
4166
+ success: input.success ?? true,
4167
+ phase: input.phase,
4168
+ otter: caller,
4169
+ ...input.durationSec != null ? { durationSec: input.durationSec } : {}
4170
+ });
4171
+ }
4172
+ return { text: JSON.stringify({ emitted }), isError: false };
4173
+ } catch (err) {
4174
+ const reason = err instanceof Error ? err.message : String(err);
4175
+ return {
4176
+ text: JSON.stringify({ emitted: false, reason: `telemetry error (non-fatal): ${reason}` }),
4177
+ isError: false
4178
+ };
4179
+ }
4180
+ }
4120
4181
  function registerPipelineTools(server2) {
4121
4182
  const DESC = "Writes state to .stackwright/ \u2014 the filesystem is the state machine.";
4122
4183
  const res = (r) => ({
@@ -4268,60 +4329,18 @@ function registerPipelineTools(server2) {
4268
4329
  );
4269
4330
  server2.tool(
4270
4331
  "stackwright_pro_emit_event",
4271
- `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}`,
4332
+ `FOREMAN ONLY \u2014 specialist otters that call this will receive an authorization rejection (no-op, not an error). 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}`,
4272
4333
  {
4273
4334
  type: import_zod13.z.enum(["phase_start", "phase_complete", "agent_invoke_start", "agent_invoke_complete"]).describe("Event type to emit"),
4274
4335
  phase: import_zod13.z.string().optional().describe("Current phase name"),
4275
4336
  targetOtter: import_zod13.z.string().optional().describe("For agent_invoke_* events: which otter is being invoked"),
4276
- success: import_zod13.z.boolean().optional().describe("For agent_invoke_complete: did the invocation succeed?"),
4337
+ success: boolCoerce(import_zod13.z.boolean().optional()).describe(
4338
+ 'For agent_invoke_complete: did the invocation succeed? (boolean; string "true"/"false" also accepted for caller tolerance)'
4339
+ ),
4277
4340
  otter: import_zod13.z.string().optional().describe('Which otter is emitting (defaults to "foreman")'),
4278
4341
  durationSec: import_zod13.z.number().optional().describe("Duration in seconds (for *_complete events)")
4279
4342
  },
4280
- async ({ type, phase, targetOtter, success, otter, durationSec }) => {
4281
- let emitted = false;
4282
- try {
4283
- if (type === "phase_start") {
4284
- if (!phase) {
4285
- return res({
4286
- text: JSON.stringify({ emitted: false, reason: "phase required for phase_start" }),
4287
- isError: false
4288
- });
4289
- }
4290
- emitted = (0, import_telemetry.emit)({ type: "phase_start", phase, otter: otter ?? "foreman" });
4291
- } else if (type === "phase_complete") {
4292
- if (!phase) {
4293
- return res({
4294
- text: JSON.stringify({ emitted: false, reason: "phase required for phase_complete" }),
4295
- isError: false
4296
- });
4297
- }
4298
- emitted = (0, import_telemetry.emit)({
4299
- type: "phase_complete",
4300
- phase,
4301
- otter: otter ?? "foreman",
4302
- ...durationSec != null ? { durationSec } : {}
4303
- });
4304
- } else if (type === "agent_invoke_start") {
4305
- emitted = (0, import_telemetry.emit)({
4306
- type: "agent_invoke_start",
4307
- targetOtter: targetOtter ?? "",
4308
- phase,
4309
- otter: otter ?? "foreman"
4310
- });
4311
- } else if (type === "agent_invoke_complete") {
4312
- emitted = (0, import_telemetry.emit)({
4313
- type: "agent_invoke_complete",
4314
- targetOtter: targetOtter ?? "",
4315
- success: success ?? true,
4316
- phase,
4317
- otter: otter ?? "foreman",
4318
- ...durationSec != null ? { durationSec } : {}
4319
- });
4320
- }
4321
- } catch {
4322
- }
4323
- return res({ text: JSON.stringify({ emitted }), isError: false });
4324
- }
4343
+ async ({ type, phase, targetOtter, success, otter, durationSec }) => res(handleEmitEvent({ type, phase, targetOtter, success, otter, durationSec }))
4325
4344
  );
4326
4345
  }
4327
4346
 
@@ -5794,7 +5813,7 @@ var _checksums = /* @__PURE__ */ new Map([
5794
5813
  ],
5795
5814
  [
5796
5815
  "stackwright-services-otter.json",
5797
- "8997bdd9a6fd3e6e02563578a1649480bc21acf919534ae41f73e70ade7cf500"
5816
+ "2a50ceb3fad166251d0ad8709a34a32118645713e0e34628165d16dced1d5c93"
5798
5817
  ]
5799
5818
  ]);
5800
5819
  Object.freeze(_checksums);
@@ -7539,7 +7558,7 @@ var package_default = {
7539
7558
  "test:coverage": "vitest run --coverage"
7540
7559
  },
7541
7560
  name: "@stackwright-pro/mcp",
7542
- version: "0.2.0-alpha.100",
7561
+ version: "0.2.0-alpha.101",
7543
7562
  description: "MCP tools for Stackwright Pro - Data Explorer, Security, ISR, and Dashboard generation",
7544
7563
  license: "SEE LICENSE IN LICENSE",
7545
7564
  main: "./dist/server.js",