showrunner-agent-staging 0.3.2-staging.1544 → 0.4.0-staging.1546
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/README.md +10 -4
- package/dist/src/adapter-runner.js +4 -4
- package/dist/src/adapter.d.ts +3 -2
- package/dist/src/agent-tools.d.ts +32 -0
- package/dist/src/client.d.ts +3 -2
- package/dist/src/note-tools.d.ts +28 -2
- package/dist/src/note-tools.js +25 -7
- package/dist/src/pieces.js +9 -15
- package/dist/src/protocol.d.ts +7 -7
- package/dist/src/protocol.js +10 -15
- package/node_modules/@showrunner/agent-contracts/dist/agent-message-piece-dtos.d.ts +3 -1
- package/node_modules/@showrunner/agent-contracts/dist/agent-message-piece-dtos.js +12 -0
- package/node_modules/@showrunner/agent-contracts/dist/agent-write-piece-dtos.d.ts +158 -0
- package/node_modules/@showrunner/agent-contracts/dist/agent-write-piece-dtos.js +196 -0
- package/node_modules/@showrunner/agent-contracts/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,17 +107,23 @@ experience, see Devin's [testing and recordings](https://docs.devin.ai/work-with
|
|
|
107
107
|
|
|
108
108
|
## Shared piece interpretation
|
|
109
109
|
|
|
110
|
-
Protocol
|
|
110
|
+
Protocol 3.0 uses the same resolved, numeric-discriminator pieces as Runner for message events,
|
|
111
111
|
chat context and notes. The API's `Transport/AgentReadMapper.cs` is the projection source of truth;
|
|
112
112
|
`shared/agent-contracts` supplies both runtimes' TypeScript schemas and input descriptions.
|
|
113
113
|
References carry resolved metadata, annotation summaries, and explicit unavailable or opaque states.
|
|
114
114
|
Tool grants and write capabilities remain installation-specific. The outgoing `showrunner v1.0`
|
|
115
115
|
fence is independent of the transport version and retains its string-discriminator vocabulary.
|
|
116
116
|
|
|
117
|
-
The connector must be upgraded for protocol
|
|
117
|
+
The connector must be upgraded for protocol 3.0. Older connectors are rejected by the protocol
|
|
118
118
|
handshake. Queued requests from the older protocol end with a visible upgrade explanation and
|
|
119
|
-
a request to send them again; they are never forwarded as unreadable payloads. Note
|
|
120
|
-
|
|
119
|
+
a request to send them again; they are never forwarded as unreadable payloads. Note writes use the same numeric write contract and API mapper as Runner. The .NET source is
|
|
120
|
+
`Bylines.Messenger.Contracts/DTOs/Agents/AgentWritePieceDtos.cs`. The provider tools adapt
|
|
121
|
+
string piece names to that contract. To keep a piece with `sourcePieceId` unchanged, pass that ID
|
|
122
|
+
as `{ "type": "retained_piece_reference", "pieceId": "..." }` in `update_note`. This preserves the
|
|
123
|
+
stored piece exactly, including annotations, drawings, cards and unavailable references, without
|
|
124
|
+
revealing hidden content. Only pieces already on that note may be retained; creating new notes
|
|
125
|
+
cannot use retained references. Updates replace the full body: omitted pieces are deleted.
|
|
126
|
+
|
|
121
127
|
|
|
122
128
|
When installing from this repository, run `npm ci --prefix ../shared/agent-contracts` before
|
|
123
129
|
`npm ci` in this directory. Reinstall the local dependency after changing its source. The npm
|
|
@@ -142,14 +142,14 @@ class InvocationAdapterClient {
|
|
|
142
142
|
commandId: this.#next("note.read"),
|
|
143
143
|
})).note;
|
|
144
144
|
}
|
|
145
|
-
async createNote(noteId,
|
|
145
|
+
async createNote(noteId, pieces) {
|
|
146
146
|
return (await this.#client.createNote(this.#event.invocation.id, {
|
|
147
|
-
commandId: this.#next("note.create"), noteId,
|
|
147
|
+
commandId: this.#next("note.create"), noteId, pieces,
|
|
148
148
|
})).note;
|
|
149
149
|
}
|
|
150
|
-
async updateNote(noteId, baseVersion,
|
|
150
|
+
async updateNote(noteId, baseVersion, pieces) {
|
|
151
151
|
return (await this.#client.updateNote(this.#event.invocation.id, noteId, {
|
|
152
|
-
commandId: this.#next("note.update"), baseVersion,
|
|
152
|
+
commandId: this.#next("note.update"), baseVersion, pieces,
|
|
153
153
|
})).note;
|
|
154
154
|
}
|
|
155
155
|
createToDo(input) {
|
package/dist/src/adapter.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CreateSurfacePieceRequest } from "@showrunner/agent-contracts/agent-write-piece-dtos";
|
|
1
2
|
import type { FileUploadInput } from "./client.js";
|
|
2
3
|
import type { ContextAgents, ContextFileSearch, ContextTodos, ContextNotes, ContextFolders, ContextFolderContents } from "./protocol.js";
|
|
3
4
|
import type { ActivityOutcome, ActivityType, AgentEvent, AgentInputResponse, ApprovalDecision, ApprovalRiskLevel, CommandResponse, ContextAsset, ContextPage, FileDownloadLink, OutputMessagePiece, QuestionSelectionType } from "./protocol.js";
|
|
@@ -107,8 +108,8 @@ export interface AdapterClient {
|
|
|
107
108
|
createFileDownloadLink(assetId: string): Promise<FileDownloadLink>;
|
|
108
109
|
sendReaction?(messageId: string, emoji: string): Promise<void>;
|
|
109
110
|
readNote(noteId: string): Promise<Note>;
|
|
110
|
-
createNote(noteId: string,
|
|
111
|
-
updateNote(noteId: string, baseVersion: number,
|
|
111
|
+
createNote(noteId: string, pieces: CreateSurfacePieceRequest[]): Promise<Note>;
|
|
112
|
+
updateNote(noteId: string, baseVersion: number, pieces: CreateSurfacePieceRequest[]): Promise<Note>;
|
|
112
113
|
createToDo(input: ToDoScheduleInput & {
|
|
113
114
|
textAttachments: TextAttachment[];
|
|
114
115
|
}): Promise<CommandResponse>;
|
|
@@ -100,6 +100,11 @@ export declare const agentToolSchemas: {
|
|
|
100
100
|
}, z.core.$strip>, z.ZodObject<{
|
|
101
101
|
type: z.ZodLiteral<"note_reference">;
|
|
102
102
|
noteId: z.ZodString;
|
|
103
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
104
|
+
type: z.ZodLiteral<"new_link">;
|
|
105
|
+
url: z.ZodString;
|
|
106
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
107
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
103
108
|
}, z.core.$strip>], "type">>;
|
|
104
109
|
}, z.core.$strip>;
|
|
105
110
|
readonly update_note: z.ZodObject<{
|
|
@@ -132,6 +137,17 @@ export declare const agentToolSchemas: {
|
|
|
132
137
|
}, z.core.$strip>, z.ZodObject<{
|
|
133
138
|
type: z.ZodLiteral<"note_reference">;
|
|
134
139
|
noteId: z.ZodString;
|
|
140
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
141
|
+
type: z.ZodLiteral<"new_link">;
|
|
142
|
+
url: z.ZodString;
|
|
143
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
144
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
145
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
+
pieceId: z.ZodString;
|
|
147
|
+
type: z.ZodLiteral<"opaque_reference">;
|
|
148
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
149
|
+
pieceId: z.ZodString;
|
|
150
|
+
type: z.ZodLiteral<"retained_piece_reference">;
|
|
135
151
|
}, z.core.$strip>], "type">>;
|
|
136
152
|
}, z.core.$strip>;
|
|
137
153
|
readonly create_task: z.ZodObject<{
|
|
@@ -304,6 +320,11 @@ export declare const agentToolDefinitions: {
|
|
|
304
320
|
}, z.core.$strip>, z.ZodObject<{
|
|
305
321
|
type: z.ZodLiteral<"note_reference">;
|
|
306
322
|
noteId: z.ZodString;
|
|
323
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
324
|
+
type: z.ZodLiteral<"new_link">;
|
|
325
|
+
url: z.ZodString;
|
|
326
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
327
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
307
328
|
}, z.core.$strip>], "type">>;
|
|
308
329
|
}, z.core.$strip> | z.ZodObject<{
|
|
309
330
|
noteId: z.ZodString;
|
|
@@ -335,6 +356,17 @@ export declare const agentToolDefinitions: {
|
|
|
335
356
|
}, z.core.$strip>, z.ZodObject<{
|
|
336
357
|
type: z.ZodLiteral<"note_reference">;
|
|
337
358
|
noteId: z.ZodString;
|
|
359
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
360
|
+
type: z.ZodLiteral<"new_link">;
|
|
361
|
+
url: z.ZodString;
|
|
362
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
363
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
364
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
365
|
+
pieceId: z.ZodString;
|
|
366
|
+
type: z.ZodLiteral<"opaque_reference">;
|
|
367
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
368
|
+
pieceId: z.ZodString;
|
|
369
|
+
type: z.ZodLiteral<"retained_piece_reference">;
|
|
338
370
|
}, z.core.$strip>], "type">>;
|
|
339
371
|
}, z.core.$strip> | z.ZodObject<{
|
|
340
372
|
dueAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CreateSurfacePieceRequest } from "@showrunner/agent-contracts/agent-write-piece-dtos";
|
|
1
2
|
import type { ContextAgents, ContextFileSearch, ContextTodos, ContextNotes, ContextFolders, ContextFolderContents } from "./protocol.js";
|
|
2
3
|
import * as signalR from "@microsoft/signalr";
|
|
3
4
|
import type { AgentEventHandler } from "./handler.js";
|
|
@@ -249,12 +250,12 @@ export declare class ExternalAgentClient {
|
|
|
249
250
|
createNote(invocationId: string, input: {
|
|
250
251
|
commandId: string;
|
|
251
252
|
noteId: string;
|
|
252
|
-
|
|
253
|
+
pieces: CreateSurfacePieceRequest[];
|
|
253
254
|
}): Promise<NoteCommandResponse>;
|
|
254
255
|
updateNote(invocationId: string, noteId: string, input: {
|
|
255
256
|
commandId: string;
|
|
256
257
|
baseVersion: number;
|
|
257
|
-
|
|
258
|
+
pieces: CreateSurfacePieceRequest[];
|
|
258
259
|
}): Promise<NoteCommandResponse>;
|
|
259
260
|
createToDo(invocationId: string, input: {
|
|
260
261
|
commandId: string;
|
package/dist/src/note-tools.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AgentInvocationContext, HostToolCapability } from "./adapter.js";
|
|
3
|
-
import { type BodyPiece } from "./pieces.js";
|
|
4
3
|
export declare const notePieceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
4
|
type: z.ZodLiteral<"text">;
|
|
6
5
|
text: z.ZodString;
|
|
@@ -28,8 +27,19 @@ export declare const notePieceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
28
27
|
}, z.core.$strip>, z.ZodObject<{
|
|
29
28
|
type: z.ZodLiteral<"note_reference">;
|
|
30
29
|
noteId: z.ZodString;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"new_link">;
|
|
32
|
+
url: z.ZodString;
|
|
33
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
pieceId: z.ZodString;
|
|
37
|
+
type: z.ZodLiteral<"opaque_reference">;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
pieceId: z.ZodString;
|
|
40
|
+
type: z.ZodLiteral<"retained_piece_reference">;
|
|
31
41
|
}, z.core.$strip>], "type">;
|
|
32
|
-
export type NotePiece =
|
|
42
|
+
export type NotePiece = z.infer<typeof notePieceSchema>;
|
|
33
43
|
export declare const noteToolSchemas: {
|
|
34
44
|
readonly read_note: z.ZodObject<{
|
|
35
45
|
noteId: z.ZodString;
|
|
@@ -63,6 +73,11 @@ export declare const noteToolSchemas: {
|
|
|
63
73
|
}, z.core.$strip>, z.ZodObject<{
|
|
64
74
|
type: z.ZodLiteral<"note_reference">;
|
|
65
75
|
noteId: z.ZodString;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"new_link">;
|
|
78
|
+
url: z.ZodString;
|
|
79
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
81
|
}, z.core.$strip>], "type">>;
|
|
67
82
|
}, z.core.$strip>;
|
|
68
83
|
readonly update_note: z.ZodObject<{
|
|
@@ -95,6 +110,17 @@ export declare const noteToolSchemas: {
|
|
|
95
110
|
}, z.core.$strip>, z.ZodObject<{
|
|
96
111
|
type: z.ZodLiteral<"note_reference">;
|
|
97
112
|
noteId: z.ZodString;
|
|
113
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
114
|
+
type: z.ZodLiteral<"new_link">;
|
|
115
|
+
url: z.ZodString;
|
|
116
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
118
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
119
|
+
pieceId: z.ZodString;
|
|
120
|
+
type: z.ZodLiteral<"opaque_reference">;
|
|
121
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
122
|
+
pieceId: z.ZodString;
|
|
123
|
+
type: z.ZodLiteral<"retained_piece_reference">;
|
|
98
124
|
}, z.core.$strip>], "type">>;
|
|
99
125
|
}, z.core.$strip>;
|
|
100
126
|
};
|
package/dist/src/note-tools.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
import { agentNotePieceSchema, namedAgentPieceSchemas, CreateAgentMessagePieceType } from "@showrunner/agent-contracts/agent-write-piece-dtos";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { ExternalAgentError, AgentNoteUpdateConflictError } from "./client.js";
|
|
4
|
-
import {
|
|
5
|
+
import { bodyPieceSchema, bodyPiecesDescription, toolFailure, toolSuccess, } from "./pieces.js";
|
|
5
6
|
const uuidSchema = z.string().uuid();
|
|
6
|
-
|
|
7
|
+
const createNotePieceSchema = z.discriminatedUnion("type", [
|
|
8
|
+
...bodyPieceSchema.options, namedAgentPieceSchemas.new_link,
|
|
9
|
+
]);
|
|
10
|
+
export const notePieceSchema = z.discriminatedUnion("type", [
|
|
11
|
+
...createNotePieceSchema.options,
|
|
12
|
+
namedAgentPieceSchemas.opaque_reference, namedAgentPieceSchemas.retained_piece_reference,
|
|
13
|
+
]);
|
|
14
|
+
const notePieceTypes = {
|
|
15
|
+
text: CreateAgentMessagePieceType.Text, new_link: CreateAgentMessagePieceType.NewLink,
|
|
16
|
+
asset_reference: CreateAgentMessagePieceType.AssetReference, folder_reference: CreateAgentMessagePieceType.FolderReference,
|
|
17
|
+
profile_reference: CreateAgentMessagePieceType.ProfileReference, stream_reference: CreateAgentMessagePieceType.StreamReference,
|
|
18
|
+
todo_reference: CreateAgentMessagePieceType.ToDoReference, message_reference: CreateAgentMessagePieceType.MessageReference,
|
|
19
|
+
note_reference: CreateAgentMessagePieceType.NoteReference, opaque_reference: CreateAgentMessagePieceType.OpaqueReference,
|
|
20
|
+
retained_piece_reference: CreateAgentMessagePieceType.RetainedPieceReference,
|
|
21
|
+
};
|
|
22
|
+
function writePieces(pieces) {
|
|
23
|
+
return pieces.map(piece => agentNotePieceSchema.parse({ ...piece, type: notePieceTypes[piece.type] }));
|
|
24
|
+
}
|
|
7
25
|
const piecesDescription = `${bodyPiecesDescription} ` +
|
|
8
26
|
"For update_note this is the complete replacement body, including the title as the first text piece.";
|
|
9
27
|
export const noteToolSchemas = {
|
|
@@ -12,7 +30,7 @@ export const noteToolSchemas = {
|
|
|
12
30
|
}),
|
|
13
31
|
create_note: z.object({
|
|
14
32
|
title: z.string().trim().min(1).max(500).describe("Short note title."),
|
|
15
|
-
pieces: z.array(
|
|
33
|
+
pieces: z.array(createNotePieceSchema).describe("Ordered body pieces after the title."),
|
|
16
34
|
}),
|
|
17
35
|
update_note: z.object({
|
|
18
36
|
noteId: uuidSchema.describe("UUID of the note to replace."),
|
|
@@ -31,7 +49,7 @@ export function noteToolDescription(name) {
|
|
|
31
49
|
if (name === "create_note") {
|
|
32
50
|
return "Create a durable Showrunner note. Prefer this over a long inline answer: put the durable content in the note, then reply with a short summary plus the returned noteId as a note_reference so the note appears as a pill.";
|
|
33
51
|
}
|
|
34
|
-
return "Replace a Showrunner note's entire body. Always read_note first. Preserve every piece that should remain.
|
|
52
|
+
return "Replace a Showrunner note's entire body. Always read_note first. Preserve every piece that should remain. For each unchanged piece that has sourcePieceId, send retained_piece_reference with pieceId set to its sourcePieceId. This preserves its exact stored content, including drawings, annotations, action cards and unavailable references. Omitted pieces are deleted. Retained pieces must belong to this same note. On version_conflict, re-read, reapply the edit, and retry with the latest version.";
|
|
35
53
|
}
|
|
36
54
|
export function noteToolEffect(name, input) {
|
|
37
55
|
const id = typeof input.noteId === "string" ? input.noteId : undefined;
|
|
@@ -51,14 +69,14 @@ export async function executeNoteTool(context, name, untrusted) {
|
|
|
51
69
|
}
|
|
52
70
|
if (name === "create_note") {
|
|
53
71
|
const input = noteToolSchemas.create_note.parse(untrusted);
|
|
54
|
-
const note = await context.client.createNote(randomUUID(),
|
|
72
|
+
const note = await context.client.createNote(randomUUID(), writePieces([
|
|
55
73
|
{ type: "text", text: input.title },
|
|
56
74
|
...input.pieces,
|
|
57
|
-
]
|
|
75
|
+
]));
|
|
58
76
|
return toolSuccess(toModelNote(note));
|
|
59
77
|
}
|
|
60
78
|
const input = noteToolSchemas.update_note.parse(untrusted);
|
|
61
|
-
const note = await context.client.updateNote(input.noteId, input.baseVersion,
|
|
79
|
+
const note = await context.client.updateNote(input.noteId, input.baseVersion, writePieces(input.pieces));
|
|
62
80
|
return toolSuccess(toModelNote(note));
|
|
63
81
|
}
|
|
64
82
|
catch (error) {
|
package/dist/src/pieces.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
+
import { namedAgentPieceSchemas } from "@showrunner/agent-contracts/agent-write-piece-dtos";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { z } from "zod";
|
|
3
|
-
const uuidSchema = z.string().uuid();
|
|
4
4
|
/**
|
|
5
5
|
* Body pieces for the durable entities an agent authors (notes and tasks). Both ride the same
|
|
6
6
|
* TextAttachment wire shape, so one schema and one encoder serve them.
|
|
7
7
|
*/
|
|
8
8
|
export const bodyPieceSchema = z.discriminatedUnion("type", [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
z.object({ type: z.literal("folder_reference"), folderId: uuidSchema }),
|
|
18
|
-
z.object({ type: z.literal("profile_reference"), profileId: uuidSchema }),
|
|
19
|
-
z.object({ type: z.literal("stream_reference"), streamId: uuidSchema }),
|
|
20
|
-
z.object({ type: z.literal("todo_reference"), todoId: uuidSchema }),
|
|
21
|
-
z.object({ type: z.literal("message_reference"), messageId: uuidSchema }),
|
|
22
|
-
z.object({ type: z.literal("note_reference"), noteId: uuidSchema }),
|
|
9
|
+
namedAgentPieceSchemas.text,
|
|
10
|
+
namedAgentPieceSchemas.asset_reference,
|
|
11
|
+
namedAgentPieceSchemas.folder_reference,
|
|
12
|
+
namedAgentPieceSchemas.profile_reference,
|
|
13
|
+
namedAgentPieceSchemas.stream_reference,
|
|
14
|
+
namedAgentPieceSchemas.todo_reference,
|
|
15
|
+
namedAgentPieceSchemas.message_reference,
|
|
16
|
+
namedAgentPieceSchemas.note_reference,
|
|
23
17
|
]);
|
|
24
18
|
export const bodyPiecesDescription = "Ordered pieces. Text pieces contain Markdown; reference pieces render as inline pills.";
|
|
25
19
|
export function attachments(pieces, streamId) {
|
package/dist/src/protocol.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const protocolVersion: {
|
|
3
|
-
readonly major:
|
|
3
|
+
readonly major: 3;
|
|
4
4
|
readonly minor: 0;
|
|
5
5
|
};
|
|
6
6
|
export declare const maxAgentEventBytes = 327680;
|
|
@@ -31,7 +31,7 @@ export declare const pairRequestSchema: z.ZodObject<{
|
|
|
31
31
|
pairingCode: z.ZodString;
|
|
32
32
|
deviceName: z.ZodString;
|
|
33
33
|
connectorVersion: z.ZodString;
|
|
34
|
-
protocolMajor: z.ZodLiteral<
|
|
34
|
+
protocolMajor: z.ZodLiteral<3>;
|
|
35
35
|
protocolMinor: z.ZodLiteral<0>;
|
|
36
36
|
}, z.core.$strip>;
|
|
37
37
|
export declare const pairResponseSchema: z.ZodObject<{
|
|
@@ -117,7 +117,7 @@ export declare const delegationCompletedEventSchema: z.ZodObject<{
|
|
|
117
117
|
}, z.core.$strip>;
|
|
118
118
|
export declare const agentEventSchema: z.ZodPipe<z.ZodUnknown, z.ZodObject<{
|
|
119
119
|
protocol: z.ZodObject<{
|
|
120
|
-
major: z.ZodLiteral<
|
|
120
|
+
major: z.ZodLiteral<3>;
|
|
121
121
|
minor: z.ZodLiteral<0>;
|
|
122
122
|
}, z.core.$strip>;
|
|
123
123
|
deliveryId: z.ZodString;
|
|
@@ -506,7 +506,7 @@ export type ApprovalRiskLevel = z.infer<typeof approvalRiskLevelSchema>;
|
|
|
506
506
|
export type ApprovalDecision = z.infer<typeof approvalDecisionSchema>;
|
|
507
507
|
export type ExternalActionResultStatus = z.infer<typeof externalActionResultStatusSchema>;
|
|
508
508
|
export declare const registerConnectorRequestSchema: z.ZodObject<{
|
|
509
|
-
protocolMajor: z.ZodLiteral<
|
|
509
|
+
protocolMajor: z.ZodLiteral<3>;
|
|
510
510
|
protocolMinor: z.ZodLiteral<0>;
|
|
511
511
|
connectorVersion: z.ZodString;
|
|
512
512
|
supportedEventTypes: z.ZodArray<z.ZodEnum<{
|
|
@@ -528,7 +528,7 @@ export declare const registerConnectorRequestSchema: z.ZodObject<{
|
|
|
528
528
|
export declare const registeredConnectorSchema: z.ZodObject<{
|
|
529
529
|
connectionId: z.ZodString;
|
|
530
530
|
serverTime: z.ZodOptional<z.ZodString>;
|
|
531
|
-
protocolMajor: z.ZodOptional<z.ZodLiteral<
|
|
531
|
+
protocolMajor: z.ZodOptional<z.ZodLiteral<3>>;
|
|
532
532
|
protocolMinor: z.ZodOptional<z.ZodLiteral<0>>;
|
|
533
533
|
heartbeatSeconds: z.ZodNumber;
|
|
534
534
|
maxConcurrentInvocations: z.ZodOptional<z.ZodNumber>;
|
|
@@ -577,7 +577,7 @@ export declare const registerConnectorResultSchema: z.ZodUnion<readonly [z.ZodOb
|
|
|
577
577
|
value: z.ZodObject<{
|
|
578
578
|
connectionId: z.ZodString;
|
|
579
579
|
serverTime: z.ZodOptional<z.ZodString>;
|
|
580
|
-
protocolMajor: z.ZodOptional<z.ZodLiteral<
|
|
580
|
+
protocolMajor: z.ZodOptional<z.ZodLiteral<3>>;
|
|
581
581
|
protocolMinor: z.ZodOptional<z.ZodLiteral<0>>;
|
|
582
582
|
heartbeatSeconds: z.ZodNumber;
|
|
583
583
|
maxConcurrentInvocations: z.ZodOptional<z.ZodNumber>;
|
|
@@ -588,7 +588,7 @@ export declare const registerConnectorResultSchema: z.ZodUnion<readonly [z.ZodOb
|
|
|
588
588
|
}, z.core.$strip>, z.ZodObject<{
|
|
589
589
|
connectionId: z.ZodString;
|
|
590
590
|
serverTime: z.ZodOptional<z.ZodString>;
|
|
591
|
-
protocolMajor: z.ZodOptional<z.ZodLiteral<
|
|
591
|
+
protocolMajor: z.ZodOptional<z.ZodLiteral<3>>;
|
|
592
592
|
protocolMinor: z.ZodOptional<z.ZodLiteral<0>>;
|
|
593
593
|
heartbeatSeconds: z.ZodNumber;
|
|
594
594
|
maxConcurrentInvocations: z.ZodOptional<z.ZodNumber>;
|
package/dist/src/protocol.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { namedAgentPieceSchemas } from "@showrunner/agent-contracts/agent-write-piece-dtos";
|
|
1
2
|
import { agentMessagePieceSchema } from "@showrunner/agent-contracts/agent-message-piece-dtos";
|
|
2
3
|
import { z } from "zod";
|
|
3
|
-
export const protocolVersion = { major:
|
|
4
|
+
export const protocolVersion = { major: 3, minor: 0 };
|
|
4
5
|
export const maxAgentEventBytes = 327_680;
|
|
5
6
|
export const serverEventTypes = [
|
|
6
7
|
"message.created",
|
|
@@ -38,7 +39,7 @@ export const connectorCommandTypes = [
|
|
|
38
39
|
export const authorTrustSchema = z.enum(["owner", "other_participant", "agent", "system"]);
|
|
39
40
|
const uuid = z.string().uuid();
|
|
40
41
|
const timestamp = z.string().datetime({ offset: true });
|
|
41
|
-
const protocolSchema = z.object({ major: z.literal(
|
|
42
|
+
const protocolSchema = z.object({ major: z.literal(protocolVersion.major), minor: z.literal(0) });
|
|
42
43
|
const installationSchema = z.object({
|
|
43
44
|
id: uuid,
|
|
44
45
|
profileId: uuid,
|
|
@@ -51,7 +52,7 @@ export const pairRequestSchema = z.object({
|
|
|
51
52
|
pairingCode: z.string().regex(/^[0-9A-HJKMNP-TV-Z]{4}-?[0-9A-HJKMNP-TV-Z]{4}$/i),
|
|
52
53
|
deviceName: z.string().min(1).max(100),
|
|
53
54
|
connectorVersion: z.string().min(1).max(32),
|
|
54
|
-
protocolMajor: z.literal(
|
|
55
|
+
protocolMajor: z.literal(protocolVersion.major),
|
|
55
56
|
protocolMinor: z.literal(0),
|
|
56
57
|
});
|
|
57
58
|
const tokenFieldsSchema = z.object({
|
|
@@ -284,23 +285,17 @@ export const activityTypeSchema = z.enum([
|
|
|
284
285
|
]);
|
|
285
286
|
export const activityOutcomeSchema = z.enum(["completed", "failed", "cancelled"]);
|
|
286
287
|
export const outputMessagePieceSchema = z.discriminatedUnion("type", [
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
z.object({ type: z.literal("profile_reference"), profileId: uuid }),
|
|
292
|
-
z.object({ type: z.literal("stream_reference"), streamId: uuid }),
|
|
293
|
-
z.object({ type: z.literal("todo_reference"), todoId: uuid }),
|
|
294
|
-
z.object({ type: z.literal("message_reference"), messageId: uuid }),
|
|
295
|
-
z.object({ type: z.literal("note_reference"), noteId: uuid }),
|
|
296
|
-
z.object({ type: z.literal("export_action"), assetIds: z.array(uuid).min(1).max(100) }),
|
|
288
|
+
namedAgentPieceSchemas.text, namedAgentPieceSchemas.new_link, namedAgentPieceSchemas.asset_reference,
|
|
289
|
+
namedAgentPieceSchemas.folder_reference, namedAgentPieceSchemas.profile_reference, namedAgentPieceSchemas.stream_reference,
|
|
290
|
+
namedAgentPieceSchemas.todo_reference, namedAgentPieceSchemas.message_reference, namedAgentPieceSchemas.note_reference,
|
|
291
|
+
namedAgentPieceSchemas.export_action,
|
|
297
292
|
]);
|
|
298
293
|
export const questionSelectionTypeSchema = z.enum(["single", "multiple"]);
|
|
299
294
|
export const approvalRiskLevelSchema = z.enum(["low", "medium", "high"]);
|
|
300
295
|
export const approvalDecisionSchema = z.enum(["approve", "decline", "cancel"]);
|
|
301
296
|
export const externalActionResultStatusSchema = z.enum(["succeeded", "failed", "partial"]);
|
|
302
297
|
export const registerConnectorRequestSchema = z.object({
|
|
303
|
-
protocolMajor: z.literal(
|
|
298
|
+
protocolMajor: z.literal(protocolVersion.major),
|
|
304
299
|
protocolMinor: z.literal(0),
|
|
305
300
|
connectorVersion: z.string().min(1).max(32),
|
|
306
301
|
supportedEventTypes: z.array(z.enum(serverEventTypes)),
|
|
@@ -319,7 +314,7 @@ export const registerConnectorRequestSchema = z.object({
|
|
|
319
314
|
export const registeredConnectorSchema = z.object({
|
|
320
315
|
connectionId: z.string().min(1),
|
|
321
316
|
serverTime: timestamp.optional(),
|
|
322
|
-
protocolMajor: z.literal(
|
|
317
|
+
protocolMajor: z.literal(protocolVersion.major).optional(),
|
|
323
318
|
protocolMinor: z.literal(0).optional(),
|
|
324
319
|
heartbeatSeconds: z.number().int().positive(),
|
|
325
320
|
maxConcurrentInvocations: z.number().int().positive().optional(),
|
|
@@ -48,6 +48,8 @@ export declare const agentMarkupSummaryScheme: z.ZodObject<{
|
|
|
48
48
|
}, z.core.$strip>;
|
|
49
49
|
export type AgentMarkupSummary = z.infer<typeof agentMarkupSummaryScheme>;
|
|
50
50
|
export type AgentMessagePiece = {
|
|
51
|
+
sourcePieceId?: string;
|
|
52
|
+
} & ({
|
|
51
53
|
type: typeof AgentMessagePieceType.Text;
|
|
52
54
|
text: string;
|
|
53
55
|
truncated?: boolean;
|
|
@@ -109,7 +111,7 @@ export type AgentMessagePiece = {
|
|
|
109
111
|
itemId: string;
|
|
110
112
|
entityType: string;
|
|
111
113
|
reason: string;
|
|
112
|
-
};
|
|
114
|
+
});
|
|
113
115
|
export declare const agentMessagePieceSchema: z.ZodType<AgentMessagePiece>;
|
|
114
116
|
export declare const agentMessageReactionSchema: z.ZodObject<{
|
|
115
117
|
emoji: z.ZodString;
|
|
@@ -44,11 +44,13 @@ exports.agentMarkupSummaryScheme = zod_1.z.object({
|
|
|
44
44
|
// Inbound: pieces the agent receives when reading messages
|
|
45
45
|
exports.agentMessagePieceSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion("type", [
|
|
46
46
|
zod_1.z.object({
|
|
47
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
47
48
|
type: zod_1.z.literal(exports.AgentMessagePieceType.Text),
|
|
48
49
|
text: zod_1.z.string(),
|
|
49
50
|
truncated: zod_1.z.boolean().optional(),
|
|
50
51
|
}).describe("Text — prose. truncated=true means the text was cut to fit the payload limit; read the full message or task with an available tool before acting. If you cannot retrieve it, ask for the missing context."),
|
|
51
52
|
zod_1.z.object({
|
|
53
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
52
54
|
type: zod_1.z.literal(exports.AgentMessagePieceType.AssetReference),
|
|
53
55
|
asset: agent_dtos_1.agentAssetScheme,
|
|
54
56
|
startTime: zod_1.z.number().nullable(),
|
|
@@ -56,22 +58,27 @@ exports.agentMessagePieceSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion(
|
|
|
56
58
|
markupSummary: exports.agentMarkupSummaryScheme.nullable(),
|
|
57
59
|
}).describe("AssetReference — embedded asset; startTime+endTime present means a range. markupSummary is present when the user drew freehand annotations on the asset. Truncation flags on file previews mean they are incomplete or omitted; fetch full details with an available tool before relying on missing context."),
|
|
58
60
|
zod_1.z.object({
|
|
61
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
59
62
|
type: zod_1.z.literal(exports.AgentMessagePieceType.FolderReference),
|
|
60
63
|
folder: agent_dtos_1.agentFolderScheme,
|
|
61
64
|
}).describe("FolderReference — folder pill."),
|
|
62
65
|
zod_1.z.object({
|
|
66
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
63
67
|
type: zod_1.z.literal(exports.AgentMessagePieceType.ProfileReference),
|
|
64
68
|
profile: agent_dtos_1.agentProfileScheme,
|
|
65
69
|
}).describe("ProfileReference — person pill."),
|
|
66
70
|
zod_1.z.object({
|
|
71
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
67
72
|
type: zod_1.z.literal(exports.AgentMessagePieceType.AgentActionReference),
|
|
68
73
|
agentAction: agent_action_dtos_1.agentActionDescriptionSchema,
|
|
69
74
|
}).describe("AgentActionReference — agent action card."),
|
|
70
75
|
zod_1.z.object({
|
|
76
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
71
77
|
type: zod_1.z.literal(exports.AgentMessagePieceType.StreamReference),
|
|
72
78
|
stream: agent_dtos_1.agentStreamScheme,
|
|
73
79
|
}).describe("StreamReference — stream pill."),
|
|
74
80
|
zod_1.z.object({
|
|
81
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
75
82
|
type: zod_1.z.literal(exports.AgentMessagePieceType.ToDoReference),
|
|
76
83
|
toDo: zod_1.z.object({
|
|
77
84
|
todoId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
@@ -81,6 +88,7 @@ exports.agentMessagePieceSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion(
|
|
|
81
88
|
}),
|
|
82
89
|
}).describe("ToDoReference — embedded to-do."),
|
|
83
90
|
zod_1.z.object({
|
|
91
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
84
92
|
type: zod_1.z.literal(exports.AgentMessagePieceType.MessageReference),
|
|
85
93
|
message: zod_1.z.object({
|
|
86
94
|
messageId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
@@ -90,6 +98,7 @@ exports.agentMessagePieceSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion(
|
|
|
90
98
|
}),
|
|
91
99
|
}).describe("MessageReference — pointer pill to a specific message. Tapping it navigates the user to that message."),
|
|
92
100
|
zod_1.z.object({
|
|
101
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
93
102
|
type: zod_1.z.literal(exports.AgentMessagePieceType.NoteReference),
|
|
94
103
|
note: zod_1.z.object({
|
|
95
104
|
noteId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
@@ -98,6 +107,7 @@ exports.agentMessagePieceSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion(
|
|
|
98
107
|
}),
|
|
99
108
|
}).describe("NoteReference — embedded note pill."),
|
|
100
109
|
zod_1.z.object({
|
|
110
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
101
111
|
type: zod_1.z.literal(exports.AgentMessagePieceType.ExternalItemReference),
|
|
102
112
|
provider: zod_1.z.string(),
|
|
103
113
|
externalId: zod_1.z.string().describe("Provider identifier: a Notion page ID, case-sensitive Figma file key, or Linear issue UUID."),
|
|
@@ -106,12 +116,14 @@ exports.agentMessagePieceSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion(
|
|
|
106
116
|
url: zod_1.z.string().nullable(),
|
|
107
117
|
}).describe("ExternalItemReference — a page, file, or issue the user tagged from a connected provider. provider+externalId identify it exactly. Use a matching provider tool if one is available to fetch the full context before acting; otherwise ask for that context. Never invent or alter the externalId."),
|
|
108
118
|
zod_1.z.object({
|
|
119
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
109
120
|
type: zod_1.z.literal(exports.AgentMessagePieceType.OpaqueReference),
|
|
110
121
|
pieceId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
111
122
|
contentType: exports.agentOpaqueContentTypeSchema,
|
|
112
123
|
description: zod_1.z.string(),
|
|
113
124
|
}).describe("OpaqueReference — content you cannot read or recreate. Preserve it unchanged only through a write tool that explicitly supports opaque references. If no such tool is available, leave the note unchanged."),
|
|
114
125
|
zod_1.z.object({
|
|
126
|
+
sourcePieceId: zod_1.z.string().check(zod_1.z.uuid()).optional().describe("Stored note piece ID. Use this as pieceId in a retained-piece reference to keep this exact piece unchanged when updating its own note."),
|
|
115
127
|
type: zod_1.z.literal(exports.AgentMessagePieceType.NotFound),
|
|
116
128
|
itemId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
117
129
|
entityType: zod_1.z.string().describe("Kind of item: \"asset\", \"folder\", \"profile\", \"action\", \"stream\", \"to_do\", \"message\", \"note\", or \"external_item\"."),
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const MAX_EXPORT_ASSET_COUNT = 100;
|
|
3
|
+
export declare const CreateAgentMessagePieceType: {
|
|
4
|
+
readonly Text: 0;
|
|
5
|
+
readonly NewLink: 1;
|
|
6
|
+
readonly AssetReference: 2;
|
|
7
|
+
readonly FolderReference: 3;
|
|
8
|
+
readonly ProfileReference: 4;
|
|
9
|
+
readonly IntegrationAction: 5;
|
|
10
|
+
readonly QuestionAction: 6;
|
|
11
|
+
readonly AgentActionReference: 7;
|
|
12
|
+
readonly StreamReference: 8;
|
|
13
|
+
readonly ToDoReference: 9;
|
|
14
|
+
readonly MessageReference: 10;
|
|
15
|
+
readonly ExportAction: 11;
|
|
16
|
+
readonly ExternalActionApproval: 12;
|
|
17
|
+
readonly NoteReference: 13;
|
|
18
|
+
readonly OpaqueReference: 14;
|
|
19
|
+
readonly RetainedPieceReference: 15;
|
|
20
|
+
};
|
|
21
|
+
export type CreateAgentMessagePieceType = typeof CreateAgentMessagePieceType[keyof typeof CreateAgentMessagePieceType];
|
|
22
|
+
export declare const createAgentMessagePieceRequestSchema: z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
|
|
23
|
+
type: z.ZodLiteral<0>;
|
|
24
|
+
text: z.ZodString;
|
|
25
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
26
|
+
type: z.ZodLiteral<1>;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<2>;
|
|
32
|
+
assetId: z.ZodString;
|
|
33
|
+
startTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
endTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
35
|
+
markup: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<3>;
|
|
38
|
+
folderId: z.ZodString;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<4>;
|
|
41
|
+
profileId: z.ZodString;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<5>;
|
|
44
|
+
integrationTypes: z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
|
|
45
|
+
readonly Dropbox: 0;
|
|
46
|
+
readonly Notion: 1;
|
|
47
|
+
readonly GoogleWorkspace: 2;
|
|
48
|
+
readonly Arena: 3;
|
|
49
|
+
readonly Frameio: 4;
|
|
50
|
+
readonly Instagram: 5;
|
|
51
|
+
readonly YouTube: 6;
|
|
52
|
+
readonly TikTok: 7;
|
|
53
|
+
readonly Vimeo: 8;
|
|
54
|
+
readonly Canva: 9;
|
|
55
|
+
readonly Figma: 10;
|
|
56
|
+
readonly Descript: 11;
|
|
57
|
+
readonly ElevenLabs: 12;
|
|
58
|
+
readonly Flora: 13;
|
|
59
|
+
readonly Krea: 14;
|
|
60
|
+
readonly Linear: 16;
|
|
61
|
+
readonly Airtable: 17;
|
|
62
|
+
}>>>;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<6>;
|
|
65
|
+
title: z.ZodString;
|
|
66
|
+
body: z.ZodString;
|
|
67
|
+
selectionType: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
|
|
68
|
+
readonly SingleSelect: 0;
|
|
69
|
+
readonly MultiSelect: 1;
|
|
70
|
+
}>>;
|
|
71
|
+
choices: z.ZodArray<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
73
|
+
type: z.ZodLiteral<7>;
|
|
74
|
+
agentActionId: z.ZodString;
|
|
75
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
76
|
+
type: z.ZodLiteral<8>;
|
|
77
|
+
streamId: z.ZodString;
|
|
78
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<9>;
|
|
80
|
+
todoId: z.ZodString;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
type: z.ZodLiteral<10>;
|
|
83
|
+
messageId: z.ZodString;
|
|
84
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
85
|
+
type: z.ZodLiteral<11>;
|
|
86
|
+
assetIds: z.ZodArray<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
type: z.ZodLiteral<13>;
|
|
89
|
+
noteId: z.ZodString;
|
|
90
|
+
}, z.core.$strip>], "type">;
|
|
91
|
+
declare const createOpaqueReferencePieceRequestSchema: z.ZodObject<{
|
|
92
|
+
type: z.ZodLiteral<14>;
|
|
93
|
+
pieceId: z.ZodString;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
declare const createRetainedPieceRequestSchema: z.ZodObject<{
|
|
96
|
+
type: z.ZodLiteral<15>;
|
|
97
|
+
pieceId: z.ZodString;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export type CreateSurfacePieceRequest = z.infer<typeof createAgentMessagePieceRequestSchema> | z.infer<typeof createOpaqueReferencePieceRequestSchema> | z.infer<typeof createRetainedPieceRequestSchema>;
|
|
100
|
+
export declare function pieceUnionFor(allowed: readonly number[]): z.ZodType<CreateSurfacePieceRequest>;
|
|
101
|
+
export declare const agentNotePieceSchema: z.ZodType<CreateSurfacePieceRequest, unknown, z.core.$ZodTypeInternals<CreateSurfacePieceRequest, unknown>>;
|
|
102
|
+
export declare const agentNoteCreatePieceSchema: z.ZodType<CreateSurfacePieceRequest, unknown, z.core.$ZodTypeInternals<CreateSurfacePieceRequest, unknown>>;
|
|
103
|
+
export declare const namedAgentPieceSchemas: {
|
|
104
|
+
text: z.ZodObject<{
|
|
105
|
+
type: z.ZodLiteral<"text">;
|
|
106
|
+
text: z.ZodString;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
new_link: z.ZodObject<{
|
|
109
|
+
type: z.ZodLiteral<"new_link">;
|
|
110
|
+
url: z.ZodString;
|
|
111
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
asset_reference: z.ZodObject<{
|
|
115
|
+
type: z.ZodLiteral<"asset_reference">;
|
|
116
|
+
assetId: z.ZodString;
|
|
117
|
+
startTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
118
|
+
endTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
119
|
+
markup: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
folder_reference: z.ZodObject<{
|
|
122
|
+
type: z.ZodLiteral<"folder_reference">;
|
|
123
|
+
folderId: z.ZodString;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
profile_reference: z.ZodObject<{
|
|
126
|
+
type: z.ZodLiteral<"profile_reference">;
|
|
127
|
+
profileId: z.ZodString;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
stream_reference: z.ZodObject<{
|
|
130
|
+
type: z.ZodLiteral<"stream_reference">;
|
|
131
|
+
streamId: z.ZodString;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
todo_reference: z.ZodObject<{
|
|
134
|
+
type: z.ZodLiteral<"todo_reference">;
|
|
135
|
+
todoId: z.ZodString;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
message_reference: z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"message_reference">;
|
|
139
|
+
messageId: z.ZodString;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
export_action: z.ZodObject<{
|
|
142
|
+
type: z.ZodLiteral<"export_action">;
|
|
143
|
+
assetIds: z.ZodArray<z.ZodString>;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
note_reference: z.ZodObject<{
|
|
146
|
+
type: z.ZodLiteral<"note_reference">;
|
|
147
|
+
noteId: z.ZodString;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
opaque_reference: z.ZodObject<{
|
|
150
|
+
pieceId: z.ZodString;
|
|
151
|
+
type: z.ZodLiteral<"opaque_reference">;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
retained_piece_reference: z.ZodObject<{
|
|
154
|
+
pieceId: z.ZodString;
|
|
155
|
+
type: z.ZodLiteral<"retained_piece_reference">;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
};
|
|
158
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.namedAgentPieceSchemas = exports.agentNoteCreatePieceSchema = exports.agentNotePieceSchema = exports.createAgentMessagePieceRequestSchema = exports.CreateAgentMessagePieceType = exports.MAX_EXPORT_ASSET_COUNT = void 0;
|
|
4
|
+
exports.pieceUnionFor = pieceUnionFor;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const agent_action_dtos_1 = require("./agent-action-dtos");
|
|
7
|
+
const integration_dtos_1 = require("./integration-dtos");
|
|
8
|
+
exports.MAX_EXPORT_ASSET_COUNT = 100;
|
|
9
|
+
exports.CreateAgentMessagePieceType = {
|
|
10
|
+
Text: 0,
|
|
11
|
+
NewLink: 1,
|
|
12
|
+
AssetReference: 2,
|
|
13
|
+
FolderReference: 3,
|
|
14
|
+
ProfileReference: 4,
|
|
15
|
+
IntegrationAction: 5,
|
|
16
|
+
QuestionAction: 6,
|
|
17
|
+
AgentActionReference: 7,
|
|
18
|
+
StreamReference: 8,
|
|
19
|
+
ToDoReference: 9,
|
|
20
|
+
MessageReference: 10,
|
|
21
|
+
ExportAction: 11,
|
|
22
|
+
ExternalActionApproval: 12,
|
|
23
|
+
NoteReference: 13,
|
|
24
|
+
OpaqueReference: 14,
|
|
25
|
+
RetainedPieceReference: 15,
|
|
26
|
+
};
|
|
27
|
+
// Outbound: pieces the agent sends when creating a message
|
|
28
|
+
function writePieceOptions(types) {
|
|
29
|
+
return [
|
|
30
|
+
zod_1.z.object({
|
|
31
|
+
type: zod_1.z.literal(types.Text),
|
|
32
|
+
text: zod_1.z.string(),
|
|
33
|
+
}).describe("Text — prose. Merge ALL consecutive prose into ONE text piece (use \\n for line breaks, " +
|
|
34
|
+
"list items, section labels within it). Only start a new text piece when a pill piece sits " +
|
|
35
|
+
"between them. The server REJECTS a message containing two text pieces in a row with nothing " +
|
|
36
|
+
"between them — merge them into one before sending."),
|
|
37
|
+
zod_1.z.object({
|
|
38
|
+
type: zod_1.z.literal(types.NewLink),
|
|
39
|
+
url: zod_1.z.string(),
|
|
40
|
+
displayName: zod_1.z.string().nullable().optional(),
|
|
41
|
+
folderId: zod_1.z.string().check(zod_1.z.uuid()).nullable().optional(),
|
|
42
|
+
}).describe("NewLink — url + optional displayName/folderId; creates and embeds a link inline."),
|
|
43
|
+
zod_1.z.object({
|
|
44
|
+
type: zod_1.z.literal(types.AssetReference),
|
|
45
|
+
assetId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
46
|
+
startTime: zod_1.z.number().nullable().optional(),
|
|
47
|
+
endTime: zod_1.z.number().nullable().optional(),
|
|
48
|
+
markup: zod_1.z.string().nullable().optional()
|
|
49
|
+
.describe("Freehand annotation drawn on top of the asset, as JSON: " +
|
|
50
|
+
"{\"v\":1,\"color\":\"#RRGGBB\",\"page\":3,\"strokes\":[{\"w\":0.006,\"pts\":[[x,y],...],\"color\":\"#RRGGBB\"}]}. " +
|
|
51
|
+
"`color` is the default stroke color (hex); each stroke may override it with its own optional `color`. " +
|
|
52
|
+
"`strokes[].w` is line width, `strokes[].pts` is a list of [x,y] points — all coordinates and widths are " +
|
|
53
|
+
"normalized 0-1 against the displayed media (top-left origin), NOT pixels, so they scale to any viewer size. " +
|
|
54
|
+
"`page` is the 0-based PDF page the markup belongs to; omit it for images/video. " +
|
|
55
|
+
"Keep drawings simple — the client renders strokes as freehand vector paths, not an image overlay. " +
|
|
56
|
+
"Limits: at most 128 strokes, 16384 total points across all strokes, 256KB encoded (oversized markup is dropped silently, not rejected)."),
|
|
57
|
+
}).superRefine((piece, ctx) => {
|
|
58
|
+
if (piece.endTime == null) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (piece.startTime == null) {
|
|
62
|
+
ctx.addIssue({
|
|
63
|
+
code: "custom",
|
|
64
|
+
path: ["startTime"],
|
|
65
|
+
message: "startTime is required when endTime is set.",
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (piece.endTime <= piece.startTime) {
|
|
70
|
+
ctx.addIssue({
|
|
71
|
+
code: "custom",
|
|
72
|
+
path: ["endTime"],
|
|
73
|
+
message: "endTime must be greater than startTime.",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}).describe("AssetReference — assetId + optional startTime; set BOTH startTime and endTime to mark a range (renders 0:15–0:30). endTime requires startTime and must be greater. Optional markup draws freehand annotation strokes on the asset."),
|
|
77
|
+
zod_1.z.object({
|
|
78
|
+
type: zod_1.z.literal(types.FolderReference),
|
|
79
|
+
folderId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
80
|
+
}).describe("FolderReference — folderId; folder pill."),
|
|
81
|
+
zod_1.z.object({
|
|
82
|
+
type: zod_1.z.literal(types.ProfileReference),
|
|
83
|
+
profileId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
84
|
+
}).describe("ProfileReference — profileId; person pill."),
|
|
85
|
+
zod_1.z.object({
|
|
86
|
+
type: zod_1.z.literal(types.IntegrationAction),
|
|
87
|
+
integrationTypes: zod_1.z.array(integration_dtos_1.integrationTypeScheme).min(1),
|
|
88
|
+
}).describe("IntegrationAction — integrationTypes[]; embeds an integrations card."),
|
|
89
|
+
zod_1.z.object({
|
|
90
|
+
type: zod_1.z.literal(types.QuestionAction),
|
|
91
|
+
title: zod_1.z.string().regex(/^\S+$/).max(32),
|
|
92
|
+
body: zod_1.z.string().min(1).max(280),
|
|
93
|
+
selectionType: agent_action_dtos_1.selectionTypeSchema,
|
|
94
|
+
choices: zod_1.z.array(zod_1.z.string().min(1).max(80)).min(2).max(5),
|
|
95
|
+
}).describe("QuestionAction — title/body/selectionType/choices; embeds a question card."),
|
|
96
|
+
zod_1.z.object({
|
|
97
|
+
type: zod_1.z.literal(types.AgentActionReference),
|
|
98
|
+
agentActionId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
99
|
+
}).describe("AgentActionReference — agentActionId; references a pre-existing action from a receipt."),
|
|
100
|
+
zod_1.z.object({
|
|
101
|
+
type: zod_1.z.literal(types.StreamReference),
|
|
102
|
+
streamId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
103
|
+
}).describe("StreamReference — streamId; stream pill."),
|
|
104
|
+
zod_1.z.object({
|
|
105
|
+
type: zod_1.z.literal(types.ToDoReference),
|
|
106
|
+
todoId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
107
|
+
}).describe("ToDoReference — todoId; to-do pill."),
|
|
108
|
+
zod_1.z.object({
|
|
109
|
+
type: zod_1.z.literal(types.MessageReference),
|
|
110
|
+
messageId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
111
|
+
}).describe("MessageReference — messageId; pointer pill that navigates the user to that message. The message must be in a stream the actor can see."),
|
|
112
|
+
zod_1.z.object({
|
|
113
|
+
type: zod_1.z.literal(types.ExportAction),
|
|
114
|
+
assetIds: zod_1.z.array(zod_1.z.string().check(zod_1.z.uuid())).min(1).max(exports.MAX_EXPORT_ASSET_COUNT),
|
|
115
|
+
}).describe("ExportAction — assetIds[]; embeds a 'Save to device' card. When the user taps it the app saves those " +
|
|
116
|
+
"files exactly the way they can today — to Photos on iPhone/iPad, to the Downloads folder on Mac — " +
|
|
117
|
+
"picking the destination itself. Use this whenever the user asks to save, download, or export files " +
|
|
118
|
+
"(ones you created or any assets already in the conversation) to their device. Put EVERY file the user " +
|
|
119
|
+
"wants into ONE piece so they get a single confirm button — never emit one card per file. All assetIds " +
|
|
120
|
+
"must be assets the actor can see."),
|
|
121
|
+
zod_1.z.object({
|
|
122
|
+
type: zod_1.z.literal(types.NoteReference),
|
|
123
|
+
noteId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
124
|
+
}).describe("NoteReference — noteId; note pill. The note must have been created by the actor, or already referenced in a stream the actor can see."),
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
exports.createAgentMessagePieceRequestSchema = zod_1.z.discriminatedUnion("type", writePieceOptions(exports.CreateAgentMessagePieceType));
|
|
128
|
+
// Keeps a drawing or marker the model read from a note (an OpaqueReference read piece) in place.
|
|
129
|
+
// Only a surface that hands these out may take one back, so it is never part of the message union.
|
|
130
|
+
const createOpaqueReferencePieceRequestSchema = zod_1.z.object({
|
|
131
|
+
type: zod_1.z.literal(exports.CreateAgentMessagePieceType.OpaqueReference),
|
|
132
|
+
pieceId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
133
|
+
}).describe("OpaqueReference — pieceId; a drawing or marker get_note returned for this note (or, with versionOf, for " +
|
|
134
|
+
"the note this versions). Pass each one back with its pieceId unchanged, where it sits among the other " +
|
|
135
|
+
"pieces: leaving it out deletes that drawing. You cannot make a new one, or move one between unrelated notes.");
|
|
136
|
+
const createRetainedPieceRequestSchema = zod_1.z.object({
|
|
137
|
+
type: zod_1.z.literal(exports.CreateAgentMessagePieceType.RetainedPieceReference),
|
|
138
|
+
pieceId: zod_1.z.string().check(zod_1.z.uuid()),
|
|
139
|
+
}).describe("RetainedPieceReference — keep an existing piece of this note unchanged using its sourcePieceId. Preserves the stored content, including annotations or unavailable references. Only valid when updating that same note; never invent an ID. Omitted pieces are deleted.");
|
|
140
|
+
const surfacePieceOptions = [
|
|
141
|
+
...exports.createAgentMessagePieceRequestSchema.options,
|
|
142
|
+
createOpaqueReferencePieceRequestSchema,
|
|
143
|
+
createRetainedPieceRequestSchema,
|
|
144
|
+
];
|
|
145
|
+
// Structural narrowing keeps unsupported variants out of the model's JSON schema;
|
|
146
|
+
// a runtime-only refinement would still advertise them to callers.
|
|
147
|
+
function pieceUnionFor(allowed) {
|
|
148
|
+
const permitted = new Set(allowed);
|
|
149
|
+
const options = surfacePieceOptions.filter((option) => permitted.has(option.shape.type.value));
|
|
150
|
+
// Every requested type must resolve to a real variant. The allow-lists name types by numeric
|
|
151
|
+
// value, so a typo — or a variant later dropped from the union — would otherwise narrow the
|
|
152
|
+
// schema silently, and the model would simply stop being told about a piece it may send.
|
|
153
|
+
// This also fails loudly if a Zod upgrade changes the shape the discriminator is read from.
|
|
154
|
+
if (options.length !== permitted.size) {
|
|
155
|
+
const resolved = new Set(options.map((option) => option.shape.type.value));
|
|
156
|
+
const missing = [...permitted].filter((type) => !resolved.has(type));
|
|
157
|
+
throw new Error(`pieceUnionFor: no piece variant for type(s) ${missing.join(", ")}`);
|
|
158
|
+
}
|
|
159
|
+
return zod_1.z.discriminatedUnion("type", options);
|
|
160
|
+
}
|
|
161
|
+
const notePieceTypes = [
|
|
162
|
+
exports.CreateAgentMessagePieceType.Text, exports.CreateAgentMessagePieceType.NewLink,
|
|
163
|
+
exports.CreateAgentMessagePieceType.AssetReference, exports.CreateAgentMessagePieceType.FolderReference,
|
|
164
|
+
exports.CreateAgentMessagePieceType.ProfileReference, exports.CreateAgentMessagePieceType.StreamReference,
|
|
165
|
+
exports.CreateAgentMessagePieceType.ToDoReference, exports.CreateAgentMessagePieceType.MessageReference,
|
|
166
|
+
exports.CreateAgentMessagePieceType.NoteReference, exports.CreateAgentMessagePieceType.OpaqueReference,
|
|
167
|
+
exports.CreateAgentMessagePieceType.RetainedPieceReference,
|
|
168
|
+
];
|
|
169
|
+
exports.agentNotePieceSchema = pieceUnionFor(notePieceTypes);
|
|
170
|
+
exports.agentNoteCreatePieceSchema = pieceUnionFor(notePieceTypes.filter(type => type !== exports.CreateAgentMessagePieceType.RetainedPieceReference));
|
|
171
|
+
// Names adapt the provider fence; field definitions and validation remain shared with Runner.
|
|
172
|
+
const named = writePieceOptions({
|
|
173
|
+
Text: "text", NewLink: "new_link", AssetReference: "asset_reference", FolderReference: "folder_reference",
|
|
174
|
+
ProfileReference: "profile_reference", IntegrationAction: "integration_action", QuestionAction: "question_action",
|
|
175
|
+
AgentActionReference: "agent_action_reference", StreamReference: "stream_reference", ToDoReference: "todo_reference",
|
|
176
|
+
MessageReference: "message_reference", ExportAction: "export_action", ExternalActionApproval: "external_action_approval",
|
|
177
|
+
NoteReference: "note_reference", OpaqueReference: "opaque_reference", RetainedPieceReference: "retained_piece_reference",
|
|
178
|
+
});
|
|
179
|
+
function namedPiece(type) {
|
|
180
|
+
const option = named.find(option => option.shape.type.value === type);
|
|
181
|
+
if (!option) {
|
|
182
|
+
throw new Error(`No named piece variant for ${type}`);
|
|
183
|
+
}
|
|
184
|
+
return option;
|
|
185
|
+
}
|
|
186
|
+
exports.namedAgentPieceSchemas = {
|
|
187
|
+
text: namedPiece("text"), new_link: namedPiece("new_link"), asset_reference: namedPiece("asset_reference"),
|
|
188
|
+
folder_reference: namedPiece("folder_reference"), profile_reference: namedPiece("profile_reference"),
|
|
189
|
+
stream_reference: namedPiece("stream_reference"), todo_reference: namedPiece("todo_reference"),
|
|
190
|
+
message_reference: namedPiece("message_reference"), export_action: namedPiece("export_action"),
|
|
191
|
+
note_reference: namedPiece("note_reference"),
|
|
192
|
+
opaque_reference: createOpaqueReferencePieceRequestSchema.extend({ type: zod_1.z.literal("opaque_reference") })
|
|
193
|
+
.describe("opaque_reference — keep a drawing or marker returned by read_note, with its pieceId unchanged. Only valid when updating that same note. Omitted pieces are deleted."),
|
|
194
|
+
retained_piece_reference: createRetainedPieceRequestSchema.extend({ type: zod_1.z.literal("retained_piece_reference") })
|
|
195
|
+
.describe("retained_piece_reference — keep a piece returned by read_note unchanged, with pieceId set to its sourcePieceId. Preserves stored content, including annotations and unavailable references. Only valid when updating that same note; never invent an ID. Omitted pieces are deleted."),
|
|
196
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@showrunner/agent-contracts",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"private": true,
|
|
5
|
-
"description": "Shared model-facing Showrunner piece schemas.
|
|
5
|
+
"description": "Shared model-facing Showrunner piece schemas. Mirrors the .NET write contracts and agent read mapper.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./*": {
|
|
8
8
|
"types": "./dist/*.d.ts",
|