@anchrd/colab-sdk 0.1.50 → 0.1.52
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/action-blocks/action-blocks.d.ts +57 -0
- package/dist/action-blocks/action-blocks.js +42 -0
- package/dist/actions/actions.d.ts +28 -0
- package/dist/actions/actions.js +11 -1
- package/dist/conversations/conversations.d.ts +566 -0
- package/dist/conversations/conversations.js +191 -0
- package/dist/dictations/dictations.d.ts +8 -0
- package/dist/dictations/dictations.js +12 -0
- package/dist/error/error.d.ts +2 -0
- package/dist/error/error.js +2 -0
- package/dist/goals/goals.d.ts +20 -0
- package/dist/grammar/grammar.d.ts +3 -0
- package/dist/grammar/grammar.js +11 -0
- package/dist/machines/machines.d.ts +1 -0
- package/dist/messages/messages.d.ts +69 -1
- package/dist/messages/messages.js +91 -7
- package/dist/nodes/nodes.d.ts +1 -0
- package/dist/nodes/nodes.js +11 -1
- package/dist/operators/operators.d.ts +89 -137
- package/dist/operators/operators.js +19 -43
- package/dist/sdk.d.ts +5 -2
- package/dist/sdk.js +5 -2
- package/dist/users/users.d.ts +5 -0
- package/dist/users/users.js +3 -0
- package/dist/written/written.d.ts +4 -0
- package/dist/written/written.js +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { idSchema } from "../ids/ids.js";
|
|
3
|
+
import { Flag, Limit } from "../list-input.js";
|
|
4
|
+
import { AttachmentId, attachmentMaxBytes, attachmentsMax, MessageAttachment, } from "../messages/messages.js";
|
|
5
|
+
import { OperatorRunTokens } from "../operators/operators.js";
|
|
6
|
+
import { IdempotencyKey } from "../primitives/primitives.js";
|
|
7
|
+
import { UserId } from "../users/users.js";
|
|
8
|
+
// A person's conversation with one of their personal Operators (E267, #1212, Funktionen ›
|
|
9
|
+
// KI-Chat). At most one is open per person; "Neuer Chat" archives it, and an archived one is never
|
|
10
|
+
// opened again: it is read and searched as context, by its person only, never by an admin.
|
|
11
|
+
//
|
|
12
|
+
// While it is open its history lives in one Durable Object per conversation, which holds the
|
|
13
|
+
// WebSocket of every browser of its person; archiving moves the history into `OPERATOR_DB`.
|
|
14
|
+
// The socket's protocol stands here, so the UI (#1213) and the runtimes (#1214) build against it.
|
|
15
|
+
export const ConversationId = idSchema("conversation").describe("The conversation, `conversation_…`.");
|
|
16
|
+
export const ConversationMessageId = idSchema("message").describe("A message of the conversation, `message_…`.");
|
|
17
|
+
export const ConversationStepId = idSchema("step");
|
|
18
|
+
// The title from the first question, cut; the person may change it.
|
|
19
|
+
export const conversationTitleMax = 120;
|
|
20
|
+
// One message of the person.
|
|
21
|
+
export const conversationTextMax = 20_000;
|
|
22
|
+
export const ConversationStatus = z.enum(["open", "archived"]);
|
|
23
|
+
// One tool call of the Operator during an answer. It may carry names (`name`: the node, the board,
|
|
24
|
+
// the query it touched): only its person ever sees a conversation.
|
|
25
|
+
export const ConversationStep = z.object({
|
|
26
|
+
stepId: ConversationStepId,
|
|
27
|
+
// The tool as `/mcp` names it (`intelligence_board_create`), or the runtime's own (`Read`).
|
|
28
|
+
tool: z.string().max(200),
|
|
29
|
+
// What it touched, in a few words; null where the call names nothing.
|
|
30
|
+
name: z.string().max(200).nullable(),
|
|
31
|
+
status: z.enum(["running", "done", "failed"]),
|
|
32
|
+
startedAt: z.iso.datetime(),
|
|
33
|
+
endedAt: z.iso.datetime().nullable(),
|
|
34
|
+
});
|
|
35
|
+
// `answering` while the Operator still writes it; `aborted` when its person stopped it, `failed`
|
|
36
|
+
// when the runtime gave up (`detail` says why).
|
|
37
|
+
export const ConversationMessageStatus = z.enum(["done", "answering", "aborted", "failed"]);
|
|
38
|
+
export const ConversationMessage = z.object({
|
|
39
|
+
messageId: ConversationMessageId,
|
|
40
|
+
role: z.enum(["person", "operator"]),
|
|
41
|
+
text: z.string(),
|
|
42
|
+
// Only the Operator's messages carry steps, in the order they began.
|
|
43
|
+
steps: z.array(ConversationStep),
|
|
44
|
+
status: ConversationMessageStatus,
|
|
45
|
+
detail: z.string().nullable(),
|
|
46
|
+
// The person's own id for a message it sent (`send.clientId`), so a browser matches its echo.
|
|
47
|
+
clientId: z.string().nullable(),
|
|
48
|
+
createdAt: z.iso.datetime(),
|
|
49
|
+
// What the answer cost and counted; null on the person's messages and where nothing was counted.
|
|
50
|
+
costUsd: z.number().min(0).nullable(),
|
|
51
|
+
tokens: OperatorRunTokens.nullable(),
|
|
52
|
+
// The files the person sent with a question (#1213, E267), shaped like a chat message's (E265);
|
|
53
|
+
// absent on every other message and on a message from before.
|
|
54
|
+
attachments: z.array(MessageAttachment).optional(),
|
|
55
|
+
});
|
|
56
|
+
export const Conversation = z.object({
|
|
57
|
+
conversationId: ConversationId,
|
|
58
|
+
// The person it belongs to.
|
|
59
|
+
userId: UserId,
|
|
60
|
+
// The personal Operator it runs with, and its name and model at this moment.
|
|
61
|
+
machineId: UserId,
|
|
62
|
+
operator: z.object({ name: z.string(), model: z.string() }).nullable(),
|
|
63
|
+
title: z.string(),
|
|
64
|
+
status: ConversationStatus,
|
|
65
|
+
messageCount: z.int().min(0),
|
|
66
|
+
// Summed over every answer, like a run's.
|
|
67
|
+
costUsd: z.number().min(0).nullable(),
|
|
68
|
+
tokens: OperatorRunTokens,
|
|
69
|
+
createdAt: z.iso.datetime(),
|
|
70
|
+
updatedAt: z.iso.datetime(),
|
|
71
|
+
archivedAt: z.iso.datetime().nullable(),
|
|
72
|
+
rev: z.int().min(1),
|
|
73
|
+
});
|
|
74
|
+
// A hit of the search: the conversation and the passage that matched.
|
|
75
|
+
export const ConversationHit = Conversation.extend({ excerpt: z.string().nullable() });
|
|
76
|
+
// ---------------------------------------------------------------------------------------------
|
|
77
|
+
// The socket: `GET /live/conversations/:conversationId` with `Upgrade: websocket`, only for the
|
|
78
|
+
// conversation's own person (anybody else, an admin too, gets the 404 before the upgrade). One
|
|
79
|
+
// JSON object per frame.
|
|
80
|
+
// The browser to the conversation.
|
|
81
|
+
export const ConversationClientMessage = z.discriminatedUnion("type", [
|
|
82
|
+
// A question. Refused with `error` `conflict` while an answer is still being written. It may carry
|
|
83
|
+
// up to ten files uploaded into this conversation (`operator_conversation_attachment_create`,
|
|
84
|
+
// #1213); with them its text may be empty.
|
|
85
|
+
z
|
|
86
|
+
.strictObject({
|
|
87
|
+
type: z.literal("send"),
|
|
88
|
+
clientId: z.string().min(1).max(64),
|
|
89
|
+
text: z.string().trim().max(conversationTextMax),
|
|
90
|
+
attachments: z.array(AttachmentId).max(attachmentsMax).optional(),
|
|
91
|
+
})
|
|
92
|
+
.refine((frame) => frame.text !== "" || (frame.attachments?.length ?? 0) > 0, {
|
|
93
|
+
message: "A question needs text or an attachment.",
|
|
94
|
+
}),
|
|
95
|
+
// Stops the answer being written; what it wrote so far stays, as `aborted`.
|
|
96
|
+
z.strictObject({ type: z.literal("abort") }),
|
|
97
|
+
]);
|
|
98
|
+
// The conversation to the browser.
|
|
99
|
+
export const ConversationServerMessage = z.discriminatedUnion("type", [
|
|
100
|
+
// The whole state, first on every connect: a browser that joins in the middle of an answer gets
|
|
101
|
+
// the answer as far as it is (`status: "answering"`) and the deltas from there.
|
|
102
|
+
z.object({
|
|
103
|
+
type: z.literal("state"),
|
|
104
|
+
conversation: Conversation,
|
|
105
|
+
messages: z.array(ConversationMessage),
|
|
106
|
+
}),
|
|
107
|
+
// A message of the person, whole (with its `clientId`), to every browser of the person.
|
|
108
|
+
z.object({ type: z.literal("message"), message: ConversationMessage }),
|
|
109
|
+
// The Operator begins to answer: its message with `status: "answering"`.
|
|
110
|
+
z.object({ type: z.literal("answer.start"), message: ConversationMessage }),
|
|
111
|
+
// The next piece of the answer's text, appended to `text`.
|
|
112
|
+
z.object({
|
|
113
|
+
type: z.literal("answer.text"),
|
|
114
|
+
messageId: ConversationMessageId,
|
|
115
|
+
delta: z.string(),
|
|
116
|
+
}),
|
|
117
|
+
// A step began (`running`) or ended (`done`, `failed`): replace the step of the same `stepId`.
|
|
118
|
+
z.object({
|
|
119
|
+
type: z.literal("answer.step"),
|
|
120
|
+
messageId: ConversationMessageId,
|
|
121
|
+
step: ConversationStep,
|
|
122
|
+
}),
|
|
123
|
+
// The answer is over, whole, with its status, cost and tokens.
|
|
124
|
+
z.object({ type: z.literal("answer.end"), message: ConversationMessage }),
|
|
125
|
+
// The conversation changed (title, cost, count).
|
|
126
|
+
z.object({ type: z.literal("conversation"), conversation: Conversation }),
|
|
127
|
+
// A frame that was refused; the socket stays open.
|
|
128
|
+
z.object({
|
|
129
|
+
type: z.literal("error"),
|
|
130
|
+
code: z.enum(["invalid", "conflict", "unavailable"]),
|
|
131
|
+
message: z.string(),
|
|
132
|
+
}),
|
|
133
|
+
]);
|
|
134
|
+
// The close codes of the socket (4000 to 4999 are the application's own); the reason is the word.
|
|
135
|
+
export const conversationClose = {
|
|
136
|
+
// "Neuer Chat" archived it: the browser opens the new one.
|
|
137
|
+
archived: { code: 4409, reason: "archived" },
|
|
138
|
+
// Its person may no longer use it (the Operator is gone, the person locked).
|
|
139
|
+
gone: { code: 4404, reason: "gone" },
|
|
140
|
+
};
|
|
141
|
+
// ---------------------------------------------------------------------------------------------
|
|
142
|
+
// The tools `operator_conversation_*`: always the caller's own conversations, in admin mode too.
|
|
143
|
+
export const ConversationListInput = z.strictObject({
|
|
144
|
+
query: z
|
|
145
|
+
.string()
|
|
146
|
+
.trim()
|
|
147
|
+
.min(2)
|
|
148
|
+
.max(200)
|
|
149
|
+
.optional()
|
|
150
|
+
.describe("Search the archived conversations by words and meaning; the hits come with the passage that matched."),
|
|
151
|
+
archived: Flag.optional().describe("true: only the archived conversations; false: only the open one. Leaving it out lists both."),
|
|
152
|
+
cursor: z.string().max(200).optional(),
|
|
153
|
+
limit: Limit.optional(),
|
|
154
|
+
});
|
|
155
|
+
export const ConversationGetInput = z.strictObject({ conversationId: ConversationId });
|
|
156
|
+
export const ConversationGetAnswer = Conversation.extend({
|
|
157
|
+
messages: z.array(ConversationMessage),
|
|
158
|
+
});
|
|
159
|
+
export const ConversationCreateInput = z.strictObject({
|
|
160
|
+
machineId: UserId.optional().describe("The personal Operator to talk with, `user_…`; leaving it out takes the one of the open conversation, else the first."),
|
|
161
|
+
});
|
|
162
|
+
export const ConversationUpdateInput = z.strictObject({
|
|
163
|
+
conversationId: ConversationId,
|
|
164
|
+
rev: z.int().min(1).describe("The rev the conversation was read with."),
|
|
165
|
+
title: z.string().trim().min(1).max(conversationTitleMax).optional(),
|
|
166
|
+
machineId: UserId.optional().describe("Another of the person's personal Operators for the open conversation, only while it has no message yet; once it has one, its Operator stays (conflict) and a new conversation takes the other."),
|
|
167
|
+
});
|
|
168
|
+
export const ConversationArchiveInput = z.strictObject({ conversationId: ConversationId });
|
|
169
|
+
// A file for the open conversation's next question (#1213, E267): uploaded first, then named by the
|
|
170
|
+
// question's `send.attachments`. Only the conversation's person, never an Operator.
|
|
171
|
+
const attachmentMaxBase64 = Math.ceil(attachmentMaxBytes / 3) * 4;
|
|
172
|
+
export const ConversationAttachmentCreateInput = z.strictObject({
|
|
173
|
+
conversationId: ConversationId.describe("Your open conversation, `conversation_…`."),
|
|
174
|
+
name: z.string().trim().min(1).max(255).describe("The file's name, e.g. `angebot.pdf`."),
|
|
175
|
+
mediaType: z
|
|
176
|
+
.string()
|
|
177
|
+
.trim()
|
|
178
|
+
.min(1)
|
|
179
|
+
.max(255)
|
|
180
|
+
.describe("The file's media type, e.g. `image/png` or `application/pdf`."),
|
|
181
|
+
content: z
|
|
182
|
+
.base64()
|
|
183
|
+
.max(attachmentMaxBase64, "An attachment holds at most 20 MB.")
|
|
184
|
+
.describe("The file's bytes as Base64, at most 20 MB after decoding."),
|
|
185
|
+
idempotencyKey: IdempotencyKey,
|
|
186
|
+
});
|
|
187
|
+
export const ConversationPurgeInput = z.strictObject({ conversationId: ConversationId });
|
|
188
|
+
export const ConversationListAnswer = z.object({
|
|
189
|
+
items: z.array(ConversationHit),
|
|
190
|
+
nextCursor: z.string().nullable(),
|
|
191
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const dictationSampleRate = 16000;
|
|
3
|
+
export declare const dictationMaxSeconds = 30;
|
|
4
|
+
export declare const dictationMaxBytes: number;
|
|
5
|
+
export declare const DictationCreateOutput: z.ZodObject<{
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type DictationCreateOutput = z.infer<typeof DictationCreateOutput>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// One dictated sentence (#1211, E266): the browser cuts the speech at its pauses and sends each
|
|
3
|
+
// sentence alone as WAV, 16-bit PCM, mono, 16 kHz, the format the speech models take without a
|
|
4
|
+
// conversion. The door `POST /api/intelligence/dictations` answers its text; nothing is stored.
|
|
5
|
+
export const dictationSampleRate = 16_000;
|
|
6
|
+
// Whisper reads 30 seconds at a time; a longer "sentence" is no pause the browser found, and is
|
|
7
|
+
// refused rather than cut.
|
|
8
|
+
export const dictationMaxSeconds = 30;
|
|
9
|
+
// The bytes of 30 seconds, with room for the head and a chunk before the sound (a `LIST` chunk, as
|
|
10
|
+
// macOS writes it): the seconds in the head are the real limit.
|
|
11
|
+
export const dictationMaxBytes = 4096 + dictationMaxSeconds * dictationSampleRate * 2;
|
|
12
|
+
export const DictationCreateOutput = z.object({ text: z.string() });
|
package/dist/error/error.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const ErrorCurrent: z.ZodObject<{
|
|
|
23
23
|
gadgetId: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
24
24
|
nodeId: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
25
25
|
machineId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
|
|
26
|
+
conversationId: z.ZodOptional<z.ZodTemplateLiteral<`conversation_${string}`>>;
|
|
26
27
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
27
28
|
rev: z.ZodNumber;
|
|
28
29
|
savedBy: z.ZodOptional<z.ZodObject<{
|
|
@@ -60,6 +61,7 @@ export declare const ErrorResponse: z.ZodObject<{
|
|
|
60
61
|
gadgetId: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
61
62
|
nodeId: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
62
63
|
machineId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
|
|
64
|
+
conversationId: z.ZodOptional<z.ZodTemplateLiteral<`conversation_${string}`>>;
|
|
63
65
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
64
66
|
rev: z.ZodNumber;
|
|
65
67
|
savedBy: z.ZodOptional<z.ZodObject<{
|
package/dist/error/error.js
CHANGED
|
@@ -34,6 +34,8 @@ export const ErrorCurrent = z.strictObject({
|
|
|
34
34
|
gadgetId: NodeRef.optional(),
|
|
35
35
|
nodeId: NodeRef.optional(),
|
|
36
36
|
machineId: idSchema("user").optional(),
|
|
37
|
+
// A person's conversation with a personal Operator (#1212).
|
|
38
|
+
conversationId: idSchema("conversation").optional(),
|
|
37
39
|
// A built connector's id (#894), `github`.
|
|
38
40
|
connectorId: z.string().optional(),
|
|
39
41
|
rev: z.number().int(),
|
package/dist/goals/goals.d.ts
CHANGED
|
@@ -649,6 +649,7 @@ export declare const GoalRunDetail: z.ZodObject<{
|
|
|
649
649
|
machine: "machine";
|
|
650
650
|
human: "human";
|
|
651
651
|
}>>;
|
|
652
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
652
653
|
machine: z.ZodNullable<z.ZodObject<{
|
|
653
654
|
kind: z.ZodEnum<{
|
|
654
655
|
operator: "operator";
|
|
@@ -667,6 +668,15 @@ export declare const GoalRunDetail: z.ZodObject<{
|
|
|
667
668
|
userId: z.ZodString;
|
|
668
669
|
name: z.ZodNullable<z.ZodString>;
|
|
669
670
|
}, z.core.$strip>>;
|
|
671
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
672
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
673
|
+
name: z.ZodString;
|
|
674
|
+
mediaType: z.ZodString;
|
|
675
|
+
size: z.ZodNumber;
|
|
676
|
+
image: z.ZodBoolean;
|
|
677
|
+
contentUrl: z.ZodString;
|
|
678
|
+
previewUrl: z.ZodNullable<z.ZodString>;
|
|
679
|
+
}, z.core.$strip>>>;
|
|
670
680
|
createdAt: z.ZodISODateTime;
|
|
671
681
|
}, z.core.$strip>>>;
|
|
672
682
|
rev: z.ZodInt;
|
|
@@ -1023,6 +1033,7 @@ export declare const GoalDetail: z.ZodObject<{
|
|
|
1023
1033
|
machine: "machine";
|
|
1024
1034
|
human: "human";
|
|
1025
1035
|
}>>;
|
|
1036
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1026
1037
|
machine: z.ZodNullable<z.ZodObject<{
|
|
1027
1038
|
kind: z.ZodEnum<{
|
|
1028
1039
|
operator: "operator";
|
|
@@ -1041,6 +1052,15 @@ export declare const GoalDetail: z.ZodObject<{
|
|
|
1041
1052
|
userId: z.ZodString;
|
|
1042
1053
|
name: z.ZodNullable<z.ZodString>;
|
|
1043
1054
|
}, z.core.$strip>>;
|
|
1055
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1056
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
1057
|
+
name: z.ZodString;
|
|
1058
|
+
mediaType: z.ZodString;
|
|
1059
|
+
size: z.ZodNumber;
|
|
1060
|
+
image: z.ZodBoolean;
|
|
1061
|
+
contentUrl: z.ZodString;
|
|
1062
|
+
previewUrl: z.ZodNullable<z.ZodString>;
|
|
1063
|
+
}, z.core.$strip>>>;
|
|
1044
1064
|
createdAt: z.ZodISODateTime;
|
|
1045
1065
|
}, z.core.$strip>>>;
|
|
1046
1066
|
rev: z.ZodInt;
|
|
@@ -14,6 +14,8 @@ export declare const resources: {
|
|
|
14
14
|
readonly version: "versions";
|
|
15
15
|
readonly chat: "chats";
|
|
16
16
|
readonly message: "messages";
|
|
17
|
+
readonly attachment: "attachments";
|
|
18
|
+
readonly dictation: "dictations";
|
|
17
19
|
readonly action: "actions";
|
|
18
20
|
readonly grant: "grants";
|
|
19
21
|
readonly link: "links";
|
|
@@ -48,6 +50,7 @@ export declare const resources: {
|
|
|
48
50
|
readonly job: "jobs";
|
|
49
51
|
readonly type: "types";
|
|
50
52
|
readonly relation: "relations";
|
|
53
|
+
readonly conversation: "conversations";
|
|
51
54
|
};
|
|
52
55
|
export declare const actions: readonly ["list", "get", "create", "update", "archive", "restore", "purge"];
|
|
53
56
|
export declare const verbs: readonly ["invite", "resend", "disable", "enable", "rotate", "share", "move", "start", "complete", "test", "revoke", "remove", "unlock", "publish", "schedule", "unpublish", "cancel", "describe"];
|
package/dist/grammar/grammar.js
CHANGED
|
@@ -34,6 +34,13 @@ export const resources = {
|
|
|
34
34
|
version: "versions",
|
|
35
35
|
chat: "chats",
|
|
36
36
|
message: "messages",
|
|
37
|
+
// A file sent with a chat message (#1210, E265), a sub-resource of the chat it was uploaded into:
|
|
38
|
+
// `intelligence_chat_attachment_create` and `_get`. No node. Confirmed by the orchestrator.
|
|
39
|
+
attachment: "attachments",
|
|
40
|
+
// One spoken sentence turned into text for the chat's input (#1211, E266): the door
|
|
41
|
+
// `POST /api/intelligence/dictations`, a person's only, no tool and no stored row. Confirmed by the
|
|
42
|
+
// orchestrator.
|
|
43
|
+
dictation: "dictations",
|
|
37
44
|
action: "actions",
|
|
38
45
|
grant: "grants",
|
|
39
46
|
link: "links",
|
|
@@ -108,6 +115,10 @@ export const resources = {
|
|
|
108
115
|
// Both named by the ticket.
|
|
109
116
|
type: "types",
|
|
110
117
|
relation: "relations",
|
|
118
|
+
// A person's conversation with one of their personal Operators (E267, #1212, Funktionen ›
|
|
119
|
+
// KI-Chat): `operator_conversation_*`. Not `chat`, a node's chat in `intelligence`. Confirmed by the
|
|
120
|
+
// orchestrator.
|
|
121
|
+
conversation: "conversations",
|
|
111
122
|
};
|
|
112
123
|
// The closed list of actions with a route of their own shape.
|
|
113
124
|
export const actions = ["list", "get", "create", "update", "archive", "restore", "purge"];
|
|
@@ -51,6 +51,7 @@ export declare const MachineKey: z.ZodObject<{
|
|
|
51
51
|
external: "external";
|
|
52
52
|
}>;
|
|
53
53
|
responsibleId: z.ZodNullable<z.ZodTemplateLiteral<`user_${string}`>>;
|
|
54
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
55
|
}, z.core.$strip>>;
|
|
55
56
|
createdAt: z.ZodISODateTime;
|
|
56
57
|
updatedAt: z.ZodISODateTime;
|
|
@@ -13,18 +13,65 @@ export declare const MessageListInput: z.ZodObject<{
|
|
|
13
13
|
topic: z.ZodOptional<z.ZodString>;
|
|
14
14
|
}, z.core.$strict>;
|
|
15
15
|
export type MessageListInput = z.infer<typeof MessageListInput>;
|
|
16
|
+
export declare const AttachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
17
|
+
export type AttachmentId = z.infer<typeof AttachmentId>;
|
|
18
|
+
export declare const attachmentsMax = 10;
|
|
19
|
+
export declare const attachmentMaxBytes: number;
|
|
20
|
+
export declare const ChatAttachmentCreateInput: z.ZodObject<{
|
|
21
|
+
chatId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
mediaType: z.ZodString;
|
|
24
|
+
content: z.ZodBase64;
|
|
25
|
+
idempotencyKey: z.ZodString;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export type ChatAttachmentCreateInput = z.infer<typeof ChatAttachmentCreateInput>;
|
|
28
|
+
export declare const ChatAttachmentGetInput: z.ZodObject<{
|
|
29
|
+
chatId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
30
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type ChatAttachmentGetInput = z.infer<typeof ChatAttachmentGetInput>;
|
|
33
|
+
export declare const MessageAttachment: z.ZodObject<{
|
|
34
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
mediaType: z.ZodString;
|
|
37
|
+
size: z.ZodNumber;
|
|
38
|
+
image: z.ZodBoolean;
|
|
39
|
+
contentUrl: z.ZodString;
|
|
40
|
+
previewUrl: z.ZodNullable<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type MessageAttachment = z.infer<typeof MessageAttachment>;
|
|
43
|
+
export declare const ChatAttachmentRead: z.ZodObject<{
|
|
44
|
+
attachment: z.ZodObject<{
|
|
45
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
mediaType: z.ZodString;
|
|
48
|
+
size: z.ZodNumber;
|
|
49
|
+
image: z.ZodBoolean;
|
|
50
|
+
contentUrl: z.ZodString;
|
|
51
|
+
previewUrl: z.ZodNullable<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
messageId: z.ZodNullable<z.ZodString>;
|
|
54
|
+
text: z.ZodNullable<z.ZodString>;
|
|
55
|
+
image: z.ZodNullable<z.ZodObject<{
|
|
56
|
+
data: z.ZodString;
|
|
57
|
+
mimeType: z.ZodString;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type ChatAttachmentRead = z.infer<typeof ChatAttachmentRead>;
|
|
16
61
|
export declare const MessageCreateInput: z.ZodObject<{
|
|
17
62
|
nodeId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
18
63
|
text: z.ZodString;
|
|
19
64
|
mentions: z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`user_${string}`>>>;
|
|
20
65
|
topic: z.ZodOptional<z.ZodString>;
|
|
66
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`attachment_${string}`>>>;
|
|
21
67
|
idempotencyKey: z.ZodString;
|
|
22
68
|
}, z.core.$strict>;
|
|
23
69
|
export type MessageCreateInput = z.infer<typeof MessageCreateInput>;
|
|
24
70
|
export declare const ChatUpdateInput: z.ZodObject<{
|
|
25
71
|
chatId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
26
|
-
readUntil: z.ZodTemplateLiteral<`message_${string}
|
|
72
|
+
readUntil: z.ZodOptional<z.ZodTemplateLiteral<`message_${string}`>>;
|
|
27
73
|
topic: z.ZodOptional<z.ZodString>;
|
|
74
|
+
typing: z.ZodOptional<z.ZodBoolean>;
|
|
28
75
|
}, z.core.$strict>;
|
|
29
76
|
export type ChatUpdateInput = z.infer<typeof ChatUpdateInput>;
|
|
30
77
|
export declare const MessageAuthor: z.ZodObject<{
|
|
@@ -34,6 +81,7 @@ export declare const MessageAuthor: z.ZodObject<{
|
|
|
34
81
|
machine: "machine";
|
|
35
82
|
human: "human";
|
|
36
83
|
}>>;
|
|
84
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
85
|
machine: z.ZodNullable<z.ZodObject<{
|
|
38
86
|
kind: z.ZodEnum<{
|
|
39
87
|
operator: "operator";
|
|
@@ -61,6 +109,7 @@ export declare const Message: z.ZodObject<{
|
|
|
61
109
|
machine: "machine";
|
|
62
110
|
human: "human";
|
|
63
111
|
}>>;
|
|
112
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
113
|
machine: z.ZodNullable<z.ZodObject<{
|
|
65
114
|
kind: z.ZodEnum<{
|
|
66
115
|
operator: "operator";
|
|
@@ -79,6 +128,15 @@ export declare const Message: z.ZodObject<{
|
|
|
79
128
|
userId: z.ZodString;
|
|
80
129
|
name: z.ZodNullable<z.ZodString>;
|
|
81
130
|
}, z.core.$strip>>;
|
|
131
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
132
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
133
|
+
name: z.ZodString;
|
|
134
|
+
mediaType: z.ZodString;
|
|
135
|
+
size: z.ZodNumber;
|
|
136
|
+
image: z.ZodBoolean;
|
|
137
|
+
contentUrl: z.ZodString;
|
|
138
|
+
previewUrl: z.ZodNullable<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>>>;
|
|
82
140
|
createdAt: z.ZodISODateTime;
|
|
83
141
|
}, z.core.$strip>;
|
|
84
142
|
export type Message = z.infer<typeof Message>;
|
|
@@ -103,6 +161,7 @@ export declare const MessageList: z.ZodObject<{
|
|
|
103
161
|
machine: "machine";
|
|
104
162
|
human: "human";
|
|
105
163
|
}>>;
|
|
164
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
165
|
machine: z.ZodNullable<z.ZodObject<{
|
|
107
166
|
kind: z.ZodEnum<{
|
|
108
167
|
operator: "operator";
|
|
@@ -121,6 +180,15 @@ export declare const MessageList: z.ZodObject<{
|
|
|
121
180
|
userId: z.ZodString;
|
|
122
181
|
name: z.ZodNullable<z.ZodString>;
|
|
123
182
|
}, z.core.$strip>>;
|
|
183
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
184
|
+
attachmentId: z.ZodTemplateLiteral<`attachment_${string}`>;
|
|
185
|
+
name: z.ZodString;
|
|
186
|
+
mediaType: z.ZodString;
|
|
187
|
+
size: z.ZodNumber;
|
|
188
|
+
image: z.ZodBoolean;
|
|
189
|
+
contentUrl: z.ZodString;
|
|
190
|
+
previewUrl: z.ZodNullable<z.ZodString>;
|
|
191
|
+
}, z.core.$strip>>>;
|
|
124
192
|
createdAt: z.ZodISODateTime;
|
|
125
193
|
}, z.core.$strip>>;
|
|
126
194
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
@@ -7,7 +7,8 @@ import { MessageMachine } from "../users/users.js";
|
|
|
7
7
|
// The chat of a node (#45, Funktionen › Chat, E49, E67): the inputs of `intelligence_message_list`,
|
|
8
8
|
// `intelligence_message_create` and `intelligence_chat_update`, and their answers. Every node but a
|
|
9
9
|
// folder has a chat; it has no row of its own, and its `chatId` is the node's id. Messages are only
|
|
10
|
-
// appended: no editing, no
|
|
10
|
+
// appended: no editing, no following. A message carries up to ten attachments (#1210, E265), each
|
|
11
|
+
// uploaded into the chat first and named by the message that sends it.
|
|
11
12
|
export const MessageId = idSchema("message").describe("A message's id, `message_…`, as intelligence_message_list returns it.");
|
|
12
13
|
// What a message may hold, in characters of Markdown.
|
|
13
14
|
export const messageMaxLength = 10_000;
|
|
@@ -37,26 +38,103 @@ export const MessageListInput = z.strictObject({
|
|
|
37
38
|
limit: PageSize.optional().describe("How many messages one page holds, 1 to 100. Leaving it out gives 50."),
|
|
38
39
|
topic: TopicName.optional().describe("Only the messages of this topic, as topics names it; an empty text reads the general topic (Allgemein). Leaving it out reads every topic. Read topics first, then only the one you need."),
|
|
39
40
|
});
|
|
40
|
-
|
|
41
|
+
// An attachment of a chat message (#1210, E265): uploaded into a chat, then sent with one message.
|
|
42
|
+
// No node: no place in the tree, no rights and no versions of its own.
|
|
43
|
+
export const AttachmentId = idSchema("attachment").describe("An attachment's id, `attachment_…`, as intelligence_chat_attachment_create or intelligence_message_list returns it.");
|
|
44
|
+
// At most this many attachments per message, each at most this many bytes (E265).
|
|
45
|
+
export const attachmentsMax = 10;
|
|
46
|
+
export const attachmentMaxBytes = 20 * 1024 * 1024;
|
|
47
|
+
// The Base64 of the largest attachment, padded: what the input's length is held to.
|
|
48
|
+
const attachmentMaxBase64 = Math.ceil(attachmentMaxBytes / 3) * 4;
|
|
49
|
+
export const ChatAttachmentCreateInput = z.strictObject({
|
|
50
|
+
chatId: NodeId.describe("The chat to attach the file in: the id of its node, `node_…`, any node you can read except a folder."),
|
|
51
|
+
name: z
|
|
52
|
+
.string()
|
|
53
|
+
.trim()
|
|
54
|
+
.min(1)
|
|
55
|
+
.max(255)
|
|
56
|
+
.describe("The file's name as it shows in the chat, e.g. `kunde-buero.jpg`."),
|
|
57
|
+
mediaType: z
|
|
58
|
+
.string()
|
|
59
|
+
.trim()
|
|
60
|
+
.min(1)
|
|
61
|
+
.max(255)
|
|
62
|
+
.describe("The file's media type, e.g. `image/jpeg` or `application/pdf`."),
|
|
63
|
+
content: z
|
|
64
|
+
.base64()
|
|
65
|
+
.max(attachmentMaxBase64, "An attachment holds at most 20 MB.")
|
|
66
|
+
.describe("The file's bytes as Base64 (standard alphabet, padded with =), at most 20 MB after decoding."),
|
|
67
|
+
idempotencyKey: IdempotencyKey,
|
|
68
|
+
});
|
|
69
|
+
export const ChatAttachmentGetInput = z.strictObject({
|
|
70
|
+
chatId: NodeId.describe("The node whose chat holds the attachment, `node_…`."),
|
|
71
|
+
attachmentId: AttachmentId,
|
|
72
|
+
});
|
|
73
|
+
// An attachment as a message and the upload name it. `image`: a raster image the browser draws and
|
|
74
|
+
// `intelligence_chat_attachment_get` hands an AI as a picture.
|
|
75
|
+
export const MessageAttachment = z.object({
|
|
76
|
+
attachmentId: AttachmentId,
|
|
77
|
+
name: z.string(),
|
|
78
|
+
mediaType: z.string(),
|
|
79
|
+
size: z.number().int(),
|
|
80
|
+
image: z.boolean(),
|
|
81
|
+
// The original, opened with the caller's own session or token.
|
|
82
|
+
contentUrl: z.string(),
|
|
83
|
+
// The smaller picture of an image; null for every other file.
|
|
84
|
+
previewUrl: z.string().nullable(),
|
|
85
|
+
});
|
|
86
|
+
// What `intelligence_chat_attachment_get` answers: the attachment, and its content as far as it can
|
|
87
|
+
// travel. An image comes as a picture beside this answer over `/mcp` (`image`, Base64 here); a text
|
|
88
|
+
// file as `text`; any other file only names `contentUrl` to load it with the caller's token.
|
|
89
|
+
export const ChatAttachmentRead = z.object({
|
|
90
|
+
attachment: MessageAttachment,
|
|
91
|
+
messageId: z.string().nullable(),
|
|
92
|
+
text: z.string().nullable(),
|
|
93
|
+
image: z.object({ data: z.string(), mimeType: z.string() }).nullable(),
|
|
94
|
+
});
|
|
95
|
+
export const MessageCreateInput = z
|
|
96
|
+
.strictObject({
|
|
41
97
|
nodeId: NodeId.describe("The node whose chat to write in: any node you can read except a folder. Reading is enough to write."),
|
|
42
98
|
text: z
|
|
43
99
|
.string()
|
|
44
100
|
.trim()
|
|
45
|
-
.min(1)
|
|
46
101
|
.max(messageMaxLength)
|
|
47
|
-
.describe("The message as Markdown, at most 10,000 characters. It cannot be edited afterwards. To point at a file
|
|
102
|
+
.describe("The message as Markdown, at most 10,000 characters; empty only with attachments. It cannot be edited afterwards. To point at a file of the tree, link its node."),
|
|
48
103
|
mentions: z
|
|
49
104
|
.array(idSchema("user"))
|
|
50
105
|
.max(50)
|
|
51
106
|
.optional()
|
|
52
107
|
.describe("The people and machines this message mentions, `user_…`; they see the chat in their Actions. Only someone who can read the node: find them with intelligence_user_list and readersOnly. One who cannot read it refuses the whole message."),
|
|
53
108
|
topic: TopicName.optional().describe("The topic the message belongs to, at most 60 characters: one of the topics intelligence_message_list names, or a new one, which starts with this message. Leaving it out writes in the general topic (Allgemein). Keep to the topic the conversation is in."),
|
|
109
|
+
attachments: z
|
|
110
|
+
.array(AttachmentId)
|
|
111
|
+
.max(attachmentsMax, "A message carries at most 10 attachments.")
|
|
112
|
+
.optional()
|
|
113
|
+
.describe("Up to 10 attachments uploaded into this chat with intelligence_chat_attachment_create and not sent yet; the message carries them."),
|
|
54
114
|
idempotencyKey: IdempotencyKey,
|
|
115
|
+
})
|
|
116
|
+
.refine((input) => input.text !== "" || (input.attachments?.length ?? 0) > 0, {
|
|
117
|
+
message: "A message needs text or an attachment.",
|
|
118
|
+
path: ["text"],
|
|
55
119
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
120
|
+
// `typing` (#1209, E264): a machine says it writes a message for this chat; the chat shows
|
|
121
|
+
// "‹Name› schreibt …" for 10 seconds, until its message comes or it says so again. Without effect for
|
|
122
|
+
// a person, whose browser says it over its socket.
|
|
123
|
+
export const ChatUpdateInput = z
|
|
124
|
+
.strictObject({
|
|
125
|
+
chatId: NodeId.describe("The chat to mark as read or to write in: the id of its node, `node_…`."),
|
|
126
|
+
readUntil: MessageId.optional().describe("The newest message of this chat you have read. Your read state never moves back: an older one changes nothing. Leave it out to only say you are writing."),
|
|
59
127
|
topic: TopicName.optional().describe("Mark only this topic as read, up to readUntil, which must be one of its messages; an empty text is the general topic. Leaving it out marks the whole chat."),
|
|
128
|
+
typing: z
|
|
129
|
+
.boolean()
|
|
130
|
+
.optional()
|
|
131
|
+
.describe("true: you are writing a message for this chat, and the people who have it open see that you write, for 10 seconds or until your message comes; send it again for longer. Only for a machine; a person's browser says it itself."),
|
|
132
|
+
})
|
|
133
|
+
.refine((input) => input.readUntil !== undefined || input.typing === true, {
|
|
134
|
+
message: "Give readUntil, typing: true, or both.",
|
|
135
|
+
})
|
|
136
|
+
.refine((input) => input.topic === undefined || input.readUntil !== undefined, {
|
|
137
|
+
message: "topic marks a topic as read and needs readUntil.",
|
|
60
138
|
});
|
|
61
139
|
// Who wrote a message. A person writing in the browser has no `appHandle`; their AI writing through a
|
|
62
140
|
// connected app carries that app's name. A machine carries its kind and an Operator its provider.
|
|
@@ -66,6 +144,9 @@ export const MessageAuthor = z.object({
|
|
|
66
144
|
// As `access` names them today; null for an account that is gone.
|
|
67
145
|
name: z.string().nullable(),
|
|
68
146
|
kind: z.enum(["human", "machine"]).nullable(),
|
|
147
|
+
// The picture of person or machine (`/auth/profile-image/…`, E263); null without one. Optional
|
|
148
|
+
// only for the readers' sake: the server always names it.
|
|
149
|
+
image: z.string().nullable().optional(),
|
|
69
150
|
// Only for a machine `access` still knows; null for a person.
|
|
70
151
|
machine: MessageMachine.nullable(),
|
|
71
152
|
appHandle: z.string().nullable(),
|
|
@@ -78,6 +159,9 @@ export const Message = z.object({
|
|
|
78
159
|
topic: z.string().nullable(),
|
|
79
160
|
author: MessageAuthor,
|
|
80
161
|
mentions: z.array(z.object({ userId: z.string(), name: z.string().nullable() })),
|
|
162
|
+
// In the order they were uploaded (#1210). Optional only for the readers' sake: the server always
|
|
163
|
+
// names them.
|
|
164
|
+
attachments: z.array(MessageAttachment).optional(),
|
|
81
165
|
createdAt: z.iso.datetime(),
|
|
82
166
|
});
|
|
83
167
|
// One topic of a chat as the list names it (#994): newest activity first.
|
package/dist/nodes/nodes.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare const NodeSort: z.ZodEnum<{
|
|
|
60
60
|
}>;
|
|
61
61
|
export type NodeSort = z.infer<typeof NodeSort>;
|
|
62
62
|
export declare const NodeQuery: z.ZodString;
|
|
63
|
+
export declare const nodeListLimitMax = 1000;
|
|
63
64
|
export declare const NodeListInput: z.ZodObject<{
|
|
64
65
|
parentId: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
65
66
|
section: z.ZodOptional<z.ZodEnum<{
|
package/dist/nodes/nodes.js
CHANGED
|
@@ -82,6 +82,16 @@ export const NodeQuery = z
|
|
|
82
82
|
.min(2)
|
|
83
83
|
.max(200)
|
|
84
84
|
.describe("Search instead of listing: words to find in titles, the text of documents, tables, files and tasks, at least two characters; each word also finds longer words it begins (preis finds Preisliste). Only what you can read, never archived nodes or chats. parentId narrows it to that folder and everything below it, section to own, shared or users; leaving both out searches own and shared together. The hits come in the order of their rank, grouped by folder; sort, foldersFirst and includeHidden do not apply.");
|
|
85
|
+
// The page size of `intelligence_node_list`, larger than other lists (E260): the tree's order is
|
|
86
|
+
// sorted in code over the whole level, so the UI asks for a level in one page instead of reading it
|
|
87
|
+
// again per page. The default stays that of every list.
|
|
88
|
+
export const nodeListLimitMax = 1000;
|
|
89
|
+
const NodeListLimit = z.coerce
|
|
90
|
+
.number()
|
|
91
|
+
.int()
|
|
92
|
+
.min(1)
|
|
93
|
+
.max(nodeListLimitMax)
|
|
94
|
+
.describe("How many entries one page holds, 1 to 1000. Leaving it out gives 50.");
|
|
85
95
|
export const NodeListInput = z.strictObject({
|
|
86
96
|
parentId: NodeId.optional().describe("List the children of this folder. Give exactly one of parentId, section and nodeIds; with query at most one of parentId and section."),
|
|
87
97
|
section: NodeSection.optional().describe("List a section of the tree instead of a folder: own (what lies in your own root folder), shared (the tops of everything others let you reach) or users (every other person's root folder, only for an admin in admin mode)."),
|
|
@@ -94,7 +104,7 @@ export const NodeListInput = z.strictObject({
|
|
|
94
104
|
.max(1000)
|
|
95
105
|
.optional()
|
|
96
106
|
.describe("The nextCursor of the previous page, unchanged. Leaving it out starts at the top."),
|
|
97
|
-
limit:
|
|
107
|
+
limit: NodeListLimit.optional(),
|
|
98
108
|
archived: Flag.optional().describe("List the archive instead: with section own or shared the archived entries there, each with its path and when it was archived; with parentId the archived nodes in that folder, also inside an archived one. Leaving it out lists what is not archived."),
|
|
99
109
|
// Over REST one comma-separated value (`?nodeIds=node_…,node_…`): a query string carries text.
|
|
100
110
|
nodeIds: z
|