ngx-json-render 0.9.9 → 0.9.10
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
|
@@ -512,6 +512,14 @@ providers: [
|
|
|
512
512
|
];
|
|
513
513
|
```
|
|
514
514
|
|
|
515
|
+
While the agent's run is still streaming an activity, its renderer is
|
|
516
|
+
loading, as under `injectUIStream`: `validate` checks the spec once that run
|
|
517
|
+
ends, not at every patch, and the catalog holds back elements whose props
|
|
518
|
+
have not arrived. An activity already on screen stays checked while a later
|
|
519
|
+
run builds another. CopilotKit mounts the activity mid-run, after the run has
|
|
520
|
+
fixed its subscribers, so the end of that run is read from the agent's
|
|
521
|
+
`isRunning` flag.
|
|
522
|
+
|
|
515
523
|
**On the server**, the model's output — prose with ` ```spec ` fenced JSONL,
|
|
516
524
|
as `catalog.prompt({ mode: 'inline' })` asks for — splits into text-message
|
|
517
525
|
events and activity deltas with `createMixedStreamParser` from
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyPatch, checkSpec, formatSpecCheckIssues, JsonRenderer } from 'ngx-json-render';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { signal, inject, DestroyRef, computed, input, Component } from '@angular/core';
|
|
3
|
+
import { signal, inject, DestroyRef, computed, input, effect, untracked, Component } from '@angular/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The `activityType` a json-render spec travels under.
|
|
@@ -234,36 +234,126 @@ function injectAgentUI(options) {
|
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
/** How often a streaming activity looks whether its run has ended. */
|
|
238
|
+
const RUN_END_POLL_MS = 250;
|
|
239
|
+
function isActivityAgent(agent) {
|
|
240
|
+
return (typeof agent === 'object' &&
|
|
241
|
+
agent !== null &&
|
|
242
|
+
typeof agent.subscribe === 'function');
|
|
243
|
+
}
|
|
244
|
+
function messageIdOf(message) {
|
|
245
|
+
const id = message?.id;
|
|
246
|
+
return typeof id === 'string' ? id : undefined;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Whether a message comes after the thread's last user message — that is,
|
|
250
|
+
* belongs to the turn now being answered.
|
|
251
|
+
*/
|
|
252
|
+
function inLatestTurn(agent, messageId) {
|
|
253
|
+
const messages = agent.messages;
|
|
254
|
+
if (!messages)
|
|
255
|
+
return true;
|
|
256
|
+
const index = messages.findIndex((m) => m.id === messageId);
|
|
257
|
+
if (index === -1)
|
|
258
|
+
return true;
|
|
259
|
+
for (let i = messages.length - 1; i > index; i--) {
|
|
260
|
+
if (messages[i].role === 'user')
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
237
265
|
/**
|
|
238
266
|
* Renders one json-render activity message. It takes the inputs every AG-UI
|
|
239
267
|
* activity renderer is given — CopilotKit Angular's `ActivityRenderer`
|
|
240
268
|
* contract — and draws `content` with `<json-render>`, which takes its
|
|
241
269
|
* registry, catalog and handlers from the nearest `provideJsonRender`.
|
|
242
270
|
*
|
|
271
|
+
* While the agent's current run is still streaming into this activity, the
|
|
272
|
+
* renderer is told it is loading, as `injectUIStream` tells it: the spec is
|
|
273
|
+
* checked once the run ends, not at every patch, and the catalog holds back
|
|
274
|
+
* elements whose props have not arrived yet. Streaming is tracked per
|
|
275
|
+
* message — a run that sends this activity a snapshot or a delta — so an
|
|
276
|
+
* activity already on screen stays checked while a later run builds another.
|
|
277
|
+
* Without an `agent` input the renderer is never loading.
|
|
278
|
+
*
|
|
243
279
|
* Register it with {@link jsonRenderActivityRenderer} rather than by hand.
|
|
244
280
|
*/
|
|
245
281
|
class JsonRenderActivity {
|
|
246
282
|
activityType = input(JSON_RENDER_ACTIVITY_TYPE, ...(ngDevMode ? [{ debugName: "activityType" }] : /* istanbul ignore next */ []));
|
|
247
283
|
content = input.required(...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
248
|
-
/** The AG-UI activity message;
|
|
284
|
+
/** The AG-UI activity message; its `id` matches the agent's events. */
|
|
249
285
|
message = input(...(ngDevMode ? [undefined, { debugName: "message" }] : /* istanbul ignore next */ []));
|
|
250
|
-
/** The agent that produced it;
|
|
286
|
+
/** The agent that produced it; its runs decide when the spec is final. */
|
|
251
287
|
agent = input(...(ngDevMode ? [undefined, { debugName: "agent" }] : /* istanbul ignore next */ []));
|
|
288
|
+
// CopilotKit hands every activity a fresh copy of its content on each event
|
|
289
|
+
// of a run, its own or another's. An unchanged copy is the same spec: not
|
|
290
|
+
// a reason to check it, and report what the check found, once more.
|
|
252
291
|
spec = computed(() => {
|
|
253
292
|
const content = this.content();
|
|
254
293
|
return isJsonRenderSpec(content) ? content : null;
|
|
255
|
-
}, ...(ngDevMode ?
|
|
294
|
+
}, { ...(ngDevMode ? { debugName: "spec" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b ||
|
|
295
|
+
(a !== null && b !== null && JSON.stringify(a) === JSON.stringify(b)) });
|
|
296
|
+
/** Whether the agent's current run is still streaming this activity. */
|
|
297
|
+
streaming = signal(false, ...(ngDevMode ? [{ debugName: "streaming" }] : /* istanbul ignore next */ []));
|
|
298
|
+
constructor() {
|
|
299
|
+
// `@ag-ui/client` fixes a run's subscribers when the run starts, and
|
|
300
|
+
// CopilotKit mounts an activity at its first snapshot — mid-run — so the
|
|
301
|
+
// subscription below never hears the end of the run that created it.
|
|
302
|
+
// While streaming, the agent's `isRunning` flag is watched instead.
|
|
303
|
+
effect((onCleanup) => {
|
|
304
|
+
const agent = this.agent();
|
|
305
|
+
if (!this.streaming() ||
|
|
306
|
+
!isActivityAgent(agent) ||
|
|
307
|
+
typeof agent.isRunning !== 'boolean') {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const timer = setInterval(() => {
|
|
311
|
+
if (!agent.isRunning)
|
|
312
|
+
this.streaming.set(false);
|
|
313
|
+
}, RUN_END_POLL_MS);
|
|
314
|
+
onCleanup(() => clearInterval(timer));
|
|
315
|
+
});
|
|
316
|
+
effect((onCleanup) => {
|
|
317
|
+
const agent = this.agent();
|
|
318
|
+
if (!isActivityAgent(agent)) {
|
|
319
|
+
this.streaming.set(false);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const ownId = () => untracked(() => messageIdOf(this.message()));
|
|
323
|
+
// CopilotKit mounts an activity when its first snapshot arrives, so a
|
|
324
|
+
// run already in progress is, as a rule, the one streaming it — unless
|
|
325
|
+
// the message belongs to an earlier turn and was mounted again.
|
|
326
|
+
untracked(() => {
|
|
327
|
+
const id = ownId();
|
|
328
|
+
this.streaming.set(agent.isRunning === true &&
|
|
329
|
+
(id === undefined || inLatestTurn(agent, id)));
|
|
330
|
+
});
|
|
331
|
+
const subscriber = {
|
|
332
|
+
onRunInitialized: () => this.streaming.set(false),
|
|
333
|
+
onEvent: ({ event }) => {
|
|
334
|
+
if ((event.type === 'ACTIVITY_SNAPSHOT' ||
|
|
335
|
+
event.type === 'ACTIVITY_DELTA') &&
|
|
336
|
+
event.messageId === ownId()) {
|
|
337
|
+
this.streaming.set(true);
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
onRunFinalized: () => this.streaming.set(false),
|
|
341
|
+
};
|
|
342
|
+
const subscription = agent.subscribe(subscriber);
|
|
343
|
+
onCleanup(() => subscription.unsubscribe());
|
|
344
|
+
});
|
|
345
|
+
}
|
|
256
346
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: JsonRenderActivity, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
257
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.25", type: JsonRenderActivity, isStandalone: true, selector: "json-render-activity", inputs: { activityType: { classPropertyName: "activityType", publicName: "activityType", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, agent: { classPropertyName: "agent", publicName: "agent", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<json-render [spec]="spec()" />`, isInline: true, dependencies: [{ kind: "component", type: JsonRenderer, selector: "json-render", inputs: ["spec", "registry", "loading", "fallback", "validate", "renderLimits", "catalog", "state", "store", "handlers", "onAction", "navigate", "validationFunctions", "functions", "directives"], outputs: ["stateChange"] }] });
|
|
347
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.25", type: JsonRenderActivity, isStandalone: true, selector: "json-render-activity", inputs: { activityType: { classPropertyName: "activityType", publicName: "activityType", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, agent: { classPropertyName: "agent", publicName: "agent", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<json-render [spec]="spec()" [loading]="streaming()" />`, isInline: true, dependencies: [{ kind: "component", type: JsonRenderer, selector: "json-render", inputs: ["spec", "registry", "loading", "fallback", "validate", "renderLimits", "catalog", "state", "store", "handlers", "onAction", "navigate", "validationFunctions", "functions", "directives"], outputs: ["stateChange"] }] });
|
|
258
348
|
}
|
|
259
349
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: JsonRenderActivity, decorators: [{
|
|
260
350
|
type: Component,
|
|
261
351
|
args: [{
|
|
262
352
|
selector: 'json-render-activity',
|
|
263
353
|
imports: [JsonRenderer],
|
|
264
|
-
template: `<json-render [spec]="spec()" />`,
|
|
354
|
+
template: `<json-render [spec]="spec()" [loading]="streaming()" />`,
|
|
265
355
|
}]
|
|
266
|
-
}], propDecorators: { activityType: [{ type: i0.Input, args: [{ isSignal: true, alias: "activityType", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], agent: [{ type: i0.Input, args: [{ isSignal: true, alias: "agent", required: false }] }] } });
|
|
356
|
+
}], ctorParameters: () => [], propDecorators: { activityType: [{ type: i0.Input, args: [{ isSignal: true, alias: "activityType", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], agent: [{ type: i0.Input, args: [{ isSignal: true, alias: "agent", required: false }] }] } });
|
|
267
357
|
/**
|
|
268
358
|
* Teach a CopilotKit Angular app to render json-render activities:
|
|
269
359
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-json-render-ag-ui.mjs","sources":["../../../projects/ngx-json-render/ag-ui/src/events.ts","../../../projects/ngx-json-render/ag-ui/src/agent-ui.ts","../../../projects/ngx-json-render/ag-ui/src/json-render-activity.ts","../../../projects/ngx-json-render/ag-ui/src/public-api.ts","../../../projects/ngx-json-render/ag-ui/src/ngx-json-render-ag-ui.ts"],"sourcesContent":["import type { JsonPatch, Spec } from '@json-render/core';\nimport { applyPatch } from 'ngx-json-render';\n\n/**\n * The `activityType` a json-render spec travels under.\n *\n * An agent sends the spec as an AG-UI activity: `ACTIVITY_SNAPSHOT` carries a\n * whole spec in `content`, and `ACTIVITY_DELTA` carries RFC 6902 patches\n * against it in `patch` — the same patches a json-render JSONL stream is made\n * of. CopilotKit carries A2UI the same way, under `\"a2ui-surface\"`.\n *\n * The name says both the format and what `content` holds — a `Spec`, the\n * object upstream calls a spec in its AI SDK part type `data-spec` — so a\n * renderer for another framework can match it without reading these docs.\n */\nexport const JSON_RENDER_ACTIVITY_TYPE = 'json-render-spec';\n\n/**\n * The part of an AG-UI event this entry point reads.\n *\n * Structural on purpose: `@ag-ui/core`'s `EventType` is a string enum, so its\n * events fit a `string` here, and nothing below needs the package at runtime\n * or pins its version.\n */\nexport interface AgUiEvent {\n readonly type: string;\n}\n\n/** The part of an AG-UI message this entry point reads. */\nexport interface AgUiMessage {\n readonly id: string;\n readonly role: string;\n}\n\n/** One spec an agent is building, keyed by its activity message. */\nexport interface AgUiSurface {\n /** The activity's `messageId`; one run can build several surfaces. */\n readonly messageId: string;\n readonly spec: Spec;\n}\n\nconst EMPTY_SPEC: Spec = { root: '', elements: {} };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Whether activity content has the shape of a spec. Only the shape: what the\n * elements say is the renderer's and the finished-spec check's business.\n */\nexport function isJsonRenderSpec(content: unknown): content is Spec {\n return (\n isRecord(content) &&\n typeof content['root'] === 'string' &&\n isRecord(content['elements'])\n );\n}\n\nfunction isPatch(value: unknown): value is JsonPatch {\n return (\n isRecord(value) &&\n typeof value['op'] === 'string' &&\n typeof value['path'] === 'string'\n );\n}\n\nfunction upsert(\n surfaces: readonly AgUiSurface[],\n messageId: string,\n spec: Spec,\n): readonly AgUiSurface[] {\n const index = surfaces.findIndex((s) => s.messageId === messageId);\n if (index === -1) return [...surfaces, { messageId, spec }];\n const next = [...surfaces];\n next[index] = { messageId, spec };\n return next;\n}\n\n/**\n * The surfaces an AG-UI message list holds, in message order.\n *\n * Used for `MESSAGES_SNAPSHOT` and to pick up the history an agent already\n * has when a hook attaches to it.\n */\nexport function surfacesFromMessages(\n messages: readonly AgUiMessage[],\n activityType: string = JSON_RENDER_ACTIVITY_TYPE,\n): readonly AgUiSurface[] {\n const surfaces: AgUiSurface[] = [];\n for (const message of messages) {\n const m = message as AgUiMessage & Record<string, unknown>;\n if (\n m.role === 'activity' &&\n m['activityType'] === activityType &&\n isJsonRenderSpec(m['content'])\n ) {\n surfaces.push({ messageId: m.id, spec: m['content'] });\n }\n }\n return surfaces;\n}\n\n/**\n * Fold one AG-UI event into the surfaces built so far.\n *\n * Returns the same array when the event does not concern json-render, so a\n * signal holding the result only notifies on a real change. A delta applies\n * through the same immutable patch engine as a JSONL stream: elements it does\n * not touch keep their identity, and the renderer skips them.\n *\n * Two leniencies, both in the direction of rendering what arrived:\n * - a delta for a surface no snapshot has opened starts from an empty spec,\n * so an agent can stream patches the way a JSONL endpoint does;\n * - a malformed patch op is dropped rather than failing the surface.\n */\nexport function applyAgUiEvent(\n surfaces: readonly AgUiSurface[],\n event: AgUiEvent,\n activityType: string = JSON_RENDER_ACTIVITY_TYPE,\n): readonly AgUiSurface[] {\n const e = event as AgUiEvent & Record<string, unknown>;\n switch (e.type) {\n case 'ACTIVITY_SNAPSHOT': {\n const messageId = e['messageId'];\n if (typeof messageId !== 'string' || e['activityType'] !== activityType) {\n return surfaces;\n }\n const content = e['content'];\n if (!isJsonRenderSpec(content)) return surfaces;\n // `replace: false` means \"only if new\": the client already has a\n // version of this surface it should keep.\n if (\n e['replace'] === false &&\n surfaces.some((s) => s.messageId === messageId)\n ) {\n return surfaces;\n }\n return upsert(surfaces, messageId, content);\n }\n case 'ACTIVITY_DELTA': {\n const messageId = e['messageId'];\n const patch = e['patch'];\n if (\n typeof messageId !== 'string' ||\n e['activityType'] !== activityType ||\n !Array.isArray(patch)\n ) {\n return surfaces;\n }\n const current =\n surfaces.find((s) => s.messageId === messageId)?.spec ?? EMPTY_SPEC;\n let spec = current;\n for (const op of patch) {\n if (isPatch(op)) spec = applyPatch(spec, op);\n }\n return spec === current ? surfaces : upsert(surfaces, messageId, spec);\n }\n case 'MESSAGES_SNAPSHOT': {\n const messages = e['messages'];\n if (!Array.isArray(messages)) return surfaces;\n // AG-UI's rule: a snapshot that carries any activity message carries\n // all of them, and one that carries none leaves the client's alone.\n const carriesActivities = messages.some(\n (m) => isRecord(m) && m['role'] === 'activity',\n );\n if (!carriesActivities) return surfaces;\n return surfacesFromMessages(messages as AgUiMessage[], activityType);\n }\n default:\n return surfaces;\n }\n}\n","import {\n DestroyRef,\n type Signal,\n computed,\n inject,\n signal,\n} from '@angular/core';\nimport type { Spec } from '@json-render/core';\nimport {\n type RenderLimits,\n type SpecCatalog,\n type SpecCheckIssue,\n type SpecValidationMode,\n checkSpec,\n formatSpecCheckIssues,\n} from 'ngx-json-render';\nimport {\n type AgUiEvent,\n type AgUiMessage,\n type AgUiSurface,\n JSON_RENDER_ACTIVITY_TYPE,\n applyAgUiEvent,\n surfacesFromMessages,\n} from './events';\n\n/**\n * The callbacks of an AG-UI subscriber this entry point uses — a subset of\n * `@ag-ui/client`'s `AgentSubscriber`.\n */\nexport interface AgUiSubscriber {\n onRunInitialized?(): void;\n onEvent?(params: { event: AgUiEvent }): void;\n onRunErrorEvent?(params: { event: { message: string } }): void;\n onRunFailed?(params: { error: Error }): void;\n onRunFinalized?(): void;\n}\n\n/**\n * What {@link injectAgentUI} needs of an agent. Any `@ag-ui/client` agent —\n * `HttpAgent`, a subclass of `AbstractAgent`, the agent CopilotKit hands out —\n * already has this shape.\n */\nexport interface AgUiAgent {\n readonly messages?: readonly AgUiMessage[];\n subscribe(subscriber: AgUiSubscriber): { unsubscribe(): void };\n}\n\n/** Options for {@link injectAgentUI}. */\nexport interface AgentUIOptions {\n /** The agent whose runs build the UI. The app runs it; the hook listens. */\n agent: AgUiAgent;\n /** Defaults to {@link JSON_RENDER_ACTIVITY_TYPE}. */\n activityType?: string;\n /**\n * Called once per surface a run touched, after the finished-spec check.\n * Skipped for a run that failed, and for a surface the check rejected.\n */\n onComplete?: (spec: Spec, messageId: string) => void;\n /** Called when a run fails or a finished surface fails the check. */\n onError?: (error: Error) => void;\n /** As for `injectUIStream`: checked once per surface, when the run ends. */\n validate?: SpecValidationMode;\n /** As for `injectUIStream`; enforced whatever `validate` is. */\n renderLimits?: RenderLimits | null;\n /** As for `injectUIStream`: lets `validate` check types and props. */\n catalog?: SpecCatalog | null;\n}\n\n/** Return type of {@link injectAgentUI}. */\nexport interface AgentUIReturn {\n /** Every json-render surface the agent has built, in order of appearance. */\n readonly surfaces: Signal<readonly AgUiSurface[]>;\n /** The most recently opened surface's spec — the one most apps render. */\n readonly spec: Signal<Spec | null>;\n /** Whether a run of the agent is in progress. */\n readonly isStreaming: Signal<boolean>;\n /** The last run's error, if any. */\n readonly error: Signal<Error | null>;\n /** What the check found in the surfaces the last run finished. */\n readonly issues: Signal<readonly SpecCheckIssue[]>;\n}\n\n/**\n * Render what an AG-UI agent streams. Subscribes to the agent, folds every\n * json-render activity it emits into signals, and checks each surface when\n * the run ends — the same contract as `injectUIStream`, with the agent in\n * place of the endpoint.\n *\n * The app keeps running the agent itself (`agent.runAgent()`, CopilotKit, a\n * reconnect); the hook only listens, so it sees every run, whoever starts it.\n * It starts from whatever surfaces are already in the agent's messages and\n * unsubscribes on destroy.\n *\n * @example\n * ```ts\n * export class AgentPage {\n * readonly agent = new HttpAgent({ url: '/api/agent' });\n * readonly ui = injectAgentUI({ agent: this.agent, catalog });\n * ask(text: string) {\n * this.agent.addMessage({ id: crypto.randomUUID(), role: 'user', content: text });\n * this.agent.runAgent();\n * }\n * }\n * // template:\n * // <json-render [spec]=\"ui.spec()\" [registry]=\"registry\" [loading]=\"ui.isStreaming()\" />\n * ```\n */\nexport function injectAgentUI(options: AgentUIOptions): AgentUIReturn {\n const activityType = options.activityType ?? JSON_RENDER_ACTIVITY_TYPE;\n const validate = options.validate ?? 'off';\n const checkOptions = {\n limits: options.renderLimits ?? null,\n catalog: options.catalog ?? null,\n };\n\n const surfaces = signal<readonly AgUiSurface[]>(\n surfacesFromMessages(options.agent.messages ?? [], activityType),\n );\n const isStreaming = signal(false);\n const error = signal<Error | null>(null);\n const issues = signal<readonly SpecCheckIssue[]>([]);\n\n // Per run: which surfaces it changed, and whether it already failed.\n let touched = new Set<string>();\n let failed = false;\n\n const fail = (err: Error) => {\n failed = true;\n error.set(err);\n options.onError?.(err);\n };\n\n const finish = () => {\n const found: SpecCheckIssue[] = [];\n let next = surfaces();\n for (const messageId of touched) {\n const surface = next.find((s) => s.messageId === messageId);\n if (!surface) continue; // a later MESSAGES_SNAPSHOT dropped it\n const check = checkSpec(surface.spec, validate, checkOptions);\n found.push(...check.issues);\n if (check.spec && check.spec !== surface.spec) {\n const fixed = check.spec;\n next = next.map((s) =>\n s.messageId === messageId ? { messageId, spec: fixed } : s,\n );\n }\n if (check.blocked || (validate === 'strict' && check.hasErrors)) {\n fail(\n new Error(\n `Generated spec failed validation:\\n${formatSpecCheckIssues(check.issues)}`,\n ),\n );\n continue;\n }\n options.onComplete?.(check.spec ?? surface.spec, messageId);\n }\n surfaces.set(next);\n issues.set(found);\n };\n\n const subscription = options.agent.subscribe({\n onRunInitialized() {\n touched = new Set();\n failed = false;\n isStreaming.set(true);\n error.set(null);\n issues.set([]);\n },\n onEvent({ event }) {\n const before = surfaces();\n const after = applyAgUiEvent(before, event, activityType);\n if (after === before) return;\n for (const surface of after) {\n if (!before.includes(surface)) touched.add(surface.messageId);\n }\n surfaces.set(after);\n },\n onRunErrorEvent({ event }) {\n fail(new Error(event.message));\n },\n onRunFailed({ error: err }) {\n // A RUN_ERROR event already reported this run; the client then fails\n // the run with the same message.\n if (!failed) fail(err instanceof Error ? err : new Error(String(err)));\n },\n onRunFinalized() {\n if (!failed) finish();\n isStreaming.set(false);\n },\n });\n\n inject(DestroyRef).onDestroy(() => subscription.unsubscribe());\n\n const spec = computed(() => surfaces().at(-1)?.spec ?? null);\n\n return {\n surfaces: surfaces.asReadonly(),\n spec,\n isStreaming: isStreaming.asReadonly(),\n error: error.asReadonly(),\n issues: issues.asReadonly(),\n };\n}\n","import { Component, type Type, computed, input } from '@angular/core';\nimport type { Spec } from '@json-render/core';\nimport { JsonRenderer } from 'ngx-json-render';\nimport { JSON_RENDER_ACTIVITY_TYPE, isJsonRenderSpec } from './events';\n\n/**\n * Renders one json-render activity message. It takes the inputs every AG-UI\n * activity renderer is given — CopilotKit Angular's `ActivityRenderer`\n * contract — and draws `content` with `<json-render>`, which takes its\n * registry, catalog and handlers from the nearest `provideJsonRender`.\n *\n * Register it with {@link jsonRenderActivityRenderer} rather than by hand.\n */\n@Component({\n selector: 'json-render-activity',\n imports: [JsonRenderer],\n template: `<json-render [spec]=\"spec()\" />`,\n})\nexport class JsonRenderActivity {\n readonly activityType = input<string>(JSON_RENDER_ACTIVITY_TYPE);\n readonly content = input.required<unknown>();\n /** The AG-UI activity message; unused, accepted for the contract. */\n readonly message = input<unknown>();\n /** The agent that produced it; unused, accepted for the contract. */\n readonly agent = input<unknown>();\n\n protected readonly spec = computed<Spec | null>(() => {\n const content = this.content();\n return isJsonRenderSpec(content) ? content : null;\n });\n}\n\n/** Options for {@link jsonRenderActivityRenderer}. */\nexport interface JsonRenderActivityRendererOptions {\n /** Defaults to {@link JSON_RENDER_ACTIVITY_TYPE}. */\n activityType?: string;\n /** Limit the renderer to one agent's activities. */\n agentId?: string;\n /** A component of your own in place of {@link JsonRenderActivity}. */\n component?: Type<unknown>;\n}\n\n/**\n * An activity renderer config in the shape CopilotKit Angular's\n * `renderActivityMessages` takes, matched structurally so this package does\n * not depend on CopilotKit.\n */\nexport interface JsonRenderActivityRendererConfig {\n activityType: string;\n agentId?: string;\n content: {\n safeParse(\n content: unknown,\n ): { success: true; data: Spec } | { success: false; error?: unknown };\n };\n component: Type<any>;\n}\n\n/**\n * Teach a CopilotKit Angular app to render json-render activities:\n *\n * ```ts\n * providers: [\n * provideJsonRender({ registry }),\n * provideCopilotKit({\n * runtimeUrl: '/api/copilotkit',\n * renderActivityMessages: [jsonRenderActivityRenderer()],\n * }),\n * ]\n * ```\n *\n * Content that is not a spec is rejected by the config's schema, so CopilotKit\n * skips the message with a warning instead of mounting an empty renderer.\n */\nexport function jsonRenderActivityRenderer(\n options: JsonRenderActivityRendererOptions = {},\n): JsonRenderActivityRendererConfig {\n return {\n activityType: options.activityType ?? JSON_RENDER_ACTIVITY_TYPE,\n ...(options.agentId !== undefined ? { agentId: options.agentId } : {}),\n content: {\n safeParse: (content) =>\n isJsonRenderSpec(content)\n ? { success: true, data: content }\n : {\n success: false,\n error: new Error(\n 'Activity content is not a json-render spec: expected { root: string, elements: object }.',\n ),\n },\n },\n component: options.component ?? JsonRenderActivity,\n };\n}\n","/*\n * Public API Surface of ngx-json-render/ag-ui\n */\n\nexport {\n JSON_RENDER_ACTIVITY_TYPE,\n applyAgUiEvent,\n isJsonRenderSpec,\n surfacesFromMessages,\n type AgUiEvent,\n type AgUiMessage,\n type AgUiSurface,\n} from './events';\nexport {\n injectAgentUI,\n type AgUiAgent,\n type AgUiSubscriber,\n type AgentUIOptions,\n type AgentUIReturn,\n} from './agent-ui';\nexport {\n JsonRenderActivity,\n jsonRenderActivityRenderer,\n type JsonRenderActivityRendererConfig,\n type JsonRenderActivityRendererOptions,\n} from './json-render-activity';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAGA;;;;;;;;;;;AAWG;AACI,MAAM,yBAAyB,GAAG;AA0BzC,MAAM,UAAU,GAAS,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;AAEnD,SAAS,QAAQ,CAAC,KAAc,EAAA;AAC9B,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAC7E;AAEA;;;AAGG;AACG,SAAU,gBAAgB,CAAC,OAAgB,EAAA;AAC/C,IAAA,QACE,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,QAAQ;AACnC,QAAA,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAEjC;AAEA,SAAS,OAAO,CAAC,KAAc,EAAA;AAC7B,IAAA,QACE,QAAQ,CAAC,KAAK,CAAC;AACf,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ;AAC/B,QAAA,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ;AAErC;AAEA,SAAS,MAAM,CACb,QAAgC,EAChC,SAAiB,EACjB,IAAU,EAAA;AAEV,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CA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AC5C,iBAAA;;AAyCD;;;;;;;;;;;;;;;AAeG;AACG,SAAU,0BAA0B,CACxC,OAAA,GAA6C,EAAE,EAAA;IAE/C,OAAO;AACL,QAAA,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,yBAAyB;QAC/D,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;AACtE,QAAA,OAAO,EAAE;YACP,SAAS,EAAE,CAAC,OAAO,KACjB,gBAAgB,CAAC,OAAO;kBACpB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO;AAChC,kBAAE;AACE,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,KAAK,EAAE,IAAI,KAAK,CACd,0FAA0F,CAC3F;AACF,iBAAA;AACR,SAAA;AACD,QAAA,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,kBAAkB;KACnD;AACH;;AC7FA;;AAEG;;ACFH;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"ngx-json-render-ag-ui.mjs","sources":["../../../projects/ngx-json-render/ag-ui/src/events.ts","../../../projects/ngx-json-render/ag-ui/src/agent-ui.ts","../../../projects/ngx-json-render/ag-ui/src/json-render-activity.ts","../../../projects/ngx-json-render/ag-ui/src/public-api.ts","../../../projects/ngx-json-render/ag-ui/src/ngx-json-render-ag-ui.ts"],"sourcesContent":["import type { JsonPatch, Spec } from '@json-render/core';\nimport { applyPatch } from 'ngx-json-render';\n\n/**\n * The `activityType` a json-render spec travels under.\n *\n * An agent sends the spec as an AG-UI activity: `ACTIVITY_SNAPSHOT` carries a\n * whole spec in `content`, and `ACTIVITY_DELTA` carries RFC 6902 patches\n * against it in `patch` — the same patches a json-render JSONL stream is made\n * of. CopilotKit carries A2UI the same way, under `\"a2ui-surface\"`.\n *\n * The name says both the format and what `content` holds — a `Spec`, the\n * object upstream calls a spec in its AI SDK part type `data-spec` — so a\n * renderer for another framework can match it without reading these docs.\n */\nexport const JSON_RENDER_ACTIVITY_TYPE = 'json-render-spec';\n\n/**\n * The part of an AG-UI event this entry point reads.\n *\n * Structural on purpose: `@ag-ui/core`'s `EventType` is a string enum, so its\n * events fit a `string` here, and nothing below needs the package at runtime\n * or pins its version.\n */\nexport interface AgUiEvent {\n readonly type: string;\n}\n\n/** The part of an AG-UI message this entry point reads. */\nexport interface AgUiMessage {\n readonly id: string;\n readonly role: string;\n}\n\n/** One spec an agent is building, keyed by its activity message. */\nexport interface AgUiSurface {\n /** The activity's `messageId`; one run can build several surfaces. */\n readonly messageId: string;\n readonly spec: Spec;\n}\n\nconst EMPTY_SPEC: Spec = { root: '', elements: {} };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Whether activity content has the shape of a spec. Only the shape: what the\n * elements say is the renderer's and the finished-spec check's business.\n */\nexport function isJsonRenderSpec(content: unknown): content is Spec {\n return (\n isRecord(content) &&\n typeof content['root'] === 'string' &&\n isRecord(content['elements'])\n );\n}\n\nfunction isPatch(value: unknown): value is JsonPatch {\n return (\n isRecord(value) &&\n typeof value['op'] === 'string' &&\n typeof value['path'] === 'string'\n );\n}\n\nfunction upsert(\n surfaces: readonly AgUiSurface[],\n messageId: string,\n spec: Spec,\n): readonly AgUiSurface[] {\n const index = surfaces.findIndex((s) => s.messageId === messageId);\n if (index === -1) return [...surfaces, { messageId, spec }];\n const next = [...surfaces];\n next[index] = { messageId, spec };\n return next;\n}\n\n/**\n * The surfaces an AG-UI message list holds, in message order.\n *\n * Used for `MESSAGES_SNAPSHOT` and to pick up the history an agent already\n * has when a hook attaches to it.\n */\nexport function surfacesFromMessages(\n messages: readonly AgUiMessage[],\n activityType: string = JSON_RENDER_ACTIVITY_TYPE,\n): readonly AgUiSurface[] {\n const surfaces: AgUiSurface[] = [];\n for (const message of messages) {\n const m = message as AgUiMessage & Record<string, unknown>;\n if (\n m.role === 'activity' &&\n m['activityType'] === activityType &&\n isJsonRenderSpec(m['content'])\n ) {\n surfaces.push({ messageId: m.id, spec: m['content'] });\n }\n }\n return surfaces;\n}\n\n/**\n * Fold one AG-UI event into the surfaces built so far.\n *\n * Returns the same array when the event does not concern json-render, so a\n * signal holding the result only notifies on a real change. A delta applies\n * through the same immutable patch engine as a JSONL stream: elements it does\n * not touch keep their identity, and the renderer skips them.\n *\n * Two leniencies, both in the direction of rendering what arrived:\n * - a delta for a surface no snapshot has opened starts from an empty spec,\n * so an agent can stream patches the way a JSONL endpoint does;\n * - a malformed patch op is dropped rather than failing the surface.\n */\nexport function applyAgUiEvent(\n surfaces: readonly AgUiSurface[],\n event: AgUiEvent,\n activityType: string = JSON_RENDER_ACTIVITY_TYPE,\n): readonly AgUiSurface[] {\n const e = event as AgUiEvent & Record<string, unknown>;\n switch (e.type) {\n case 'ACTIVITY_SNAPSHOT': {\n const messageId = e['messageId'];\n if (typeof messageId !== 'string' || e['activityType'] !== activityType) {\n return surfaces;\n }\n const content = e['content'];\n if (!isJsonRenderSpec(content)) return surfaces;\n // `replace: false` means \"only if new\": the client already has a\n // version of this surface it should keep.\n if (\n e['replace'] === false &&\n surfaces.some((s) => s.messageId === messageId)\n ) {\n return surfaces;\n }\n return upsert(surfaces, messageId, content);\n }\n case 'ACTIVITY_DELTA': {\n const messageId = e['messageId'];\n const patch = e['patch'];\n if (\n typeof messageId !== 'string' ||\n e['activityType'] !== activityType ||\n !Array.isArray(patch)\n ) {\n return surfaces;\n }\n const current =\n surfaces.find((s) => s.messageId === messageId)?.spec ?? EMPTY_SPEC;\n let spec = current;\n for (const op of patch) {\n if (isPatch(op)) spec = applyPatch(spec, op);\n }\n return spec === current ? surfaces : upsert(surfaces, messageId, spec);\n }\n case 'MESSAGES_SNAPSHOT': {\n const messages = e['messages'];\n if (!Array.isArray(messages)) return surfaces;\n // AG-UI's rule: a snapshot that carries any activity message carries\n // all of them, and one that carries none leaves the client's alone.\n const carriesActivities = messages.some(\n (m) => isRecord(m) && m['role'] === 'activity',\n );\n if (!carriesActivities) return surfaces;\n return surfacesFromMessages(messages as AgUiMessage[], activityType);\n }\n default:\n return surfaces;\n }\n}\n","import {\n DestroyRef,\n type Signal,\n computed,\n inject,\n signal,\n} from '@angular/core';\nimport type { Spec } from '@json-render/core';\nimport {\n type RenderLimits,\n type SpecCatalog,\n type SpecCheckIssue,\n type SpecValidationMode,\n checkSpec,\n formatSpecCheckIssues,\n} from 'ngx-json-render';\nimport {\n type AgUiEvent,\n type AgUiMessage,\n type AgUiSurface,\n JSON_RENDER_ACTIVITY_TYPE,\n applyAgUiEvent,\n surfacesFromMessages,\n} from './events';\n\n/**\n * The callbacks of an AG-UI subscriber this entry point uses — a subset of\n * `@ag-ui/client`'s `AgentSubscriber`.\n */\nexport interface AgUiSubscriber {\n onRunInitialized?(): void;\n onEvent?(params: { event: AgUiEvent }): void;\n onRunErrorEvent?(params: { event: { message: string } }): void;\n onRunFailed?(params: { error: Error }): void;\n onRunFinalized?(): void;\n}\n\n/**\n * What {@link injectAgentUI} needs of an agent. Any `@ag-ui/client` agent —\n * `HttpAgent`, a subclass of `AbstractAgent`, the agent CopilotKit hands out —\n * already has this shape.\n */\nexport interface AgUiAgent {\n readonly messages?: readonly AgUiMessage[];\n subscribe(subscriber: AgUiSubscriber): { unsubscribe(): void };\n}\n\n/** Options for {@link injectAgentUI}. */\nexport interface AgentUIOptions {\n /** The agent whose runs build the UI. The app runs it; the hook listens. */\n agent: AgUiAgent;\n /** Defaults to {@link JSON_RENDER_ACTIVITY_TYPE}. */\n activityType?: string;\n /**\n * Called once per surface a run touched, after the finished-spec check.\n * Skipped for a run that failed, and for a surface the check rejected.\n */\n onComplete?: (spec: Spec, messageId: string) => void;\n /** Called when a run fails or a finished surface fails the check. */\n onError?: (error: Error) => void;\n /** As for `injectUIStream`: checked once per surface, when the run ends. */\n validate?: SpecValidationMode;\n /** As for `injectUIStream`; enforced whatever `validate` is. */\n renderLimits?: RenderLimits | null;\n /** As for `injectUIStream`: lets `validate` check types and props. */\n catalog?: SpecCatalog | null;\n}\n\n/** Return type of {@link injectAgentUI}. */\nexport interface AgentUIReturn {\n /** Every json-render surface the agent has built, in order of appearance. */\n readonly surfaces: Signal<readonly AgUiSurface[]>;\n /** The most recently opened surface's spec — the one most apps render. */\n readonly spec: Signal<Spec | null>;\n /** Whether a run of the agent is in progress. */\n readonly isStreaming: Signal<boolean>;\n /** The last run's error, if any. */\n readonly error: Signal<Error | null>;\n /** What the check found in the surfaces the last run finished. */\n readonly issues: Signal<readonly SpecCheckIssue[]>;\n}\n\n/**\n * Render what an AG-UI agent streams. Subscribes to the agent, folds every\n * json-render activity it emits into signals, and checks each surface when\n * the run ends — the same contract as `injectUIStream`, with the agent in\n * place of the endpoint.\n *\n * The app keeps running the agent itself (`agent.runAgent()`, CopilotKit, a\n * reconnect); the hook only listens, so it sees every run, whoever starts it.\n * It starts from whatever surfaces are already in the agent's messages and\n * unsubscribes on destroy.\n *\n * @example\n * ```ts\n * export class AgentPage {\n * readonly agent = new HttpAgent({ url: '/api/agent' });\n * readonly ui = injectAgentUI({ agent: this.agent, catalog });\n * ask(text: string) {\n * this.agent.addMessage({ id: crypto.randomUUID(), role: 'user', content: text });\n * this.agent.runAgent();\n * }\n * }\n * // template:\n * // <json-render [spec]=\"ui.spec()\" [registry]=\"registry\" [loading]=\"ui.isStreaming()\" />\n * ```\n */\nexport function injectAgentUI(options: AgentUIOptions): AgentUIReturn {\n const activityType = options.activityType ?? JSON_RENDER_ACTIVITY_TYPE;\n const validate = options.validate ?? 'off';\n const checkOptions = {\n limits: options.renderLimits ?? null,\n catalog: options.catalog ?? null,\n };\n\n const surfaces = signal<readonly AgUiSurface[]>(\n surfacesFromMessages(options.agent.messages ?? [], activityType),\n );\n const isStreaming = signal(false);\n const error = signal<Error | null>(null);\n const issues = signal<readonly SpecCheckIssue[]>([]);\n\n // Per run: which surfaces it changed, and whether it already failed.\n let touched = new Set<string>();\n let failed = false;\n\n const fail = (err: Error) => {\n failed = true;\n error.set(err);\n options.onError?.(err);\n };\n\n const finish = () => {\n const found: SpecCheckIssue[] = [];\n let next = surfaces();\n for (const messageId of touched) {\n const surface = next.find((s) => s.messageId === messageId);\n if (!surface) continue; // a later MESSAGES_SNAPSHOT dropped it\n const check = checkSpec(surface.spec, validate, checkOptions);\n found.push(...check.issues);\n if (check.spec && check.spec !== surface.spec) {\n const fixed = check.spec;\n next = next.map((s) =>\n s.messageId === messageId ? { messageId, spec: fixed } : s,\n );\n }\n if (check.blocked || (validate === 'strict' && check.hasErrors)) {\n fail(\n new Error(\n `Generated spec failed validation:\\n${formatSpecCheckIssues(check.issues)}`,\n ),\n );\n continue;\n }\n options.onComplete?.(check.spec ?? surface.spec, messageId);\n }\n surfaces.set(next);\n issues.set(found);\n };\n\n const subscription = options.agent.subscribe({\n onRunInitialized() {\n touched = new Set();\n failed = false;\n isStreaming.set(true);\n error.set(null);\n issues.set([]);\n },\n onEvent({ event }) {\n const before = surfaces();\n const after = applyAgUiEvent(before, event, activityType);\n if (after === before) return;\n for (const surface of after) {\n if (!before.includes(surface)) touched.add(surface.messageId);\n }\n surfaces.set(after);\n },\n onRunErrorEvent({ event }) {\n fail(new Error(event.message));\n },\n onRunFailed({ error: err }) {\n // A RUN_ERROR event already reported this run; the client then fails\n // the run with the same message.\n if (!failed) fail(err instanceof Error ? err : new Error(String(err)));\n },\n onRunFinalized() {\n if (!failed) finish();\n isStreaming.set(false);\n },\n });\n\n inject(DestroyRef).onDestroy(() => subscription.unsubscribe());\n\n const spec = computed(() => surfaces().at(-1)?.spec ?? null);\n\n return {\n surfaces: surfaces.asReadonly(),\n spec,\n isStreaming: isStreaming.asReadonly(),\n error: error.asReadonly(),\n issues: issues.asReadonly(),\n };\n}\n","import {\n Component,\n type Type,\n computed,\n effect,\n input,\n signal,\n untracked,\n} from '@angular/core';\nimport type { Spec } from '@json-render/core';\nimport { JsonRenderer } from 'ngx-json-render';\nimport type { AgUiAgent, AgUiSubscriber } from './agent-ui';\nimport { JSON_RENDER_ACTIVITY_TYPE, isJsonRenderSpec } from './events';\n\n/**\n * What {@link JsonRenderActivity} reads of the agent CopilotKit hands it. An\n * `@ag-ui/client` `AbstractAgent` has this shape; anything else is ignored.\n */\ninterface ActivityAgent extends AgUiAgent {\n readonly isRunning?: boolean;\n}\n\n/** How often a streaming activity looks whether its run has ended. */\nconst RUN_END_POLL_MS = 250;\n\nfunction isActivityAgent(agent: unknown): agent is ActivityAgent {\n return (\n typeof agent === 'object' &&\n agent !== null &&\n typeof (agent as { subscribe?: unknown }).subscribe === 'function'\n );\n}\n\nfunction messageIdOf(message: unknown): string | undefined {\n const id = (message as { id?: unknown } | null | undefined)?.id;\n return typeof id === 'string' ? id : undefined;\n}\n\n/**\n * Whether a message comes after the thread's last user message — that is,\n * belongs to the turn now being answered.\n */\nfunction inLatestTurn(agent: ActivityAgent, messageId: string): boolean {\n const messages = agent.messages;\n if (!messages) return true;\n const index = messages.findIndex((m) => m.id === messageId);\n if (index === -1) return true;\n for (let i = messages.length - 1; i > index; i--) {\n if (messages[i]!.role === 'user') return false;\n }\n return true;\n}\n\n/**\n * Renders one json-render activity message. It takes the inputs every AG-UI\n * activity renderer is given — CopilotKit Angular's `ActivityRenderer`\n * contract — and draws `content` with `<json-render>`, which takes its\n * registry, catalog and handlers from the nearest `provideJsonRender`.\n *\n * While the agent's current run is still streaming into this activity, the\n * renderer is told it is loading, as `injectUIStream` tells it: the spec is\n * checked once the run ends, not at every patch, and the catalog holds back\n * elements whose props have not arrived yet. Streaming is tracked per\n * message — a run that sends this activity a snapshot or a delta — so an\n * activity already on screen stays checked while a later run builds another.\n * Without an `agent` input the renderer is never loading.\n *\n * Register it with {@link jsonRenderActivityRenderer} rather than by hand.\n */\n@Component({\n selector: 'json-render-activity',\n imports: [JsonRenderer],\n template: `<json-render [spec]=\"spec()\" [loading]=\"streaming()\" />`,\n})\nexport class JsonRenderActivity {\n readonly activityType = input<string>(JSON_RENDER_ACTIVITY_TYPE);\n readonly content = input.required<unknown>();\n /** The AG-UI activity message; its `id` matches the agent's events. */\n readonly message = input<unknown>();\n /** The agent that produced it; its runs decide when the spec is final. */\n readonly agent = input<unknown>();\n\n // CopilotKit hands every activity a fresh copy of its content on each event\n // of a run, its own or another's. An unchanged copy is the same spec: not\n // a reason to check it, and report what the check found, once more.\n protected readonly spec = computed<Spec | null>(\n () => {\n const content = this.content();\n return isJsonRenderSpec(content) ? content : null;\n },\n {\n equal: (a, b) =>\n a === b ||\n (a !== null && b !== null && JSON.stringify(a) === JSON.stringify(b)),\n },\n );\n\n /** Whether the agent's current run is still streaming this activity. */\n protected readonly streaming = signal(false);\n\n constructor() {\n // `@ag-ui/client` fixes a run's subscribers when the run starts, and\n // CopilotKit mounts an activity at its first snapshot — mid-run — so the\n // subscription below never hears the end of the run that created it.\n // While streaming, the agent's `isRunning` flag is watched instead.\n effect((onCleanup) => {\n const agent = this.agent();\n if (\n !this.streaming() ||\n !isActivityAgent(agent) ||\n typeof agent.isRunning !== 'boolean'\n ) {\n return;\n }\n const timer = setInterval(() => {\n if (!agent.isRunning) this.streaming.set(false);\n }, RUN_END_POLL_MS);\n onCleanup(() => clearInterval(timer));\n });\n\n effect((onCleanup) => {\n const agent = this.agent();\n if (!isActivityAgent(agent)) {\n this.streaming.set(false);\n return;\n }\n const ownId = () => untracked(() => messageIdOf(this.message()));\n // CopilotKit mounts an activity when its first snapshot arrives, so a\n // run already in progress is, as a rule, the one streaming it — unless\n // the message belongs to an earlier turn and was mounted again.\n untracked(() => {\n const id = ownId();\n this.streaming.set(\n agent.isRunning === true &&\n (id === undefined || inLatestTurn(agent, id)),\n );\n });\n const subscriber: AgUiSubscriber = {\n onRunInitialized: () => this.streaming.set(false),\n onEvent: ({ event }) => {\n if (\n (event.type === 'ACTIVITY_SNAPSHOT' ||\n event.type === 'ACTIVITY_DELTA') &&\n (event as { messageId?: unknown }).messageId === ownId()\n ) {\n this.streaming.set(true);\n }\n },\n onRunFinalized: () => this.streaming.set(false),\n };\n const subscription = agent.subscribe(subscriber);\n onCleanup(() => subscription.unsubscribe());\n });\n }\n}\n\n/** Options for {@link jsonRenderActivityRenderer}. */\nexport interface JsonRenderActivityRendererOptions {\n /** Defaults to {@link JSON_RENDER_ACTIVITY_TYPE}. */\n activityType?: string;\n /** Limit the renderer to one agent's activities. */\n agentId?: string;\n /** A component of your own in place of {@link JsonRenderActivity}. */\n component?: Type<unknown>;\n}\n\n/**\n * An activity renderer config in the shape CopilotKit Angular's\n * `renderActivityMessages` takes, matched structurally so this package does\n * not depend on CopilotKit.\n */\nexport interface JsonRenderActivityRendererConfig {\n activityType: string;\n agentId?: string;\n content: {\n safeParse(\n content: unknown,\n ): { success: true; data: Spec } | { success: false; error?: unknown };\n };\n component: Type<any>;\n}\n\n/**\n * Teach a CopilotKit Angular app to render json-render activities:\n *\n * ```ts\n * providers: [\n * provideJsonRender({ registry }),\n * provideCopilotKit({\n * runtimeUrl: '/api/copilotkit',\n * renderActivityMessages: [jsonRenderActivityRenderer()],\n * }),\n * ]\n * ```\n *\n * Content that is not a spec is rejected by the config's schema, so CopilotKit\n * skips the message with a warning instead of mounting an empty renderer.\n */\nexport function jsonRenderActivityRenderer(\n options: JsonRenderActivityRendererOptions = {},\n): JsonRenderActivityRendererConfig {\n return {\n activityType: options.activityType ?? JSON_RENDER_ACTIVITY_TYPE,\n ...(options.agentId !== undefined ? { agentId: options.agentId } : {}),\n content: {\n safeParse: (content) =>\n isJsonRenderSpec(content)\n ? { success: true, data: content }\n : {\n success: false,\n error: new Error(\n 'Activity content is not a json-render spec: expected { root: string, elements: object }.',\n ),\n },\n },\n component: options.component ?? JsonRenderActivity,\n };\n}\n","/*\n * Public API Surface of ngx-json-render/ag-ui\n */\n\nexport {\n JSON_RENDER_ACTIVITY_TYPE,\n applyAgUiEvent,\n isJsonRenderSpec,\n surfacesFromMessages,\n type AgUiEvent,\n type AgUiMessage,\n type AgUiSurface,\n} from './events';\nexport {\n injectAgentUI,\n type AgUiAgent,\n type AgUiSubscriber,\n type AgentUIOptions,\n type AgentUIReturn,\n} from './agent-ui';\nexport {\n JsonRenderActivity,\n jsonRenderActivityRenderer,\n type JsonRenderActivityRendererConfig,\n type JsonRenderActivityRendererOptions,\n} from './json-render-activity';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAGA;;;;;;;;;;;AAWG;AACI,MAAM,yBAAyB,GAAG;AA0BzC,MAAM,UAAU,GAAS,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;AAEnD,SAAS,QAAQ,CAAC,KAAc,EAAA;AAC9B,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAC7E;AAEA;;;AAGG;AACG,SAAU,gBAAgB,CAAC,OAAgB,EAAA;AAC/C,IAAA,QACE,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,QAAQ;AACnC,QAAA,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAEjC;AAEA,SAAS,OAAO,CAAC,KAAc,EAAA;AAC7B,IAAA,QACE,QAAQ,CAAC,KAAK,CAAC;AACf,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ;AAC/B,QAAA,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ;AAErC;AAEA,SAAS,MAAM,CACb,QAAgC,EAChC,SAAiB,EACjB,IAAU,EAAA;AAEV,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC;IAClE,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,CAAC,GAAG,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC3D,IAAA,MAAM,IAAI,GAAG,C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AAA,EAAA,OAAA,EAAA,OAAA,EAAA,UAAA,EAAA,UAAA,EAAA,UAAA,EAAA,qBAAA,EAAA,WAAA,EAAA,YAAA,CAAA,EAAA,OAAA,EAAA,CAAA,aAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;4FAGX,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,sBAAsB;oBAChC,OAAO,EAAE,CAAC,YAAY,CAAC;AACvB,oBAAA,QAAQ,EAAE,CAAA,uDAAA,CAAyD;AACpE,iBAAA;;AA6GD;;;;;;;;;;;;;;;AAeG;AACG,SAAU,0BAA0B,CACxC,OAAA,GAA6C,EAAE,EAAA;IAE/C,OAAO;AACL,QAAA,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,yBAAyB;QAC/D,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;AACtE,QAAA,OAAO,EAAE;YACP,SAAS,EAAE,CAAC,OAAO,KACjB,gBAAgB,CAAC,OAAO;kBACpB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO;AAChC,kBAAE;AACE,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,KAAK,EAAE,IAAI,KAAK,CACd,0FAA0F,CAC3F;AACF,iBAAA;AACR,SAAA;AACD,QAAA,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,kBAAkB;KACnD;AACH;;ACzNA;;AAEG;;ACFH;;AAEG;;"}
|
package/package.json
CHANGED
|
@@ -160,16 +160,27 @@ declare function injectAgentUI(options: AgentUIOptions): AgentUIReturn;
|
|
|
160
160
|
* contract — and draws `content` with `<json-render>`, which takes its
|
|
161
161
|
* registry, catalog and handlers from the nearest `provideJsonRender`.
|
|
162
162
|
*
|
|
163
|
+
* While the agent's current run is still streaming into this activity, the
|
|
164
|
+
* renderer is told it is loading, as `injectUIStream` tells it: the spec is
|
|
165
|
+
* checked once the run ends, not at every patch, and the catalog holds back
|
|
166
|
+
* elements whose props have not arrived yet. Streaming is tracked per
|
|
167
|
+
* message — a run that sends this activity a snapshot or a delta — so an
|
|
168
|
+
* activity already on screen stays checked while a later run builds another.
|
|
169
|
+
* Without an `agent` input the renderer is never loading.
|
|
170
|
+
*
|
|
163
171
|
* Register it with {@link jsonRenderActivityRenderer} rather than by hand.
|
|
164
172
|
*/
|
|
165
173
|
declare class JsonRenderActivity {
|
|
166
174
|
readonly activityType: _angular_core.InputSignal<string>;
|
|
167
175
|
readonly content: _angular_core.InputSignal<unknown>;
|
|
168
|
-
/** The AG-UI activity message;
|
|
176
|
+
/** The AG-UI activity message; its `id` matches the agent's events. */
|
|
169
177
|
readonly message: _angular_core.InputSignal<unknown>;
|
|
170
|
-
/** The agent that produced it;
|
|
178
|
+
/** The agent that produced it; its runs decide when the spec is final. */
|
|
171
179
|
readonly agent: _angular_core.InputSignal<unknown>;
|
|
172
180
|
protected readonly spec: _angular_core.Signal<Spec | null>;
|
|
181
|
+
/** Whether the agent's current run is still streaming this activity. */
|
|
182
|
+
protected readonly streaming: _angular_core.WritableSignal<boolean>;
|
|
183
|
+
constructor();
|
|
173
184
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<JsonRenderActivity, never>;
|
|
174
185
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<JsonRenderActivity, "json-render-activity", never, { "activityType": { "alias": "activityType"; "required": false; "isSignal": true; }; "content": { "alias": "content"; "required": true; "isSignal": true; }; "message": { "alias": "message"; "required": false; "isSignal": true; }; "agent": { "alias": "agent"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
175
186
|
}
|