showrunner-agent-staging 0.5.135-staging.2139 → 0.5.135-staging.2142

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.
@@ -14,7 +14,7 @@ import { isBareApprovalReply } from "./approval-replies.js";
14
14
  import { withoutDanglingDashes } from "./output-vocabulary.js";
15
15
  import { withoutHarnessMarkup } from "./harness-markup.js";
16
16
  import { isPermissionRefusal, normalizeWorkReportSpacing, replySummaryPieces, replyNotePieces, shouldCreateReplyNote } from "./reply-note.js";
17
- import { isTransientFailure } from "./handler.js";
17
+ import { isDueTask, isTransientFailure } from "./handler.js";
18
18
  import { describeStoppedWork } from "./process-ledger.js";
19
19
  import { withoutCheckoutPaths, withoutHostPaths } from "./checkout-paths.js";
20
20
  import { ActiveRunRegistry, overlapInstructions } from "./active-runs.js";
@@ -329,8 +329,10 @@ export function createAdapterProcessor(input) {
329
329
  deliveryId: correction.deliveryId,
330
330
  expectsReply,
331
331
  text: answeredCardReply === undefined
332
- ? `New message to you from ${correction.event.type === "message.created" && correction.event.message.authorTrust === "agent"
333
- ? "the agent you asked" : correction.initiatingProfile.displayName}, posted in ${whereSent(correction)} while you work:\n` +
332
+ ? (isDueTask(correction)
333
+ ? `A scheduled task of yours came due while you work, for ${correction.initiatingProfile.displayName}:\n`
334
+ : `New message to you from ${correction.event.type === "message.created" && correction.event.message.authorTrust === "agent"
335
+ ? "the agent you asked" : correction.initiatingProfile.displayName}, posted in ${whereSent(correction)} while you work:\n`) +
334
336
  withMediaFallbacks(messageText(correction), media.fallbackText) +
335
337
  (expectsReply
336
338
  ? "\nIf a reply is needed, address the person as ‘you’ and set replyToMessageId to its messageId. " +
@@ -644,14 +644,19 @@ export function createCloudServer(options) {
644
644
  const resourcePath = path.slice("/.well-known/oauth-protected-resource".length);
645
645
  json(response, 200, {
646
646
  resource: isMcpPath(resourcePath, mcpPath) ? `${origin}${resourcePath}` : options.toolServerUrl,
647
- authorization_servers: [origin],
647
+ // The person's MCP names an authorization server of its own, whose sign-in address carries the
648
+ // resource: some clients never send `resource`, and without it sign-in would be agent pairing.
649
+ authorization_servers: [isUserMcpPath(resourcePath, mcpPath) ? `${origin}${resourcePath}` : origin],
648
650
  bearer_methods_supported: ["header"],
649
651
  resource_name: "Showrunner",
650
652
  });
651
653
  return;
652
654
  }
653
- if (request.method === "GET" && path === "/.well-known/oauth-authorization-server") {
654
- const metadata = await fetcher(`${apiBaseUrl}/api/agent-oauth/metadata`, { signal: AbortSignal.timeout(10_000) })
655
+ const authorizationServerPrefix = "/.well-known/oauth-authorization-server";
656
+ const issuerPath = path.startsWith(authorizationServerPrefix) ? path.slice(authorizationServerPrefix.length) : undefined;
657
+ if (request.method === "GET" && (issuerPath === "" || (issuerPath !== undefined && isUserMcpPath(issuerPath, mcpPath)))) {
658
+ const query = issuerPath === "" ? "" : `?resource=${encodeURIComponent(`${origin}${issuerPath}`)}`;
659
+ const metadata = await fetcher(`${apiBaseUrl}/api/agent-oauth/metadata${query}`, { signal: AbortSignal.timeout(10_000) })
655
660
  .then((result) => result.ok ? result.json() : undefined)
656
661
  .catch(() => undefined);
657
662
  if (metadata === undefined) {
@@ -271,12 +271,8 @@ export function createMcpRequestHandler(options) {
271
271
  };
272
272
  return handler;
273
273
  async function handleRequest(request, response) {
274
- if (request.method !== "POST") {
275
- // Stateless: there is no server-initiated stream to open and no session to end.
276
- closeRequestAfterResponse(request, response);
277
- response.writeHead(405, { Allow: "POST" }).end();
278
- return;
279
- }
274
+ // The challenge comes before the method check: an agent handed only the address often probes it
275
+ // with a GET, and the challenge is what tells it where to sign in.
280
276
  const principal = await options.authenticate(request);
281
277
  if (principal === undefined) {
282
278
  closeRequestAfterResponse(request, response);
@@ -284,6 +280,12 @@ export function createMcpRequestHandler(options) {
284
280
  .end(JSON.stringify({ error: "unauthorized" }));
285
281
  return;
286
282
  }
283
+ if (request.method !== "POST") {
284
+ // Stateless: there is no server-initiated stream to open and no session to end.
285
+ closeRequestAfterResponse(request, response);
286
+ response.writeHead(405, { Allow: "POST" }).end();
287
+ return;
288
+ }
287
289
  const contentLength = Number(request.headers["content-length"]);
288
290
  if (contentLength > maxRequestBytes) {
289
291
  rejectOversizedRequest(request, response);
@@ -79,6 +79,7 @@ export declare class AgentEventHandler {
79
79
  waitForIdle(): Promise<void>;
80
80
  processPending(): Promise<void>;
81
81
  }
82
+ export declare function isDueTask(event: AgentEvent): boolean;
82
83
  export declare function isTransientFailure(error: unknown): boolean;
83
84
  export declare class InvocationCancelledError extends Error {
84
85
  }
@@ -539,17 +539,17 @@ function canCorrect(active, correction) {
539
539
  return answers !== undefined && (answers === active.invocation.id ||
540
540
  (active.event.type === "message.created" && answers === active.event.answersInvocationId));
541
541
  }
542
- if (active.event.type !== "message.created" || correction.event.message.authorTrust === "system" ||
543
- correction.event.scheduledToDoId !== undefined)
542
+ if (active.event.type !== "message.created" || correction.event.message.authorTrust === "system")
544
543
  return false;
545
- // A due task runs on its own and is never folded into a live run. A person's message reaches the live
546
- // run whatever started it or whichever thread it's in, as typing into the CLI reaches it while it
547
- // works; the agent answers it in its own thread.
548
- const senderProfileId = correction.event.message.senderProfileId;
549
- return senderProfileId === correction.initiatingProfile.id &&
550
- (senderProfileId === active.initiatingProfile.id || senderProfileId === (active.installation.ownerProfileId ?? active.trust.ownerProfileId));
544
+ // A person's message or a due task reaches the live run whatever started it or whichever thread it's in,
545
+ // as typing into the CLI reaches it while it works; the agent answers it in its own thread. A due task is
546
+ // sent by whoever created the task, so only the person it runs for counts.
547
+ const initiator = correction.initiatingProfile.id;
548
+ if (correction.event.scheduledToDoId === undefined && correction.event.message.senderProfileId !== initiator)
549
+ return false;
550
+ return initiator === active.initiatingProfile.id || initiator === (active.installation.ownerProfileId ?? active.trust.ownerProfileId);
551
551
  }
552
- function isDueTask(event) {
552
+ export function isDueTask(event) {
553
553
  return event.event.type === "message.created" && event.event.scheduledToDoId !== undefined;
554
554
  }
555
555
  function abortError(signal) {
@@ -9,6 +9,7 @@ export declare const AgentActionType: {
9
9
  readonly ExternalActionResult: 6;
10
10
  readonly ConnectionIssue: 7;
11
11
  readonly IMessageImport: 8;
12
+ readonly OtherApps: 10;
12
13
  };
13
14
  export type AgentActionType = (typeof AgentActionType)[keyof typeof AgentActionType];
14
15
  export declare const SelectionType: {
@@ -126,5 +127,8 @@ export declare const agentActionDescriptionSchema: z.ZodDiscriminatedUnion<[z.Zo
126
127
  }, z.core.$strip>, z.ZodObject<{
127
128
  type: z.ZodLiteral<8>;
128
129
  agentActionId: z.ZodString;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ type: z.ZodLiteral<10>;
132
+ agentActionId: z.ZodString;
129
133
  }, z.core.$strip>], "type">;
130
134
  export type AgentActionDescription = z.infer<typeof agentActionDescriptionSchema>;
@@ -14,6 +14,7 @@ exports.AgentActionType = {
14
14
  ExternalActionResult: 6,
15
15
  ConnectionIssue: 7,
16
16
  IMessageImport: 8,
17
+ OtherApps: 10,
17
18
  };
18
19
  exports.SelectionType = {
19
20
  SingleSelect: 0,
@@ -88,4 +89,8 @@ exports.agentActionDescriptionSchema = zod_1.z.discriminatedUnion("type", [
88
89
  type: zod_1.z.literal(exports.AgentActionType.IMessageImport),
89
90
  agentActionId: zod_1.z.string().check(zod_1.z.uuid()),
90
91
  }).describe("IMessageImport — the iMessage import card. On Mac it starts the scan; elsewhere it says the import runs from the Mac app."),
92
+ zod_1.z.object({
93
+ type: zod_1.z.literal(exports.AgentActionType.OtherApps),
94
+ agentActionId: zod_1.z.string().check(zod_1.z.uuid()),
95
+ }).describe("OtherApps — the Showrunner MCP card. It opens the Settings page where the user connects Claude, ChatGPT, Cursor and other apps."),
91
96
  ]);
@@ -18,6 +18,7 @@ export declare const CreateAgentMessagePieceType: {
18
18
  readonly OpaqueReference: 14;
19
19
  readonly RetainedPieceReference: 15;
20
20
  readonly IMessageImportAction: 16;
21
+ readonly OtherAppsAction: 17;
21
22
  };
22
23
  export type CreateAgentMessagePieceType = typeof CreateAgentMessagePieceType[keyof typeof CreateAgentMessagePieceType];
23
24
  export declare const createAgentMessagePieceRequestSchema: z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
@@ -96,6 +97,8 @@ export declare const createAgentMessagePieceRequestSchema: z.ZodDiscriminatedUni
96
97
  noteId: z.ZodString;
97
98
  }, z.core.$strip>, z.ZodObject<{
98
99
  type: z.ZodLiteral<16>;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ type: z.ZodLiteral<17>;
99
102
  }, z.core.$strip>], "type">;
100
103
  declare const createOpaqueReferencePieceRequestSchema: z.ZodObject<{
101
104
  type: z.ZodLiteral<14>;
@@ -24,6 +24,7 @@ exports.CreateAgentMessagePieceType = {
24
24
  OpaqueReference: 14,
25
25
  RetainedPieceReference: 15,
26
26
  IMessageImportAction: 16,
27
+ OtherAppsAction: 17,
27
28
  };
28
29
  // Outbound: pieces the agent sends when creating a message
29
30
  function writePieceOptions(types) {
@@ -127,6 +128,10 @@ function writePieceOptions(types) {
127
128
  type: zod_1.z.literal(types.IMessageImportAction),
128
129
  }).describe("IMessageImportAction — no fields; embeds the iMessage import card. On Mac it starts the scan; " +
129
130
  "elsewhere it says the import runs from the Mac app. Send it with one short sentence of prose."),
131
+ zod_1.z.object({
132
+ type: zod_1.z.literal(types.OtherAppsAction),
133
+ }).describe("OtherAppsAction — no fields; embeds the Showrunner MCP card, which opens the Settings page where the user " +
134
+ "connects Claude, ChatGPT, Cursor and other apps to Showrunner. Send it with one short sentence of prose."),
130
135
  ];
131
136
  }
132
137
  exports.createAgentMessagePieceRequestSchema = zod_1.z.discriminatedUnion("type", writePieceOptions(exports.CreateAgentMessagePieceType));
@@ -183,7 +188,7 @@ const named = writePieceOptions({
183
188
  AgentActionReference: "agent_action_reference", StreamReference: "stream_reference", ToDoReference: "todo_reference",
184
189
  MessageReference: "message_reference", ExportAction: "export_action", ExternalActionApproval: "external_action_approval",
185
190
  NoteReference: "note_reference", OpaqueReference: "opaque_reference", RetainedPieceReference: "retained_piece_reference",
186
- IMessageImportAction: "imessage_import_action",
191
+ IMessageImportAction: "imessage_import_action", OtherAppsAction: "other_apps_action",
187
192
  });
188
193
  function namedPiece(type) {
189
194
  const option = named.find(option => option.shape.type.value === type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "showrunner-agent-staging",
3
- "version": "0.5.135-staging.2139",
3
+ "version": "0.5.135-staging.2142",
4
4
  "description": "Provider-neutral connector SDK for Showrunner agents",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",