@adecore/agent-contracts 0.21.1 → 0.21.2
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/chat.js +7 -4
- package/dist/text.js +1 -1
- package/package.json +2 -2
- package/src/chat.ts +8 -4
- package/src/text.ts +1 -1
package/dist/chat.js
CHANGED
|
@@ -29,12 +29,14 @@ export const CHAT_ATTACHMENTS_MAX_BYTES = 10 * 1024 * 1024;
|
|
|
29
29
|
export const CHAT_ATTACHMENT_MAX_BYTES = CHAT_ATTACHMENTS_MAX_BYTES;
|
|
30
30
|
export const CHAT_ATTACHMENTS_MAX_COUNT = 8;
|
|
31
31
|
const MAX_BASE64_LENGTH = Math.ceil(CHAT_ATTACHMENT_MAX_BYTES / 3) * 4;
|
|
32
|
+
function paddingOf(data) {
|
|
33
|
+
return data.endsWith('==') ? 2 : data.endsWith('=') ? 1 : 0;
|
|
34
|
+
}
|
|
32
35
|
export function attachmentBytes(data) {
|
|
33
|
-
return Math.floor((data.length * 3) / 4) - (data
|
|
36
|
+
return Math.floor((data.length * 3) / 4) - paddingOf(data);
|
|
34
37
|
}
|
|
35
38
|
function isBase64(data) {
|
|
36
|
-
|
|
37
|
-
return data.length % 4 === 0 && !/[^A-Za-z0-9+/]/.test(data.slice(0, data.length - padding));
|
|
39
|
+
return data.length % 4 === 0 && !/[^A-Za-z0-9+/]/.test(data.slice(0, data.length - paddingOf(data)));
|
|
38
40
|
}
|
|
39
41
|
const IMAGE_MIME_BY_EXTENSION = new Map([
|
|
40
42
|
['png', 'image/png'],
|
|
@@ -408,6 +410,7 @@ export const ChatSubagentItemSchema = z.object({
|
|
|
408
410
|
// Where the CLI keeps this subagent's own conversation; set once the daemon found it.
|
|
409
411
|
native: z.object({ agentId: z.string().optional(), threadId: z.string().optional() }).optional(),
|
|
410
412
|
// Who opened it: the CLI with its own tool, or a verb with `--task` that made a node; absent is `native`.
|
|
413
|
+
// The second value keeps its legacy spelling, since stored threads carry it.
|
|
411
414
|
origin: z.enum(['native', 'ruimte']).optional(),
|
|
412
415
|
// The node a `--task` opened, whose own conversation this row stands for.
|
|
413
416
|
childId: z.string().optional(),
|
|
@@ -514,7 +517,7 @@ export const ChatCompactionItemSchema = z.object({
|
|
|
514
517
|
});
|
|
515
518
|
/*
|
|
516
519
|
* Never a new member here, and never a new value in an enum a chat or a push already carries: the
|
|
517
|
-
*
|
|
520
|
+
* native client validates `chat.attach` and `chat.history` whole, so one item it does not know rejects
|
|
518
521
|
* the entire conversation. Add optional fields instead.
|
|
519
522
|
*/
|
|
520
523
|
export const ChatItemSchema = z.discriminatedUnion('kind', [
|
package/dist/text.js
CHANGED
|
@@ -2,7 +2,7 @@ const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
|
2
2
|
/*
|
|
3
3
|
* The longest start of `text` that fits in `max` UTF-16 units, the measure a schema's `max` counts in,
|
|
4
4
|
* cut only between characters as a person sees them. A cut between the halves of a surrogate pair
|
|
5
|
-
* leaves a lone half, which JSON writes as an escape
|
|
5
|
+
* leaves a lone half, which JSON writes as an escape a native client refuses along with its whole frame.
|
|
6
6
|
*/
|
|
7
7
|
export function clipText(text, max) {
|
|
8
8
|
if (text.length <= max) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agent-contracts",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"description": "Schemas and port contracts for agent chats, provider accounts, models and usage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"test": "bun --conditions=source test"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@adecore/intelligent-ui": "0.21.
|
|
84
|
+
"@adecore/intelligent-ui": "0.21.2",
|
|
85
85
|
"zod": "^4.6.5"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
package/src/chat.ts
CHANGED
|
@@ -37,13 +37,16 @@ export const CHAT_ATTACHMENT_MAX_BYTES = CHAT_ATTACHMENTS_MAX_BYTES;
|
|
|
37
37
|
export const CHAT_ATTACHMENTS_MAX_COUNT = 8;
|
|
38
38
|
const MAX_BASE64_LENGTH = Math.ceil(CHAT_ATTACHMENT_MAX_BYTES / 3) * 4;
|
|
39
39
|
|
|
40
|
+
function paddingOf(data: string): number {
|
|
41
|
+
return data.endsWith('==') ? 2 : data.endsWith('=') ? 1 : 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
export function attachmentBytes(data: string): number {
|
|
41
|
-
return Math.floor((data.length * 3) / 4) - (data
|
|
45
|
+
return Math.floor((data.length * 3) / 4) - paddingOf(data);
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
function isBase64(data: string): boolean {
|
|
45
|
-
|
|
46
|
-
return data.length % 4 === 0 && !/[^A-Za-z0-9+/]/.test(data.slice(0, data.length - padding));
|
|
49
|
+
return data.length % 4 === 0 && !/[^A-Za-z0-9+/]/.test(data.slice(0, data.length - paddingOf(data)));
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
const IMAGE_MIME_BY_EXTENSION = new Map([
|
|
@@ -487,6 +490,7 @@ export const ChatSubagentItemSchema = z.object({
|
|
|
487
490
|
// Where the CLI keeps this subagent's own conversation; set once the daemon found it.
|
|
488
491
|
native: z.object({ agentId: z.string().optional(), threadId: z.string().optional() }).optional(),
|
|
489
492
|
// Who opened it: the CLI with its own tool, or a verb with `--task` that made a node; absent is `native`.
|
|
493
|
+
// The second value keeps its legacy spelling, since stored threads carry it.
|
|
490
494
|
origin: z.enum(['native', 'ruimte']).optional(),
|
|
491
495
|
// The node a `--task` opened, whose own conversation this row stands for.
|
|
492
496
|
childId: z.string().optional(),
|
|
@@ -613,7 +617,7 @@ export const ChatCompactionItemSchema = z.object({
|
|
|
613
617
|
|
|
614
618
|
/*
|
|
615
619
|
* Never a new member here, and never a new value in an enum a chat or a push already carries: the
|
|
616
|
-
*
|
|
620
|
+
* native client validates `chat.attach` and `chat.history` whole, so one item it does not know rejects
|
|
617
621
|
* the entire conversation. Add optional fields instead.
|
|
618
622
|
*/
|
|
619
623
|
export const ChatItemSchema = z.discriminatedUnion('kind', [
|
package/src/text.ts
CHANGED
|
@@ -3,7 +3,7 @@ const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
|
3
3
|
/*
|
|
4
4
|
* The longest start of `text` that fits in `max` UTF-16 units, the measure a schema's `max` counts in,
|
|
5
5
|
* cut only between characters as a person sees them. A cut between the halves of a surrogate pair
|
|
6
|
-
* leaves a lone half, which JSON writes as an escape
|
|
6
|
+
* leaves a lone half, which JSON writes as an escape a native client refuses along with its whole frame.
|
|
7
7
|
*/
|
|
8
8
|
export function clipText(text: string, max: number): string {
|
|
9
9
|
if (text.length <= max) {
|