showrunner-agent-staging 0.2.1-staging.1273 → 0.2.3-staging.1275

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.
@@ -131,6 +131,12 @@ class InvocationAdapterClient {
131
131
  searchContext(query, options) {
132
132
  return this.#client.search(this.#event.invocation.id, query, options);
133
133
  }
134
+ listFolderContents(folderId, cursor) {
135
+ return this.#client.listFolderContents(this.#event.invocation.id, folderId, cursor);
136
+ }
137
+ listFolders(streamId, cursor) {
138
+ return this.#client.listFolders(this.#event.invocation.id, streamId, cursor);
139
+ }
134
140
  readAsset(assetId) {
135
141
  return this.#client.readAsset(this.#event.invocation.id, assetId);
136
142
  }
@@ -1,3 +1,4 @@
1
+ import type { ContextFolders, ContextFolderContents } from "./protocol.js";
1
2
  import type { ActivityOutcome, ActivityType, AgentEvent, AgentInputResponse, ApprovalDecision, ApprovalRiskLevel, CommandResponse, ContextAsset, ContextPage, FileDownloadLink, OutputMessagePiece, QuestionSelectionType } from "./protocol.js";
2
3
  import type { Note, TextAttachment } from "./protocol.js";
3
4
  export type ContextPageOptions = {
@@ -114,6 +115,8 @@ export interface AdapterClient {
114
115
  readThreadContext(options: ContextPageOptions): Promise<ContextPage>;
115
116
  readRecentContext(options: ContextPageOptions): Promise<ContextPage>;
116
117
  searchContext(query: string, options: ContextPageOptions): Promise<ContextPage>;
118
+ listFolderContents(folderId: string, cursor?: string | null): Promise<ContextFolderContents>;
119
+ listFolders(streamId?: string, cursor?: string | null): Promise<ContextFolders>;
117
120
  readAsset(assetId: string): Promise<ContextAsset>;
118
121
  uploadFile(input: {
119
122
  fileName: string;
@@ -18,6 +18,14 @@ export declare const agentToolSchemas: {
18
18
  cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
19
  limit: z.ZodOptional<z.ZodNumber>;
20
20
  }, z.core.$strip>;
21
+ readonly list_folder_contents: z.ZodObject<{
22
+ folderId: z.ZodString;
23
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ }, z.core.$strip>;
25
+ readonly list_folders: z.ZodObject<{
26
+ streamId: z.ZodOptional<z.ZodString>;
27
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ }, z.core.$strip>;
21
29
  readonly read_asset: z.ZodObject<{
22
30
  assetId: z.ZodString;
23
31
  }, z.core.$strip>;
@@ -187,7 +195,7 @@ export declare const agentToolSchemas: {
187
195
  };
188
196
  export type AgentToolName = keyof typeof agentToolSchemas;
189
197
  export declare const agentToolDefinitions: {
190
- name: "read_thread" | "read_recent" | "search_workspace" | "read_asset" | "upload_file" | "read_note" | "create_note" | "update_note" | "create_task" | "update_task" | "update_task_schedule" | "complete_task";
198
+ name: "read_thread" | "read_recent" | "search_workspace" | "list_folder_contents" | "list_folders" | "read_asset" | "upload_file" | "read_note" | "create_note" | "update_note" | "create_task" | "update_task" | "update_task_schedule" | "complete_task";
191
199
  description: string;
192
200
  inputSchema: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
193
201
  cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -199,6 +207,12 @@ export declare const agentToolDefinitions: {
199
207
  query: z.ZodString;
200
208
  cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
201
209
  limit: z.ZodOptional<z.ZodNumber>;
210
+ }, z.core.$strip> | z.ZodObject<{
211
+ folderId: z.ZodString;
212
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
213
+ }, z.core.$strip> | z.ZodObject<{
214
+ streamId: z.ZodOptional<z.ZodString>;
215
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
202
216
  }, z.core.$strip> | z.ZodObject<{
203
217
  assetId: z.ZodString;
204
218
  }, z.core.$strip> | z.ZodObject<{
@@ -1,3 +1,4 @@
1
+ import type { ContextFolders, ContextFolderContents } from "./protocol.js";
1
2
  import * as signalR from "@microsoft/signalr";
2
3
  import type { AgentEventHandler } from "./handler.js";
3
4
  import type { AgentModelOption, HostToolCapability, HostToolGrantKey } from "./adapter.js";
@@ -201,6 +202,8 @@ export declare class ExternalAgentClient {
201
202
  cursor?: string | null;
202
203
  limit?: number;
203
204
  }): Promise<ContextPage>;
205
+ listFolders(invocationId: string, streamId?: string, cursor?: string | null): Promise<ContextFolders>;
206
+ listFolderContents(invocationId: string, folderId: string, cursor?: string | null): Promise<ContextFolderContents>;
204
207
  readAsset(invocationId: string, assetId: string): Promise<ContextAsset>;
205
208
  readNote(invocationId: string, noteId: string, input: {
206
209
  commandId: string;
@@ -1,3 +1,4 @@
1
+ import { contextFoldersSchema, contextFolderContentsSchema } from "./protocol.js";
1
2
  import * as signalR from "@microsoft/signalr";
2
3
  import { z } from "zod";
3
4
  import { resolveAdapterModels } from "./adapter.js";
@@ -336,6 +337,49 @@ export class ExternalAgentClient {
336
337
  q: query,
337
338
  });
338
339
  }
340
+ async listFolders(invocationId, streamId, cursor) {
341
+ const params = new URLSearchParams();
342
+ if (streamId !== undefined) {
343
+ params.set("streamId", streamId);
344
+ }
345
+ if (cursor != null) {
346
+ params.set("cursor", cursor);
347
+ }
348
+ const token = await this.accessToken();
349
+ const response = await this.#fetch(`${this.#apiBaseUrl}/api/external-agent-gateway/v1/invocations/${invocationId}/context/folders?${params.toString()}`, {
350
+ method: "GET",
351
+ headers: {
352
+ Authorization: `Bearer ${token}`,
353
+ "X-Showrunner-Connector-Version": this.#connectorVersion,
354
+ "X-Showrunner-Protocol": "1.0",
355
+ },
356
+ signal: AbortSignal.timeout(30_000),
357
+ });
358
+ if (!response.ok) {
359
+ throw new ExternalAgentError(`http_${response.status}`, "Connector folder request failed.", response.status);
360
+ }
361
+ return contextFoldersSchema.parse(await response.json());
362
+ }
363
+ async listFolderContents(invocationId, folderId, cursor) {
364
+ const params = new URLSearchParams();
365
+ if (cursor != null) {
366
+ params.set("cursor", cursor);
367
+ }
368
+ const token = await this.accessToken();
369
+ const response = await this.#fetch(`${this.#apiBaseUrl}/api/external-agent-gateway/v1/invocations/${invocationId}/context/folders/${folderId}?${params.toString()}`, {
370
+ method: "GET",
371
+ headers: {
372
+ Authorization: `Bearer ${token}`,
373
+ "X-Showrunner-Connector-Version": this.#connectorVersion,
374
+ "X-Showrunner-Protocol": "1.0",
375
+ },
376
+ signal: AbortSignal.timeout(30_000),
377
+ });
378
+ if (!response.ok) {
379
+ throw new ExternalAgentError(`http_${response.status}`, "Connector folder request failed.", response.status);
380
+ }
381
+ return contextFolderContentsSchema.parse(await response.json());
382
+ }
339
383
  async readAsset(invocationId, assetId) {
340
384
  const token = await this.accessToken();
341
385
  const response = await this.#fetch(`${this.#apiBaseUrl}/api/external-agent-gateway/v1/invocations/${invocationId}/context/assets/${assetId}`, {
@@ -14,6 +14,14 @@ export declare const contextToolSchemas: {
14
14
  cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
15
  limit: z.ZodOptional<z.ZodNumber>;
16
16
  }, z.core.$strip>;
17
+ readonly list_folder_contents: z.ZodObject<{
18
+ folderId: z.ZodString;
19
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ }, z.core.$strip>;
21
+ readonly list_folders: z.ZodObject<{
22
+ streamId: z.ZodOptional<z.ZodString>;
23
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ }, z.core.$strip>;
17
25
  readonly read_asset: z.ZodObject<{
18
26
  assetId: z.ZodString;
19
27
  }, z.core.$strip>;
@@ -12,6 +12,14 @@ export const contextToolSchemas = {
12
12
  cursor: cursorSchema,
13
13
  limit: limitSchema,
14
14
  }),
15
+ list_folder_contents: z.object({
16
+ folderId: uuidSchema.describe("Folder ID returned by list_folders."),
17
+ cursor: uuidSchema.nullable().optional().describe("nextCursor from the previous contents page."),
18
+ }),
19
+ list_folders: z.object({
20
+ streamId: uuidSchema.optional().describe("A reachable chat ID. Omit for this conversation."),
21
+ cursor: uuidSchema.nullable().optional().describe("nextCursor from the previous folder page."),
22
+ }),
15
23
  read_asset: z.object({
16
24
  assetId: uuidSchema.describe("UUID of a file, image, video, or voice note referenced in context."),
17
25
  }),
@@ -30,6 +38,10 @@ export function contextToolDescription(name) {
30
38
  return "Search the messages you can read for keywords. Reach for this the moment a question refers to "
31
39
  + "something older than what you were handed — do not answer \"I don't have that\" without searching first. "
32
40
  + "Every result carries a messageId you can cite back as a message_reference pill.";
41
+ case "list_folder_contents":
42
+ return "List direct subfolders, files and links in a reachable folder. itemType: 0 folder, 1 file, 2 link. Use folder IDs to navigate, asset IDs with read_asset. Pass nextCursor to continue. Does not list notes or tasks.";
43
+ case "list_folders":
44
+ return "List folders in a reachable chat with IDs, names, parent IDs and file counts. Pass nextCursor to continue.";
33
45
  case "read_asset":
34
46
  return "Read one file's metadata: display name, mime type, size, duration for audio/video, and its folder. "
35
47
  + "Use it before commenting on a media asset so your timestamps and ranges are real.";
@@ -43,6 +55,8 @@ export function contextToolEffect(name, input) {
43
55
  const query = typeof input.query === "string" ? input.query.slice(0, 120) : "";
44
56
  return `Search workspace messages for ${query}`;
45
57
  }
58
+ case "list_folder_contents": return "List contents of a reachable folder";
59
+ case "list_folders": return "List folders in a reachable chat";
46
60
  case "read_asset": {
47
61
  const id = typeof input.assetId === "string" ? input.assetId : "by id";
48
62
  return `Read file metadata for ${id}`;
@@ -62,6 +76,8 @@ export function contextReadIsWithinGrant(name, scope) {
62
76
  case "read_thread": return scope.canReadThreadHistory;
63
77
  case "read_recent": return scope.canReadRecentMessages;
64
78
  case "search_workspace": return scope.canSearch;
79
+ case "list_folder_contents":
80
+ case "list_folders":
65
81
  case "read_asset": return scope.canReadFiles;
66
82
  }
67
83
  }
@@ -78,6 +94,8 @@ export function contextToolApprovalBody(name, scope) {
78
94
  return `Read messages in ${target}`;
79
95
  case "search_workspace":
80
96
  return `Search messages in ${target}`;
97
+ case "list_folder_contents":
98
+ case "list_folders": return `Read folders accessible from ${target}`;
81
99
  case "read_asset":
82
100
  return `Read file details in ${target}`;
83
101
  }
@@ -96,6 +114,14 @@ export async function executeContextTool(context, name, untrusted) {
96
114
  const input = contextToolSchemas.search_workspace.parse(untrusted);
97
115
  return toolSuccess(toModelPage(await context.client.searchContext(input.query, pageOptions(input))));
98
116
  }
117
+ if (name === "list_folder_contents") {
118
+ const input = contextToolSchemas.list_folder_contents.parse(untrusted);
119
+ return toolSuccess(await context.client.listFolderContents(input.folderId, input.cursor));
120
+ }
121
+ if (name === "list_folders") {
122
+ const input = contextToolSchemas.list_folders.parse(untrusted);
123
+ return toolSuccess(await context.client.listFolders(input.streamId, input.cursor));
124
+ }
99
125
  const input = contextToolSchemas.read_asset.parse(untrusted);
100
126
  return toolSuccess(toModelAsset(await context.client.readAsset(input.assetId)));
101
127
  }
@@ -655,4 +655,26 @@ export declare const registerConnectorResultSchema: z.ZodUnion<readonly [z.ZodOb
655
655
  }, z.core.$strip>]>;
656
656
  export type DeliveryRejectionReason = z.infer<typeof deliveryRejectionReasonSchema>;
657
657
  export type RegisteredConnector = z.infer<typeof registeredConnectorSchema>;
658
+ export declare const contextFoldersSchema: z.ZodObject<{
659
+ folders: z.ZodArray<z.ZodObject<{
660
+ folderId: z.ZodString;
661
+ streamId: z.ZodString;
662
+ displayName: z.ZodString;
663
+ parentFolderId: z.ZodNullable<z.ZodString>;
664
+ assetCount: z.ZodNumber;
665
+ }, z.core.$strip>>;
666
+ nextCursor: z.ZodNullable<z.ZodString>;
667
+ }, z.core.$strip>;
668
+ export type ContextFolders = z.infer<typeof contextFoldersSchema>;
669
+ export declare const contextFolderContentsSchema: z.ZodObject<{
670
+ folderId: z.ZodString;
671
+ streamId: z.ZodString;
672
+ items: z.ZodArray<z.ZodObject<{
673
+ id: z.ZodString;
674
+ displayName: z.ZodString;
675
+ itemType: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>]>;
676
+ }, z.core.$strip>>;
677
+ nextCursor: z.ZodNullable<z.ZodString>;
678
+ }, z.core.$strip>;
679
+ export type ContextFolderContents = z.infer<typeof contextFolderContentsSchema>;
658
680
  export {};
@@ -360,3 +360,23 @@ export const registerConnectorResultSchema = z.union([
360
360
  z.object({ ok: z.literal(true) }).and(registeredConnectorSchema),
361
361
  z.object({ ok: z.literal(false), error: connectorErrorSchema }),
362
362
  ]);
363
+ export const contextFoldersSchema = z.object({
364
+ folders: z.array(z.object({
365
+ folderId: z.string().uuid(),
366
+ streamId: z.string().uuid(),
367
+ displayName: z.string(),
368
+ parentFolderId: z.string().uuid().nullable(),
369
+ assetCount: z.number().int().nonnegative(),
370
+ })),
371
+ nextCursor: z.string().uuid().nullable(),
372
+ });
373
+ export const contextFolderContentsSchema = z.object({
374
+ folderId: z.string().uuid(),
375
+ streamId: z.string().uuid(),
376
+ items: z.array(z.object({
377
+ id: z.string().uuid(),
378
+ displayName: z.string(),
379
+ itemType: z.union([z.literal(0), z.literal(1), z.literal(2)]),
380
+ })),
381
+ nextCursor: z.string().uuid().nullable(),
382
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "showrunner-agent-staging",
3
- "version": "0.2.1-staging.1273",
3
+ "version": "0.2.3-staging.1275",
4
4
  "description": "Provider-neutral connector SDK for Showrunner agents",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",