@axiom-lattice/protocols 4.3.1 → 4.4.0

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.
@@ -82,7 +82,7 @@ describe("parseTrustedRunContext", () => {
82
82
  expect(calls).toBe(0);
83
83
  });
84
84
 
85
- it.each(["tenantId", "responsibility"])(
85
+ it.each(["tenantId", "responsibility", "source"])(
86
86
  "rejects a nested %s getter without invoking it",
87
87
  (field) => {
88
88
  let calls = 0;
@@ -146,7 +146,79 @@ describe("parseTrustedRunContext", () => {
146
146
  .toThrow("Invalid trusted agent run context");
147
147
  });
148
148
 
149
- it.each(Object.keys(validProjectTask()))("rejects an empty project task %s", (field) => {
149
+ it("round-trips an explicit project task provenance source", () => {
150
+ const parsed = parseTrustedRunContext({
151
+ projectTask: { ...validProjectTask(), source: "project_task" },
152
+ });
153
+
154
+ expect(parsed.projectTask?.source).toBe("project_task");
155
+ });
156
+
157
+ it("leaves project task provenance source undefined when absent", () => {
158
+ const parsed = parseTrustedRunContext({ projectTask: validProjectTask() });
159
+
160
+ expect(parsed.projectTask?.source).toBeUndefined();
161
+ expect(Object.prototype.hasOwnProperty.call(parsed.projectTask, "source")).toBe(false);
162
+ });
163
+
164
+ it("treats an explicit project task provenance source of undefined as absent", () => {
165
+ const parsed = parseTrustedRunContext({
166
+ projectTask: { ...validProjectTask(), source: undefined },
167
+ });
168
+
169
+ expect(parsed.projectTask?.source).toBeUndefined();
170
+ expect(Object.prototype.hasOwnProperty.call(parsed.projectTask, "source")).toBe(false);
171
+ });
172
+
173
+ it("rejects a non-string project task provenance source", () => {
174
+ expect(() => parseTrustedRunContext({
175
+ projectTask: { ...validProjectTask(), source: 42 },
176
+ })).toThrow("Invalid trusted agent run context");
177
+ });
178
+
179
+ it("rejects an empty project task provenance source", () => {
180
+ expect(() => parseTrustedRunContext({
181
+ projectTask: { ...validProjectTask(), source: "" },
182
+ })).toThrow("Invalid trusted agent run context");
183
+ });
184
+
185
+ it("round-trips an explicit project room provenance source", () => {
186
+ const parsed = parseTrustedRunContext({
187
+ projectRoom: { ...validProjectRoom(), source: "room_message" },
188
+ });
189
+
190
+ expect(parsed.projectRoom?.source).toBe("room_message");
191
+ });
192
+
193
+ it("leaves project room provenance source undefined when absent", () => {
194
+ const parsed = parseTrustedRunContext({ projectRoom: validProjectRoom() });
195
+
196
+ expect(parsed.projectRoom?.source).toBeUndefined();
197
+ expect(Object.prototype.hasOwnProperty.call(parsed.projectRoom, "source")).toBe(false);
198
+ });
199
+
200
+ it("treats an explicit project room provenance source of undefined as absent", () => {
201
+ const parsed = parseTrustedRunContext({
202
+ projectRoom: { ...validProjectRoom(), source: undefined },
203
+ });
204
+
205
+ expect(parsed.projectRoom?.source).toBeUndefined();
206
+ expect(Object.prototype.hasOwnProperty.call(parsed.projectRoom, "source")).toBe(false);
207
+ });
208
+
209
+ it("rejects a non-string project room provenance source", () => {
210
+ expect(() => parseTrustedRunContext({
211
+ projectRoom: { ...validProjectRoom(), source: 42 },
212
+ })).toThrow("Invalid trusted agent run context");
213
+ });
214
+
215
+ it("rejects an empty project room provenance source", () => {
216
+ expect(() => parseTrustedRunContext({
217
+ projectRoom: { ...validProjectRoom(), source: "" },
218
+ })).toThrow("Invalid trusted agent run context");
219
+ });
220
+
221
+ it.each([...Object.keys(validProjectTask()), "source"])("rejects an empty project task %s", (field) => {
150
222
  expect(() => parseTrustedRunContext({
151
223
  projectTask: { ...validProjectTask(), [field]: "" },
152
224
  })).toThrow("Invalid trusted agent run context");
@@ -193,7 +265,7 @@ describe("parseTrustedRunContext", () => {
193
265
  expect(calls).toBe(0);
194
266
  });
195
267
 
196
- it.each(Object.keys(validProjectTask()))(
268
+ it.each([...Object.keys(validProjectTask()), "source"])(
197
269
  "rejects a nested project task %s getter without invoking it",
198
270
  (field) => {
199
271
  let calls = 0;
@@ -0,0 +1,23 @@
1
+ import type { PluginMeta, PluginUiResource } from "../PluginProtocol";
2
+
3
+ describe("plugin inline uiResources contract", () => {
4
+ it("round-trips inline UI html and csp on a PluginMeta object", () => {
5
+ const resource: PluginUiResource = {
6
+ html: "<!doctype html><html><body>hello</body></html>",
7
+ csp: { connectDomains: ["https://api.example.com"] },
8
+ };
9
+
10
+ const meta: PluginMeta = {
11
+ type: "demo",
12
+ name: "Demo",
13
+ description: "demo plugin",
14
+ uiResources: { "ui://demo/app": resource },
15
+ };
16
+
17
+ expect(meta.uiResources?.["ui://demo/app"].html).toContain("hello");
18
+ expect(meta.uiResources?.["ui://demo/app"].csp?.connectDomains).toEqual([
19
+ "https://api.example.com",
20
+ ]);
21
+ expect(resource.mimeType).toBeUndefined();
22
+ });
23
+ });
package/src/index.ts CHANGED
@@ -80,6 +80,8 @@ export type {
80
80
  PluginDiscoveredResource,
81
81
  PluginContext,
82
82
  PluginToolMeta,
83
+ PluginToolUi,
84
+ PluginUiResource,
83
85
  PluginSkillResource,
84
86
  PluginSkillDefinition,
85
87
  PluginStandardConnectionConfig,
@@ -92,3 +94,4 @@ export * from "./SandboxPluginProtocol";
92
94
  export * from "./types";
93
95
  export * from "./TrustedRunContextProtocol";
94
96
  export * from "./OpenProtocol";
97
+ export * from "./McpUiProtocol";