@tangle-network/agent-interface 5.10.1 → 5.10.3

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 CHANGED
@@ -5,6 +5,12 @@ agents, the sidecar, and provider adapters: capabilities, agent profiles,
5
5
  message parts, and harness descriptors. This is the canonical home for those
6
6
  shapes; higher-level packages import from here rather than redefining them.
7
7
 
8
+ `partitionBySpeaker` and its `Speaker`, `SpeakerPart`, `SpeakerState` and
9
+ `SpeakerSection` types are available from the root and the server-safe `/speaker`
10
+ entry. Stored parts follow their preceding speaker; explicit live `speaker` tags
11
+ win over position. Repeated headers update the same section, unowned parts come
12
+ first, and input objects retain their identity. UI chat re-exports this contract.
13
+
8
14
  ## Authored subscription seats
9
15
 
10
16
  `AgentProfile.seats` is an optional ordered chain for continuing one logical agent
@@ -18,9 +18,14 @@ export declare function isBoundedJsonValue(value: unknown): boolean;
18
18
  export declare function isBoundedEventContentJson(value: unknown, { omitUndefinedObjectFields }?: {
19
19
  omitUndefinedObjectFields?: boolean;
20
20
  }): boolean;
21
- /** Digest material omits undefined object fields; portable profile values require data properties. */
22
- export declare function isBoundedJsonMaterial(value: unknown, { dataPropertiesOnly }?: {
21
+ /**
22
+ * Digest material omits undefined object fields; portable profile values require data properties.
23
+ * `content` bounds strings by the serialized UTF-8 budget instead of each string's length, for
24
+ * opaque values that may legitimately copy unbounded typed fields such as inline file content.
25
+ */
26
+ export declare function isBoundedJsonMaterial(value: unknown, { dataPropertiesOnly, content }?: {
23
27
  dataPropertiesOnly?: boolean;
28
+ content?: boolean;
24
29
  }): boolean;
25
30
  export declare const boundedJsonSchema: z.ZodCustom<unknown, unknown>;
26
31
  export declare const boundedJsonRecordSchema: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
@@ -63,9 +63,13 @@ function serializedJsonStringBytes(value) {
63
63
  export function isBoundedEventContentJson(value, { omitUndefinedObjectFields = false } = {}) {
64
64
  return boundedJson(value, { content: true, omitUndefinedObjectFields });
65
65
  }
66
- /** Digest material omits undefined object fields; portable profile values require data properties. */
67
- export function isBoundedJsonMaterial(value, { dataPropertiesOnly = false } = {}) {
68
- return boundedJson(value, { material: true, omitUndefinedObjectFields: true, dataPropertiesOnly });
66
+ /**
67
+ * Digest material omits undefined object fields; portable profile values require data properties.
68
+ * `content` bounds strings by the serialized UTF-8 budget instead of each string's length, for
69
+ * opaque values that may legitimately copy unbounded typed fields such as inline file content.
70
+ */
71
+ export function isBoundedJsonMaterial(value, { dataPropertiesOnly = false, content = false } = {}) {
72
+ return boundedJson(value, { material: true, omitUndefinedObjectFields: true, dataPropertiesOnly, content });
69
73
  }
70
74
  /** One iterative walker owns structural admission; typed domains keep their own schema limits. */
71
75
  function boundedJson(value, options = {}) {
package/dist/index.d.ts CHANGED
@@ -47,3 +47,4 @@ export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
47
47
  export * from "./native-session-event.js";
48
48
  export * from "./learning-state.js";
49
49
  export * from "./proxy-secrets.js";
50
+ export * from "./speaker.js";
package/dist/index.js CHANGED
@@ -49,3 +49,4 @@ export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
49
49
  export * from "./native-session-event.js";
50
50
  export * from "./learning-state.js";
51
51
  export * from "./proxy-secrets.js";
52
+ export * from "./speaker.js";
@@ -12,7 +12,7 @@ import { AgentProfileValueError, assertAgentProfileValue, canonicalAgentProfileJ
12
12
  import { harnessHonorsEffort, harnessHonorsModel, harnessModelSupport, harnessReasoningEfforts, harnessSystemPromptIntents, resolveModelProvider, } from "./harness-capabilities.js";
13
13
  import { SANDBOX_SIZE_PRESET_NAMES, } from "./sandbox-size.js";
14
14
  const profileOpaqueValueSchema = z.unknown().transform((value, context) => {
15
- if (value === undefined || isBoundedJsonMaterial(value, { dataPropertiesOnly: true }))
15
+ if (value === undefined || isBoundedJsonMaterial(value, { dataPropertiesOnly: true, content: true }))
16
16
  return structuredClone(value);
17
17
  try {
18
18
  assertAgentProfileValue(value, []);
@@ -376,7 +376,7 @@ export const agentProfileMetadataSchema = ownPropertyRecordSchema(z.unknown(), {
376
376
  prepareValue: (key, value) => {
377
377
  if (key === "training")
378
378
  return value;
379
- if (value === undefined || isBoundedJsonMaterial(value, { dataPropertiesOnly: true }))
379
+ if (value === undefined || isBoundedJsonMaterial(value, { dataPropertiesOnly: true, content: true }))
380
380
  return structuredClone(value);
381
381
  assertAgentProfileValue(value, [key]);
382
382
  return z.NEVER;
@@ -0,0 +1,41 @@
1
+ /** Where one responder is in its answer. */
2
+ export type SpeakerState = "answering" | "done" | "failed";
3
+ /**
4
+ * A responder of a turn addressed to several agents. In the turn's parts it is
5
+ * a `{ type: "speaker", id, name, handle?, state? }` part written before the
6
+ * responder's answer.
7
+ */
8
+ export interface Speaker {
9
+ /** The agent's stable id. It keys the avatar's tone and a live part's `speaker` tag. */
10
+ id: string;
11
+ name: string;
12
+ /** What a person types after `@` to address the agent. */
13
+ handle?: string;
14
+ /** Set once the responder ended; absent while it answers and on rows written before responders reported an end. */
15
+ state?: SpeakerState;
16
+ }
17
+ export type SpeakerPart = Speaker & {
18
+ type: "speaker";
19
+ };
20
+ /** One responder's share of a turn: its speaker part and the parts it wrote. */
21
+ export interface SpeakerSection<T> {
22
+ /** The latest speaker part for this responder; null for the parts no speaker owns. */
23
+ speaker: (T & SpeakerPart) | null;
24
+ parts: T[];
25
+ }
26
+ /**
27
+ * Splits one assistant turn's parts by the agent that wrote them.
28
+ *
29
+ * A stored row holds a speaker part before each responder's answer, so a part
30
+ * belongs to the speaker part before it. A live stream announces every
31
+ * responder first and then interleaves their output, so a part names its owner
32
+ * in `speaker` (the responder's id), which wins over position. A later speaker
33
+ * part with an id already seen replaces that responder's speaker part, which is
34
+ * how its end state arrives, and never opens a second section.
35
+ *
36
+ * Sections keep the order speakers were first announced. Parts no speaker owns
37
+ * come first, in a section whose `speaker` is null; a turn without speaker
38
+ * parts is that one section. No part is dropped, copied or reordered within its
39
+ * section.
40
+ */
41
+ export declare function partitionBySpeaker<T extends object>(parts: readonly T[]): SpeakerSection<T>[];
@@ -0,0 +1,39 @@
1
+ function isSpeakerPart(part) {
2
+ const record = part;
3
+ return !!record && record.type === "speaker" && typeof record.id === "string" && typeof record.name === "string";
4
+ }
5
+ /**
6
+ * Splits one assistant turn's parts by the agent that wrote them.
7
+ *
8
+ * A stored row holds a speaker part before each responder's answer, so a part
9
+ * belongs to the speaker part before it. A live stream announces every
10
+ * responder first and then interleaves their output, so a part names its owner
11
+ * in `speaker` (the responder's id), which wins over position. A later speaker
12
+ * part with an id already seen replaces that responder's speaker part, which is
13
+ * how its end state arrives, and never opens a second section.
14
+ *
15
+ * Sections keep the order speakers were first announced. Parts no speaker owns
16
+ * come first, in a section whose `speaker` is null; a turn without speaker
17
+ * parts is that one section. No part is dropped, copied or reordered within its
18
+ * section.
19
+ */
20
+ export function partitionBySpeaker(parts) {
21
+ const sections = new Map();
22
+ const unowned = [];
23
+ let current;
24
+ for (const part of parts) {
25
+ if (isSpeakerPart(part)) {
26
+ current = sections.get(part.id);
27
+ if (current)
28
+ current.speaker = part;
29
+ else
30
+ sections.set(part.id, (current = { speaker: part, parts: [] }));
31
+ continue;
32
+ }
33
+ const tag = part.speaker;
34
+ const owner = typeof tag === "string" ? sections.get(tag) : current;
35
+ (owner?.parts ?? unowned).push(part);
36
+ }
37
+ const owned = [...sections.values()];
38
+ return unowned.length > 0 || owned.length === 0 ? [{ speaker: null, parts: unowned }, ...owned] : owned;
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "5.10.1",
3
+ "version": "5.10.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -66,6 +66,11 @@
66
66
  "import": "./dist/learning-state.js",
67
67
  "types": "./dist/learning-state.d.ts",
68
68
  "default": "./dist/learning-state.js"
69
+ },
70
+ "./speaker": {
71
+ "import": "./dist/speaker.js",
72
+ "types": "./dist/speaker.d.ts",
73
+ "default": "./dist/speaker.js"
69
74
  }
70
75
  },
71
76
  "repository": {