@xemahq/kernel-contracts 0.2.3 → 0.3.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://xema.dev/schemas/awp-spec.v1.json",
3
- "emittedAt": "2026-06-07T09:05:01.778Z",
3
+ "emittedAt": "2026-06-07T10:41:18.819Z",
4
4
  "spec": {
5
5
  "id": "awp/v1",
6
6
  "version": "1.2.0",
@@ -0,0 +1,5 @@
1
+ export * from './lib/chat-widget-kind';
2
+ export * from './lib/chat-widget-payloads';
3
+ export * from './lib/chat-widget-envelope';
4
+ export * from './lib/widget-contribution';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widget/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/chat-widget-kind"), exports);
18
+ __exportStar(require("./lib/chat-widget-payloads"), exports);
19
+ __exportStar(require("./lib/chat-widget-envelope"), exports);
20
+ __exportStar(require("./lib/widget-contribution"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/widget/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,6DAA2C;AAC3C,6DAA2C;AAC3C,4DAA0C"}
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export interface ChatWidgetEnvelope {
3
+ readonly kind: string;
4
+ readonly version: number;
5
+ readonly payload: unknown;
6
+ }
7
+ export declare const ChatWidgetEnvelopeSchema: z.ZodType<ChatWidgetEnvelope>;
8
+ export declare enum ChatWidgetFallbackReason {
9
+ UnknownKind = "unknown-kind",
10
+ InvalidPayload = "invalid-payload",
11
+ UnsupportedVersion = "unsupported-version"
12
+ }
13
+ //# sourceMappingURL=chat-widget-envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-widget-envelope.d.ts","sourceRoot":"","sources":["../../../src/widget/lib/chat-widget-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAGD,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAIjE,CAAC;AAOH,oBAAY,wBAAwB;IAClC,WAAW,iBAAiB;IAC5B,cAAc,oBAAoB;IAClC,kBAAkB,wBAAwB;CAC3C"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatWidgetFallbackReason = exports.ChatWidgetEnvelopeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ChatWidgetEnvelopeSchema = zod_1.z.object({
6
+ kind: zod_1.z.string().min(1),
7
+ version: zod_1.z.number().int().positive(),
8
+ payload: zod_1.z.unknown(),
9
+ });
10
+ var ChatWidgetFallbackReason;
11
+ (function (ChatWidgetFallbackReason) {
12
+ ChatWidgetFallbackReason["UnknownKind"] = "unknown-kind";
13
+ ChatWidgetFallbackReason["InvalidPayload"] = "invalid-payload";
14
+ ChatWidgetFallbackReason["UnsupportedVersion"] = "unsupported-version";
15
+ })(ChatWidgetFallbackReason || (exports.ChatWidgetFallbackReason = ChatWidgetFallbackReason = {}));
16
+ //# sourceMappingURL=chat-widget-envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-widget-envelope.js","sourceRoot":"","sources":["../../../src/widget/lib/chat-widget-envelope.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAyBX,QAAA,wBAAwB,GAAkC,OAAC,CAAC,MAAM,CAAC;IAC9E,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACpC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC;AAOH,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,wDAA4B,CAAA;IAC5B,8DAAkC,CAAA;IAClC,sEAA0C,CAAA;AAC5C,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC"}
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ export declare enum ChatWidgetKind {
3
+ Plan = "plan",
4
+ Diff = "diff",
5
+ Approval = "approval",
6
+ Table = "table",
7
+ Chart = "chart",
8
+ FileEdit = "file-edit"
9
+ }
10
+ export declare const ChatWidgetKindSchema: z.ZodEnum<typeof ChatWidgetKind>;
11
+ export declare enum ChatChartKind {
12
+ Bar = "bar",
13
+ Line = "line"
14
+ }
15
+ export declare const ChatChartKindSchema: z.ZodEnum<typeof ChatChartKind>;
16
+ //# sourceMappingURL=chat-widget-kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-widget-kind.d.ts","sourceRoot":"","sources":["../../../src/widget/lib/chat-widget-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuBxB,oBAAY,cAAc;IAExB,IAAI,SAAS;IAEb,IAAI,SAAS;IAEb,QAAQ,aAAa;IAErB,KAAK,UAAU;IAEf,KAAK,UAAU;IAEf,QAAQ,cAAc;CACvB;AAGD,eAAO,MAAM,oBAAoB,kCAA+B,CAAC;AAMjE,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,eAAO,MAAM,mBAAmB,iCAA8B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatChartKindSchema = exports.ChatChartKind = exports.ChatWidgetKindSchema = exports.ChatWidgetKind = void 0;
4
+ const zod_1 = require("zod");
5
+ var ChatWidgetKind;
6
+ (function (ChatWidgetKind) {
7
+ ChatWidgetKind["Plan"] = "plan";
8
+ ChatWidgetKind["Diff"] = "diff";
9
+ ChatWidgetKind["Approval"] = "approval";
10
+ ChatWidgetKind["Table"] = "table";
11
+ ChatWidgetKind["Chart"] = "chart";
12
+ ChatWidgetKind["FileEdit"] = "file-edit";
13
+ })(ChatWidgetKind || (exports.ChatWidgetKind = ChatWidgetKind = {}));
14
+ exports.ChatWidgetKindSchema = zod_1.z.nativeEnum(ChatWidgetKind);
15
+ var ChatChartKind;
16
+ (function (ChatChartKind) {
17
+ ChatChartKind["Bar"] = "bar";
18
+ ChatChartKind["Line"] = "line";
19
+ })(ChatChartKind || (exports.ChatChartKind = ChatChartKind = {}));
20
+ exports.ChatChartKindSchema = zod_1.z.nativeEnum(ChatChartKind);
21
+ //# sourceMappingURL=chat-widget-kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-widget-kind.js","sourceRoot":"","sources":["../../../src/widget/lib/chat-widget-kind.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAuBxB,IAAY,cAaX;AAbD,WAAY,cAAc;IAExB,+BAAa,CAAA;IAEb,+BAAa,CAAA;IAEb,uCAAqB,CAAA;IAErB,iCAAe,CAAA;IAEf,iCAAe,CAAA;IAEf,wCAAsB,CAAA;AACxB,CAAC,EAbW,cAAc,8BAAd,cAAc,QAazB;AAGY,QAAA,oBAAoB,GAAG,OAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAMjE,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,8BAAa,CAAA;AACf,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAEY,QAAA,mBAAmB,GAAG,OAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ import { ChatWidgetKind } from './chat-widget-kind';
3
+ export declare enum WidgetTodoState {
4
+ Todo = "todo",
5
+ Active = "active",
6
+ Done = "done"
7
+ }
8
+ export declare const WidgetTodoStateSchema: z.ZodEnum<typeof WidgetTodoState>;
9
+ export declare const PlanWidgetItemSchema: z.ZodObject<{
10
+ label: z.ZodString;
11
+ state: z.ZodEnum<typeof WidgetTodoState>;
12
+ }, z.core.$strip>;
13
+ export declare const PlanWidgetPayloadSchema: z.ZodObject<{
14
+ title: z.ZodOptional<z.ZodString>;
15
+ items: z.ZodArray<z.ZodObject<{
16
+ label: z.ZodString;
17
+ state: z.ZodEnum<typeof WidgetTodoState>;
18
+ }, z.core.$strip>>;
19
+ }, z.core.$strip>;
20
+ export type PlanWidgetPayload = z.infer<typeof PlanWidgetPayloadSchema>;
21
+ export declare const DiffWidgetPayloadSchema: z.ZodObject<{
22
+ path: z.ZodString;
23
+ add: z.ZodNumber;
24
+ del: z.ZodNumber;
25
+ hunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ }, z.core.$strip>;
27
+ export type DiffWidgetPayload = z.infer<typeof DiffWidgetPayloadSchema>;
28
+ export declare const FileEditWidgetPayloadSchema: z.ZodObject<{
29
+ path: z.ZodString;
30
+ summary: z.ZodOptional<z.ZodString>;
31
+ add: z.ZodNumber;
32
+ del: z.ZodNumber;
33
+ }, z.core.$strip>;
34
+ export type FileEditWidgetPayload = z.infer<typeof FileEditWidgetPayloadSchema>;
35
+ export declare const ApprovalWidgetPayloadSchema: z.ZodObject<{
36
+ sessionId: z.ZodString;
37
+ accent: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export type ApprovalWidgetPayload = z.infer<typeof ApprovalWidgetPayloadSchema>;
40
+ export declare const TableWidgetColumnSchema: z.ZodObject<{
41
+ key: z.ZodString;
42
+ label: z.ZodString;
43
+ }, z.core.$strip>;
44
+ export declare const TableWidgetPayloadSchema: z.ZodObject<{
45
+ columns: z.ZodArray<z.ZodObject<{
46
+ key: z.ZodString;
47
+ label: z.ZodString;
48
+ }, z.core.$strip>>;
49
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
50
+ }, z.core.$strip>;
51
+ export type TableWidgetPayload = z.infer<typeof TableWidgetPayloadSchema>;
52
+ export declare const ChartWidgetSeriesSchema: z.ZodObject<{
53
+ label: z.ZodString;
54
+ points: z.ZodArray<z.ZodObject<{
55
+ x: z.ZodString;
56
+ y: z.ZodNumber;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export declare const ChartWidgetPayloadSchema: z.ZodObject<{
60
+ kind: z.ZodEnum<typeof import("./chat-widget-kind").ChatChartKind>;
61
+ series: z.ZodArray<z.ZodObject<{
62
+ label: z.ZodString;
63
+ points: z.ZodArray<z.ZodObject<{
64
+ x: z.ZodString;
65
+ y: z.ZodNumber;
66
+ }, z.core.$strip>>;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>;
69
+ export type ChartWidgetPayload = z.infer<typeof ChartWidgetPayloadSchema>;
70
+ export declare const FIRST_PARTY_WIDGET_PAYLOAD_SCHEMAS: Readonly<Record<ChatWidgetKind, z.ZodTypeAny>>;
71
+ export declare const FIRST_PARTY_WIDGET_VERSIONS: Readonly<Record<ChatWidgetKind, number>>;
72
+ //# sourceMappingURL=chat-widget-payloads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-widget-payloads.d.ts","sourceRoot":"","sources":["../../../src/widget/lib/chat-widget-payloads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAuB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAkBzE,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AACD,eAAO,MAAM,qBAAqB,mCAAgC,CAAC;AAGnE,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC;AAGH,eAAO,MAAM,uBAAuB;;;;;;iBAGlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAMxE,eAAO,MAAM,uBAAuB;;;;;iBAKlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAGxE,eAAO,MAAM,2BAA2B;;;;;iBAKtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAOhF,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAGhF,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAGH,eAAO,MAAM,wBAAwB;;;;;;iBAGnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAG1E,eAAO,MAAM,uBAAuB;;;;;;iBAGlC,CAAC;AAGH,eAAO,MAAM,wBAAwB;;;;;;;;;iBAGnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAQ1E,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,CAQrC,CAAC;AAOF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAChD,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAQ/B,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FIRST_PARTY_WIDGET_VERSIONS = exports.FIRST_PARTY_WIDGET_PAYLOAD_SCHEMAS = exports.ChartWidgetPayloadSchema = exports.ChartWidgetSeriesSchema = exports.TableWidgetPayloadSchema = exports.TableWidgetColumnSchema = exports.ApprovalWidgetPayloadSchema = exports.FileEditWidgetPayloadSchema = exports.DiffWidgetPayloadSchema = exports.PlanWidgetPayloadSchema = exports.PlanWidgetItemSchema = exports.WidgetTodoStateSchema = exports.WidgetTodoState = void 0;
4
+ const zod_1 = require("zod");
5
+ const chat_widget_kind_1 = require("./chat-widget-kind");
6
+ var WidgetTodoState;
7
+ (function (WidgetTodoState) {
8
+ WidgetTodoState["Todo"] = "todo";
9
+ WidgetTodoState["Active"] = "active";
10
+ WidgetTodoState["Done"] = "done";
11
+ })(WidgetTodoState || (exports.WidgetTodoState = WidgetTodoState = {}));
12
+ exports.WidgetTodoStateSchema = zod_1.z.nativeEnum(WidgetTodoState);
13
+ exports.PlanWidgetItemSchema = zod_1.z.object({
14
+ label: zod_1.z.string().min(1),
15
+ state: exports.WidgetTodoStateSchema,
16
+ });
17
+ exports.PlanWidgetPayloadSchema = zod_1.z.object({
18
+ title: zod_1.z.string().optional(),
19
+ items: zod_1.z.array(exports.PlanWidgetItemSchema),
20
+ });
21
+ exports.DiffWidgetPayloadSchema = zod_1.z.object({
22
+ path: zod_1.z.string().min(1),
23
+ add: zod_1.z.number(),
24
+ del: zod_1.z.number(),
25
+ hunks: zod_1.z.array(zod_1.z.string()).optional(),
26
+ });
27
+ exports.FileEditWidgetPayloadSchema = zod_1.z.object({
28
+ path: zod_1.z.string().min(1),
29
+ summary: zod_1.z.string().optional(),
30
+ add: zod_1.z.number(),
31
+ del: zod_1.z.number(),
32
+ });
33
+ exports.ApprovalWidgetPayloadSchema = zod_1.z.object({
34
+ sessionId: zod_1.z.string().min(1),
35
+ accent: zod_1.z.string().optional(),
36
+ });
37
+ exports.TableWidgetColumnSchema = zod_1.z.object({
38
+ key: zod_1.z.string().min(1),
39
+ label: zod_1.z.string().min(1),
40
+ });
41
+ exports.TableWidgetPayloadSchema = zod_1.z.object({
42
+ columns: zod_1.z.array(exports.TableWidgetColumnSchema),
43
+ rows: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.union([zod_1.z.string(), zod_1.z.number()]))),
44
+ });
45
+ exports.ChartWidgetSeriesSchema = zod_1.z.object({
46
+ label: zod_1.z.string().min(1),
47
+ points: zod_1.z.array(zod_1.z.object({ x: zod_1.z.string(), y: zod_1.z.number() })),
48
+ });
49
+ exports.ChartWidgetPayloadSchema = zod_1.z.object({
50
+ kind: chat_widget_kind_1.ChatChartKindSchema,
51
+ series: zod_1.z.array(exports.ChartWidgetSeriesSchema),
52
+ });
53
+ exports.FIRST_PARTY_WIDGET_PAYLOAD_SCHEMAS = {
54
+ [chat_widget_kind_1.ChatWidgetKind.Plan]: exports.PlanWidgetPayloadSchema,
55
+ [chat_widget_kind_1.ChatWidgetKind.Diff]: exports.DiffWidgetPayloadSchema,
56
+ [chat_widget_kind_1.ChatWidgetKind.Approval]: exports.ApprovalWidgetPayloadSchema,
57
+ [chat_widget_kind_1.ChatWidgetKind.Table]: exports.TableWidgetPayloadSchema,
58
+ [chat_widget_kind_1.ChatWidgetKind.Chart]: exports.ChartWidgetPayloadSchema,
59
+ [chat_widget_kind_1.ChatWidgetKind.FileEdit]: exports.FileEditWidgetPayloadSchema,
60
+ };
61
+ exports.FIRST_PARTY_WIDGET_VERSIONS = {
62
+ [chat_widget_kind_1.ChatWidgetKind.Plan]: 1,
63
+ [chat_widget_kind_1.ChatWidgetKind.Diff]: 1,
64
+ [chat_widget_kind_1.ChatWidgetKind.Approval]: 1,
65
+ [chat_widget_kind_1.ChatWidgetKind.Table]: 1,
66
+ [chat_widget_kind_1.ChatWidgetKind.Chart]: 1,
67
+ [chat_widget_kind_1.ChatWidgetKind.FileEdit]: 1,
68
+ };
69
+ //# sourceMappingURL=chat-widget-payloads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-widget-payloads.js","sourceRoot":"","sources":["../../../src/widget/lib/chat-widget-payloads.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export interface WidgetContributionManifest {
3
+ readonly kind: string;
4
+ readonly version: number;
5
+ readonly displayName: string;
6
+ readonly summary: string;
7
+ readonly payloadSchema: Record<string, unknown>;
8
+ }
9
+ export declare const WidgetContributionManifestSchema: z.ZodType<WidgetContributionManifest>;
10
+ export interface WidgetKindCatalogueEntry {
11
+ readonly kind: string;
12
+ readonly version: number;
13
+ readonly displayName: string;
14
+ readonly summary: string;
15
+ readonly payloadSchema: Record<string, unknown>;
16
+ readonly source: WidgetKindSource;
17
+ readonly biomeId?: string;
18
+ }
19
+ export declare enum WidgetKindSource {
20
+ FirstParty = "first-party",
21
+ Biome = "biome"
22
+ }
23
+ export declare const WidgetKindSourceSchema: z.ZodEnum<typeof WidgetKindSource>;
24
+ //# sourceMappingURL=widget-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-contribution.d.ts","sourceRoot":"","sources":["../../../src/widget/lib/widget-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,MAAM,WAAW,0BAA0B;IAMzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjD;AAUD,eAAO,MAAM,gCAAgC,EAAE,CAAC,CAAC,OAAO,CAAC,0BAA0B,CActC,CAAC;AAY9C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,oBAAY,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,sBAAsB,oCAAiC,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidgetKindSourceSchema = exports.WidgetKindSource = exports.WidgetContributionManifestSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const WIDGET_KIND_SLUG_REGEX = /^[a-z][a-z0-9-]*$/;
6
+ exports.WidgetContributionManifestSchema = zod_1.z.object({
7
+ kind: zod_1.z
8
+ .string()
9
+ .min(1)
10
+ .max(100)
11
+ .regex(WIDGET_KIND_SLUG_REGEX, 'Widget kind slug must be lowercase letters, digits, and hyphens (start with a letter).'),
12
+ version: zod_1.z.number().int().positive(),
13
+ displayName: zod_1.z.string().min(1).max(200),
14
+ summary: zod_1.z.string().min(1).max(1000),
15
+ payloadSchema: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
16
+ });
17
+ var WidgetKindSource;
18
+ (function (WidgetKindSource) {
19
+ WidgetKindSource["FirstParty"] = "first-party";
20
+ WidgetKindSource["Biome"] = "biome";
21
+ })(WidgetKindSource || (exports.WidgetKindSource = WidgetKindSource = {}));
22
+ exports.WidgetKindSourceSchema = zod_1.z.nativeEnum(WidgetKindSource);
23
+ //# sourceMappingURL=widget-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-contribution.js","sourceRoot":"","sources":["../../../src/widget/lib/widget-contribution.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AA0CxB,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAQtC,QAAA,gCAAgC,GAC3C,OAAC,CAAC,MAAM,CAAC;IACP,IAAI,EAAE,OAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,KAAK,CACJ,sBAAsB,EACtB,wFAAwF,CACzF;IACH,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACpC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACpC,aAAa,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC;CACjD,CAA0C,CAAC;AAwB9C,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,8CAA0B,CAAA;IAC1B,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAEY,QAAA,sBAAsB,GAAG,OAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/kernel-contracts",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the 32 kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -0,0 +1,4 @@
1
+ export * from './lib/chat-widget-kind';
2
+ export * from './lib/chat-widget-payloads';
3
+ export * from './lib/chat-widget-envelope';
4
+ export * from './lib/widget-contribution';
@@ -0,0 +1,41 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * `ChatWidgetEnvelope` — a single widget instance recorded on an assistant
5
+ * message's `metadata.widgets[]` and rendered by the host-web ChatWidget
6
+ * registry (HANDOFF §3.2).
7
+ *
8
+ * `kind` is a first-party {@link ChatWidgetKind} value OR a namespaced biome
9
+ * string (`<biomeId>:<kind>`). `version` is the monotonic schema version for
10
+ * THIS kind — the FE renders the registered renderer when `version <=
11
+ * supportedVersion`, else a safe fallback card. `payload` is the kind-specific
12
+ * payload (validated by the producer against the kind's schema; the FE
13
+ * re-validates before render so a malformed payload renders the fallback rather
14
+ * than being dropped).
15
+ *
16
+ * This is the kernel-canonical mirror of the FE `ChatWidgetEnvelope` interface
17
+ * — keep the shapes value-identical.
18
+ */
19
+ export interface ChatWidgetEnvelope {
20
+ readonly kind: string;
21
+ readonly version: number;
22
+ readonly payload: unknown;
23
+ }
24
+
25
+ /** Zod validator for {@link ChatWidgetEnvelope}. */
26
+ export const ChatWidgetEnvelopeSchema: z.ZodType<ChatWidgetEnvelope> = z.object({
27
+ kind: z.string().min(1),
28
+ version: z.number().int().positive(),
29
+ payload: z.unknown(),
30
+ });
31
+
32
+ /**
33
+ * Why a widget fell back to the safe card — populated on the FE resolved
34
+ * decision so the Studio debugger can see WHY. Mirror of the FE
35
+ * `ChatWidgetFallbackReason`. Closed set.
36
+ */
37
+ export enum ChatWidgetFallbackReason {
38
+ UnknownKind = 'unknown-kind',
39
+ InvalidPayload = 'invalid-payload',
40
+ UnsupportedVersion = 'unsupported-version',
41
+ }
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * `ChatWidgetKind` — the closed first-party set of rich in-chat widget kinds an
5
+ * agent may render through the generic `render_widget` tool (see the Xema OS
6
+ * ChatWidget feature). Each kind is a GENERIC, domain-agnostic presentation
7
+ * primitive — chosen to cover the broadest possible range of "structured thing
8
+ * the agent wants to show the user" without baking in any vertical semantics.
9
+ *
10
+ * ── Value-identity invariant ────────────────────────────────────────────────
11
+ * This enum is the kernel-canonical mirror of the host-web FE model
12
+ * (`submodules/xema-host-web/src/views/project/sessions/thin/chat-widget-model.ts`,
13
+ * `ChatWidgetKind`). The two MUST stay value-identical: the FE consumes this
14
+ * contract via the frontend-bridge sync, and the registry resolves a payload to
15
+ * a renderer by matching `kind`. Adding a generic kind = add the enum member in
16
+ * BOTH places (the "2-file rule") plus a payload schema below.
17
+ *
18
+ * ── Closed first-party set vs. open biome set ───────────────────────────────
19
+ * A biome contributes its OWN widget kind as a namespaced string
20
+ * (`<biomeId>:<kind>`) through a `widget-kind` contribution — it never extends
21
+ * this enum. This mirrors the closed-enum + open-namespaced-string pattern used
22
+ * by the FE registry's `registerChatWidget`.
23
+ */
24
+ export enum ChatWidgetKind {
25
+ /** A checklist / plan (todo items with status). The agent's "here's the plan". */
26
+ Plan = 'plan',
27
+ /** A single-file unified diff (path + hunks). "Here's the change I propose." */
28
+ Diff = 'diff',
29
+ /** A suspended capability call awaiting human approval, keyed by approval id. */
30
+ Approval = 'approval',
31
+ /** A generic columns + rows table. The universal "show me structured records". */
32
+ Table = 'table',
33
+ /** A compact bar/line chart over labelled series. "Visualise these numbers." */
34
+ Chart = 'chart',
35
+ /** A header-only file-change summary (path + add/del counts), no hunks. */
36
+ FileEdit = 'file-edit',
37
+ }
38
+
39
+ /** Zod mirror of {@link ChatWidgetKind} for wire-boundary validation. */
40
+ export const ChatWidgetKindSchema = z.nativeEnum(ChatWidgetKind);
41
+
42
+ /**
43
+ * The chart shapes the first-party `chart` widget can draw. Closed set — kept
44
+ * value-identical with the FE's `ChatChartKind`.
45
+ */
46
+ export enum ChatChartKind {
47
+ Bar = 'bar',
48
+ Line = 'line',
49
+ }
50
+
51
+ export const ChatChartKindSchema = z.nativeEnum(ChatChartKind);
@@ -0,0 +1,130 @@
1
+ import { z } from 'zod';
2
+
3
+ import { ChatChartKindSchema, ChatWidgetKind } from './chat-widget-kind';
4
+
5
+ /**
6
+ * Per-kind payload contracts for the first-party {@link ChatWidgetKind} set.
7
+ *
8
+ * These schemas are the WIRE contract the `render_widget` tool validates against
9
+ * before a widget envelope is recorded onto an assistant message's
10
+ * `metadata.widgets[]`. They are kept STRUCTURALLY value-identical with the FE
11
+ * narrowing validators in
12
+ * `submodules/xema-host-web/src/views/project/sessions/thin/chat-widget-builtins.tsx`
13
+ * — the FE re-validates client-side (so a future/unknown payload still routes to
14
+ * the safe fallback card), but the runtime fails fast on a bad payload so a
15
+ * malformed widget never reaches the transcript.
16
+ *
17
+ * Zero runtime deps beyond zod (kernel-leaf invariant).
18
+ */
19
+
20
+ /** Mirror of the FE `TodoState` (session-kit). Closed set. */
21
+ export enum WidgetTodoState {
22
+ Todo = 'todo',
23
+ Active = 'active',
24
+ Done = 'done',
25
+ }
26
+ export const WidgetTodoStateSchema = z.nativeEnum(WidgetTodoState);
27
+
28
+ /** A single plan/checklist item. Mirrors session-kit `TodoItem`. */
29
+ export const PlanWidgetItemSchema = z.object({
30
+ label: z.string().min(1),
31
+ state: WidgetTodoStateSchema,
32
+ });
33
+
34
+ /** `plan` payload — a titled checklist of todo items. */
35
+ export const PlanWidgetPayloadSchema = z.object({
36
+ title: z.string().optional(),
37
+ items: z.array(PlanWidgetItemSchema),
38
+ });
39
+ export type PlanWidgetPayload = z.infer<typeof PlanWidgetPayloadSchema>;
40
+
41
+ /**
42
+ * `diff` payload — a single-file unified diff. `hunks` are raw diff lines whose
43
+ * first character is the marker (`+`/`-`/space). Mirrors session-kit `DiffFile`.
44
+ */
45
+ export const DiffWidgetPayloadSchema = z.object({
46
+ path: z.string().min(1),
47
+ add: z.number(),
48
+ del: z.number(),
49
+ hunks: z.array(z.string()).optional(),
50
+ });
51
+ export type DiffWidgetPayload = z.infer<typeof DiffWidgetPayloadSchema>;
52
+
53
+ /** `file-edit` payload — a header-only file change summary (no hunks). */
54
+ export const FileEditWidgetPayloadSchema = z.object({
55
+ path: z.string().min(1),
56
+ summary: z.string().optional(),
57
+ add: z.number(),
58
+ del: z.number(),
59
+ });
60
+ export type FileEditWidgetPayload = z.infer<typeof FileEditWidgetPayloadSchema>;
61
+
62
+ /**
63
+ * `approval` payload — the suspended capability call awaiting approval, keyed by
64
+ * the session it belongs to. The FE mounts the same Pillar-3 inline approval
65
+ * card from this id.
66
+ */
67
+ export const ApprovalWidgetPayloadSchema = z.object({
68
+ sessionId: z.string().min(1),
69
+ accent: z.string().optional(),
70
+ });
71
+ export type ApprovalWidgetPayload = z.infer<typeof ApprovalWidgetPayloadSchema>;
72
+
73
+ /** A `table` column descriptor. */
74
+ export const TableWidgetColumnSchema = z.object({
75
+ key: z.string().min(1),
76
+ label: z.string().min(1),
77
+ });
78
+
79
+ /** `table` payload — generic columns + rows. Cells are strings or numbers. */
80
+ export const TableWidgetPayloadSchema = z.object({
81
+ columns: z.array(TableWidgetColumnSchema),
82
+ rows: z.array(z.record(z.string(), z.union([z.string(), z.number()]))),
83
+ });
84
+ export type TableWidgetPayload = z.infer<typeof TableWidgetPayloadSchema>;
85
+
86
+ /** A single chart series (one bar/line group). */
87
+ export const ChartWidgetSeriesSchema = z.object({
88
+ label: z.string().min(1),
89
+ points: z.array(z.object({ x: z.string(), y: z.number() })),
90
+ });
91
+
92
+ /** `chart` payload — a compact bar/line chart over labelled series. */
93
+ export const ChartWidgetPayloadSchema = z.object({
94
+ kind: ChatChartKindSchema,
95
+ series: z.array(ChartWidgetSeriesSchema),
96
+ });
97
+ export type ChartWidgetPayload = z.infer<typeof ChartWidgetPayloadSchema>;
98
+
99
+ /**
100
+ * The closed registry of first-party kind → payload schema. The single source
101
+ * of truth the `render_widget` tool & runtime use to validate a first-party
102
+ * widget payload by `kind`. Adding a generic kind = one enum member + one schema
103
+ * here + the FE mirror (the "2-file rule").
104
+ */
105
+ export const FIRST_PARTY_WIDGET_PAYLOAD_SCHEMAS: Readonly<
106
+ Record<ChatWidgetKind, z.ZodTypeAny>
107
+ > = {
108
+ [ChatWidgetKind.Plan]: PlanWidgetPayloadSchema,
109
+ [ChatWidgetKind.Diff]: DiffWidgetPayloadSchema,
110
+ [ChatWidgetKind.Approval]: ApprovalWidgetPayloadSchema,
111
+ [ChatWidgetKind.Table]: TableWidgetPayloadSchema,
112
+ [ChatWidgetKind.Chart]: ChartWidgetPayloadSchema,
113
+ [ChatWidgetKind.FileEdit]: FileEditWidgetPayloadSchema,
114
+ };
115
+
116
+ /**
117
+ * The current schema version for each first-party kind. Bumped when a kind's
118
+ * payload schema changes shape; the FE renders the registered renderer only
119
+ * when `envelope.version <= supportedVersion`, else the safe fallback.
120
+ */
121
+ export const FIRST_PARTY_WIDGET_VERSIONS: Readonly<
122
+ Record<ChatWidgetKind, number>
123
+ > = {
124
+ [ChatWidgetKind.Plan]: 1,
125
+ [ChatWidgetKind.Diff]: 1,
126
+ [ChatWidgetKind.Approval]: 1,
127
+ [ChatWidgetKind.Table]: 1,
128
+ [ChatWidgetKind.Chart]: 1,
129
+ [ChatWidgetKind.FileEdit]: 1,
130
+ };
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Manifest shape carried by every `ContributionKind.WidgetKind` envelope.
5
+ *
6
+ * One contribution = one widget kind. The shape mirrors
7
+ * `CapabilityContributionManifest` (see `../capability/lib/capability-contribution.ts`)
8
+ * so the generic `BootstrapContributionsService<TKind, TManifest>` template and
9
+ * the codemod can ingest it the same way every other contribution kind is
10
+ * ingested. Provenance (`biomeId`, `biomeVersion`) is stamped by the bootstrap
11
+ * pipeline from the discovering biome's manifest — authors do NOT declare it
12
+ * inline.
13
+ *
14
+ * A biome contributes a widget kind so its frontend biome can register a
15
+ * renderer for it via `registerChatWidget('<biomeId>:<kind>', …)`. The
16
+ * `kind` here is the BARE, biome-local kind slug; the catalogue namespaces it
17
+ * to `<biomeId>:<kind>` at ingest so it can never shadow a first-party kind.
18
+ *
19
+ * Validation is fail-fast: a contribution that violates any constraint is
20
+ * rejected at boot. `payloadSchema` is an opaque JSON Schema passed through
21
+ * verbatim (the catalogue surfaces it to the FE and to authoring tools; it is
22
+ * NOT a kernel-validated shape — validating it as JSON Schema here would be
23
+ * either partial or pull in a JSON-Schema validator, violating the kernel-leaf
24
+ * invariant).
25
+ */
26
+ export interface WidgetContributionManifest {
27
+ /**
28
+ * Biome-local kind slug (lowercase, hyphenated). Namespaced to
29
+ * `<biomeId>:<kind>` by the catalogue — a biome can never claim a bare
30
+ * first-party kind.
31
+ */
32
+ readonly kind: string;
33
+ /** Monotonic schema version for this kind's payload. */
34
+ readonly version: number;
35
+ /** Human-readable display name surfaced in the catalogue (≤ 200 chars). */
36
+ readonly displayName: string;
37
+ /** One-line summary of WHAT the widget shows + WHEN to use it (≤ 1000 chars). */
38
+ readonly summary: string;
39
+ /** JSON Schema for the widget payload — passed through verbatim. */
40
+ readonly payloadSchema: Record<string, unknown>;
41
+ }
42
+
43
+ const WIDGET_KIND_SLUG_REGEX = /^[a-z][a-z0-9-]*$/;
44
+
45
+ /**
46
+ * Zod validator for {@link WidgetContributionManifest}. The bootstrap template
47
+ * and the catalogue's `POST /widget-kinds/register` route BOTH route every
48
+ * candidate manifest through this before persisting, so a malformed
49
+ * contribution fails at the boundary instead of at render time.
50
+ */
51
+ export const WidgetContributionManifestSchema: z.ZodType<WidgetContributionManifest> =
52
+ z.object({
53
+ kind: z
54
+ .string()
55
+ .min(1)
56
+ .max(100)
57
+ .regex(
58
+ WIDGET_KIND_SLUG_REGEX,
59
+ 'Widget kind slug must be lowercase letters, digits, and hyphens (start with a letter).',
60
+ ),
61
+ version: z.number().int().positive(),
62
+ displayName: z.string().min(1).max(200),
63
+ summary: z.string().min(1).max(1000),
64
+ payloadSchema: z.record(z.string(), z.unknown()),
65
+ }) as z.ZodType<WidgetContributionManifest>;
66
+
67
+ /**
68
+ * A resolved widget-kind catalogue entry — what `GET /widget-kinds` returns. It
69
+ * unifies the closed first-party set and the open biome-contributed set behind
70
+ * ONE shape the FE consumes to know which kinds exist (and to register
71
+ * biome-contributed kinds into the open FE registry).
72
+ *
73
+ * `source` discriminates provenance; `kind` is the FULLY-NAMESPACED slug the FE
74
+ * registry keys by (a first-party kind is its bare enum value; a biome kind is
75
+ * `<biomeId>:<kind>`).
76
+ */
77
+ export interface WidgetKindCatalogueEntry {
78
+ readonly kind: string;
79
+ readonly version: number;
80
+ readonly displayName: string;
81
+ readonly summary: string;
82
+ readonly payloadSchema: Record<string, unknown>;
83
+ readonly source: WidgetKindSource;
84
+ /** Present only for biome-contributed kinds. */
85
+ readonly biomeId?: string;
86
+ }
87
+
88
+ /** Provenance of a catalogue entry. Closed set. */
89
+ export enum WidgetKindSource {
90
+ FirstParty = 'first-party',
91
+ Biome = 'biome',
92
+ }
93
+
94
+ export const WidgetKindSourceSchema = z.nativeEnum(WidgetKindSource);