@myagentroam/protocol 0.11.44 → 0.11.46

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/index.js CHANGED
@@ -617,7 +617,7 @@ export const scheduledRunAuthorizeRequestSchema = z
617
617
  workspaceId: boundedIdentifierSchema,
618
618
  ownerUserId: positiveSafeIntegerSchema,
619
619
  runner: runnerNameSchema,
620
- model: z.string().max(256).nullable()
620
+ modelId: z.string().max(256).nullable()
621
621
  })
622
622
  .strict();
623
623
  export const restartRunAuthorizeRequestSchema = scheduledRunAuthorizeRequestSchema
@@ -1645,13 +1645,15 @@ export const runnerProfileSchema = z.object({
1645
1645
  capabilities: z.array(z.string().min(1).max(80)).max(64)
1646
1646
  });
1647
1647
  /** The last explicitly chosen Composer configuration belongs to one Node Runner. */
1648
- export const runnerDefaultConfigurationSchema = z.object({
1648
+ export const runnerDefaultConfigurationSchema = z
1649
+ .object({
1649
1650
  runner: runnerNameSchema,
1650
- model: z.string().trim().min(1).max(128),
1651
+ modelId: z.string().trim().min(1).max(128),
1651
1652
  /** Runners without a reasoning-variant dimension persist an empty effort value. */
1652
1653
  effort: z.string().trim().max(64),
1653
1654
  access: z.string().trim().min(1).max(128)
1654
- });
1655
+ })
1656
+ .strict();
1655
1657
  /** A Runner command is selected from a Node-declared profile, never guessed from `/` text. */
1656
1658
  export const runnerCommandExecutionSchema = z.object({
1657
1659
  commandId: z.string().min(1).max(128),
@@ -1886,6 +1888,19 @@ const reasoningItemSchema = conversationItemBaseSchema.extend({
1886
1888
  })
1887
1889
  });
1888
1890
  export const subagentOperationSchema = z.enum(['START', 'STATUS', 'CANCEL', 'MESSAGE', 'RESUME']);
1891
+ /** Agent operations describe calls, not the lifecycle of their target Sessions. */
1892
+ export const agentOperationPresentationSchema = z.object({
1893
+ action: z.enum(['START', 'SEND', 'WAIT', 'STOP', 'LIST', 'VIEW']),
1894
+ targets: z
1895
+ .array(z.object({
1896
+ agentId: z.string().min(1).max(128),
1897
+ sessionId: z.string().min(1).max(128).optional(),
1898
+ title: z.string().min(1).max(500).optional()
1899
+ }))
1900
+ .max(100),
1901
+ targetsTruncated: z.literal(true).optional(),
1902
+ scope: z.string().min(1).max(32).optional()
1903
+ });
1889
1904
  export const subagentLatestMessageSchema = z.object({
1890
1905
  itemId: z.string().min(1).max(128),
1891
1906
  turnId: z.string().min(1).max(128),
@@ -1947,65 +1962,6 @@ export const executionPresentationSchema = z
1947
1962
  })
1948
1963
  .strict()
1949
1964
  .refine((value) => new TextEncoder().encode(JSON.stringify(value)).length <= 128 * 1024, 'Execution presentation exceeds 128 KiB');
1950
- /** Append output channels of the same call; snapshots and terminal items replace normally. */
1951
- export function appendExecutionPresentation(previous, incoming) {
1952
- const before = executionPresentationSchema.safeParse(previous);
1953
- const update = executionPresentationSchema.safeParse(incoming);
1954
- if (!update.success || !update.data.execution.output)
1955
- return incoming;
1956
- const prior = before.success ? before.data.execution : undefined;
1957
- const next = update.data.execution;
1958
- const channels = new Map((prior?.output ?? []).map((block) => [block.channel, block.text]));
1959
- let clipped = false;
1960
- for (const block of next.output ?? []) {
1961
- const text = (channels.get(block.channel) ?? '') + block.text;
1962
- let tail = text.slice(-10_000);
1963
- if (tail.length < text.length) {
1964
- clipped = true;
1965
- if (/^[\uDC00-\uDFFF]/u.test(tail))
1966
- tail = tail.slice(1);
1967
- }
1968
- channels.set(block.channel, tail);
1969
- }
1970
- const output = [...channels].map(([channel, text]) => ({ channel, text }));
1971
- let head = clipped || prior?.truncation?.output === 'HEAD' || next.truncation?.output === 'HEAD';
1972
- const make = () => ({
1973
- kind: 'EXECUTION',
1974
- execution: {
1975
- ...prior,
1976
- ...next,
1977
- output,
1978
- ...(head || prior?.truncation || next.truncation
1979
- ? {
1980
- truncation: {
1981
- ...prior?.truncation,
1982
- ...next.truncation,
1983
- ...(head ? { output: 'HEAD' } : {})
1984
- }
1985
- }
1986
- : {})
1987
- }
1988
- });
1989
- const size = () => new TextEncoder().encode(JSON.stringify(make())).length;
1990
- for (const block of output) {
1991
- if (size() <= 128 * 1024)
1992
- break;
1993
- head = true;
1994
- const original = block.text;
1995
- let low = 0;
1996
- let high = original.length;
1997
- while (low < high) {
1998
- const middle = Math.floor((low + high) / 2);
1999
- block.text = original.slice(middle).replace(/^[\uDC00-\uDFFF]/u, '');
2000
- if (size() <= 128 * 1024)
2001
- high = middle;
2002
- else
2003
- low = middle + 1;
2004
- }
2005
- block.text = original.slice(low).replace(/^[\uDC00-\uDFFF]/u, '');
2006
- }
2007
- return make();
2008
- }
2009
1965
  const toolCallPresentationSchema = z.discriminatedUnion('kind', [
2010
1966
  z.object({
2011
1967
  kind: z.literal('READ'),
@@ -2051,9 +2007,85 @@ export const toolPresentationSchema = z.union([
2051
2007
  toolCallPresentationSchema,
2052
2008
  executionPresentationSchema
2053
2009
  ]);
2010
+ export const toolOutputSchema = z
2011
+ .object({
2012
+ blocks: executionOutputSchema,
2013
+ truncation: z.enum(['HEAD', 'SOURCE']).optional()
2014
+ })
2015
+ .strict()
2016
+ .refine((value) => new TextEncoder().encode(JSON.stringify(value)).length <= 128 * 1024, 'Tool output exceeds 128 KiB');
2017
+ /** Bound public channel tails before serialization, retaining SOURCE when its direction is unknown. */
2018
+ export function boundToolOutput(blocks, truncation) {
2019
+ let clipped = false;
2020
+ const bounded = [];
2021
+ for (const { channel, text } of blocks) {
2022
+ const existing = bounded.find((block) => block.channel === channel);
2023
+ const tail = text.slice(-10_000);
2024
+ const joined = (existing?.text ?? '') + tail;
2025
+ const value = joined.slice(-10_000).replace(/^[\uDC00-\uDFFF]/u, '');
2026
+ clipped ||= tail.length < text.length || value.length < joined.length;
2027
+ if (existing)
2028
+ existing.text = value;
2029
+ else
2030
+ bounded.push({ channel, text: value });
2031
+ }
2032
+ const make = () => ({
2033
+ blocks: bounded,
2034
+ ...(truncation === 'SOURCE'
2035
+ ? { truncation: 'SOURCE' }
2036
+ : clipped || truncation === 'HEAD'
2037
+ ? { truncation: 'HEAD' }
2038
+ : {})
2039
+ });
2040
+ const size = () => new TextEncoder().encode(JSON.stringify(make())).length;
2041
+ for (const block of bounded) {
2042
+ if (size() <= 128 * 1024)
2043
+ break;
2044
+ clipped = true;
2045
+ const original = block.text;
2046
+ let low = 0;
2047
+ let high = original.length;
2048
+ while (low < high) {
2049
+ const middle = Math.floor((low + high) / 2);
2050
+ block.text = original.slice(middle).replace(/^[\uDC00-\uDFFF]/u, '');
2051
+ if (size() <= 128 * 1024)
2052
+ high = middle;
2053
+ else
2054
+ low = middle + 1;
2055
+ }
2056
+ block.text = original.slice(low).replace(/^[\uDC00-\uDFFF]/u, '');
2057
+ }
2058
+ return toolOutputSchema.parse(make());
2059
+ }
2060
+ /** Append only true deltas; incompatible channel representations require a real snapshot. */
2061
+ export function appendToolOutput(previous, incoming) {
2062
+ const channels = new Map((previous?.blocks ?? []).map(({ channel, text }) => [channel, text]));
2063
+ for (const block of incoming.blocks)
2064
+ channels.set(block.channel, (channels.get(block.channel) ?? '') + block.text);
2065
+ const source = previous?.truncation === 'SOURCE' || incoming.truncation === 'SOURCE';
2066
+ return boundToolOutput([...channels].map(([channel, text]) => ({ channel, text })), source ? 'SOURCE' : (previous?.truncation ?? incoming.truncation));
2067
+ }
2068
+ /** An output delta must not erase independent input clipping facts. */
2069
+ export function retainExecutionInputTruncation(previous, incoming) {
2070
+ const before = executionPresentationSchema.safeParse(previous);
2071
+ const after = executionPresentationSchema.safeParse(incoming);
2072
+ if (!before.success ||
2073
+ !after.success ||
2074
+ before.data.execution.truncation?.input !== true ||
2075
+ after.data.execution.truncation?.input !== undefined)
2076
+ return incoming;
2077
+ return {
2078
+ ...after.data,
2079
+ execution: {
2080
+ ...after.data.execution,
2081
+ truncation: { ...after.data.execution.truncation, input: true }
2082
+ }
2083
+ };
2084
+ }
2054
2085
  const toolOutputSnapshotSchema = z
2055
2086
  .object({ text: z.string().max(10000), truncated: z.boolean() })
2056
2087
  .strict();
2088
+ const readableToolOutputSchema = z.union([toolOutputSchema, toolOutputSnapshotSchema]);
2057
2089
  const toolCallItemSchema = conversationItemBaseSchema.extend({
2058
2090
  kind: z.literal('tool_call'),
2059
2091
  payload: z.object({
@@ -2064,10 +2096,14 @@ const toolCallItemSchema = conversationItemBaseSchema.extend({
2064
2096
  outputSummary: z.string().max(10000).nullable(),
2065
2097
  progressLabel: z.string().max(500).nullable(),
2066
2098
  errorCode: z.string().max(80).nullable(),
2067
- truncated: z.boolean(),
2068
- output: toolOutputSnapshotSchema.optional(),
2099
+ errorMessage: z.string().max(1000).optional(),
2100
+ truncated: z.boolean().optional(),
2101
+ inputTruncated: z.literal(true).optional(),
2102
+ outputSummaryTruncated: z.literal(true).optional(),
2103
+ output: readableToolOutputSchema.optional(),
2069
2104
  toolCategory: z.enum(['IMAGE_GENERATION']).optional(),
2070
2105
  toolPresentation: toolCallPresentationSchema.optional(),
2106
+ agentOperation: agentOperationPresentationSchema.optional(),
2071
2107
  subagentOperation: subagentOperationSchema.optional(),
2072
2108
  subagentWait: z.boolean().optional(),
2073
2109
  subagentId: z.string().min(1).max(128).nullable().optional(),
@@ -2086,11 +2122,13 @@ const commandExecutionItemSchema = conversationItemBaseSchema.extend({
2086
2122
  title: z.string().min(1).max(128).optional(),
2087
2123
  command: z.string().max(10000),
2088
2124
  cwd: z.string().max(4096).nullable(),
2089
- outputPreview: z.string().max(10000),
2125
+ outputPreview: z.string().max(10000).optional(),
2126
+ outputSummary: z.string().max(10000).nullable().optional(),
2127
+ outputSummaryTruncated: z.literal(true).optional(),
2090
2128
  exitCode: z.number().int().nullable(),
2091
2129
  durationMs: z.number().int().nonnegative().nullable(),
2092
- truncated: z.boolean(),
2093
- output: toolOutputSnapshotSchema.optional(),
2130
+ truncated: z.boolean().optional(),
2131
+ output: readableToolOutputSchema.optional(),
2094
2132
  toolPresentation: executionPresentationSchema.optional()
2095
2133
  })
2096
2134
  });
@@ -3261,6 +3299,7 @@ export const workbenchNodeOperationSchema = z.enum([
3261
3299
  'workspace.changes.current',
3262
3300
  'workspace.change.diff',
3263
3301
  'workspace.change.restore',
3302
+ 'workspace.git.fetch',
3264
3303
  'workspace.git.refs.list',
3265
3304
  'workspace.git.history.list',
3266
3305
  'workspace.git.commit.files',
@@ -271,5 +271,46 @@ export declare const notificationCreatedSchema: z.ZodObject<{
271
271
  };
272
272
  };
273
273
  }>;
274
+ export declare const NOTIFICATION_TARGET_READ_ID_LIMIT = 250;
275
+ export declare const notificationTargetReadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
276
+ type: z.ZodLiteral<"notification.session-read">;
277
+ nodeId: z.ZodString;
278
+ workspaceId: z.ZodString;
279
+ sessionId: z.ZodString;
280
+ notificationIds: z.ZodArray<z.ZodString, "many">;
281
+ readAt: z.ZodNumber;
282
+ }, "strict", z.ZodTypeAny, {
283
+ type: "notification.session-read";
284
+ sessionId: string;
285
+ workspaceId: string;
286
+ nodeId: string;
287
+ notificationIds: string[];
288
+ readAt: number;
289
+ }, {
290
+ type: "notification.session-read";
291
+ sessionId: string;
292
+ workspaceId: string;
293
+ nodeId: string;
294
+ notificationIds: string[];
295
+ readAt: number;
296
+ }>, z.ZodObject<{
297
+ type: z.ZodLiteral<"notification.conversation-read">;
298
+ nodeId: z.ZodString;
299
+ conversationId: z.ZodString;
300
+ notificationIds: z.ZodArray<z.ZodString, "many">;
301
+ readAt: z.ZodNumber;
302
+ }, "strict", z.ZodTypeAny, {
303
+ type: "notification.conversation-read";
304
+ nodeId: string;
305
+ conversationId: string;
306
+ notificationIds: string[];
307
+ readAt: number;
308
+ }, {
309
+ type: "notification.conversation-read";
310
+ nodeId: string;
311
+ conversationId: string;
312
+ notificationIds: string[];
313
+ readAt: number;
314
+ }>]>;
274
315
  export type NotificationTarget = Readonly<z.infer<typeof notificationTargetSchema>>;
275
316
  export type ServerNotification = Readonly<z.infer<typeof serverNotificationSchema>>;
@@ -41,3 +41,25 @@ export const notificationCreatedSchema = z
41
41
  notification: serverNotificationSchema
42
42
  })
43
43
  .strict();
44
+ export const NOTIFICATION_TARGET_READ_ID_LIMIT = 250;
45
+ export const notificationTargetReadSchema = z.discriminatedUnion('type', [
46
+ z
47
+ .object({
48
+ type: z.literal('notification.session-read'),
49
+ nodeId: identity,
50
+ workspaceId: identity,
51
+ sessionId: identity,
52
+ notificationIds: z.array(identity).max(NOTIFICATION_TARGET_READ_ID_LIMIT),
53
+ readAt: timestamp
54
+ })
55
+ .strict(),
56
+ z
57
+ .object({
58
+ type: z.literal('notification.conversation-read'),
59
+ nodeId: identity,
60
+ conversationId: identity,
61
+ notificationIds: z.array(identity).max(NOTIFICATION_TARGET_READ_ID_LIMIT),
62
+ readAt: timestamp
63
+ })
64
+ .strict()
65
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/protocol",
3
- "version": "0.11.44",
3
+ "version": "0.11.46",
4
4
  "description": "Shared runtime protocol schemas for MyAgentRoam.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",