@axiom-lattice/protocols 4.1.3 → 4.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/protocols",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "description": "Unified protocol type definitions for Axiom Lattice framework",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  AgentWebAppAppearance,
3
3
  AgentWebAppFeatures,
4
+ AgentWebAppIdentityAssurance,
4
5
  } from "./AgentWebAppStoreProtocol";
5
6
 
6
7
  /** Server-owned metadata that isolates an external user's Web App thread. */
@@ -63,7 +64,7 @@ export interface AgentWebAppBootstrap {
63
64
  defaultModelKey?: string;
64
65
  features: AgentWebAppFeatures;
65
66
  appearance: AgentWebAppAppearance;
66
- identityAssurance: "unverified";
67
+ identityAssurance: AgentWebAppIdentityAssurance;
67
68
  };
68
69
  projects: Array<{
69
70
  id: string;
@@ -17,6 +17,8 @@ export interface AgentWebAppFeatures {
17
17
  attachments: boolean;
18
18
  hitl: boolean;
19
19
  genUI: boolean;
20
+ /** File panel surface. Tolerated missing (treated as false) for records created before Phase 2. */
21
+ files?: boolean;
20
22
  }
21
23
 
22
24
  /** Optional display customization for an Agent Web App. */
@@ -26,6 +28,31 @@ export interface AgentWebAppAppearance {
26
28
  primaryColor?: string;
27
29
  }
28
30
 
31
+ /** Identity assurance levels reported by the runtime. */
32
+ export type AgentWebAppIdentityAssurance = "unverified" | "verified";
33
+
34
+ /** How external callers may identify themselves for this web app. */
35
+ export type AgentWebAppIdentityPolicy = "unverified" | "verified" | "both";
36
+
37
+ /** One trusted issuer entry. `secret` pairs with HS256, `jwksUrl` with RS256. */
38
+ export interface AgentWebAppIssuerConfig {
39
+ /** Exact `iss` claim match. */
40
+ iss: string;
41
+ /** Exact `aud` claim match; conventionally the webAppId. */
42
+ aud: string;
43
+ alg: "HS256" | "RS256";
44
+ /** Shared secret for HS256. */
45
+ secret?: string;
46
+ /** JWKS endpoint URL for RS256. */
47
+ jwksUrl?: string;
48
+ }
49
+
50
+ /** Identity configuration block for a web app. Absent = V1 unverified behavior. */
51
+ export interface AgentWebAppIdentityConfig {
52
+ policy: AgentWebAppIdentityPolicy;
53
+ issuers: AgentWebAppIssuerConfig[];
54
+ }
55
+
29
56
  /** Persisted React SDK publication of an assistant. */
30
57
  export interface AgentWebApp {
31
58
  id: string;
@@ -40,6 +67,7 @@ export interface AgentWebApp {
40
67
  scope: AgentWebAppScope;
41
68
  features: AgentWebAppFeatures;
42
69
  appearance: AgentWebAppAppearance;
70
+ identity?: AgentWebAppIdentityConfig;
43
71
  createdAt: Date;
44
72
  updatedAt: Date;
45
73
  }
@@ -55,6 +83,7 @@ export interface CreateAgentWebAppInput {
55
83
  scope: AgentWebAppScope;
56
84
  features: AgentWebAppFeatures;
57
85
  appearance: AgentWebAppAppearance;
86
+ identity?: AgentWebAppIdentityConfig;
58
87
  }
59
88
 
60
89
  /** Editable fields accepted when updating an Agent Web App. Nested objects use merge semantics. */
@@ -64,6 +93,7 @@ export interface UpdateAgentWebAppInput {
64
93
  scope?: Partial<AgentWebAppScope>;
65
94
  features?: Partial<AgentWebAppFeatures>;
66
95
  appearance?: Partial<AgentWebAppAppearance>;
96
+ identity?: AgentWebAppIdentityConfig;
67
97
  }
68
98
 
69
99
  /** Internal persistence patch. Nested objects are complete replacements when provided. */
@@ -73,6 +103,7 @@ export interface AgentWebAppStorePatch {
73
103
  scope?: AgentWebAppScope;
74
104
  features?: AgentWebAppFeatures;
75
105
  appearance?: AgentWebAppAppearance;
106
+ identity?: AgentWebAppIdentityConfig;
76
107
  status?: AgentWebAppStatus;
77
108
  }
78
109
 
@@ -0,0 +1,104 @@
1
+ import { MessageChunkTypes, type MessageChunk } from "./MessageProtocol";
2
+ import {
3
+ parseAgentWebAppGenUIBlock,
4
+ type AgentWebAppInterrupt,
5
+ type AgentWebAppStreamEvent,
6
+ } from "./AgentWebAppRuntimeProtocol";
7
+
8
+ /** Per-consumer projection metadata; it does not control Agent execution. */
9
+ export interface AgentWebAppStreamProjectionContext {
10
+ readonly startedToolIds: Set<string>;
11
+ readonly allowInterrupts: boolean;
12
+ readonly allowGenUI: boolean;
13
+ }
14
+
15
+ /** Create projection metadata shared by all chunks in one public stream. */
16
+ export function createAgentWebAppStreamProjectionContext(options: { allowInterrupts?: boolean; allowGenUI?: boolean } = {}): AgentWebAppStreamProjectionContext {
17
+ return { startedToolIds: new Set<string>(), allowInterrupts: options.allowInterrupts ?? true, allowGenUI: options.allowGenUI ?? false };
18
+ }
19
+
20
+ /** Purely project one internal Agent chunk onto zero or more stable public events. */
21
+ export function projectAgentWebAppChunk(
22
+ chunk: MessageChunk,
23
+ context?: AgentWebAppStreamProjectionContext,
24
+ ): AgentWebAppStreamEvent[] {
25
+ if (chunk.type === MessageChunkTypes.AI) {
26
+ const events: AgentWebAppStreamEvent[] = [];
27
+ const startedToolIds = context?.startedToolIds ?? new Set<string>();
28
+ if (typeof chunk.data.content === "string" && chunk.data.content) events.push({ type: "message.delta", text: chunk.data.content });
29
+ if (context?.allowGenUI && Array.isArray(chunk.data.content)) {
30
+ for (const value of chunk.data.content) {
31
+ const block = parseAgentWebAppGenUIBlock(value);
32
+ if (block) events.push({ type: "genui.render", block });
33
+ }
34
+ }
35
+ for (const call of chunk.data.tool_call_chunks ?? []) {
36
+ if (call.id && call.name && !startedToolIds.has(call.id)) {
37
+ startedToolIds.add(call.id);
38
+ events.push({ type: "tool.started", id: call.id, name: call.name });
39
+ }
40
+ }
41
+ for (const call of chunk.data.tool_calls ?? []) {
42
+ if (!startedToolIds.has(call.id)) {
43
+ startedToolIds.add(call.id);
44
+ events.push({ type: "tool.started", id: call.id, name: call.name });
45
+ }
46
+ }
47
+ return events;
48
+ }
49
+ if (chunk.type === MessageChunkTypes.TOOL && chunk.data.tool_call_id) {
50
+ return [{ type: "tool.completed", id: chunk.data.tool_call_id }];
51
+ }
52
+ if (chunk.type === MessageChunkTypes.INTERRUPT) {
53
+ if (context && !context.allowInterrupts) return [{ type: "stream.completed" }];
54
+ const interrupt = publicInterrupt(chunk);
55
+ return interrupt
56
+ ? [{ type: "interrupt.created", interrupt }, { type: "stream.completed" }]
57
+ : [{ type: "stream.completed" }];
58
+ }
59
+ if (chunk.type === MessageChunkTypes.MESSAGE_COMPLETED) {
60
+ return [
61
+ { type: "message.completed", messageId: chunk.data.id },
62
+ { type: "stream.completed" },
63
+ ];
64
+ }
65
+ if (chunk.type === MessageChunkTypes.MESSAGE_FAILED) {
66
+ return [
67
+ { type: "error", error: { code: "STREAM_FAILED", message: "Stream failed", retryable: true } },
68
+ { type: "stream.completed" },
69
+ ];
70
+ }
71
+ return [];
72
+ }
73
+
74
+ function publicInterrupt(chunk: MessageChunk): AgentWebAppInterrupt | undefined {
75
+ const value = parseInterruptContent(chunk.data.content);
76
+ if (!value) return undefined;
77
+ const topLevelId = (chunk as unknown as { id?: unknown }).id;
78
+ const id = typeof topLevelId === "string" ? topLevelId : chunk.data.id;
79
+ if (!id) return undefined;
80
+ return {
81
+ id,
82
+ type: typeof value.type === "string" ? value.type : "input",
83
+ prompt: typeof value.prompt === "string"
84
+ ? value.prompt
85
+ : typeof value.message === "string" ? value.message : "Input required",
86
+ ...(isRecord(value.data) ? { data: value.data } : {}),
87
+ };
88
+ }
89
+
90
+ function parseInterruptContent(content: unknown): Record<string, unknown> | undefined {
91
+ if (!content) return {};
92
+ if (isRecord(content)) return content;
93
+ if (typeof content !== "string") return undefined;
94
+ try {
95
+ const parsed: unknown = JSON.parse(content);
96
+ return isRecord(parsed) ? parsed : { prompt: content };
97
+ } catch {
98
+ return { prompt: content };
99
+ }
100
+ }
101
+
102
+ function isRecord(value: unknown): value is Record<string, unknown> {
103
+ return typeof value === "object" && value !== null && !Array.isArray(value);
104
+ }
package/src/index.ts CHANGED
@@ -48,6 +48,7 @@ export * from "./A2AApiKeyStoreProtocol";
48
48
  export * from "./ConversationStoreProtocol";
49
49
  export * from "./AgentWebAppStoreProtocol";
50
50
  export * from "./AgentWebAppRuntimeProtocol";
51
+ export * from "./AgentWebAppStreamProjection";
51
52
  export * from "./CapabilityBundleStoreProtocol";
52
53
  export * from "./CapabilityRuntimeProtocol";
53
54
  export * from "./ProjectRoomProtocol";