@meshmakers/octo-ai-console 3.5.780 → 3.5.800

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,1295 +1,1411 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, Injectable, InjectionToken, makeEnvironmentProviders, input, computed, ChangeDetectionStrategy, Component, output, signal } from '@angular/core';
3
- import { HttpClient, HttpParams } from '@angular/common/http';
4
- import { ReplaySubject, Subject } from 'rxjs';
5
- import { CommonModule } from '@angular/common';
6
- import * as i1 from '@angular/forms';
7
- import { FormsModule } from '@angular/forms';
8
-
9
- /**
10
- * Typed REST client for the AI Adapter's session endpoints. Every method maps
11
- * 1:1 to a controller route on the C# side
12
- * (`src/AiServices/TenantApi/v1/Controllers/SessionsController.cs`).
13
- *
14
- * The service does NOT cache responses or hold session state — each call is a
15
- * pure pass-through to `HttpClient`. Components that need a derived view (e.g.
16
- * a session list with status counts) should compose over the returned
17
- * observables themselves; that keeps the client free of UI concerns and lets
18
- * host apps mix Apollo / GraphQL state in the same component without dueling
19
- * caches.
20
- */
21
- /**
22
- * Not `providedIn: 'root'` — `AI_ADAPTER_OPTIONS` is provided per-route in host
23
- * apps (the tenant id is read from the route param, which the root injector
24
- * doesn't see). A root-provided service would resolve through the root injector
25
- * and fail with NG0201 on `AI_ADAPTER_OPTIONS`. Standalone components that
26
- * inject this service pick up the route-level provider via the element
27
- * injector hierarchy.
28
- */
29
- class AiAdapterClientService {
30
- http = inject(HttpClient);
31
- options = inject(AI_ADAPTER_OPTIONS);
32
- /**
33
- * `GET /{tenantId}/v1/sessions` — list all sessions for the configured tenant.
34
- * Optional `status` filter narrows to one lifecycle state when present.
35
- */
36
- listSessions(status) {
37
- const url = `${this.tenantBase()}/sessions`;
38
- let params = new HttpParams();
39
- if (status) {
40
- params = params.set('status', status);
41
- }
42
- return this.http.get(url, { params });
43
- }
44
- /** `GET /{tenantId}/v1/sessions/{sessionId}` — single session by rtId. */
45
- getSession(sessionId) {
46
- return this.http.get(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}`);
47
- }
48
- /**
49
- * `POST /{tenantId}/v1/sessions` — start a new session. Returns the persisted
50
- * session plus the quota gate's decision so the caller can render either a
51
- * "Running" pill or a "Queued (n)" pill without a second round-trip.
52
- */
53
- createSession(request) {
54
- return this.http.post(`${this.tenantBase()}/sessions`, request);
55
- }
56
- /**
57
- * `POST /{tenantId}/v1/sessions/{sessionId}/cancel` — request graceful
58
- * cancellation; the orchestrator transitions the session to `Cancelled`
59
- * once the worker has acknowledged.
60
- */
61
- cancelSession(sessionId) {
62
- return this.http.post(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/cancel`, null);
63
- }
64
- /**
65
- * `DELETE /{tenantId}/v1/sessions/{sessionId}` — hard-delete a terminal
66
- * session. The server refuses non-terminal sessions with HTTP 409 and the
67
- * <code>invalid_state_transition</code> error code, so callers should cancel
68
- * first when the session is still in flight. 204 on success; the response
69
- * has no body.
70
- */
71
- deleteSession(sessionId) {
72
- return this.http.delete(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}`);
73
- }
74
- /**
75
- * `POST /{tenantId}/v1/sessions/{sessionId}/messages` — append a follow-up
76
- * user turn to a `Completed` session. The adapter re-materialises the
77
- * workspace (fresh credential snapshot), recovers Claude's session id from
78
- * the persisted `system/init` event of the original turn, and spawns
79
- * <code>claude --resume &lt;id&gt;</code> so the conversation context
80
- * carries over. The next turn's events stream on the same SignalR channel
81
- * as the prior turn — there is no separate subscription to set up.
82
- *
83
- * Server response is 202 with the updated session DTO (status flipped back
84
- * to `Running`); the caller can use the returned status to drive an
85
- * optimistic UI update. Non-Completed sessions return 409 with
86
- * <code>invalid_state_transition</code>; a session whose first turn died
87
- * before claude emitted init returns 409 with
88
- * <code>claude_session_id_not_captured</code>.
89
- */
90
- sendMessage(sessionId, text) {
91
- return this.http.post(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/messages`, { text });
92
- }
93
- /**
94
- * `GET /{tenantId}/v1/sessions/{sessionId}/events?sinceSequence=N` — replay
95
- * persisted events for a session. UI uses this on reconnect to backfill any
96
- * events SignalR missed while disconnected (drives the resume-from-sequence
97
- * path in {@link AiSessionStreamService}).
98
- */
99
- listEvents(sessionId, sinceSequence) {
100
- const url = `${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/events`;
101
- let params = new HttpParams();
102
- if (sinceSequence != null) {
103
- params = params.set('sinceSequence', sinceSequence.toString());
104
- }
105
- return this.http.get(url, { params });
106
- }
107
- /**
108
- * `POST /{tenantId}/v1/sessions/{sessionId}/approvals/{requestId}` — submit
109
- * the user's decision on a paused approval gate. Server fans
110
- * `OnApprovalDecidedAsync` to every connection on the session.
111
- */
112
- decideApproval(sessionId, requestId, decision) {
113
- return this.http.post(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}` +
114
- `/approvals/${encodeURIComponent(requestId)}`, decision);
115
- }
116
- /**
117
- * `POST /{tenantId}/v1/credentials/tickets` — mint a one-time credential-
118
- * registration ticket (#4133). The admin sees the plaintext code once in
119
- * the response; the server stores only the SHA-256 hash. The matching
120
- * redemption call (`POST /v1/credentials/tickets/redeem`) is anonymous and
121
- * NOT in this client because the redeemer is by design a different person
122
- * on a different machine — they use the bastion CLI, not the Studio.
123
- */
124
- issueCredentialTicket(request) {
125
- return this.http.post(`${this.tenantBase()}/credentials/tickets`, request);
126
- }
127
- /**
128
- * `POST /{tenantId}/v1/credentials/github-pat` — register a GitHub Personal
129
- * Access Token (#4124). The adapter validates the token against GitHub's
130
- * `/user` endpoint before encryption; a refused token surfaces as HTTP 422
131
- * with `error: 'github_refused_token'`. The response is intentionally minimal
132
- * (`{ rtId }`); the host re-fetches the list so the rendering path stays
133
- * shared with refresh.
134
- */
135
- registerGitHubPat(request) {
136
- return this.http.post(`${this.tenantBase()}/credentials/github-pat`, request);
137
- }
138
- /**
139
- * `GET /{tenantId}/v1/credentials/github-pat` — list registered PATs with a
140
- * masked tail + GitHub login. Plaintext never crosses the wire.
141
- */
142
- listGitHubPats() {
143
- return this.http.get(`${this.tenantBase()}/credentials/github-pat`);
144
- }
145
- /**
146
- * `DELETE /{tenantId}/v1/credentials/github-pat/{rtId}` — revoke a PAT. The
147
- * ciphertext is deleted, not soft-tombstoned. Returns void on 204.
148
- */
149
- deleteGitHubPat(rtId) {
150
- return this.http.delete(`${this.tenantBase()}/credentials/github-pat/${encodeURIComponent(rtId)}`);
151
- }
152
- /**
153
- * `GET /{tenantId}/v1/app-templates` — list the Custom-App templates the
154
- * adapter exposes for the wizard (#4145). Phase-1 returns the same three
155
- * static entries for every tenant; the wire shape is stable so per-tenant
156
- * overrides can ride it without an SPA bump.
157
- */
158
- getAppTemplates() {
159
- return this.http.get(`${this.tenantBase()}/app-templates`);
160
- }
161
- tenantBase() {
162
- return `${this.options.baseUrl}/${encodeURIComponent(this.options.tenantId)}/v1`;
163
- }
164
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiAdapterClientService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
165
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiAdapterClientService });
166
- }
167
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiAdapterClientService, decorators: [{
168
- type: Injectable
169
- }] });
170
-
171
- /**
172
- * Internal wrapper around the SignalR connection. The library does not pin a
173
- * SignalR version — host applications inject a `HubConnectionBuilder` they
174
- * already use, which keeps the library agnostic of the
175
- * `@microsoft/signalr` major version line (six and seven have diverged on the
176
- * `withAutomaticReconnect()` defaults).
177
- *
178
- * For now the connection is constructed deferred — `streamSession` builds it on
179
- * demand so the host can defer the SignalR JS bundle behind a route lazy-load.
180
- * Phase-1 ships a stub backed by `ReplaySubject` so demo apps can drive
181
- * components without a live hub; the real connection wiring lives behind a
182
- * `connectionFactory` provider the host overrides.
183
- */
184
- /**
185
- * Not `providedIn: 'root'` — see <see cref="AiAdapterClientService"/> for the
186
- * rationale: `AI_ADAPTER_OPTIONS` is a per-route token, the root injector
187
- * cannot resolve it. Element-level injection picks up the route-level provider.
188
- */
189
- class AiSessionStreamService {
190
- options = inject(AI_ADAPTER_OPTIONS);
191
- client = inject(AiAdapterClientService);
192
- connectionFactory = inject(AI_SESSION_STREAM_CONNECTION_FACTORY, { optional: true });
193
- /**
194
- * Open a streaming session. Returns the per-stream subjects and a
195
- * `disconnect()` closer. When the host has provided an
196
- * {@link AI_SESSION_STREAM_CONNECTION_FACTORY}, a live SignalR connection is
197
- * built against {@link hubUrl} and the five hub callbacks
198
- * (`OnSessionEventAsync`, `OnSessionStatusChangedAsync`,
199
- * `OnApprovalRequestedAsync`, `OnApprovalDecidedAsync`, `OnQuotaWarningAsync`)
200
- * are routed into the matching subject. Without a factory, the service
201
- * degrades to REST-only backfill — the original Phase-1 stub contract.
202
- *
203
- * Tracking the highest sequence we've emitted lets the host reconnect after a
204
- * network blip by passing `sinceSequence` to {@link replay} (the SignalR
205
- * `onreconnected` hook fires that with the highest seen sequence).
206
- */
207
- streamSession(sessionId) {
208
- const events$ = new ReplaySubject(256);
209
- const statusChanges$ = new Subject();
210
- const approvalsRequested$ = new Subject();
211
- const approvalsDecided$ = new Subject();
212
- const quotaWarnings$ = new Subject();
213
- // Backfill any persisted events the hub-connect process would have missed
214
- // — REST returns the full history up to "now", and the live channel takes
215
- // it from there. The combination is at-least-once with deterministic
216
- // ordering courtesy of the persisted `sequence` field.
217
- let highestSequence = 0;
218
- const backfill = this.client.listEvents(sessionId).subscribe({
219
- next: (events) => {
220
- for (const event of events) {
221
- highestSequence = Math.max(highestSequence, event.sequence);
222
- events$.next(event);
223
- }
224
- },
225
- });
226
- let connection = null;
227
- if (this.connectionFactory) {
228
- connection = this.connectionFactory(this.hubUrl);
229
- }
230
- if (connection) {
231
- const conn = connection;
232
- conn.on('OnSessionEventAsync', (payload) => {
233
- const event = payload;
234
- highestSequence = Math.max(highestSequence, event.sequence ?? 0);
235
- events$.next(event);
236
- });
237
- conn.on('OnSessionStatusChangedAsync', (payload) => {
238
- statusChanges$.next(payload);
239
- });
240
- conn.on('OnApprovalRequestedAsync', (payload) => {
241
- approvalsRequested$.next(payload);
242
- });
243
- conn.on('OnApprovalDecidedAsync', (payload) => {
244
- approvalsDecided$.next(payload);
245
- });
246
- conn.on('OnQuotaWarningAsync', (payload) => {
247
- quotaWarnings$.next(payload);
248
- });
249
- conn.onreconnected(() => {
250
- // Pull anything we missed during the disconnect window so the
251
- // events$ stream stays gap-free without the caller having to do
252
- // their own bookkeeping.
253
- this.replay(sessionId, highestSequence, events$);
254
- });
255
- // Start the connection, then ask the hub to scope this connection's
256
- // group membership to the session. Failures are intentionally swallowed
257
- // — backfill stays valid and the UI degrades to REST-only instead of
258
- // crashing.
259
- conn
260
- .start()
261
- .then(() => conn.invoke('SubscribeToSessionAsync', sessionId))
262
- .catch(() => {
263
- /* hub start / subscribe failed — REST backfill still serves the UI */
264
- });
265
- }
266
- return {
267
- events$: events$.asObservable(),
268
- statusChanges$: statusChanges$.asObservable(),
269
- approvalsRequested$: approvalsRequested$.asObservable(),
270
- approvalsDecided$: approvalsDecided$.asObservable(),
271
- quotaWarnings$: quotaWarnings$.asObservable(),
272
- disconnect: () => {
273
- backfill.unsubscribe();
274
- if (connection) {
275
- // Best-effort — `stop()` may reject during teardown; the subjects
276
- // get completed regardless so consumers see clean termination.
277
- connection.stop().catch(() => undefined);
278
- connection = null;
279
- }
280
- events$.complete();
281
- statusChanges$.complete();
282
- approvalsRequested$.complete();
283
- approvalsDecided$.complete();
284
- quotaWarnings$.complete();
285
- },
286
- };
287
- }
288
- /**
289
- * Backfill missing events from a known sequence number and push them into
290
- * the host's existing stream. Used by a SignalR `onreconnected` hook the
291
- * host wires up.
292
- */
293
- replay(sessionId, sinceSequence, sink) {
294
- this.client.listEvents(sessionId, sinceSequence).subscribe({
295
- next: (events) => events.forEach((event) => sink.next(event)),
296
- });
297
- }
298
- /**
299
- * Tenant-scoped hub URL. Composition matches the AI Adapter's hub map —
300
- * `app.MapHub<AiHub>("/{tenantId:tenantId}/aiHub")` — so the host's
301
- * `hubPath` is appended after the tenant segment. Host apps that mount the
302
- * hub at a different relative path override `hubPath` via
303
- * `AI_ADAPTER_OPTIONS`.
304
- */
305
- get hubUrl() {
306
- const trimmed = this.options.hubPath.startsWith('/')
307
- ? this.options.hubPath
308
- : `/${this.options.hubPath}`;
309
- return `${this.options.baseUrl}/${this.options.tenantId}${trimmed}`;
310
- }
311
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiSessionStreamService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
312
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiSessionStreamService });
313
- }
314
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiSessionStreamService, decorators: [{
315
- type: Injectable
316
- }] });
317
-
318
- /**
319
- * DI token the services in this library read at construction time.
320
- * Provided by {@link provideOctoAiConsole}.
321
- */
322
- const AI_ADAPTER_OPTIONS = new InjectionToken('mm-octo-ai-console.adapter-options');
323
- /**
324
- * Optional DI token a host application provides to enable the live SignalR
325
- * channel on {@link AiSessionStreamService}. When absent, the service degrades
326
- * to REST-only backfill.
327
- */
328
- const AI_SESSION_STREAM_CONNECTION_FACTORY = new InjectionToken('mm-octo-ai-console.session-stream-connection-factory');
329
- /**
330
- * Composable provider that surfaces the library's adapter configuration to the
331
- * Angular DI container. Host applications call this once in `app.config.ts`:
332
- *
333
- * ```ts
334
- * providers: [
335
- * provideOctoAiConsole({
336
- * baseUrl: 'https://ai.acme.cloud',
337
- * tenantId: 'acme',
338
- * hubPath: '/hubs/ai',
339
- * }),
340
- * ]
341
- * ```
342
- */
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, Injectable, InjectionToken, computed, inject, input, makeEnvironmentProviders, output, signal } from "@angular/core";
3
+ import { HttpClient, HttpParams } from "@angular/common/http";
4
+ import { ReplaySubject, Subject } from "rxjs";
5
+ import { CommonModule } from "@angular/common";
6
+ import * as i1 from "@angular/forms";
7
+ import { FormsModule } from "@angular/forms";
8
+ var AiAdapterClientService = class AiAdapterClientService {
9
+ http = inject(HttpClient);
10
+ options = inject(AI_ADAPTER_OPTIONS);
11
+ listSessions(status) {
12
+ const url = `${this.tenantBase()}/sessions`;
13
+ let params = new HttpParams();
14
+ if (status) params = params.set("status", status);
15
+ return this.http.get(url, { params });
16
+ }
17
+ getSession(sessionId) {
18
+ return this.http.get(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}`);
19
+ }
20
+ createSession(request) {
21
+ return this.http.post(`${this.tenantBase()}/sessions`, request);
22
+ }
23
+ cancelSession(sessionId) {
24
+ return this.http.post(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/cancel`, null);
25
+ }
26
+ deleteSession(sessionId) {
27
+ return this.http.delete(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}`);
28
+ }
29
+ sendMessage(sessionId, text) {
30
+ return this.http.post(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/messages`, { text });
31
+ }
32
+ listEvents(sessionId, sinceSequence) {
33
+ const url = `${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/events`;
34
+ let params = new HttpParams();
35
+ if (sinceSequence != null) params = params.set("sinceSequence", sinceSequence.toString());
36
+ return this.http.get(url, { params });
37
+ }
38
+ decideApproval(sessionId, requestId, decision) {
39
+ return this.http.post(`${this.tenantBase()}/sessions/${encodeURIComponent(sessionId)}/approvals/${encodeURIComponent(requestId)}`, decision);
40
+ }
41
+ issueCredentialTicket(request) {
42
+ return this.http.post(`${this.tenantBase()}/credentials/tickets`, request);
43
+ }
44
+ registerGitHubPat(request) {
45
+ return this.http.post(`${this.tenantBase()}/credentials/github-pat`, request);
46
+ }
47
+ listGitHubPats() {
48
+ return this.http.get(`${this.tenantBase()}/credentials/github-pat`);
49
+ }
50
+ deleteGitHubPat(rtId) {
51
+ return this.http.delete(`${this.tenantBase()}/credentials/github-pat/${encodeURIComponent(rtId)}`);
52
+ }
53
+ getAppTemplates() {
54
+ return this.http.get(`${this.tenantBase()}/app-templates`);
55
+ }
56
+ tenantBase() {
57
+ return `${this.options.baseUrl}/${encodeURIComponent(this.options.tenantId)}/v1`;
58
+ }
59
+ static ɵfac = i0.ɵɵngDeclareFactory({
60
+ minVersion: "12.0.0",
61
+ version: "22.3.0",
62
+ ngImport: i0,
63
+ type: AiAdapterClientService,
64
+ deps: [],
65
+ target: i0.ɵɵFactoryTarget.Injectable
66
+ });
67
+ static ɵprov = i0.ɵɵngDeclareInjectable({
68
+ minVersion: "12.0.0",
69
+ version: "22.3.0",
70
+ ngImport: i0,
71
+ type: AiAdapterClientService
72
+ });
73
+ };
74
+ i0.ɵɵngDeclareClassMetadata({
75
+ minVersion: "12.0.0",
76
+ version: "22.3.0",
77
+ ngImport: i0,
78
+ type: AiAdapterClientService,
79
+ decorators: [{ type: Injectable }]
80
+ });
81
+ var AiSessionStreamService = class AiSessionStreamService {
82
+ options = inject(AI_ADAPTER_OPTIONS);
83
+ client = inject(AiAdapterClientService);
84
+ connectionFactory = inject(AI_SESSION_STREAM_CONNECTION_FACTORY, { optional: true });
85
+ streamSession(sessionId) {
86
+ const events$ = new ReplaySubject(256);
87
+ const statusChanges$ = new Subject();
88
+ const approvalsRequested$ = new Subject();
89
+ const approvalsDecided$ = new Subject();
90
+ const quotaWarnings$ = new Subject();
91
+ let highestSequence = 0;
92
+ const backfill = this.client.listEvents(sessionId).subscribe({ next: (events) => {
93
+ for (const event of events) {
94
+ highestSequence = Math.max(highestSequence, event.sequence);
95
+ events$.next(event);
96
+ }
97
+ } });
98
+ let connection = null;
99
+ if (this.connectionFactory) connection = this.connectionFactory(this.hubUrl);
100
+ if (connection) {
101
+ const conn = connection;
102
+ conn.on("OnSessionEventAsync", (payload) => {
103
+ const event = payload;
104
+ highestSequence = Math.max(highestSequence, event.sequence ?? 0);
105
+ events$.next(event);
106
+ });
107
+ conn.on("OnSessionStatusChangedAsync", (payload) => {
108
+ statusChanges$.next(payload);
109
+ });
110
+ conn.on("OnApprovalRequestedAsync", (payload) => {
111
+ approvalsRequested$.next(payload);
112
+ });
113
+ conn.on("OnApprovalDecidedAsync", (payload) => {
114
+ approvalsDecided$.next(payload);
115
+ });
116
+ conn.on("OnQuotaWarningAsync", (payload) => {
117
+ quotaWarnings$.next(payload);
118
+ });
119
+ conn.onreconnected(() => {
120
+ this.replay(sessionId, highestSequence, events$);
121
+ });
122
+ conn.start().then(() => conn.invoke("SubscribeToSessionAsync", sessionId)).catch(() => {});
123
+ }
124
+ return {
125
+ events$: events$.asObservable(),
126
+ statusChanges$: statusChanges$.asObservable(),
127
+ approvalsRequested$: approvalsRequested$.asObservable(),
128
+ approvalsDecided$: approvalsDecided$.asObservable(),
129
+ quotaWarnings$: quotaWarnings$.asObservable(),
130
+ disconnect: () => {
131
+ backfill.unsubscribe();
132
+ if (connection) {
133
+ connection.stop().catch(() => void 0);
134
+ connection = null;
135
+ }
136
+ events$.complete();
137
+ statusChanges$.complete();
138
+ approvalsRequested$.complete();
139
+ approvalsDecided$.complete();
140
+ quotaWarnings$.complete();
141
+ }
142
+ };
143
+ }
144
+ replay(sessionId, sinceSequence, sink) {
145
+ this.client.listEvents(sessionId, sinceSequence).subscribe({ next: (events) => events.forEach((event) => sink.next(event)) });
146
+ }
147
+ get hubUrl() {
148
+ const trimmed = this.options.hubPath.startsWith("/") ? this.options.hubPath : `/${this.options.hubPath}`;
149
+ return `${this.options.baseUrl}/${this.options.tenantId}${trimmed}`;
150
+ }
151
+ static ɵfac = i0.ɵɵngDeclareFactory({
152
+ minVersion: "12.0.0",
153
+ version: "22.3.0",
154
+ ngImport: i0,
155
+ type: AiSessionStreamService,
156
+ deps: [],
157
+ target: i0.ɵɵFactoryTarget.Injectable
158
+ });
159
+ static ɵprov = i0.ɵɵngDeclareInjectable({
160
+ minVersion: "12.0.0",
161
+ version: "22.3.0",
162
+ ngImport: i0,
163
+ type: AiSessionStreamService
164
+ });
165
+ };
166
+ i0.ɵɵngDeclareClassMetadata({
167
+ minVersion: "12.0.0",
168
+ version: "22.3.0",
169
+ ngImport: i0,
170
+ type: AiSessionStreamService,
171
+ decorators: [{ type: Injectable }]
172
+ });
173
+ const AI_ADAPTER_OPTIONS = new InjectionToken("mm-octo-ai-console.adapter-options");
174
+ const AI_SESSION_STREAM_CONNECTION_FACTORY = new InjectionToken("mm-octo-ai-console.session-stream-connection-factory");
343
175
  function provideOctoAiConsole(options) {
344
- // Provide AiAdapterClientService + AiSessionStreamService alongside the
345
- // options token. Both services drop `providedIn: 'root'` (6d0e7daf) because
346
- // the options they read are route-scoped — a host with multiple tenants
347
- // composes the provider with the right tenant id per route, and root-
348
- // singleton services would freeze the first route's options. Bundling the
349
- // services into the same provider chain means a host's `providers: [
350
- // provideOctoAiConsole({...}) ]` is enough; no manual listing required.
351
- return makeEnvironmentProviders([
352
- { provide: AI_ADAPTER_OPTIONS, useValue: options },
353
- AiAdapterClientService,
354
- AiSessionStreamService,
355
- ]);
356
- }
357
-
358
- /**
359
- * Status pill that mirrors the eight values `AiSessionStatus` carries on the
360
- * wire. The component is purely visual — it takes a status string in and emits
361
- * a CSS class + display label that the host's stylesheet can theme via the
362
- * `--mm-ai-status-*` custom properties.
363
- */
364
- class AiJobStatusBadgeComponent {
365
- status = input.required(/* @ts-ignore */
366
- ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
367
- variant = computed(() => {
368
- switch (this.status()) {
369
- case 'Running':
370
- return 'running';
371
- case 'Queued':
372
- return 'queued';
373
- case 'Paused':
374
- return 'paused';
375
- case 'Completed':
376
- return 'completed';
377
- case 'Failed':
378
- case 'Cancelled':
379
- return 'failed';
380
- case 'QuotaBlocked':
381
- case 'RateLimited':
382
- return 'blocked';
383
- default:
384
- return 'queued';
385
- }
386
- }, /* @ts-ignore */
387
- ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
388
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiJobStatusBadgeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
389
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: AiJobStatusBadgeComponent, isStandalone: true, selector: "mm-ai-job-status-badge", inputs: { status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<span class=\"mm-ai-status-badge mm-ai-status-badge--{{ variant() }}\">\n {{ status() }}\n</span>\n", styles: [":host{display:inline-block;--mm-ai-status-running-bg: #1f6feb;--mm-ai-status-running-fg: #ffffff;--mm-ai-status-queued-bg: #6e7681;--mm-ai-status-queued-fg: #ffffff;--mm-ai-status-paused-bg: #d29922;--mm-ai-status-paused-fg: #1c1c1c;--mm-ai-status-completed-bg: #2ea44f;--mm-ai-status-completed-fg: #ffffff;--mm-ai-status-failed-bg: #d73a49;--mm-ai-status-failed-fg: #ffffff;--mm-ai-status-blocked-bg: #8957e5;--mm-ai-status-blocked-fg: #ffffff}.mm-ai-status-badge{display:inline-block;padding:.15rem .65rem;border-radius:9999px;font-size:.8rem;font-weight:600;line-height:1.2}.mm-ai-status-badge--running{background:var(--mm-ai-status-running-bg);color:var(--mm-ai-status-running-fg)}.mm-ai-status-badge--queued{background:var(--mm-ai-status-queued-bg);color:var(--mm-ai-status-queued-fg)}.mm-ai-status-badge--paused{background:var(--mm-ai-status-paused-bg);color:var(--mm-ai-status-paused-fg)}.mm-ai-status-badge--completed{background:var(--mm-ai-status-completed-bg);color:var(--mm-ai-status-completed-fg)}.mm-ai-status-badge--failed{background:var(--mm-ai-status-failed-bg);color:var(--mm-ai-status-failed-fg)}.mm-ai-status-badge--blocked{background:var(--mm-ai-status-blocked-bg);color:var(--mm-ai-status-blocked-fg)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
176
+ return makeEnvironmentProviders([
177
+ {
178
+ provide: AI_ADAPTER_OPTIONS,
179
+ useValue: options
180
+ },
181
+ AiAdapterClientService,
182
+ AiSessionStreamService
183
+ ]);
390
184
  }
391
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiJobStatusBadgeComponent, decorators: [{
392
- type: Component,
393
- args: [{ selector: 'mm-ai-job-status-badge', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<span class=\"mm-ai-status-badge mm-ai-status-badge--{{ variant() }}\">\n {{ status() }}\n</span>\n", styles: [":host{display:inline-block;--mm-ai-status-running-bg: #1f6feb;--mm-ai-status-running-fg: #ffffff;--mm-ai-status-queued-bg: #6e7681;--mm-ai-status-queued-fg: #ffffff;--mm-ai-status-paused-bg: #d29922;--mm-ai-status-paused-fg: #1c1c1c;--mm-ai-status-completed-bg: #2ea44f;--mm-ai-status-completed-fg: #ffffff;--mm-ai-status-failed-bg: #d73a49;--mm-ai-status-failed-fg: #ffffff;--mm-ai-status-blocked-bg: #8957e5;--mm-ai-status-blocked-fg: #ffffff}.mm-ai-status-badge{display:inline-block;padding:.15rem .65rem;border-radius:9999px;font-size:.8rem;font-weight:600;line-height:1.2}.mm-ai-status-badge--running{background:var(--mm-ai-status-running-bg);color:var(--mm-ai-status-running-fg)}.mm-ai-status-badge--queued{background:var(--mm-ai-status-queued-bg);color:var(--mm-ai-status-queued-fg)}.mm-ai-status-badge--paused{background:var(--mm-ai-status-paused-bg);color:var(--mm-ai-status-paused-fg)}.mm-ai-status-badge--completed{background:var(--mm-ai-status-completed-bg);color:var(--mm-ai-status-completed-fg)}.mm-ai-status-badge--failed{background:var(--mm-ai-status-failed-bg);color:var(--mm-ai-status-failed-fg)}.mm-ai-status-badge--blocked{background:var(--mm-ai-status-blocked-bg);color:var(--mm-ai-status-blocked-fg)}\n"] }]
394
- }], propDecorators: { status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: true }] }] } });
395
-
396
- /**
397
- * List view of an AI Adapter tenant's sessions. The host owns data fetching —
398
- * the component takes the array as an input signal and emits the rtId on
399
- * row click. Keeping it data-source-agnostic lets refinery wire its own
400
- * Apollo cache while a bastion CLI could pass static fixtures in a Storybook.
401
- *
402
- * Cancel and Delete are surfaced as inline per-row actions and emitted as
403
- * separate outputs — the host owns the confirmation dialog and the actual
404
- * REST call. The component only knows which actions are valid for which
405
- * status, so a Running session never offers Delete and a Completed session
406
- * never offers Cancel.
407
- */
408
- class AiSessionListComponent {
409
- sessions = input.required(/* @ts-ignore */
410
- ...(ngDevMode ? [{ debugName: "sessions" }] : /* istanbul ignore next */ []));
411
- selectedSessionId = input(null, /* @ts-ignore */
412
- ...(ngDevMode ? [{ debugName: "selectedSessionId" }] : /* istanbul ignore next */ []));
413
- sessionSelected = output();
414
- cancelRequested = output();
415
- deleteRequested = output();
416
- orderedSessions = computed(() => [...this.sessions()].sort((a, b) => b.startedAt.localeCompare(a.startedAt)), /* @ts-ignore */
417
- ...(ngDevMode ? [{ debugName: "orderedSessions" }] : /* istanbul ignore next */ []));
418
- /**
419
- * Terminal status set, kept in sync with the C# `AiAgentSessionService.IsTerminal`
420
- * predicate. Delete is gated to this set; Cancel is gated to its complement.
421
- * If the wire enum grows a new terminal kind, both predicates must be
422
- * updated here AND on the server.
423
- */
424
- static TERMINAL_STATUSES = new Set(['Completed', 'Failed', 'Cancelled']);
425
- canCancel(status) {
426
- return !AiSessionListComponent.TERMINAL_STATUSES.has(status);
427
- }
428
- canDelete(status) {
429
- return AiSessionListComponent.TERMINAL_STATUSES.has(status);
430
- }
431
- onSelect(sessionRtId) {
432
- this.sessionSelected.emit(sessionRtId);
433
- }
434
- onCancel(sessionRtId, event) {
435
- // Without stopPropagation the row click also fires and selects this
436
- // session, which then redirects focus and tears the inline-action button
437
- // out from under the user mid-confirmation.
438
- event.stopPropagation();
439
- this.cancelRequested.emit(sessionRtId);
440
- }
441
- onDelete(sessionRtId, event) {
442
- event.stopPropagation();
443
- this.deleteRequested.emit(sessionRtId);
444
- }
445
- age(startedAt) {
446
- const started = Date.parse(startedAt);
447
- if (Number.isNaN(started)) {
448
- return '';
449
- }
450
- const now = Date.now();
451
- const seconds = Math.floor((now - started) / 1000);
452
- if (seconds < 60) {
453
- return `${seconds}s ago`;
454
- }
455
- const minutes = Math.floor(seconds / 60);
456
- if (minutes < 60) {
457
- return `${minutes}m ago`;
458
- }
459
- const hours = Math.floor(minutes / 60);
460
- if (hours < 24) {
461
- return `${hours}h ago`;
462
- }
463
- const days = Math.floor(hours / 24);
464
- return `${days}d ago`;
465
- }
466
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiSessionListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
467
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AiSessionListComponent, isStandalone: true, selector: "mm-ai-session-list", inputs: { sessions: { classPropertyName: "sessions", publicName: "sessions", isSignal: true, isRequired: true, transformFunction: null }, selectedSessionId: { classPropertyName: "selectedSessionId", publicName: "selectedSessionId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sessionSelected: "sessionSelected", cancelRequested: "cancelRequested", deleteRequested: "deleteRequested" }, ngImport: i0, template: "<ul class=\"mm-ai-session-list\">\n @for (session of orderedSessions(); track session.sessionRtId) {\n <li\n class=\"mm-ai-session-list__row\"\n [class.mm-ai-session-list__row--selected]=\"\n session.sessionRtId === selectedSessionId()\n \"\n >\n <button\n type=\"button\"\n class=\"mm-ai-session-list__button\"\n (click)=\"onSelect(session.sessionRtId)\"\n >\n <!--\n Row layout: goal + status badge on top, meta + actions on the\n bottom. The two-line shape lets a narrow sidebar (Refinery\n Studio caps the column at 18rem) breathe \u2014 the previous\n horizontal cram had the goal text overlap the action buttons\n on every row.\n -->\n <div class=\"mm-ai-session-list__top\">\n <span class=\"mm-ai-session-list__goal\">{{ session.goalSummary }}</span>\n <mm-ai-job-status-badge [status]=\"session.status\" />\n </div>\n <div class=\"mm-ai-session-list__bottom\">\n <span class=\"mm-ai-session-list__meta\">\n {{ age(session.startedAt) }}\n <span class=\"mm-ai-session-list__dot\">\u00B7</span>\n {{ session.tokensConsumed }} tok\n </span>\n @if (session.previewUrl) {\n <!--\n #4136 \u2014 preview-deploy URL the server surfaces when the\n worker pod's nginx sidecar has a build to serve. Opens in\n a new tab so the sidebar scroll position survives.\n stopPropagation prevents the row click from also firing.\n -->\n <a\n class=\"mm-ai-session-list__preview\"\n [href]=\"session.previewUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n (click)=\"$event.stopPropagation()\"\n >\n Preview\n </a>\n }\n <span class=\"mm-ai-session-list__spacer\"></span>\n <span class=\"mm-ai-session-list__actions\">\n @if (canCancel(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--cancel\"\n [attr.aria-label]=\"'Cancel session ' + session.goalSummary\"\n (click)=\"onCancel(session.sessionRtId, $event)\"\n >\n Cancel\n </button>\n }\n @if (canDelete(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--delete\"\n [attr.aria-label]=\"'Delete session ' + session.goalSummary\"\n (click)=\"onDelete(session.sessionRtId, $event)\"\n >\n Delete\n </button>\n }\n </span>\n </div>\n </button>\n </li>\n } @empty {\n <li class=\"mm-ai-session-list__empty\">No sessions yet.</li>\n }\n</ul>\n", styles: [":host{display:block;--mm-ai-list-bg: #16191d;--mm-ai-list-row-bg: #1f2227;--mm-ai-list-row-selected: #2a3142;--mm-ai-list-border: #2f343b;--mm-ai-list-text: #e6e6e6;--mm-ai-list-muted: #9aa0a6;--mm-ai-list-accent: #64ceb9;--mm-ai-list-action-cancel: #da9162;--mm-ai-list-action-delete: #ec658f}.mm-ai-session-list{list-style:none;margin:0;padding:0;background:var(--mm-ai-list-bg);border-radius:.5rem;display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.mm-ai-session-list__row{background:var(--mm-ai-list-row-bg);border:1px solid var(--mm-ai-list-border);border-radius:.4rem}.mm-ai-session-list__row--selected{background:var(--mm-ai-list-row-selected)}.mm-ai-session-list__button{width:100%;display:flex;flex-direction:column;gap:.3rem;padding:.5rem .75rem;background:transparent;color:var(--mm-ai-list-text);border:none;cursor:pointer;text-align:left;font-family:inherit;min-width:0}.mm-ai-session-list__button:hover{background:#ffffff08}.mm-ai-session-list__top{display:flex;align-items:center;gap:.5rem;min-width:0}.mm-ai-session-list__goal{flex:1;min-width:0;font-size:.85rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mm-ai-session-list__bottom{display:flex;align-items:center;gap:.5rem;font-size:.7rem;color:var(--mm-ai-list-muted);font-variant-numeric:tabular-nums;min-width:0}.mm-ai-session-list__meta{display:inline-flex;align-items:baseline;gap:.35rem;flex-shrink:0}.mm-ai-session-list__dot{opacity:.5}.mm-ai-session-list__spacer{flex:1}.mm-ai-session-list__preview{color:var(--mm-ai-list-accent);font-size:.7rem;text-decoration:underline;text-underline-offset:2px;flex-shrink:0}.mm-ai-session-list__preview:hover{text-decoration-thickness:2px}.mm-ai-session-list__empty{padding:1rem;text-align:center;color:var(--mm-ai-list-muted);font-style:italic}.mm-ai-session-list__actions{display:flex;gap:.25rem;flex-shrink:0;opacity:.45;transition:opacity .15s ease}.mm-ai-session-list__row:hover .mm-ai-session-list__actions,.mm-ai-session-list__row--selected .mm-ai-session-list__actions{opacity:1}.mm-ai-session-list__action{padding:.15rem .5rem;background:transparent;border:1px solid var(--mm-ai-list-border);border-radius:.25rem;color:var(--mm-ai-list-text);font-family:inherit;font-size:.65rem;cursor:pointer;transition:border-color .15s ease,color .15s ease,background-color .15s ease}.mm-ai-session-list__action:hover{background:#ffffff0a}.mm-ai-session-list__action--cancel{color:var(--mm-ai-list-action-cancel);border-color:color-mix(in srgb,var(--mm-ai-list-action-cancel) 40%,transparent)}.mm-ai-session-list__action--cancel:hover{border-color:var(--mm-ai-list-action-cancel)}.mm-ai-session-list__action--delete{color:var(--mm-ai-list-action-delete);border-color:color-mix(in srgb,var(--mm-ai-list-action-delete) 40%,transparent)}.mm-ai-session-list__action--delete:hover{border-color:var(--mm-ai-list-action-delete)}\n"], dependencies: [{ kind: "component", type: AiJobStatusBadgeComponent, selector: "mm-ai-job-status-badge", inputs: ["status"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
468
- }
469
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiSessionListComponent, decorators: [{
470
- type: Component,
471
- args: [{ selector: 'mm-ai-session-list', imports: [AiJobStatusBadgeComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ul class=\"mm-ai-session-list\">\n @for (session of orderedSessions(); track session.sessionRtId) {\n <li\n class=\"mm-ai-session-list__row\"\n [class.mm-ai-session-list__row--selected]=\"\n session.sessionRtId === selectedSessionId()\n \"\n >\n <button\n type=\"button\"\n class=\"mm-ai-session-list__button\"\n (click)=\"onSelect(session.sessionRtId)\"\n >\n <!--\n Row layout: goal + status badge on top, meta + actions on the\n bottom. The two-line shape lets a narrow sidebar (Refinery\n Studio caps the column at 18rem) breathe \u2014 the previous\n horizontal cram had the goal text overlap the action buttons\n on every row.\n -->\n <div class=\"mm-ai-session-list__top\">\n <span class=\"mm-ai-session-list__goal\">{{ session.goalSummary }}</span>\n <mm-ai-job-status-badge [status]=\"session.status\" />\n </div>\n <div class=\"mm-ai-session-list__bottom\">\n <span class=\"mm-ai-session-list__meta\">\n {{ age(session.startedAt) }}\n <span class=\"mm-ai-session-list__dot\">\u00B7</span>\n {{ session.tokensConsumed }} tok\n </span>\n @if (session.previewUrl) {\n <!--\n #4136 \u2014 preview-deploy URL the server surfaces when the\n worker pod's nginx sidecar has a build to serve. Opens in\n a new tab so the sidebar scroll position survives.\n stopPropagation prevents the row click from also firing.\n -->\n <a\n class=\"mm-ai-session-list__preview\"\n [href]=\"session.previewUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n (click)=\"$event.stopPropagation()\"\n >\n Preview\n </a>\n }\n <span class=\"mm-ai-session-list__spacer\"></span>\n <span class=\"mm-ai-session-list__actions\">\n @if (canCancel(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--cancel\"\n [attr.aria-label]=\"'Cancel session ' + session.goalSummary\"\n (click)=\"onCancel(session.sessionRtId, $event)\"\n >\n Cancel\n </button>\n }\n @if (canDelete(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--delete\"\n [attr.aria-label]=\"'Delete session ' + session.goalSummary\"\n (click)=\"onDelete(session.sessionRtId, $event)\"\n >\n Delete\n </button>\n }\n </span>\n </div>\n </button>\n </li>\n } @empty {\n <li class=\"mm-ai-session-list__empty\">No sessions yet.</li>\n }\n</ul>\n", styles: [":host{display:block;--mm-ai-list-bg: #16191d;--mm-ai-list-row-bg: #1f2227;--mm-ai-list-row-selected: #2a3142;--mm-ai-list-border: #2f343b;--mm-ai-list-text: #e6e6e6;--mm-ai-list-muted: #9aa0a6;--mm-ai-list-accent: #64ceb9;--mm-ai-list-action-cancel: #da9162;--mm-ai-list-action-delete: #ec658f}.mm-ai-session-list{list-style:none;margin:0;padding:0;background:var(--mm-ai-list-bg);border-radius:.5rem;display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.mm-ai-session-list__row{background:var(--mm-ai-list-row-bg);border:1px solid var(--mm-ai-list-border);border-radius:.4rem}.mm-ai-session-list__row--selected{background:var(--mm-ai-list-row-selected)}.mm-ai-session-list__button{width:100%;display:flex;flex-direction:column;gap:.3rem;padding:.5rem .75rem;background:transparent;color:var(--mm-ai-list-text);border:none;cursor:pointer;text-align:left;font-family:inherit;min-width:0}.mm-ai-session-list__button:hover{background:#ffffff08}.mm-ai-session-list__top{display:flex;align-items:center;gap:.5rem;min-width:0}.mm-ai-session-list__goal{flex:1;min-width:0;font-size:.85rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mm-ai-session-list__bottom{display:flex;align-items:center;gap:.5rem;font-size:.7rem;color:var(--mm-ai-list-muted);font-variant-numeric:tabular-nums;min-width:0}.mm-ai-session-list__meta{display:inline-flex;align-items:baseline;gap:.35rem;flex-shrink:0}.mm-ai-session-list__dot{opacity:.5}.mm-ai-session-list__spacer{flex:1}.mm-ai-session-list__preview{color:var(--mm-ai-list-accent);font-size:.7rem;text-decoration:underline;text-underline-offset:2px;flex-shrink:0}.mm-ai-session-list__preview:hover{text-decoration-thickness:2px}.mm-ai-session-list__empty{padding:1rem;text-align:center;color:var(--mm-ai-list-muted);font-style:italic}.mm-ai-session-list__actions{display:flex;gap:.25rem;flex-shrink:0;opacity:.45;transition:opacity .15s ease}.mm-ai-session-list__row:hover .mm-ai-session-list__actions,.mm-ai-session-list__row--selected .mm-ai-session-list__actions{opacity:1}.mm-ai-session-list__action{padding:.15rem .5rem;background:transparent;border:1px solid var(--mm-ai-list-border);border-radius:.25rem;color:var(--mm-ai-list-text);font-family:inherit;font-size:.65rem;cursor:pointer;transition:border-color .15s ease,color .15s ease,background-color .15s ease}.mm-ai-session-list__action:hover{background:#ffffff0a}.mm-ai-session-list__action--cancel{color:var(--mm-ai-list-action-cancel);border-color:color-mix(in srgb,var(--mm-ai-list-action-cancel) 40%,transparent)}.mm-ai-session-list__action--cancel:hover{border-color:var(--mm-ai-list-action-cancel)}.mm-ai-session-list__action--delete{color:var(--mm-ai-list-action-delete);border-color:color-mix(in srgb,var(--mm-ai-list-action-delete) 40%,transparent)}.mm-ai-session-list__action--delete:hover{border-color:var(--mm-ai-list-action-delete)}\n"] }]
472
- }], propDecorators: { sessions: [{ type: i0.Input, args: [{ isSignal: true, alias: "sessions", required: true }] }], selectedSessionId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedSessionId", required: false }] }], sessionSelected: [{ type: i0.Output, args: ["sessionSelected"] }], cancelRequested: [{ type: i0.Output, args: ["cancelRequested"] }], deleteRequested: [{ type: i0.Output, args: ["deleteRequested"] }] } });
473
-
474
- /**
475
- * Parse one persisted session event into a `ParsedView`. Falls back to
476
- * `unknown` (never throws) when the payload is malformed — we'd rather show
477
- * "unrecognised event" than crash the whole transcript.
478
- */
185
+ var AiJobStatusBadgeComponent = class AiJobStatusBadgeComponent {
186
+ status = input.required(...ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []);
187
+ variant = computed(() => {
188
+ switch (this.status()) {
189
+ case "Running": return "running";
190
+ case "Queued": return "queued";
191
+ case "Paused": return "paused";
192
+ case "Completed": return "completed";
193
+ case "Failed":
194
+ case "Cancelled": return "failed";
195
+ case "QuotaBlocked":
196
+ case "RateLimited": return "blocked";
197
+ default: return "queued";
198
+ }
199
+ }, ...ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []);
200
+ static ɵfac = i0.ɵɵngDeclareFactory({
201
+ minVersion: "12.0.0",
202
+ version: "22.3.0",
203
+ ngImport: i0,
204
+ type: AiJobStatusBadgeComponent,
205
+ deps: [],
206
+ target: i0.ɵɵFactoryTarget.Component
207
+ });
208
+ static ɵcmp = i0.ɵɵngDeclareComponent({
209
+ minVersion: "17.1.0",
210
+ version: "22.3.0",
211
+ type: AiJobStatusBadgeComponent,
212
+ isStandalone: true,
213
+ selector: "mm-ai-job-status-badge",
214
+ inputs: { status: {
215
+ classPropertyName: "status",
216
+ publicName: "status",
217
+ isSignal: true,
218
+ isRequired: true,
219
+ transformFunction: null
220
+ } },
221
+ ngImport: i0,
222
+ template: "<span class=\"mm-ai-status-badge mm-ai-status-badge--{{ variant() }}\">\n {{ status() }}\n</span>\n",
223
+ styles: [":host{display:inline-block;--mm-ai-status-running-bg: #1f6feb;--mm-ai-status-running-fg: #ffffff;--mm-ai-status-queued-bg: #6e7681;--mm-ai-status-queued-fg: #ffffff;--mm-ai-status-paused-bg: #d29922;--mm-ai-status-paused-fg: #1c1c1c;--mm-ai-status-completed-bg: #2ea44f;--mm-ai-status-completed-fg: #ffffff;--mm-ai-status-failed-bg: #d73a49;--mm-ai-status-failed-fg: #ffffff;--mm-ai-status-blocked-bg: #8957e5;--mm-ai-status-blocked-fg: #ffffff}.mm-ai-status-badge{display:inline-block;padding:.15rem .65rem;border-radius:9999px;font-size:.8rem;font-weight:600;line-height:1.2}.mm-ai-status-badge--running{background:var(--mm-ai-status-running-bg);color:var(--mm-ai-status-running-fg)}.mm-ai-status-badge--queued{background:var(--mm-ai-status-queued-bg);color:var(--mm-ai-status-queued-fg)}.mm-ai-status-badge--paused{background:var(--mm-ai-status-paused-bg);color:var(--mm-ai-status-paused-fg)}.mm-ai-status-badge--completed{background:var(--mm-ai-status-completed-bg);color:var(--mm-ai-status-completed-fg)}.mm-ai-status-badge--failed{background:var(--mm-ai-status-failed-bg);color:var(--mm-ai-status-failed-fg)}.mm-ai-status-badge--blocked{background:var(--mm-ai-status-blocked-bg);color:var(--mm-ai-status-blocked-fg)}\n"],
224
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
225
+ });
226
+ };
227
+ i0.ɵɵngDeclareClassMetadata({
228
+ minVersion: "12.0.0",
229
+ version: "22.3.0",
230
+ ngImport: i0,
231
+ type: AiJobStatusBadgeComponent,
232
+ decorators: [{
233
+ type: Component,
234
+ args: [{
235
+ selector: "mm-ai-job-status-badge",
236
+ imports: [],
237
+ changeDetection: ChangeDetectionStrategy.OnPush,
238
+ template: "<span class=\"mm-ai-status-badge mm-ai-status-badge--{{ variant() }}\">\n {{ status() }}\n</span>\n",
239
+ styles: [":host{display:inline-block;--mm-ai-status-running-bg: #1f6feb;--mm-ai-status-running-fg: #ffffff;--mm-ai-status-queued-bg: #6e7681;--mm-ai-status-queued-fg: #ffffff;--mm-ai-status-paused-bg: #d29922;--mm-ai-status-paused-fg: #1c1c1c;--mm-ai-status-completed-bg: #2ea44f;--mm-ai-status-completed-fg: #ffffff;--mm-ai-status-failed-bg: #d73a49;--mm-ai-status-failed-fg: #ffffff;--mm-ai-status-blocked-bg: #8957e5;--mm-ai-status-blocked-fg: #ffffff}.mm-ai-status-badge{display:inline-block;padding:.15rem .65rem;border-radius:9999px;font-size:.8rem;font-weight:600;line-height:1.2}.mm-ai-status-badge--running{background:var(--mm-ai-status-running-bg);color:var(--mm-ai-status-running-fg)}.mm-ai-status-badge--queued{background:var(--mm-ai-status-queued-bg);color:var(--mm-ai-status-queued-fg)}.mm-ai-status-badge--paused{background:var(--mm-ai-status-paused-bg);color:var(--mm-ai-status-paused-fg)}.mm-ai-status-badge--completed{background:var(--mm-ai-status-completed-bg);color:var(--mm-ai-status-completed-fg)}.mm-ai-status-badge--failed{background:var(--mm-ai-status-failed-bg);color:var(--mm-ai-status-failed-fg)}.mm-ai-status-badge--blocked{background:var(--mm-ai-status-blocked-bg);color:var(--mm-ai-status-blocked-fg)}\n"]
240
+ }]
241
+ }],
242
+ propDecorators: { status: [{
243
+ type: i0.Input,
244
+ args: [{
245
+ isSignal: true,
246
+ alias: "status",
247
+ required: true
248
+ }]
249
+ }] }
250
+ });
251
+ var AiSessionListComponent = class AiSessionListComponent {
252
+ sessions = input.required(...ngDevMode ? [{ debugName: "sessions" }] : /* istanbul ignore next */ []);
253
+ selectedSessionId = input(null, ...ngDevMode ? [{ debugName: "selectedSessionId" }] : /* istanbul ignore next */ []);
254
+ sessionSelected = output();
255
+ cancelRequested = output();
256
+ deleteRequested = output();
257
+ orderedSessions = computed(() => [...this.sessions()].sort((a, b) => b.startedAt.localeCompare(a.startedAt)), ...ngDevMode ? [{ debugName: "orderedSessions" }] : /* istanbul ignore next */ []);
258
+ static TERMINAL_STATUSES = /* @__PURE__ */ new Set([
259
+ "Completed",
260
+ "Failed",
261
+ "Cancelled"
262
+ ]);
263
+ canCancel(status) {
264
+ return !AiSessionListComponent.TERMINAL_STATUSES.has(status);
265
+ }
266
+ canDelete(status) {
267
+ return AiSessionListComponent.TERMINAL_STATUSES.has(status);
268
+ }
269
+ onSelect(sessionRtId) {
270
+ this.sessionSelected.emit(sessionRtId);
271
+ }
272
+ onCancel(sessionRtId, event) {
273
+ event.stopPropagation();
274
+ this.cancelRequested.emit(sessionRtId);
275
+ }
276
+ onDelete(sessionRtId, event) {
277
+ event.stopPropagation();
278
+ this.deleteRequested.emit(sessionRtId);
279
+ }
280
+ age(startedAt) {
281
+ const started = Date.parse(startedAt);
282
+ if (Number.isNaN(started)) return "";
283
+ const seconds = Math.floor((Date.now() - started) / 1e3);
284
+ if (seconds < 60) return `${seconds}s ago`;
285
+ const minutes = Math.floor(seconds / 60);
286
+ if (minutes < 60) return `${minutes}m ago`;
287
+ const hours = Math.floor(minutes / 60);
288
+ if (hours < 24) return `${hours}h ago`;
289
+ return `${Math.floor(hours / 24)}d ago`;
290
+ }
291
+ static ɵfac = i0.ɵɵngDeclareFactory({
292
+ minVersion: "12.0.0",
293
+ version: "22.3.0",
294
+ ngImport: i0,
295
+ type: AiSessionListComponent,
296
+ deps: [],
297
+ target: i0.ɵɵFactoryTarget.Component
298
+ });
299
+ static ɵcmp = i0.ɵɵngDeclareComponent({
300
+ minVersion: "17.0.0",
301
+ version: "22.3.0",
302
+ type: AiSessionListComponent,
303
+ isStandalone: true,
304
+ selector: "mm-ai-session-list",
305
+ inputs: {
306
+ sessions: {
307
+ classPropertyName: "sessions",
308
+ publicName: "sessions",
309
+ isSignal: true,
310
+ isRequired: true,
311
+ transformFunction: null
312
+ },
313
+ selectedSessionId: {
314
+ classPropertyName: "selectedSessionId",
315
+ publicName: "selectedSessionId",
316
+ isSignal: true,
317
+ isRequired: false,
318
+ transformFunction: null
319
+ }
320
+ },
321
+ outputs: {
322
+ sessionSelected: "sessionSelected",
323
+ cancelRequested: "cancelRequested",
324
+ deleteRequested: "deleteRequested"
325
+ },
326
+ ngImport: i0,
327
+ template: "<ul class=\"mm-ai-session-list\">\n @for (session of orderedSessions(); track session.sessionRtId) {\n <li\n class=\"mm-ai-session-list__row\"\n [class.mm-ai-session-list__row--selected]=\"\n session.sessionRtId === selectedSessionId()\n \"\n >\n <button\n type=\"button\"\n class=\"mm-ai-session-list__button\"\n (click)=\"onSelect(session.sessionRtId)\"\n >\n <!--\n Row layout: goal + status badge on top, meta + actions on the\n bottom. The two-line shape lets a narrow sidebar (Refinery\n Studio caps the column at 18rem) breathe — the previous\n horizontal cram had the goal text overlap the action buttons\n on every row.\n -->\n <div class=\"mm-ai-session-list__top\">\n <span class=\"mm-ai-session-list__goal\">{{ session.goalSummary }}</span>\n <mm-ai-job-status-badge [status]=\"session.status\" />\n </div>\n <div class=\"mm-ai-session-list__bottom\">\n <span class=\"mm-ai-session-list__meta\">\n {{ age(session.startedAt) }}\n <span class=\"mm-ai-session-list__dot\">·</span>\n {{ session.tokensConsumed }} tok\n </span>\n @if (session.previewUrl) {\n <!--\n #4136 — preview-deploy URL the server surfaces when the\n worker pod's nginx sidecar has a build to serve. Opens in\n a new tab so the sidebar scroll position survives.\n stopPropagation prevents the row click from also firing.\n -->\n <a\n class=\"mm-ai-session-list__preview\"\n [href]=\"session.previewUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n (click)=\"$event.stopPropagation()\"\n >\n Preview\n </a>\n }\n <span class=\"mm-ai-session-list__spacer\"></span>\n <span class=\"mm-ai-session-list__actions\">\n @if (canCancel(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--cancel\"\n [attr.aria-label]=\"'Cancel session ' + session.goalSummary\"\n (click)=\"onCancel(session.sessionRtId, $event)\"\n >\n Cancel\n </button>\n }\n @if (canDelete(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--delete\"\n [attr.aria-label]=\"'Delete session ' + session.goalSummary\"\n (click)=\"onDelete(session.sessionRtId, $event)\"\n >\n Delete\n </button>\n }\n </span>\n </div>\n </button>\n </li>\n } @empty {\n <li class=\"mm-ai-session-list__empty\">No sessions yet.</li>\n }\n</ul>\n",
328
+ styles: [":host{display:block;--mm-ai-list-bg: #16191d;--mm-ai-list-row-bg: #1f2227;--mm-ai-list-row-selected: #2a3142;--mm-ai-list-border: #2f343b;--mm-ai-list-text: #e6e6e6;--mm-ai-list-muted: #9aa0a6;--mm-ai-list-accent: #64ceb9;--mm-ai-list-action-cancel: #da9162;--mm-ai-list-action-delete: #ec658f}.mm-ai-session-list{list-style:none;margin:0;padding:0;background:var(--mm-ai-list-bg);border-radius:.5rem;display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.mm-ai-session-list__row{background:var(--mm-ai-list-row-bg);border:1px solid var(--mm-ai-list-border);border-radius:.4rem}.mm-ai-session-list__row--selected{background:var(--mm-ai-list-row-selected)}.mm-ai-session-list__button{width:100%;display:flex;flex-direction:column;gap:.3rem;padding:.5rem .75rem;background:transparent;color:var(--mm-ai-list-text);border:none;cursor:pointer;text-align:left;font-family:inherit;min-width:0}.mm-ai-session-list__button:hover{background:#ffffff08}.mm-ai-session-list__top{display:flex;align-items:center;gap:.5rem;min-width:0}.mm-ai-session-list__goal{flex:1;min-width:0;font-size:.85rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mm-ai-session-list__bottom{display:flex;align-items:center;gap:.5rem;font-size:.7rem;color:var(--mm-ai-list-muted);font-variant-numeric:tabular-nums;min-width:0}.mm-ai-session-list__meta{display:inline-flex;align-items:baseline;gap:.35rem;flex-shrink:0}.mm-ai-session-list__dot{opacity:.5}.mm-ai-session-list__spacer{flex:1}.mm-ai-session-list__preview{color:var(--mm-ai-list-accent);font-size:.7rem;text-decoration:underline;text-underline-offset:2px;flex-shrink:0}.mm-ai-session-list__preview:hover{text-decoration-thickness:2px}.mm-ai-session-list__empty{padding:1rem;text-align:center;color:var(--mm-ai-list-muted);font-style:italic}.mm-ai-session-list__actions{display:flex;gap:.25rem;flex-shrink:0;opacity:.45;transition:opacity .15s ease}.mm-ai-session-list__row:hover .mm-ai-session-list__actions,.mm-ai-session-list__row--selected .mm-ai-session-list__actions{opacity:1}.mm-ai-session-list__action{padding:.15rem .5rem;background:transparent;border:1px solid var(--mm-ai-list-border);border-radius:.25rem;color:var(--mm-ai-list-text);font-family:inherit;font-size:.65rem;cursor:pointer;transition:border-color .15s ease,color .15s ease,background-color .15s ease}.mm-ai-session-list__action:hover{background:#ffffff0a}.mm-ai-session-list__action--cancel{color:var(--mm-ai-list-action-cancel);border-color:color-mix(in srgb,var(--mm-ai-list-action-cancel) 40%,transparent)}.mm-ai-session-list__action--cancel:hover{border-color:var(--mm-ai-list-action-cancel)}.mm-ai-session-list__action--delete{color:var(--mm-ai-list-action-delete);border-color:color-mix(in srgb,var(--mm-ai-list-action-delete) 40%,transparent)}.mm-ai-session-list__action--delete:hover{border-color:var(--mm-ai-list-action-delete)}\n"],
329
+ dependencies: [{
330
+ kind: "component",
331
+ type: AiJobStatusBadgeComponent,
332
+ selector: "mm-ai-job-status-badge",
333
+ inputs: ["status"]
334
+ }],
335
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
336
+ });
337
+ };
338
+ i0.ɵɵngDeclareClassMetadata({
339
+ minVersion: "12.0.0",
340
+ version: "22.3.0",
341
+ ngImport: i0,
342
+ type: AiSessionListComponent,
343
+ decorators: [{
344
+ type: Component,
345
+ args: [{
346
+ selector: "mm-ai-session-list",
347
+ imports: [AiJobStatusBadgeComponent],
348
+ changeDetection: ChangeDetectionStrategy.OnPush,
349
+ template: "<ul class=\"mm-ai-session-list\">\n @for (session of orderedSessions(); track session.sessionRtId) {\n <li\n class=\"mm-ai-session-list__row\"\n [class.mm-ai-session-list__row--selected]=\"\n session.sessionRtId === selectedSessionId()\n \"\n >\n <button\n type=\"button\"\n class=\"mm-ai-session-list__button\"\n (click)=\"onSelect(session.sessionRtId)\"\n >\n <!--\n Row layout: goal + status badge on top, meta + actions on the\n bottom. The two-line shape lets a narrow sidebar (Refinery\n Studio caps the column at 18rem) breathe — the previous\n horizontal cram had the goal text overlap the action buttons\n on every row.\n -->\n <div class=\"mm-ai-session-list__top\">\n <span class=\"mm-ai-session-list__goal\">{{ session.goalSummary }}</span>\n <mm-ai-job-status-badge [status]=\"session.status\" />\n </div>\n <div class=\"mm-ai-session-list__bottom\">\n <span class=\"mm-ai-session-list__meta\">\n {{ age(session.startedAt) }}\n <span class=\"mm-ai-session-list__dot\">·</span>\n {{ session.tokensConsumed }} tok\n </span>\n @if (session.previewUrl) {\n <!--\n #4136 — preview-deploy URL the server surfaces when the\n worker pod's nginx sidecar has a build to serve. Opens in\n a new tab so the sidebar scroll position survives.\n stopPropagation prevents the row click from also firing.\n -->\n <a\n class=\"mm-ai-session-list__preview\"\n [href]=\"session.previewUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n (click)=\"$event.stopPropagation()\"\n >\n Preview\n </a>\n }\n <span class=\"mm-ai-session-list__spacer\"></span>\n <span class=\"mm-ai-session-list__actions\">\n @if (canCancel(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--cancel\"\n [attr.aria-label]=\"'Cancel session ' + session.goalSummary\"\n (click)=\"onCancel(session.sessionRtId, $event)\"\n >\n Cancel\n </button>\n }\n @if (canDelete(session.status)) {\n <button\n type=\"button\"\n class=\"mm-ai-session-list__action mm-ai-session-list__action--delete\"\n [attr.aria-label]=\"'Delete session ' + session.goalSummary\"\n (click)=\"onDelete(session.sessionRtId, $event)\"\n >\n Delete\n </button>\n }\n </span>\n </div>\n </button>\n </li>\n } @empty {\n <li class=\"mm-ai-session-list__empty\">No sessions yet.</li>\n }\n</ul>\n",
350
+ styles: [":host{display:block;--mm-ai-list-bg: #16191d;--mm-ai-list-row-bg: #1f2227;--mm-ai-list-row-selected: #2a3142;--mm-ai-list-border: #2f343b;--mm-ai-list-text: #e6e6e6;--mm-ai-list-muted: #9aa0a6;--mm-ai-list-accent: #64ceb9;--mm-ai-list-action-cancel: #da9162;--mm-ai-list-action-delete: #ec658f}.mm-ai-session-list{list-style:none;margin:0;padding:0;background:var(--mm-ai-list-bg);border-radius:.5rem;display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.mm-ai-session-list__row{background:var(--mm-ai-list-row-bg);border:1px solid var(--mm-ai-list-border);border-radius:.4rem}.mm-ai-session-list__row--selected{background:var(--mm-ai-list-row-selected)}.mm-ai-session-list__button{width:100%;display:flex;flex-direction:column;gap:.3rem;padding:.5rem .75rem;background:transparent;color:var(--mm-ai-list-text);border:none;cursor:pointer;text-align:left;font-family:inherit;min-width:0}.mm-ai-session-list__button:hover{background:#ffffff08}.mm-ai-session-list__top{display:flex;align-items:center;gap:.5rem;min-width:0}.mm-ai-session-list__goal{flex:1;min-width:0;font-size:.85rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mm-ai-session-list__bottom{display:flex;align-items:center;gap:.5rem;font-size:.7rem;color:var(--mm-ai-list-muted);font-variant-numeric:tabular-nums;min-width:0}.mm-ai-session-list__meta{display:inline-flex;align-items:baseline;gap:.35rem;flex-shrink:0}.mm-ai-session-list__dot{opacity:.5}.mm-ai-session-list__spacer{flex:1}.mm-ai-session-list__preview{color:var(--mm-ai-list-accent);font-size:.7rem;text-decoration:underline;text-underline-offset:2px;flex-shrink:0}.mm-ai-session-list__preview:hover{text-decoration-thickness:2px}.mm-ai-session-list__empty{padding:1rem;text-align:center;color:var(--mm-ai-list-muted);font-style:italic}.mm-ai-session-list__actions{display:flex;gap:.25rem;flex-shrink:0;opacity:.45;transition:opacity .15s ease}.mm-ai-session-list__row:hover .mm-ai-session-list__actions,.mm-ai-session-list__row--selected .mm-ai-session-list__actions{opacity:1}.mm-ai-session-list__action{padding:.15rem .5rem;background:transparent;border:1px solid var(--mm-ai-list-border);border-radius:.25rem;color:var(--mm-ai-list-text);font-family:inherit;font-size:.65rem;cursor:pointer;transition:border-color .15s ease,color .15s ease,background-color .15s ease}.mm-ai-session-list__action:hover{background:#ffffff0a}.mm-ai-session-list__action--cancel{color:var(--mm-ai-list-action-cancel);border-color:color-mix(in srgb,var(--mm-ai-list-action-cancel) 40%,transparent)}.mm-ai-session-list__action--cancel:hover{border-color:var(--mm-ai-list-action-cancel)}.mm-ai-session-list__action--delete{color:var(--mm-ai-list-action-delete);border-color:color-mix(in srgb,var(--mm-ai-list-action-delete) 40%,transparent)}.mm-ai-session-list__action--delete:hover{border-color:var(--mm-ai-list-action-delete)}\n"]
351
+ }]
352
+ }],
353
+ propDecorators: {
354
+ sessions: [{
355
+ type: i0.Input,
356
+ args: [{
357
+ isSignal: true,
358
+ alias: "sessions",
359
+ required: true
360
+ }]
361
+ }],
362
+ selectedSessionId: [{
363
+ type: i0.Input,
364
+ args: [{
365
+ isSignal: true,
366
+ alias: "selectedSessionId",
367
+ required: false
368
+ }]
369
+ }],
370
+ sessionSelected: [{
371
+ type: i0.Output,
372
+ args: ["sessionSelected"]
373
+ }],
374
+ cancelRequested: [{
375
+ type: i0.Output,
376
+ args: ["cancelRequested"]
377
+ }],
378
+ deleteRequested: [{
379
+ type: i0.Output,
380
+ args: ["deleteRequested"]
381
+ }]
382
+ }
383
+ });
479
384
  function parseSessionEvent(event) {
480
- const payload = safeJsonParse(event.payload);
481
- if (payload === parseFailure) {
482
- return {
483
- event,
484
- view: {
485
- kind: 'unknown',
486
- summary: 'Malformed event payload',
487
- raw: event.payload,
488
- },
489
- };
490
- }
491
- if (event.kind === 'StatusChange' && isRecord(payload)) {
492
- // The orchestrator emits a StatusChange wrapper around any non-content
493
- // worker event — system/init, hooks, rate-limit, etc. Demote based on the
494
- // wrapped `type` so the renderer can collapse the noise.
495
- if (isClaudeStreamFrame(payload)) {
496
- return { event, view: viewFromClaudeFrame(payload) };
497
- }
498
- const status = readString(payload, 'newStatus') ?? readString(payload, 'status');
499
- if (status) {
500
- return { event, view: { kind: 'status-change', status, raw: payload } };
501
- }
502
- }
503
- if (event.kind === 'Hook' && isRecord(payload)) {
504
- return { event, view: viewSystemHook(payload) };
505
- }
506
- if (event.kind === 'Message' && isRecord(payload)) {
507
- if (isClaudeStreamFrame(payload)) {
508
- return { event, view: viewFromClaudeFrame(payload) };
509
- }
510
- // Bare text Message — promote to a single-part assistant bubble so the
511
- // visual treatment is consistent.
512
- const text = readString(payload, 'text');
513
- if (text) {
514
- return {
515
- event,
516
- view: {
517
- kind: 'assistant',
518
- parts: [{ type: 'text', text }],
519
- model: null,
520
- usage: null,
521
- raw: payload,
522
- },
523
- };
524
- }
525
- }
526
- if (event.kind === 'ToolCall' && isRecord(payload)) {
527
- return {
528
- event,
529
- view: {
530
- kind: 'assistant',
531
- parts: [
532
- {
533
- type: 'tool_use',
534
- id: readString(payload, 'callId') ?? '',
535
- toolName: readString(payload, 'toolName') ?? 'tool',
536
- input: payload['arguments'] ?? null,
537
- },
538
- ],
539
- model: null,
540
- usage: null,
541
- raw: payload,
542
- },
543
- };
544
- }
545
- if (event.kind === 'ToolResult' && isRecord(payload)) {
546
- return {
547
- event,
548
- view: {
549
- kind: 'tool-result',
550
- toolUseId: readString(payload, 'callId') ?? readString(payload, 'toolUseId') ?? '',
551
- content: stringifyToolContent(payload['result'] ?? payload['content']),
552
- isError: readBoolean(payload, 'isError') ?? false,
553
- raw: payload,
554
- },
555
- };
556
- }
557
- if (event.kind === 'Error') {
558
- return {
559
- event,
560
- view: {
561
- kind: 'unknown',
562
- summary: typeof payload === 'string' ? payload : 'Error event',
563
- raw: payload,
564
- },
565
- };
566
- }
567
- return {
568
- event,
569
- view: { kind: 'unknown', summary: `Unhandled kind: ${event.kind}`, raw: payload },
570
- };
385
+ const payload = safeJsonParse(event.payload);
386
+ if (payload === parseFailure) return {
387
+ event,
388
+ view: {
389
+ kind: "unknown",
390
+ summary: "Malformed event payload",
391
+ raw: event.payload
392
+ }
393
+ };
394
+ if (event.kind === "StatusChange" && isRecord(payload)) {
395
+ if (isClaudeStreamFrame(payload)) return {
396
+ event,
397
+ view: viewFromClaudeFrame(payload)
398
+ };
399
+ const status = readString(payload, "newStatus") ?? readString(payload, "status");
400
+ if (status) return {
401
+ event,
402
+ view: {
403
+ kind: "status-change",
404
+ status,
405
+ raw: payload
406
+ }
407
+ };
408
+ }
409
+ if (event.kind === "Hook" && isRecord(payload)) return {
410
+ event,
411
+ view: viewSystemHook(payload)
412
+ };
413
+ if (event.kind === "Message" && isRecord(payload)) {
414
+ if (isClaudeStreamFrame(payload)) return {
415
+ event,
416
+ view: viewFromClaudeFrame(payload)
417
+ };
418
+ const text = readString(payload, "text");
419
+ if (text) return {
420
+ event,
421
+ view: {
422
+ kind: "assistant",
423
+ parts: [{
424
+ type: "text",
425
+ text
426
+ }],
427
+ model: null,
428
+ usage: null,
429
+ raw: payload
430
+ }
431
+ };
432
+ }
433
+ if (event.kind === "ToolCall" && isRecord(payload)) return {
434
+ event,
435
+ view: {
436
+ kind: "assistant",
437
+ parts: [{
438
+ type: "tool_use",
439
+ id: readString(payload, "callId") ?? "",
440
+ toolName: readString(payload, "toolName") ?? "tool",
441
+ input: payload["arguments"] ?? null
442
+ }],
443
+ model: null,
444
+ usage: null,
445
+ raw: payload
446
+ }
447
+ };
448
+ if (event.kind === "ToolResult" && isRecord(payload)) return {
449
+ event,
450
+ view: {
451
+ kind: "tool-result",
452
+ toolUseId: readString(payload, "callId") ?? readString(payload, "toolUseId") ?? "",
453
+ content: stringifyToolContent(payload["result"] ?? payload["content"]),
454
+ isError: readBoolean(payload, "isError") ?? false,
455
+ raw: payload
456
+ }
457
+ };
458
+ if (event.kind === "Error") return {
459
+ event,
460
+ view: {
461
+ kind: "unknown",
462
+ summary: typeof payload === "string" ? payload : "Error event",
463
+ raw: payload
464
+ }
465
+ };
466
+ return {
467
+ event,
468
+ view: {
469
+ kind: "unknown",
470
+ summary: `Unhandled kind: ${event.kind}`,
471
+ raw: payload
472
+ }
473
+ };
571
474
  }
572
- /**
573
- * Sort parsed events by sequence so out-of-order arrival (the REST backfill +
574
- * live SignalR union) renders deterministically. Kept here so the component
575
- * doesn't redo the sort logic every render cycle.
576
- */
577
475
  function parseAndOrder(events) {
578
- return [...events]
579
- .sort((a, b) => a.sequence - b.sequence)
580
- .map(parseSessionEvent);
476
+ return [...events].sort((a, b) => a.sequence - b.sequence).map(parseSessionEvent);
581
477
  }
582
- // ────────────────────────────────────────────────────────────────────────────
583
- // Internals
584
- // ────────────────────────────────────────────────────────────────────────────
585
- const parseFailure = Symbol('parseFailure');
478
+ const parseFailure = Symbol("parseFailure");
586
479
  function safeJsonParse(raw) {
587
- try {
588
- return JSON.parse(raw);
589
- }
590
- catch {
591
- return parseFailure;
592
- }
480
+ try {
481
+ return JSON.parse(raw);
482
+ } catch {
483
+ return parseFailure;
484
+ }
593
485
  }
594
486
  function isRecord(v) {
595
- return typeof v === 'object' && v !== null && !Array.isArray(v);
487
+ return typeof v === "object" && v !== null && !Array.isArray(v);
596
488
  }
597
489
  function readString(rec, key) {
598
- const v = rec[key];
599
- return typeof v === 'string' && v.length > 0 ? v : null;
490
+ const v = rec[key];
491
+ return typeof v === "string" && v.length > 0 ? v : null;
600
492
  }
601
493
  function readNumber(rec, key) {
602
- const v = rec[key];
603
- return typeof v === 'number' && Number.isFinite(v) ? v : null;
494
+ const v = rec[key];
495
+ return typeof v === "number" && Number.isFinite(v) ? v : null;
604
496
  }
605
497
  function readBoolean(rec, key) {
606
- const v = rec[key];
607
- return typeof v === 'boolean' ? v : null;
498
+ const v = rec[key];
499
+ return typeof v === "boolean" ? v : null;
608
500
  }
609
- /**
610
- * Claude Code's stream-json shapes a frame as `{ type, ... }` with a small
611
- * vocabulary: `system`, `assistant`, `user`, `result`, `rate_limit_event`.
612
- * We branch on `type` (+ optional `subtype` for `system`) and rely on every
613
- * other claim being optional — the renderer must not crash on a frame we've
614
- * never seen.
615
- */
616
501
  function isClaudeStreamFrame(rec) {
617
- return typeof rec['type'] === 'string';
502
+ return typeof rec["type"] === "string";
618
503
  }
619
504
  function viewFromClaudeFrame(rec) {
620
- const type = rec['type'];
621
- if (type === 'system') {
622
- const subtype = readString(rec, 'subtype');
623
- if (subtype === 'init') {
624
- return {
625
- kind: 'system',
626
- subKind: 'init',
627
- summary: `Worker initialised — ${readString(rec, 'model') ?? 'model'}`,
628
- raw: rec,
629
- };
630
- }
631
- if (subtype === 'hook_started' || subtype === 'hook_response') {
632
- const hookName = readString(rec, 'hook_name') ?? 'hook';
633
- return {
634
- kind: 'system',
635
- subKind: 'hook',
636
- summary: subtype === 'hook_started'
637
- ? `Hook started — ${hookName}`
638
- : `Hook completed — ${hookName}`,
639
- raw: rec,
640
- };
641
- }
642
- return {
643
- kind: 'system',
644
- subKind: 'other',
645
- summary: `System event${subtype ? ' — ' + subtype : ''}`,
646
- raw: rec,
647
- };
648
- }
649
- if (type === 'rate_limit_event') {
650
- const info = rec['rate_limit_info'];
651
- let summary = 'Rate-limit event';
652
- if (isRecord(info)) {
653
- const status = readString(info, 'status');
654
- const rateLimitType = readString(info, 'rateLimitType');
655
- if (status && rateLimitType) {
656
- summary = `Rate-limit ${status} (${rateLimitType})`;
657
- }
658
- }
659
- return { kind: 'system', subKind: 'rate-limit', summary, raw: rec };
660
- }
661
- if (type === 'assistant') {
662
- const message = rec['message'];
663
- if (isRecord(message)) {
664
- const parts = extractAssistantParts(message['content']);
665
- const model = readString(message, 'model');
666
- const usage = isRecord(message['usage']) ? extractUsage(message['usage']) : null;
667
- return {
668
- kind: 'assistant',
669
- parts,
670
- model,
671
- usage,
672
- raw: rec,
673
- };
674
- }
675
- }
676
- if (type === 'user') {
677
- // claude wraps tool_result inside a `user` frame's content. Extract the
678
- // first tool_result we find; if there isn't one, fall through to unknown.
679
- const message = rec['message'];
680
- if (isRecord(message) && Array.isArray(message['content'])) {
681
- for (const part of message['content']) {
682
- if (isRecord(part) && part['type'] === 'tool_result') {
683
- const rawContent = part['content'];
684
- return {
685
- kind: 'tool-result',
686
- toolUseId: readString(part, 'tool_use_id') ?? '',
687
- content: stringifyToolContent(rawContent),
688
- isError: readBoolean(part, 'is_error') ?? false,
689
- raw: rec,
690
- };
691
- }
692
- }
693
- }
694
- }
695
- if (type === 'result') {
696
- const usage = isRecord(rec['usage']) ? extractUsage(rec['usage']) : null;
697
- return {
698
- kind: 'result',
699
- text: readString(rec, 'result') ?? '',
700
- durationMs: readNumber(rec, 'duration_ms') ?? 0,
701
- usage,
702
- costUsd: readNumber(rec, 'total_cost_usd'),
703
- reason: readString(rec, 'terminal_reason') ?? readString(rec, 'stop_reason') ?? 'completed',
704
- isError: readBoolean(rec, 'is_error') ?? false,
705
- raw: rec,
706
- };
707
- }
708
- return {
709
- kind: 'unknown',
710
- summary: `Unrecognised claude frame type: ${typeof type === 'string' ? type : 'n/a'}`,
711
- raw: rec,
712
- };
505
+ const type = rec["type"];
506
+ if (type === "system") {
507
+ const subtype = readString(rec, "subtype");
508
+ if (subtype === "init") return {
509
+ kind: "system",
510
+ subKind: "init",
511
+ summary: `Worker initialised — ${readString(rec, "model") ?? "model"}`,
512
+ raw: rec
513
+ };
514
+ if (subtype === "hook_started" || subtype === "hook_response") {
515
+ const hookName = readString(rec, "hook_name") ?? "hook";
516
+ return {
517
+ kind: "system",
518
+ subKind: "hook",
519
+ summary: subtype === "hook_started" ? `Hook started — ${hookName}` : `Hook completed — ${hookName}`,
520
+ raw: rec
521
+ };
522
+ }
523
+ return {
524
+ kind: "system",
525
+ subKind: "other",
526
+ summary: `System event${subtype ? " — " + subtype : ""}`,
527
+ raw: rec
528
+ };
529
+ }
530
+ if (type === "rate_limit_event") {
531
+ const info = rec["rate_limit_info"];
532
+ let summary = "Rate-limit event";
533
+ if (isRecord(info)) {
534
+ const status = readString(info, "status");
535
+ const rateLimitType = readString(info, "rateLimitType");
536
+ if (status && rateLimitType) summary = `Rate-limit ${status} (${rateLimitType})`;
537
+ }
538
+ return {
539
+ kind: "system",
540
+ subKind: "rate-limit",
541
+ summary,
542
+ raw: rec
543
+ };
544
+ }
545
+ if (type === "assistant") {
546
+ const message = rec["message"];
547
+ if (isRecord(message)) return {
548
+ kind: "assistant",
549
+ parts: extractAssistantParts(message["content"]),
550
+ model: readString(message, "model"),
551
+ usage: isRecord(message["usage"]) ? extractUsage(message["usage"]) : null,
552
+ raw: rec
553
+ };
554
+ }
555
+ if (type === "user") {
556
+ const message = rec["message"];
557
+ if (isRecord(message) && Array.isArray(message["content"])) {
558
+ for (const part of message["content"]) if (isRecord(part) && part["type"] === "tool_result") {
559
+ const rawContent = part["content"];
560
+ return {
561
+ kind: "tool-result",
562
+ toolUseId: readString(part, "tool_use_id") ?? "",
563
+ content: stringifyToolContent(rawContent),
564
+ isError: readBoolean(part, "is_error") ?? false,
565
+ raw: rec
566
+ };
567
+ }
568
+ }
569
+ }
570
+ if (type === "result") {
571
+ const usage = isRecord(rec["usage"]) ? extractUsage(rec["usage"]) : null;
572
+ return {
573
+ kind: "result",
574
+ text: readString(rec, "result") ?? "",
575
+ durationMs: readNumber(rec, "duration_ms") ?? 0,
576
+ usage,
577
+ costUsd: readNumber(rec, "total_cost_usd"),
578
+ reason: readString(rec, "terminal_reason") ?? readString(rec, "stop_reason") ?? "completed",
579
+ isError: readBoolean(rec, "is_error") ?? false,
580
+ raw: rec
581
+ };
582
+ }
583
+ return {
584
+ kind: "unknown",
585
+ summary: `Unrecognised claude frame type: ${typeof type === "string" ? type : "n/a"}`,
586
+ raw: rec
587
+ };
713
588
  }
714
589
  function viewSystemHook(rec) {
715
- // Hooks come through as a `Hook` event-kind on our side but the payload
716
- // shape matches claude's hook_started / hook_response stream-json.
717
- return viewFromClaudeFrame(rec);
590
+ return viewFromClaudeFrame(rec);
718
591
  }
719
592
  function extractAssistantParts(content) {
720
- if (!Array.isArray(content)) {
721
- return [];
722
- }
723
- const parts = [];
724
- for (const part of content) {
725
- if (!isRecord(part)) {
726
- continue;
727
- }
728
- if (part['type'] === 'text') {
729
- const text = readString(part, 'text');
730
- if (text !== null) {
731
- parts.push({ type: 'text', text });
732
- }
733
- }
734
- else if (part['type'] === 'tool_use') {
735
- parts.push({
736
- type: 'tool_use',
737
- id: readString(part, 'id') ?? '',
738
- toolName: readString(part, 'name') ?? 'tool',
739
- input: part['input'] ?? null,
740
- });
741
- }
742
- }
743
- return parts;
593
+ if (!Array.isArray(content)) return [];
594
+ const parts = [];
595
+ for (const part of content) {
596
+ if (!isRecord(part)) continue;
597
+ if (part["type"] === "text") {
598
+ const text = readString(part, "text");
599
+ if (text !== null) parts.push({
600
+ type: "text",
601
+ text
602
+ });
603
+ } else if (part["type"] === "tool_use") parts.push({
604
+ type: "tool_use",
605
+ id: readString(part, "id") ?? "",
606
+ toolName: readString(part, "name") ?? "tool",
607
+ input: part["input"] ?? null
608
+ });
609
+ }
610
+ return parts;
744
611
  }
745
612
  function extractUsage(usage) {
746
- return {
747
- input: readNumber(usage, 'input_tokens') ?? 0,
748
- output: readNumber(usage, 'output_tokens') ?? 0,
749
- cacheRead: readNumber(usage, 'cache_read_input_tokens') ?? undefined,
750
- cacheCreation: readNumber(usage, 'cache_creation_input_tokens') ?? undefined,
751
- };
613
+ return {
614
+ input: readNumber(usage, "input_tokens") ?? 0,
615
+ output: readNumber(usage, "output_tokens") ?? 0,
616
+ cacheRead: readNumber(usage, "cache_read_input_tokens") ?? void 0,
617
+ cacheCreation: readNumber(usage, "cache_creation_input_tokens") ?? void 0
618
+ };
752
619
  }
753
- /**
754
- * Tool result `content` comes in many shapes: a plain string, an array of
755
- * `{type:'text', text:...}` blocks (the Anthropic content-block format), or
756
- * raw JSON. Flatten everything we recognise into a single string for the
757
- * UI; the consumer can still pop the raw payload for inspection.
758
- */
759
620
  function stringifyToolContent(content) {
760
- if (typeof content === 'string') {
761
- return content;
762
- }
763
- if (Array.isArray(content)) {
764
- return content
765
- .map((block) => {
766
- if (isRecord(block) && block['type'] === 'text') {
767
- return readString(block, 'text') ?? '';
768
- }
769
- return JSON.stringify(block);
770
- })
771
- .join('\n');
772
- }
773
- if (content === undefined || content === null) {
774
- return '';
775
- }
776
- try {
777
- return JSON.stringify(content, null, 2);
778
- }
779
- catch {
780
- return String(content);
781
- }
782
- }
783
-
784
- /**
785
- * Read-only transcript of a session, derived from the events stream.
786
- *
787
- * The component takes raw `AiSessionEventDto` entries, runs them through the
788
- * `event-parser` to produce a typed `ParsedView` per event, and renders each
789
- * kind with its own treatment — assistant bubbles for chat text, expandable
790
- * cards for tool calls + tool results, single-line collapsed strips for the
791
- * system / hook noise, and a stats panel for the terminal `result` summary.
792
- *
793
- * Markdown rendering inside assistant text is still deferred (concept §10);
794
- * for now the parser hands plain text to the template and the SCSS preserves
795
- * line breaks via `white-space: pre-wrap`. Picking a renderer (markdown-it vs
796
- * marked) is gated on a CSP review and a markdown-corpus regression test.
797
- */
798
- class AiChatStreamComponent {
799
- events = input.required(/* @ts-ignore */
800
- ...(ngDevMode ? [{ debugName: "events" }] : /* istanbul ignore next */ []));
801
- /**
802
- * Sorted + parsed. Recomputes whenever the input signal changes; the sort
803
- * is stable so live appends from SignalR keep prior render positions.
804
- */
805
- parsedEvents = computed(() => parseAndOrder(this.events()), /* @ts-ignore */
806
- ...(ngDevMode ? [{ debugName: "parsedEvents" }] : /* istanbul ignore next */ []));
807
- /**
808
- * Per-event "show raw JSON" toggle. Keyed by sequence so live appends
809
- * don't flicker existing toggles closed. A `Set<number>` rather than a
810
- * record so add / delete avoids `keyof` shenanigans.
811
- */
812
- expandedSet = signal(new Set(), /* @ts-ignore */
813
- ...(ngDevMode ? [{ debugName: "expandedSet" }] : /* istanbul ignore next */ []));
814
- isExpanded(sequence) {
815
- return this.expandedSet().has(sequence);
816
- }
817
- toggleRaw(sequence) {
818
- this.expandedSet.update((prev) => {
819
- const next = new Set(prev);
820
- if (next.has(sequence)) {
821
- next.delete(sequence);
822
- }
823
- else {
824
- next.add(sequence);
825
- }
826
- return next;
827
- });
828
- }
829
- /**
830
- * `HH:MM:SS` formatter — full ISO is too noisy in a 30-event transcript.
831
- * Returns the input unchanged if parsing fails so we don't pretend events
832
- * we can't read are recent.
833
- */
834
- formatTime(iso) {
835
- const d = new Date(iso);
836
- if (Number.isNaN(d.getTime())) {
837
- return iso;
838
- }
839
- return d.toLocaleTimeString('de-AT', { hour12: false });
840
- }
841
- /** Compact "1234 tok" for the assistant header. */
842
- formatTokenCount(n) {
843
- if (n >= 1000) {
844
- return `${(n / 1000).toFixed(1)} ktok`;
845
- }
846
- return `${n} tok`;
847
- }
848
- /** Duration in either `ms` (sub-second) or `s.SS`. */
849
- formatDuration(ms) {
850
- if (ms < 1000) {
851
- return `${Math.round(ms)} ms`;
852
- }
853
- return `${(ms / 1000).toFixed(2)} s`;
854
- }
855
- /** Cost in EUR-style decimals; null + zero collapse to a dash. */
856
- formatCost(usd) {
857
- if (usd == null || usd === 0) {
858
- return '—';
859
- }
860
- return `$${usd.toFixed(4)}`;
861
- }
862
- /** Pretty-print arbitrary tool_use input or raw blocks for the expandable detail panel. */
863
- formatRaw(value) {
864
- if (value === undefined || value === null) {
865
- return '';
866
- }
867
- if (typeof value === 'string') {
868
- return value;
869
- }
870
- try {
871
- return JSON.stringify(value, null, 2);
872
- }
873
- catch {
874
- return String(value);
875
- }
876
- }
877
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiChatStreamComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
878
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AiChatStreamComponent, isStandalone: true, selector: "mm-ai-chat-stream", inputs: { events: { classPropertyName: "events", publicName: "events", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<div class=\"mm-ai-chat\">\n @for (parsed of parsedEvents(); track parsed.event.sequence) {\n @switch (parsed.view.kind) {\n @case ('assistant') {\n <article class=\"mm-ai-chat__bubble mm-ai-chat__bubble--assistant\">\n <header class=\"mm-ai-chat__bubble-header\">\n <span class=\"mm-ai-chat__role\">Assistant</span>\n @if (parsed.view.model; as model) {\n <span class=\"mm-ai-chat__meta\">{{ model }}</span>\n }\n @if (parsed.view.usage; as usage) {\n <span class=\"mm-ai-chat__meta\">\n {{ formatTokenCount(usage.input + usage.output) }}\n </span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @for (part of parsed.view.parts; track $index) {\n @switch (part.type) {\n @case ('text') {\n <p class=\"mm-ai-chat__text\">{{ part.text }}</p>\n }\n @case ('tool_use') {\n <div class=\"mm-ai-chat__tool-use\">\n <header class=\"mm-ai-chat__tool-use-header\">\n <span class=\"mm-ai-chat__tool-badge\">tool</span>\n <span class=\"mm-ai-chat__tool-name\">{{ part.toolName }}</span>\n </header>\n <pre class=\"mm-ai-chat__tool-input\">{{ formatRaw(part.input) }}</pre>\n </div>\n }\n }\n }\n </article>\n }\n\n @case ('tool-result') {\n <article\n class=\"mm-ai-chat__tool-result\"\n [class.mm-ai-chat__tool-result--error]=\"parsed.view.isError\"\n >\n <header class=\"mm-ai-chat__tool-result-header\">\n <span class=\"mm-ai-chat__role\">Tool result</span>\n @if (parsed.view.isError) {\n <span class=\"mm-ai-chat__error-badge\">error</span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n <pre class=\"mm-ai-chat__tool-result-body\">{{ parsed.view.content }}</pre>\n </article>\n }\n\n @case ('result') {\n <article class=\"mm-ai-chat__result\"\n [class.mm-ai-chat__result--error]=\"parsed.view.isError\">\n <header class=\"mm-ai-chat__result-header\">\n <span class=\"mm-ai-chat__role\">{{ parsed.view.reason }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @if (parsed.view.text) {\n <p class=\"mm-ai-chat__result-text\">{{ parsed.view.text }}</p>\n }\n <dl class=\"mm-ai-chat__result-stats\">\n <div>\n <dt>Duration</dt>\n <dd>{{ formatDuration(parsed.view.durationMs) }}</dd>\n </div>\n <div>\n <dt>Tokens (in/out)</dt>\n <dd>\n @if (parsed.view.usage) {\n {{ formatTokenCount(parsed.view.usage.input) }}\n /\n {{ formatTokenCount(parsed.view.usage.output) }}\n } @else {\n \u2014\n }\n </dd>\n </div>\n <div>\n <dt>Cost</dt>\n <dd>{{ formatCost(parsed.view.costUsd) }}</dd>\n </div>\n </dl>\n </article>\n }\n\n @case ('system') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system\"\n [class.mm-ai-chat__system--init]=\"parsed.view.subKind === 'init'\"\n [class.mm-ai-chat__system--hook]=\"parsed.view.subKind === 'hook'\"\n [class.mm-ai-chat__system--rate]=\"parsed.view.subKind === 'rate-limit'\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '\u25BE' : '\u25B8' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n\n @case ('status-change') {\n <div class=\"mm-ai-chat__status\">\n <span class=\"mm-ai-chat__status-label\">Status</span>\n <span class=\"mm-ai-chat__status-value\">{{ parsed.view.status }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </div>\n }\n\n @case ('unknown') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system mm-ai-chat__system--unknown\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '\u25BE' : '\u25B8' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n }\n } @empty {\n <div class=\"mm-ai-chat__empty\">\n No events yet \u2014 the worker hasn't emitted anything.\n </div>\n }\n</div>\n", styles: [":host{display:block;--mm-ai-chat-bg: transparent;--mm-ai-chat-card-bg: rgba(31, 46, 64, .55);--mm-ai-chat-card-bg-elevated: rgba(31, 46, 64, .85);--mm-ai-chat-border: rgba(100, 206, 185, .18);--mm-ai-chat-border-strong: rgba(100, 206, 185, .4);--mm-ai-chat-text: #e6e6e6;--mm-ai-chat-muted: #9292a6;--mm-ai-chat-accent-assistant: #64ceb9;--mm-ai-chat-accent-tool: #00a8dc;--mm-ai-chat-accent-tool-result: #00a8dc;--mm-ai-chat-accent-system: #6c4da8;--mm-ai-chat-accent-rate-limit: #da9162;--mm-ai-chat-accent-result: #64ceb9;--mm-ai-chat-accent-error: #ec658f}.mm-ai-chat{display:flex;flex-direction:column;gap:.5rem;padding:.25rem;background:var(--mm-ai-chat-bg);color:var(--mm-ai-chat-text);font-size:.85rem;line-height:1.45}.mm-ai-chat__empty{color:var(--mm-ai-chat-muted);text-align:center;padding:1.5rem;font-style:italic}.mm-ai-chat__bubble{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-assistant);border-radius:.5rem;padding:.6rem .75rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__bubble-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__role{font-weight:700;color:var(--mm-ai-chat-accent-assistant)}.mm-ai-chat__meta{font-family:Roboto Mono,monospace;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__time{margin-left:auto;font-variant-numeric:tabular-nums;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__text{margin:0;white-space:pre-wrap;word-break:break-word}.mm-ai-chat__tool-use{border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-tool);border-radius:.35rem;background:var(--mm-ai-chat-card-bg-elevated);padding:.4rem .5rem}.mm-ai-chat__tool-use-header{display:flex;align-items:baseline;gap:.4rem;font-size:.7rem}.mm-ai-chat__tool-badge{background:var(--mm-ai-chat-accent-tool);color:#07172b;padding:0 6px;border-radius:.25rem;font-weight:700;font-size:.65rem}.mm-ai-chat__tool-name{font-family:Roboto Mono,monospace;color:var(--mm-ai-chat-text);font-weight:600}.mm-ai-chat__tool-input{margin:.35rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;color:var(--mm-ai-chat-muted);max-height:14rem;overflow-y:auto}.mm-ai-chat__tool-result{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-tool-result);border-radius:.5rem;padding:.55rem .75rem;margin-left:1.25rem}.mm-ai-chat__tool-result--error{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__tool-result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__tool-result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-tool-result)}.mm-ai-chat__error-badge{background:var(--mm-ai-chat-accent-error);color:#07172b;padding:0 6px;border-radius:.25rem;font-size:.6rem;font-weight:700}.mm-ai-chat__tool-result-body{margin:.4rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;max-height:18rem;overflow-y:auto}.mm-ai-chat__result{background:var(--mm-ai-chat-card-bg-elevated);border:1px solid var(--mm-ai-chat-border-strong);border-top:3px solid var(--mm-ai-chat-accent-result);border-radius:.5rem;padding:.7rem .85rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__result--error{border-top-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-result)}.mm-ai-chat__result-text{margin:0;white-space:pre-wrap;word-break:break-word;font-style:italic;color:var(--mm-ai-chat-text)}.mm-ai-chat__result-stats{margin:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(7rem,1fr));gap:.5rem;font-family:Roboto Mono,monospace;font-size:.75rem}.mm-ai-chat__result-stats div{display:flex;flex-direction:column;gap:.2rem;padding:.4rem .5rem;background:#64ceb90f;border-radius:.3rem}.mm-ai-chat__result-stats dt{font-size:.62rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-stats dd{margin:0;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system{all:unset;cursor:pointer;display:flex;align-items:center;gap:.5rem;padding:.35rem .6rem;background:#64ceb908;border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-system);border-radius:.4rem;font-size:.78rem;color:var(--mm-ai-chat-muted);transition:background-color .15s ease}.mm-ai-chat__system:hover{background:#64ceb90f}.mm-ai-chat__system:focus-visible{outline:2px solid var(--mm-ai-chat-accent-assistant);outline-offset:1px}.mm-ai-chat__system--init{border-left-color:var(--mm-ai-chat-accent-tool)}.mm-ai-chat__system--hook{border-left-color:var(--mm-ai-chat-accent-system)}.mm-ai-chat__system--rate{border-left-color:var(--mm-ai-chat-accent-rate-limit)}.mm-ai-chat__system--unknown{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__system-chevron{font-size:.7rem;width:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__system-summary{flex:1;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system-detail{margin:-.25rem 0 0 1.5rem;padding:.5rem .6rem;background:#00000040;border-radius:.35rem;font-family:Roboto Mono,monospace;font-size:.7rem;white-space:pre-wrap;word-break:break-word;max-height:22rem;overflow-y:auto;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status{display:flex;align-items:baseline;gap:.5rem;padding:.25rem .5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-label{color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-value{color:var(--mm-ai-chat-text);font-weight:600}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
879
- }
880
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiChatStreamComponent, decorators: [{
881
- type: Component,
882
- args: [{ selector: 'mm-ai-chat-stream', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mm-ai-chat\">\n @for (parsed of parsedEvents(); track parsed.event.sequence) {\n @switch (parsed.view.kind) {\n @case ('assistant') {\n <article class=\"mm-ai-chat__bubble mm-ai-chat__bubble--assistant\">\n <header class=\"mm-ai-chat__bubble-header\">\n <span class=\"mm-ai-chat__role\">Assistant</span>\n @if (parsed.view.model; as model) {\n <span class=\"mm-ai-chat__meta\">{{ model }}</span>\n }\n @if (parsed.view.usage; as usage) {\n <span class=\"mm-ai-chat__meta\">\n {{ formatTokenCount(usage.input + usage.output) }}\n </span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @for (part of parsed.view.parts; track $index) {\n @switch (part.type) {\n @case ('text') {\n <p class=\"mm-ai-chat__text\">{{ part.text }}</p>\n }\n @case ('tool_use') {\n <div class=\"mm-ai-chat__tool-use\">\n <header class=\"mm-ai-chat__tool-use-header\">\n <span class=\"mm-ai-chat__tool-badge\">tool</span>\n <span class=\"mm-ai-chat__tool-name\">{{ part.toolName }}</span>\n </header>\n <pre class=\"mm-ai-chat__tool-input\">{{ formatRaw(part.input) }}</pre>\n </div>\n }\n }\n }\n </article>\n }\n\n @case ('tool-result') {\n <article\n class=\"mm-ai-chat__tool-result\"\n [class.mm-ai-chat__tool-result--error]=\"parsed.view.isError\"\n >\n <header class=\"mm-ai-chat__tool-result-header\">\n <span class=\"mm-ai-chat__role\">Tool result</span>\n @if (parsed.view.isError) {\n <span class=\"mm-ai-chat__error-badge\">error</span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n <pre class=\"mm-ai-chat__tool-result-body\">{{ parsed.view.content }}</pre>\n </article>\n }\n\n @case ('result') {\n <article class=\"mm-ai-chat__result\"\n [class.mm-ai-chat__result--error]=\"parsed.view.isError\">\n <header class=\"mm-ai-chat__result-header\">\n <span class=\"mm-ai-chat__role\">{{ parsed.view.reason }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @if (parsed.view.text) {\n <p class=\"mm-ai-chat__result-text\">{{ parsed.view.text }}</p>\n }\n <dl class=\"mm-ai-chat__result-stats\">\n <div>\n <dt>Duration</dt>\n <dd>{{ formatDuration(parsed.view.durationMs) }}</dd>\n </div>\n <div>\n <dt>Tokens (in/out)</dt>\n <dd>\n @if (parsed.view.usage) {\n {{ formatTokenCount(parsed.view.usage.input) }}\n /\n {{ formatTokenCount(parsed.view.usage.output) }}\n } @else {\n \u2014\n }\n </dd>\n </div>\n <div>\n <dt>Cost</dt>\n <dd>{{ formatCost(parsed.view.costUsd) }}</dd>\n </div>\n </dl>\n </article>\n }\n\n @case ('system') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system\"\n [class.mm-ai-chat__system--init]=\"parsed.view.subKind === 'init'\"\n [class.mm-ai-chat__system--hook]=\"parsed.view.subKind === 'hook'\"\n [class.mm-ai-chat__system--rate]=\"parsed.view.subKind === 'rate-limit'\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '\u25BE' : '\u25B8' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n\n @case ('status-change') {\n <div class=\"mm-ai-chat__status\">\n <span class=\"mm-ai-chat__status-label\">Status</span>\n <span class=\"mm-ai-chat__status-value\">{{ parsed.view.status }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </div>\n }\n\n @case ('unknown') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system mm-ai-chat__system--unknown\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '\u25BE' : '\u25B8' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n }\n } @empty {\n <div class=\"mm-ai-chat__empty\">\n No events yet \u2014 the worker hasn't emitted anything.\n </div>\n }\n</div>\n", styles: [":host{display:block;--mm-ai-chat-bg: transparent;--mm-ai-chat-card-bg: rgba(31, 46, 64, .55);--mm-ai-chat-card-bg-elevated: rgba(31, 46, 64, .85);--mm-ai-chat-border: rgba(100, 206, 185, .18);--mm-ai-chat-border-strong: rgba(100, 206, 185, .4);--mm-ai-chat-text: #e6e6e6;--mm-ai-chat-muted: #9292a6;--mm-ai-chat-accent-assistant: #64ceb9;--mm-ai-chat-accent-tool: #00a8dc;--mm-ai-chat-accent-tool-result: #00a8dc;--mm-ai-chat-accent-system: #6c4da8;--mm-ai-chat-accent-rate-limit: #da9162;--mm-ai-chat-accent-result: #64ceb9;--mm-ai-chat-accent-error: #ec658f}.mm-ai-chat{display:flex;flex-direction:column;gap:.5rem;padding:.25rem;background:var(--mm-ai-chat-bg);color:var(--mm-ai-chat-text);font-size:.85rem;line-height:1.45}.mm-ai-chat__empty{color:var(--mm-ai-chat-muted);text-align:center;padding:1.5rem;font-style:italic}.mm-ai-chat__bubble{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-assistant);border-radius:.5rem;padding:.6rem .75rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__bubble-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__role{font-weight:700;color:var(--mm-ai-chat-accent-assistant)}.mm-ai-chat__meta{font-family:Roboto Mono,monospace;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__time{margin-left:auto;font-variant-numeric:tabular-nums;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__text{margin:0;white-space:pre-wrap;word-break:break-word}.mm-ai-chat__tool-use{border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-tool);border-radius:.35rem;background:var(--mm-ai-chat-card-bg-elevated);padding:.4rem .5rem}.mm-ai-chat__tool-use-header{display:flex;align-items:baseline;gap:.4rem;font-size:.7rem}.mm-ai-chat__tool-badge{background:var(--mm-ai-chat-accent-tool);color:#07172b;padding:0 6px;border-radius:.25rem;font-weight:700;font-size:.65rem}.mm-ai-chat__tool-name{font-family:Roboto Mono,monospace;color:var(--mm-ai-chat-text);font-weight:600}.mm-ai-chat__tool-input{margin:.35rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;color:var(--mm-ai-chat-muted);max-height:14rem;overflow-y:auto}.mm-ai-chat__tool-result{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-tool-result);border-radius:.5rem;padding:.55rem .75rem;margin-left:1.25rem}.mm-ai-chat__tool-result--error{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__tool-result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__tool-result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-tool-result)}.mm-ai-chat__error-badge{background:var(--mm-ai-chat-accent-error);color:#07172b;padding:0 6px;border-radius:.25rem;font-size:.6rem;font-weight:700}.mm-ai-chat__tool-result-body{margin:.4rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;max-height:18rem;overflow-y:auto}.mm-ai-chat__result{background:var(--mm-ai-chat-card-bg-elevated);border:1px solid var(--mm-ai-chat-border-strong);border-top:3px solid var(--mm-ai-chat-accent-result);border-radius:.5rem;padding:.7rem .85rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__result--error{border-top-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-result)}.mm-ai-chat__result-text{margin:0;white-space:pre-wrap;word-break:break-word;font-style:italic;color:var(--mm-ai-chat-text)}.mm-ai-chat__result-stats{margin:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(7rem,1fr));gap:.5rem;font-family:Roboto Mono,monospace;font-size:.75rem}.mm-ai-chat__result-stats div{display:flex;flex-direction:column;gap:.2rem;padding:.4rem .5rem;background:#64ceb90f;border-radius:.3rem}.mm-ai-chat__result-stats dt{font-size:.62rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-stats dd{margin:0;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system{all:unset;cursor:pointer;display:flex;align-items:center;gap:.5rem;padding:.35rem .6rem;background:#64ceb908;border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-system);border-radius:.4rem;font-size:.78rem;color:var(--mm-ai-chat-muted);transition:background-color .15s ease}.mm-ai-chat__system:hover{background:#64ceb90f}.mm-ai-chat__system:focus-visible{outline:2px solid var(--mm-ai-chat-accent-assistant);outline-offset:1px}.mm-ai-chat__system--init{border-left-color:var(--mm-ai-chat-accent-tool)}.mm-ai-chat__system--hook{border-left-color:var(--mm-ai-chat-accent-system)}.mm-ai-chat__system--rate{border-left-color:var(--mm-ai-chat-accent-rate-limit)}.mm-ai-chat__system--unknown{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__system-chevron{font-size:.7rem;width:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__system-summary{flex:1;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system-detail{margin:-.25rem 0 0 1.5rem;padding:.5rem .6rem;background:#00000040;border-radius:.35rem;font-family:Roboto Mono,monospace;font-size:.7rem;white-space:pre-wrap;word-break:break-word;max-height:22rem;overflow-y:auto;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status{display:flex;align-items:baseline;gap:.5rem;padding:.25rem .5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-label{color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-value{color:var(--mm-ai-chat-text);font-weight:600}\n"] }]
883
- }], propDecorators: { events: [{ type: i0.Input, args: [{ isSignal: true, alias: "events", required: true }] }] } });
884
-
885
- /**
886
- * Expandable card surface for one tool invocation in a session transcript.
887
- * Click the header to toggle arguments + result; the body is rendered as
888
- * pretty-printed JSON so the host doesn't need its own json formatter.
889
- */
890
- class AiToolCallComponent {
891
- call = input.required(/* @ts-ignore */
892
- ...(ngDevMode ? [{ debugName: "call" }] : /* istanbul ignore next */ []));
893
- expanded = signal(false, /* @ts-ignore */
894
- ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
895
- statusVariant = computed(() => {
896
- const status = this.call().status;
897
- switch (status) {
898
- case 'Succeeded':
899
- return 'succeeded';
900
- case 'Failed':
901
- return 'failed';
902
- case 'Rejected':
903
- return 'rejected';
904
- case 'Approved':
905
- case 'Pending':
906
- return 'pending';
907
- default:
908
- return 'pending';
909
- }
910
- }, /* @ts-ignore */
911
- ...(ngDevMode ? [{ debugName: "statusVariant" }] : /* istanbul ignore next */ []));
912
- argumentsJson = computed(() => this.format(this.call().arguments), /* @ts-ignore */
913
- ...(ngDevMode ? [{ debugName: "argumentsJson" }] : /* istanbul ignore next */ []));
914
- resultJson = computed(() => {
915
- const result = this.call().result;
916
- return result === undefined ? null : this.format(result);
917
- }, /* @ts-ignore */
918
- ...(ngDevMode ? [{ debugName: "resultJson" }] : /* istanbul ignore next */ []));
919
- toggleExpanded() {
920
- this.expanded.update((v) => !v);
921
- }
922
- format(value) {
923
- if (value === null || value === undefined) {
924
- return '';
925
- }
926
- try {
927
- return JSON.stringify(value, null, 2);
928
- }
929
- catch {
930
- return String(value);
931
- }
932
- }
933
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiToolCallComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
934
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AiToolCallComponent, isStandalone: true, selector: "mm-ai-tool-call", inputs: { call: { classPropertyName: "call", publicName: "call", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<div class=\"mm-ai-tool-call mm-ai-tool-call--{{ statusVariant() }}\">\n <button\n type=\"button\"\n class=\"mm-ai-tool-call__header\"\n (click)=\"toggleExpanded()\"\n [attr.aria-expanded]=\"expanded()\"\n >\n <span class=\"mm-ai-tool-call__chevron\">\n {{ expanded() ? '\u25BE' : '\u25B8' }}\n </span>\n <span class=\"mm-ai-tool-call__name\">{{ call().toolName }}</span>\n <span class=\"mm-ai-tool-call__status\">{{ call().status }}</span>\n @if (call().durationMs != null) {\n <span class=\"mm-ai-tool-call__duration\">\n {{ call().durationMs }}ms\n </span>\n }\n </button>\n\n @if (expanded()) {\n <div class=\"mm-ai-tool-call__body\">\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Arguments</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ argumentsJson() }}</pre>\n </div>\n\n @if (resultJson() !== null) {\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Result</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ resultJson() }}</pre>\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{display:block;--mm-ai-tool-bg: #1f2227;--mm-ai-tool-border: #2f343b;--mm-ai-tool-text: #e6e6e6;--mm-ai-tool-muted: #9aa0a6;--mm-ai-tool-success: #2ea44f;--mm-ai-tool-failed: #d73a49;--mm-ai-tool-rejected: #d29922;--mm-ai-tool-pending: #6e7681;--mm-ai-tool-code-bg: #16191d}.mm-ai-tool-call{border:1px solid var(--mm-ai-tool-border);border-radius:.5rem;background:var(--mm-ai-tool-bg);color:var(--mm-ai-tool-text);margin:.4rem 0;overflow:hidden}.mm-ai-tool-call--succeeded{border-left:3px solid var(--mm-ai-tool-success)}.mm-ai-tool-call--failed{border-left:3px solid var(--mm-ai-tool-failed)}.mm-ai-tool-call--rejected{border-left:3px solid var(--mm-ai-tool-rejected)}.mm-ai-tool-call--pending{border-left:3px solid var(--mm-ai-tool-pending)}.mm-ai-tool-call__header{width:100%;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;background:transparent;color:inherit;border:none;cursor:pointer;text-align:left;font-family:inherit;font-size:.9rem}.mm-ai-tool-call__header:hover{background:#ffffff0a}.mm-ai-tool-call__chevron{width:1rem;text-align:center;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__name{font-weight:600;flex:1}.mm-ai-tool-call__status,.mm-ai-tool-call__duration{font-size:.75rem;color:var(--mm-ai-tool-muted);font-variant-numeric:tabular-nums}.mm-ai-tool-call__body{border-top:1px solid var(--mm-ai-tool-border);padding:.5rem .75rem}.mm-ai-tool-call__section+.mm-ai-tool-call__section{margin-top:.75rem}.mm-ai-tool-call__heading{margin:0 0 .25rem;font-size:.75rem;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-tool-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
935
- }
936
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiToolCallComponent, decorators: [{
937
- type: Component,
938
- args: [{ selector: 'mm-ai-tool-call', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mm-ai-tool-call mm-ai-tool-call--{{ statusVariant() }}\">\n <button\n type=\"button\"\n class=\"mm-ai-tool-call__header\"\n (click)=\"toggleExpanded()\"\n [attr.aria-expanded]=\"expanded()\"\n >\n <span class=\"mm-ai-tool-call__chevron\">\n {{ expanded() ? '\u25BE' : '\u25B8' }}\n </span>\n <span class=\"mm-ai-tool-call__name\">{{ call().toolName }}</span>\n <span class=\"mm-ai-tool-call__status\">{{ call().status }}</span>\n @if (call().durationMs != null) {\n <span class=\"mm-ai-tool-call__duration\">\n {{ call().durationMs }}ms\n </span>\n }\n </button>\n\n @if (expanded()) {\n <div class=\"mm-ai-tool-call__body\">\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Arguments</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ argumentsJson() }}</pre>\n </div>\n\n @if (resultJson() !== null) {\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Result</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ resultJson() }}</pre>\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{display:block;--mm-ai-tool-bg: #1f2227;--mm-ai-tool-border: #2f343b;--mm-ai-tool-text: #e6e6e6;--mm-ai-tool-muted: #9aa0a6;--mm-ai-tool-success: #2ea44f;--mm-ai-tool-failed: #d73a49;--mm-ai-tool-rejected: #d29922;--mm-ai-tool-pending: #6e7681;--mm-ai-tool-code-bg: #16191d}.mm-ai-tool-call{border:1px solid var(--mm-ai-tool-border);border-radius:.5rem;background:var(--mm-ai-tool-bg);color:var(--mm-ai-tool-text);margin:.4rem 0;overflow:hidden}.mm-ai-tool-call--succeeded{border-left:3px solid var(--mm-ai-tool-success)}.mm-ai-tool-call--failed{border-left:3px solid var(--mm-ai-tool-failed)}.mm-ai-tool-call--rejected{border-left:3px solid var(--mm-ai-tool-rejected)}.mm-ai-tool-call--pending{border-left:3px solid var(--mm-ai-tool-pending)}.mm-ai-tool-call__header{width:100%;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;background:transparent;color:inherit;border:none;cursor:pointer;text-align:left;font-family:inherit;font-size:.9rem}.mm-ai-tool-call__header:hover{background:#ffffff0a}.mm-ai-tool-call__chevron{width:1rem;text-align:center;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__name{font-weight:600;flex:1}.mm-ai-tool-call__status,.mm-ai-tool-call__duration{font-size:.75rem;color:var(--mm-ai-tool-muted);font-variant-numeric:tabular-nums}.mm-ai-tool-call__body{border-top:1px solid var(--mm-ai-tool-border);padding:.5rem .75rem}.mm-ai-tool-call__section+.mm-ai-tool-call__section{margin-top:.75rem}.mm-ai-tool-call__heading{margin:0 0 .25rem;font-size:.75rem;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-tool-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word}\n"] }]
939
- }], propDecorators: { call: [{ type: i0.Input, args: [{ isSignal: true, alias: "call", required: true }] }] } });
940
-
941
- /**
942
- * Approval modal. The host opens it when a `AiApprovalRequestedDto` arrives on
943
- * the SignalR stream, fills the `request` input, and listens for the `decide`
944
- * output to call `AiAdapterClientService.decideApproval`. The modal itself is
945
- * presentation-only: no networking, no global state, no portal magic.
946
- *
947
- * The host is expected to wrap the modal in its own backdrop / focus-trap so
948
- * the library doesn't pull in a positioning dependency (CDK overlay, Kendo
949
- * window, ng-bootstrap, …) — each host shop already has one.
950
- */
951
- class AiApprovalModalComponent {
952
- request = input.required(/* @ts-ignore */
953
- ...(ngDevMode ? [{ debugName: "request" }] : /* istanbul ignore next */ []));
954
- decide = output();
955
- dismiss = output();
956
- comment = signal('', /* @ts-ignore */
957
- ...(ngDevMode ? [{ debugName: "comment" }] : /* istanbul ignore next */ []));
958
- prettyPayload = computed(() => {
959
- try {
960
- return JSON.stringify(JSON.parse(this.request().payload), null, 2);
961
- }
962
- catch {
963
- return this.request().payload;
964
- }
965
- }, /* @ts-ignore */
966
- ...(ngDevMode ? [{ debugName: "prettyPayload" }] : /* istanbul ignore next */ []));
967
- approve() {
968
- this.decide.emit({
969
- outcome: 'Approved',
970
- comment: this.commentOrUndefined(),
971
- });
972
- }
973
- reject() {
974
- this.decide.emit({
975
- outcome: 'Rejected',
976
- comment: this.commentOrUndefined(),
977
- });
978
- }
979
- onDismiss() {
980
- this.dismiss.emit();
981
- }
982
- commentOrUndefined() {
983
- const trimmed = this.comment().trim();
984
- return trimmed.length > 0 ? trimmed : undefined;
985
- }
986
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiApprovalModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
987
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: AiApprovalModalComponent, isStandalone: true, selector: "mm-ai-approval-modal", inputs: { request: { classPropertyName: "request", publicName: "request", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { decide: "decide", dismiss: "dismiss" }, ngImport: i0, template: "<div class=\"mm-ai-approval\">\n <header class=\"mm-ai-approval__header\">\n <h3 class=\"mm-ai-approval__title\">Approve tool call</h3>\n <button\n type=\"button\"\n class=\"mm-ai-approval__close\"\n (click)=\"onDismiss()\"\n aria-label=\"Dismiss\"\n >\n \u00D7\n </button>\n </header>\n\n <div class=\"mm-ai-approval__meta\">\n <div><span>Tool:</span> <code>{{ request().toolName }}</code></div>\n <div><span>Reason:</span> <code>{{ request().reason }}</code></div>\n <div><span>Session:</span> <code>{{ request().sessionId }}</code></div>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Payload</h4>\n <pre class=\"mm-ai-approval__code\">{{ prettyPayload() }}</pre>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Comment <span>(optional)</span></h4>\n <textarea\n class=\"mm-ai-approval__comment\"\n [ngModel]=\"comment()\"\n (ngModelChange)=\"comment.set($event)\"\n rows=\"3\"\n placeholder=\"Why is this approved or rejected?\"\n ></textarea>\n </div>\n\n <footer class=\"mm-ai-approval__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--reject\"\n (click)=\"reject()\"\n >\n Reject\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--approve\"\n (click)=\"approve()\"\n >\n Approve\n </button>\n </footer>\n</div>\n", styles: [":host{display:block;--mm-ai-approval-bg: #1f2227;--mm-ai-approval-border: #2f343b;--mm-ai-approval-text: #e6e6e6;--mm-ai-approval-muted: #9aa0a6;--mm-ai-approval-approve: #2ea44f;--mm-ai-approval-reject: #d73a49;--mm-ai-approval-code-bg: #16191d}.mm-ai-approval{background:var(--mm-ai-approval-bg);color:var(--mm-ai-approval-text);border:1px solid var(--mm-ai-approval-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(36rem,100%)}.mm-ai-approval__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-approval__title{margin:0;font-size:1rem}.mm-ai-approval__close{background:transparent;color:var(--mm-ai-approval-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-approval__close:hover{color:var(--mm-ai-approval-text)}.mm-ai-approval__meta{display:grid;gap:.25rem;font-size:.85rem;margin-bottom:.75rem}.mm-ai-approval__meta span{color:var(--mm-ai-approval-muted);margin-right:.35rem}.mm-ai-approval__meta code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.mm-ai-approval__section{margin-bottom:.75rem}.mm-ai-approval__heading{margin:0 0 .3rem;font-size:.75rem;color:var(--mm-ai-approval-muted)}.mm-ai-approval__heading span{text-transform:none;opacity:.6}.mm-ai-approval__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word;max-height:14rem}.mm-ai-approval__comment{width:100%;box-sizing:border-box;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);color:inherit;border:1px solid var(--mm-ai-approval-border);border-radius:.3rem;font-family:inherit;font-size:.85rem;resize:vertical}.mm-ai-approval__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-approval__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-approval__btn--approve{background:var(--mm-ai-approval-approve);color:#fff}.mm-ai-approval__btn--reject{background:var(--mm-ai-approval-reject);color:#fff}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
988
- }
989
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiApprovalModalComponent, decorators: [{
990
- type: Component,
991
- args: [{ selector: 'mm-ai-approval-modal', imports: [FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mm-ai-approval\">\n <header class=\"mm-ai-approval__header\">\n <h3 class=\"mm-ai-approval__title\">Approve tool call</h3>\n <button\n type=\"button\"\n class=\"mm-ai-approval__close\"\n (click)=\"onDismiss()\"\n aria-label=\"Dismiss\"\n >\n \u00D7\n </button>\n </header>\n\n <div class=\"mm-ai-approval__meta\">\n <div><span>Tool:</span> <code>{{ request().toolName }}</code></div>\n <div><span>Reason:</span> <code>{{ request().reason }}</code></div>\n <div><span>Session:</span> <code>{{ request().sessionId }}</code></div>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Payload</h4>\n <pre class=\"mm-ai-approval__code\">{{ prettyPayload() }}</pre>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Comment <span>(optional)</span></h4>\n <textarea\n class=\"mm-ai-approval__comment\"\n [ngModel]=\"comment()\"\n (ngModelChange)=\"comment.set($event)\"\n rows=\"3\"\n placeholder=\"Why is this approved or rejected?\"\n ></textarea>\n </div>\n\n <footer class=\"mm-ai-approval__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--reject\"\n (click)=\"reject()\"\n >\n Reject\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--approve\"\n (click)=\"approve()\"\n >\n Approve\n </button>\n </footer>\n</div>\n", styles: [":host{display:block;--mm-ai-approval-bg: #1f2227;--mm-ai-approval-border: #2f343b;--mm-ai-approval-text: #e6e6e6;--mm-ai-approval-muted: #9aa0a6;--mm-ai-approval-approve: #2ea44f;--mm-ai-approval-reject: #d73a49;--mm-ai-approval-code-bg: #16191d}.mm-ai-approval{background:var(--mm-ai-approval-bg);color:var(--mm-ai-approval-text);border:1px solid var(--mm-ai-approval-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(36rem,100%)}.mm-ai-approval__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-approval__title{margin:0;font-size:1rem}.mm-ai-approval__close{background:transparent;color:var(--mm-ai-approval-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-approval__close:hover{color:var(--mm-ai-approval-text)}.mm-ai-approval__meta{display:grid;gap:.25rem;font-size:.85rem;margin-bottom:.75rem}.mm-ai-approval__meta span{color:var(--mm-ai-approval-muted);margin-right:.35rem}.mm-ai-approval__meta code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.mm-ai-approval__section{margin-bottom:.75rem}.mm-ai-approval__heading{margin:0 0 .3rem;font-size:.75rem;color:var(--mm-ai-approval-muted)}.mm-ai-approval__heading span{text-transform:none;opacity:.6}.mm-ai-approval__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word;max-height:14rem}.mm-ai-approval__comment{width:100%;box-sizing:border-box;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);color:inherit;border:1px solid var(--mm-ai-approval-border);border-radius:.3rem;font-family:inherit;font-size:.85rem;resize:vertical}.mm-ai-approval__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-approval__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-approval__btn--approve{background:var(--mm-ai-approval-approve);color:#fff}.mm-ai-approval__btn--reject{background:var(--mm-ai-approval-reject);color:#fff}\n"] }]
992
- }], propDecorators: { request: [{ type: i0.Input, args: [{ isSignal: true, alias: "request", required: true }] }], decide: [{ type: i0.Output, args: ["decide"] }], dismiss: [{ type: i0.Output, args: ["dismiss"] }] } });
993
-
994
- /**
995
- * Two-bar usage indicator (daily + monthly) with threshold colour state.
996
- * Inputs are unit-agnostic counts and caps; the component does not parse the
997
- * tenant's `AiQuotaLimit` itself — the host is expected to feed numbers the
998
- * adapter already aggregated.
999
- */
1000
- class AiQuotaIndicatorComponent {
1001
- dailyConsumed = input.required(/* @ts-ignore */
1002
- ...(ngDevMode ? [{ debugName: "dailyConsumed" }] : /* istanbul ignore next */ []));
1003
- dailyCap = input.required(/* @ts-ignore */
1004
- ...(ngDevMode ? [{ debugName: "dailyCap" }] : /* istanbul ignore next */ []));
1005
- monthlyConsumed = input(null, /* @ts-ignore */
1006
- ...(ngDevMode ? [{ debugName: "monthlyConsumed" }] : /* istanbul ignore next */ []));
1007
- monthlyCap = input(null, /* @ts-ignore */
1008
- ...(ngDevMode ? [{ debugName: "monthlyCap" }] : /* istanbul ignore next */ []));
1009
- dailyPercent = computed(() => this.percent(this.dailyConsumed(), this.dailyCap()), /* @ts-ignore */
1010
- ...(ngDevMode ? [{ debugName: "dailyPercent" }] : /* istanbul ignore next */ []));
1011
- monthlyPercent = computed(() => {
1012
- const consumed = this.monthlyConsumed();
1013
- const cap = this.monthlyCap();
1014
- if (consumed == null || cap == null) {
1015
- return null;
1016
- }
1017
- return this.percent(consumed, cap);
1018
- }, /* @ts-ignore */
1019
- ...(ngDevMode ? [{ debugName: "monthlyPercent" }] : /* istanbul ignore next */ []));
1020
- dailyState = computed(() => this.toState(this.dailyPercent()), /* @ts-ignore */
1021
- ...(ngDevMode ? [{ debugName: "dailyState" }] : /* istanbul ignore next */ []));
1022
- monthlyState = computed(() => {
1023
- const pct = this.monthlyPercent();
1024
- return pct == null ? null : this.toState(pct);
1025
- }, /* @ts-ignore */
1026
- ...(ngDevMode ? [{ debugName: "monthlyState" }] : /* istanbul ignore next */ []));
1027
- percent(consumed, cap) {
1028
- if (cap <= 0) {
1029
- return 0;
1030
- }
1031
- return Math.min(100, Math.round((consumed / cap) * 100));
1032
- }
1033
- toState(percent) {
1034
- if (percent >= 100) {
1035
- return 'critical';
1036
- }
1037
- if (percent >= 80) {
1038
- return 'warning';
1039
- }
1040
- return 'ok';
1041
- }
1042
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiQuotaIndicatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1043
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AiQuotaIndicatorComponent, isStandalone: true, selector: "mm-ai-quota-indicator", inputs: { dailyConsumed: { classPropertyName: "dailyConsumed", publicName: "dailyConsumed", isSignal: true, isRequired: true, transformFunction: null }, dailyCap: { classPropertyName: "dailyCap", publicName: "dailyCap", isSignal: true, isRequired: true, transformFunction: null }, monthlyConsumed: { classPropertyName: "monthlyConsumed", publicName: "monthlyConsumed", isSignal: true, isRequired: false, transformFunction: null }, monthlyCap: { classPropertyName: "monthlyCap", publicName: "monthlyCap", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"mm-ai-quota\">\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Daily</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ dailyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"dailyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ dailyConsumed() }} / {{ dailyCap() }} ({{ dailyPercent() }}%)\n </span>\n </div>\n\n @if (monthlyPercent() !== null) {\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Monthly</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ monthlyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"monthlyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ monthlyConsumed() }} / {{ monthlyCap() }} ({{ monthlyPercent() }}%)\n </span>\n </div>\n }\n</div>\n", styles: [":host{display:block;--mm-ai-quota-track-bg: #2a2a2a;--mm-ai-quota-ok: #2ea44f;--mm-ai-quota-warning: #d29922;--mm-ai-quota-critical: #d73a49}.mm-ai-quota{display:flex;flex-direction:column;gap:.5rem;font-size:.85rem}.mm-ai-quota__row{display:grid;grid-template-columns:4.5rem 1fr auto;align-items:center;gap:.5rem}.mm-ai-quota__label{font-weight:600;opacity:.7}.mm-ai-quota__bar{height:.5rem;border-radius:9999px;background:var(--mm-ai-quota-track-bg);overflow:hidden}.mm-ai-quota__bar--ok .mm-ai-quota__fill{background:var(--mm-ai-quota-ok)}.mm-ai-quota__bar--warning .mm-ai-quota__fill{background:var(--mm-ai-quota-warning)}.mm-ai-quota__bar--critical .mm-ai-quota__fill{background:var(--mm-ai-quota-critical)}.mm-ai-quota__fill{height:100%;transition:width .2s ease}.mm-ai-quota__count{font-variant-numeric:tabular-nums;opacity:.8}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1044
- }
1045
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiQuotaIndicatorComponent, decorators: [{
1046
- type: Component,
1047
- args: [{ selector: 'mm-ai-quota-indicator', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mm-ai-quota\">\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Daily</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ dailyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"dailyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ dailyConsumed() }} / {{ dailyCap() }} ({{ dailyPercent() }}%)\n </span>\n </div>\n\n @if (monthlyPercent() !== null) {\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Monthly</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ monthlyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"monthlyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ monthlyConsumed() }} / {{ monthlyCap() }} ({{ monthlyPercent() }}%)\n </span>\n </div>\n }\n</div>\n", styles: [":host{display:block;--mm-ai-quota-track-bg: #2a2a2a;--mm-ai-quota-ok: #2ea44f;--mm-ai-quota-warning: #d29922;--mm-ai-quota-critical: #d73a49}.mm-ai-quota{display:flex;flex-direction:column;gap:.5rem;font-size:.85rem}.mm-ai-quota__row{display:grid;grid-template-columns:4.5rem 1fr auto;align-items:center;gap:.5rem}.mm-ai-quota__label{font-weight:600;opacity:.7}.mm-ai-quota__bar{height:.5rem;border-radius:9999px;background:var(--mm-ai-quota-track-bg);overflow:hidden}.mm-ai-quota__bar--ok .mm-ai-quota__fill{background:var(--mm-ai-quota-ok)}.mm-ai-quota__bar--warning .mm-ai-quota__fill{background:var(--mm-ai-quota-warning)}.mm-ai-quota__bar--critical .mm-ai-quota__fill{background:var(--mm-ai-quota-critical)}.mm-ai-quota__fill{height:100%;transition:width .2s ease}.mm-ai-quota__count{font-variant-numeric:tabular-nums;opacity:.8}\n"] }]
1048
- }], propDecorators: { dailyConsumed: [{ type: i0.Input, args: [{ isSignal: true, alias: "dailyConsumed", required: true }] }], dailyCap: [{ type: i0.Input, args: [{ isSignal: true, alias: "dailyCap", required: true }] }], monthlyConsumed: [{ type: i0.Input, args: [{ isSignal: true, alias: "monthlyConsumed", required: false }] }], monthlyCap: [{ type: i0.Input, args: [{ isSignal: true, alias: "monthlyCap", required: false }] }] } });
1049
-
1050
- /**
1051
- * Self-service credential-ticket issuer (#4133, concept §10). Admin picks a
1052
- * scope + TTL, hits **Issue ticket**, copies the displayed code, hands it to
1053
- * a developer / operator out-of-band. The plaintext code is shown exactly
1054
- * once — refreshing the panel after issue clears it so a careless screenshot
1055
- * doesn't leak.
1056
- *
1057
- * Theme-neutral by design: visuals use CSS custom properties with neutral
1058
- * defaults so the host (Refinery Studio LCARS, demo-app, etc.) can override
1059
- * them via `--mm-ai-ticket-*` variables without touching the component.
1060
- */
1061
- class AiCredentialTicketIssueComponent {
1062
- client = inject(AiAdapterClientService);
1063
- scope = signal('CredentialRegister', /* @ts-ignore */
1064
- ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
1065
- ttlMinutes = signal(5, /* @ts-ignore */
1066
- ...(ngDevMode ? [{ debugName: "ttlMinutes" }] : /* istanbul ignore next */ []));
1067
- issuing = signal(false, /* @ts-ignore */
1068
- ...(ngDevMode ? [{ debugName: "issuing" }] : /* istanbul ignore next */ []));
1069
- issued = signal(null, /* @ts-ignore */
1070
- ...(ngDevMode ? [{ debugName: "issued" }] : /* istanbul ignore next */ []));
1071
- error = signal(null, /* @ts-ignore */
1072
- ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
1073
- copied = signal(false, /* @ts-ignore */
1074
- ...(ngDevMode ? [{ debugName: "copied" }] : /* istanbul ignore next */ []));
1075
- /** Available scope choices — kept in sync with `AiCredentialTicketScope`. */
1076
- scopes = [
1077
- {
1078
- value: 'CredentialRegister',
1079
- label: 'Subscription token',
1080
- hint: 'For the bastion CLI to register an Anthropic OAuth pair on this tenant.',
1081
- },
1082
- {
1083
- value: 'DevSshKeyRegister',
1084
- label: 'Developer SSH key',
1085
- hint: 'For a developer to register their own SSH public key on this tenant.',
1086
- },
1087
- ];
1088
- onIssue() {
1089
- if (this.issuing()) {
1090
- return;
1091
- }
1092
- const ttl = this.normalizedTtl();
1093
- this.issuing.set(true);
1094
- this.error.set(null);
1095
- this.copied.set(false);
1096
- this.issued.set(null);
1097
- this.client
1098
- .issueCredentialTicket({
1099
- scope: this.scope(),
1100
- ttlMinutes: ttl,
1101
- })
1102
- .subscribe({
1103
- next: (response) => {
1104
- this.issued.set(response);
1105
- this.issuing.set(false);
1106
- },
1107
- error: (err) => {
1108
- this.error.set(this.formatError(err));
1109
- this.issuing.set(false);
1110
- },
1111
- });
1112
- }
1113
- onCopy() {
1114
- const code = this.issued()?.code;
1115
- if (!code) {
1116
- return;
1117
- }
1118
- // navigator.clipboard requires a secure context; if it's unavailable the
1119
- // operator can still select + copy by hand. Falling back silently keeps
1120
- // the panel usable on http://localhost dev origins.
1121
- if (navigator.clipboard && navigator.clipboard.writeText) {
1122
- navigator.clipboard.writeText(code).then(() => this.copied.set(true), () => this.copied.set(false));
1123
- }
1124
- }
1125
- onClear() {
1126
- this.issued.set(null);
1127
- this.copied.set(false);
1128
- }
1129
- normalizedTtl() {
1130
- const v = Math.trunc(this.ttlMinutes());
1131
- // Server clamps to 60 anyway; clamp here too so the slider can't push a
1132
- // value the request would silently truncate.
1133
- if (Number.isNaN(v) || v < 1) {
1134
- return 1;
1135
- }
1136
- if (v > 60) {
1137
- return 60;
1138
- }
1139
- return v;
1140
- }
1141
- formatError(err) {
1142
- if (typeof err === 'object' &&
1143
- err !== null &&
1144
- 'status' in err &&
1145
- typeof err.status === 'number') {
1146
- const status = err.status;
1147
- if (status === 401 || status === 403) {
1148
- return 'Not authorised — only tenant admins can issue tickets.';
1149
- }
1150
- if (status === 400) {
1151
- return 'Invalid request — check the scope value.';
1152
- }
1153
- return `Server returned HTTP ${status}.`;
1154
- }
1155
- return 'Failed to reach the AI Adapter — check the network.';
1156
- }
1157
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiCredentialTicketIssueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1158
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AiCredentialTicketIssueComponent, isStandalone: true, selector: "mm-ai-credential-ticket-issue", ngImport: i0, template: "<section class=\"mm-ai-ticket\">\n <header class=\"mm-ai-ticket__header\">\n <div class=\"mm-ai-ticket__title\">Issue credential ticket</div>\n <div class=\"mm-ai-ticket__subtitle\">\n Mint a one-time code an operator redeems on their own machine.\n </div>\n </header>\n\n @if (!issued()) {\n <form\n class=\"mm-ai-ticket__form\"\n (ngSubmit)=\"onIssue()\"\n #issueForm=\"ngForm\"\n >\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">Scope</span>\n <select\n class=\"mm-ai-ticket__select\"\n [ngModel]=\"scope()\"\n (ngModelChange)=\"scope.set($event)\"\n name=\"scope\"\n [disabled]=\"issuing()\"\n >\n @for (s of scopes; track s.value) {\n <option [value]=\"s.value\">{{ s.label }}</option>\n }\n </select>\n </label>\n <p class=\"mm-ai-ticket__hint\">\n @for (s of scopes; track s.value) {\n @if (s.value === scope()) {\n {{ s.hint }}\n }\n }\n </p>\n\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">TTL (minutes)</span>\n <input\n class=\"mm-ai-ticket__input\"\n type=\"number\"\n min=\"1\"\n max=\"60\"\n step=\"1\"\n [ngModel]=\"ttlMinutes()\"\n (ngModelChange)=\"ttlMinutes.set(+$event)\"\n name=\"ttlMinutes\"\n [disabled]=\"issuing()\"\n />\n </label>\n <p class=\"mm-ai-ticket__hint\">\n Default 5 minutes. Server clamps to 60 \u2014 long TTLs leak.\n </p>\n\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--primary\"\n type=\"submit\"\n [disabled]=\"issuing()\"\n >\n @if (issuing()) {\n Issuing\u2026\n } @else {\n Issue ticket\n }\n </button>\n </div>\n\n @if (error()) {\n <p class=\"mm-ai-ticket__error\">{{ error() }}</p>\n }\n </form>\n } @else {\n <div class=\"mm-ai-ticket__result\">\n <p class=\"mm-ai-ticket__result-label\">\n One-time code (copy now \u2014 not shown again):\n </p>\n <div class=\"mm-ai-ticket__code-row\">\n <code class=\"mm-ai-ticket__code\">{{ issued()!.code }}</code>\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--secondary\"\n type=\"button\"\n (click)=\"onCopy()\"\n >\n @if (copied()) {\n Copied\n } @else {\n Copy\n }\n </button>\n </div>\n <dl class=\"mm-ai-ticket__meta\">\n <div>\n <dt>Scope</dt>\n <dd>{{ issued()!.scope }}</dd>\n </div>\n <div>\n <dt>Expires at</dt>\n <dd>{{ issued()!.expiresAt }}</dd>\n </div>\n <div>\n <dt>Ticket rtId</dt>\n <dd><code>{{ issued()!.rtId }}</code></dd>\n </div>\n </dl>\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button\"\n type=\"button\"\n (click)=\"onClear()\"\n >\n Issue another\n </button>\n </div>\n </div>\n }\n</section>\n", styles: [":host{display:block;--mm-ai-ticket-bg: #16191d;--mm-ai-ticket-surface: #1f2227;--mm-ai-ticket-border: #2f343b;--mm-ai-ticket-text: #e6e6e6;--mm-ai-ticket-muted: #9aa0a6;--mm-ai-ticket-accent: #64ceb9;--mm-ai-ticket-error: #ec658f;--mm-ai-ticket-code-bg: #0f1115}.mm-ai-ticket{background:var(--mm-ai-ticket-bg);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.5rem;padding:1rem 1.25rem;display:flex;flex-direction:column;gap:.85rem;font-family:inherit}.mm-ai-ticket__header{display:flex;flex-direction:column;gap:.15rem}.mm-ai-ticket__title{font-size:1rem;font-weight:600}.mm-ai-ticket__subtitle{font-size:.8rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__form,.mm-ai-ticket__result{display:flex;flex-direction:column;gap:.6rem}.mm-ai-ticket__field{display:flex;flex-direction:column;gap:.25rem}.mm-ai-ticket__label{font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__select,.mm-ai-ticket__input{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .55rem;font-family:inherit;font-size:.9rem}.mm-ai-ticket__select:focus,.mm-ai-ticket__input:focus{outline:2px solid var(--mm-ai-ticket-accent);outline-offset:1px}.mm-ai-ticket__select:disabled,.mm-ai-ticket__input:disabled{opacity:.6;cursor:not-allowed}.mm-ai-ticket__hint{margin:0;font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__actions{display:flex;gap:.5rem;margin-top:.25rem}.mm-ai-ticket__button{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .85rem;font-family:inherit;font-size:.85rem;cursor:pointer}.mm-ai-ticket__button:hover:not(:disabled){border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__button:disabled{opacity:.5;cursor:not-allowed}.mm-ai-ticket__button--primary{background:var(--mm-ai-ticket-accent);color:#0a0c0f;border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__error{margin:0;font-size:.8rem;color:var(--mm-ai-ticket-error)}.mm-ai-ticket__result-label{margin:0;font-size:.85rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__code-row{display:flex;align-items:center;gap:.5rem}.mm-ai-ticket__code{flex:1;background:var(--mm-ai-ticket-code-bg);color:var(--mm-ai-ticket-accent);padding:.5rem .75rem;border-radius:.3rem;font-family:Roboto Mono,ui-monospace,monospace;font-size:1.05rem;-webkit-user-select:all;user-select:all}.mm-ai-ticket__meta{display:grid;grid-template-columns:max-content 1fr;gap:.2rem .75rem;margin:0;font-size:.8rem}.mm-ai-ticket__meta>div{display:contents}.mm-ai-ticket__meta dt{color:var(--mm-ai-ticket-muted);font-size:.7rem}.mm-ai-ticket__meta dd{margin:0;font-family:Roboto Mono,ui-monospace,monospace}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
621
+ if (typeof content === "string") return content;
622
+ if (Array.isArray(content)) return content.map((block) => {
623
+ if (isRecord(block) && block["type"] === "text") return readString(block, "text") ?? "";
624
+ return JSON.stringify(block);
625
+ }).join("\n");
626
+ if (content === void 0 || content === null) return "";
627
+ try {
628
+ return JSON.stringify(content, null, 2);
629
+ } catch {
630
+ return String(content);
631
+ }
1159
632
  }
1160
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiCredentialTicketIssueComponent, decorators: [{
1161
- type: Component,
1162
- args: [{ selector: 'mm-ai-credential-ticket-issue', imports: [CommonModule, FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<section class=\"mm-ai-ticket\">\n <header class=\"mm-ai-ticket__header\">\n <div class=\"mm-ai-ticket__title\">Issue credential ticket</div>\n <div class=\"mm-ai-ticket__subtitle\">\n Mint a one-time code an operator redeems on their own machine.\n </div>\n </header>\n\n @if (!issued()) {\n <form\n class=\"mm-ai-ticket__form\"\n (ngSubmit)=\"onIssue()\"\n #issueForm=\"ngForm\"\n >\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">Scope</span>\n <select\n class=\"mm-ai-ticket__select\"\n [ngModel]=\"scope()\"\n (ngModelChange)=\"scope.set($event)\"\n name=\"scope\"\n [disabled]=\"issuing()\"\n >\n @for (s of scopes; track s.value) {\n <option [value]=\"s.value\">{{ s.label }}</option>\n }\n </select>\n </label>\n <p class=\"mm-ai-ticket__hint\">\n @for (s of scopes; track s.value) {\n @if (s.value === scope()) {\n {{ s.hint }}\n }\n }\n </p>\n\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">TTL (minutes)</span>\n <input\n class=\"mm-ai-ticket__input\"\n type=\"number\"\n min=\"1\"\n max=\"60\"\n step=\"1\"\n [ngModel]=\"ttlMinutes()\"\n (ngModelChange)=\"ttlMinutes.set(+$event)\"\n name=\"ttlMinutes\"\n [disabled]=\"issuing()\"\n />\n </label>\n <p class=\"mm-ai-ticket__hint\">\n Default 5 minutes. Server clamps to 60 \u2014 long TTLs leak.\n </p>\n\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--primary\"\n type=\"submit\"\n [disabled]=\"issuing()\"\n >\n @if (issuing()) {\n Issuing\u2026\n } @else {\n Issue ticket\n }\n </button>\n </div>\n\n @if (error()) {\n <p class=\"mm-ai-ticket__error\">{{ error() }}</p>\n }\n </form>\n } @else {\n <div class=\"mm-ai-ticket__result\">\n <p class=\"mm-ai-ticket__result-label\">\n One-time code (copy now \u2014 not shown again):\n </p>\n <div class=\"mm-ai-ticket__code-row\">\n <code class=\"mm-ai-ticket__code\">{{ issued()!.code }}</code>\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--secondary\"\n type=\"button\"\n (click)=\"onCopy()\"\n >\n @if (copied()) {\n Copied\n } @else {\n Copy\n }\n </button>\n </div>\n <dl class=\"mm-ai-ticket__meta\">\n <div>\n <dt>Scope</dt>\n <dd>{{ issued()!.scope }}</dd>\n </div>\n <div>\n <dt>Expires at</dt>\n <dd>{{ issued()!.expiresAt }}</dd>\n </div>\n <div>\n <dt>Ticket rtId</dt>\n <dd><code>{{ issued()!.rtId }}</code></dd>\n </div>\n </dl>\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button\"\n type=\"button\"\n (click)=\"onClear()\"\n >\n Issue another\n </button>\n </div>\n </div>\n }\n</section>\n", styles: [":host{display:block;--mm-ai-ticket-bg: #16191d;--mm-ai-ticket-surface: #1f2227;--mm-ai-ticket-border: #2f343b;--mm-ai-ticket-text: #e6e6e6;--mm-ai-ticket-muted: #9aa0a6;--mm-ai-ticket-accent: #64ceb9;--mm-ai-ticket-error: #ec658f;--mm-ai-ticket-code-bg: #0f1115}.mm-ai-ticket{background:var(--mm-ai-ticket-bg);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.5rem;padding:1rem 1.25rem;display:flex;flex-direction:column;gap:.85rem;font-family:inherit}.mm-ai-ticket__header{display:flex;flex-direction:column;gap:.15rem}.mm-ai-ticket__title{font-size:1rem;font-weight:600}.mm-ai-ticket__subtitle{font-size:.8rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__form,.mm-ai-ticket__result{display:flex;flex-direction:column;gap:.6rem}.mm-ai-ticket__field{display:flex;flex-direction:column;gap:.25rem}.mm-ai-ticket__label{font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__select,.mm-ai-ticket__input{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .55rem;font-family:inherit;font-size:.9rem}.mm-ai-ticket__select:focus,.mm-ai-ticket__input:focus{outline:2px solid var(--mm-ai-ticket-accent);outline-offset:1px}.mm-ai-ticket__select:disabled,.mm-ai-ticket__input:disabled{opacity:.6;cursor:not-allowed}.mm-ai-ticket__hint{margin:0;font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__actions{display:flex;gap:.5rem;margin-top:.25rem}.mm-ai-ticket__button{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .85rem;font-family:inherit;font-size:.85rem;cursor:pointer}.mm-ai-ticket__button:hover:not(:disabled){border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__button:disabled{opacity:.5;cursor:not-allowed}.mm-ai-ticket__button--primary{background:var(--mm-ai-ticket-accent);color:#0a0c0f;border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__error{margin:0;font-size:.8rem;color:var(--mm-ai-ticket-error)}.mm-ai-ticket__result-label{margin:0;font-size:.85rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__code-row{display:flex;align-items:center;gap:.5rem}.mm-ai-ticket__code{flex:1;background:var(--mm-ai-ticket-code-bg);color:var(--mm-ai-ticket-accent);padding:.5rem .75rem;border-radius:.3rem;font-family:Roboto Mono,ui-monospace,monospace;font-size:1.05rem;-webkit-user-select:all;user-select:all}.mm-ai-ticket__meta{display:grid;grid-template-columns:max-content 1fr;gap:.2rem .75rem;margin:0;font-size:.8rem}.mm-ai-ticket__meta>div{display:contents}.mm-ai-ticket__meta dt{color:var(--mm-ai-ticket-muted);font-size:.7rem}.mm-ai-ticket__meta dd{margin:0;font-family:Roboto Mono,ui-monospace,monospace}\n"] }]
1163
- }] });
1164
-
1165
- /**
1166
- * "New App from Template" wizard (#4145). Presentation-only — the host fetches
1167
- * the template catalogue via {@link AiAdapterClientService.getAppTemplates},
1168
- * feeds it into the `templates` input, and listens for `submit` / `cancel` to
1169
- * call `createSession`.
1170
- *
1171
- * The component is intentionally framework-agnostic (no Kendo, no CDK overlay)
1172
- * so consumers can wrap it in whatever modal shell they already have — same
1173
- * convention as `AiApprovalModalComponent`.
1174
- *
1175
- * The interpolation engine is *deliberately* dumb: a regex substitution over
1176
- * `{{placeholder}}` tokens. The wizard only collects two inputs (project name +
1177
- * primary entity), and a full Handlebars dependency for two tokens would be
1178
- * overkill. If a future template needs richer rendering, switch this to
1179
- * `handlebars.precompile`-at-build-time and re-evaluate.
1180
- */
1181
- class AiNewAppDialogComponent {
1182
- /** Available templates from the adapter — typically 3 in Phase 1. */
1183
- templates = input.required(/* @ts-ignore */
1184
- ...(ngDevMode ? [{ debugName: "templates" }] : /* istanbul ignore next */ []));
1185
- /** Tenant name shown in the dialog header so the operator confirms the scope. */
1186
- tenantName = input('', /* @ts-ignore */
1187
- ...(ngDevMode ? [{ debugName: "tenantName" }] : /* istanbul ignore next */ []));
1188
- /**
1189
- * Emitted on Submit with the fully interpolated Goal + the picked template id.
1190
- * Named `confirmed` (not `submit`) because Angular flags native-event collisions
1191
- * — `submit` is a DOM event and triggers `@angular-eslint/no-output-native`.
1192
- */
1193
- confirmed = output();
1194
- /**
1195
- * Emitted on Cancel / dismiss. The host hides the wizard on this signal.
1196
- * Named `cancelled` for the same reason `confirmed` is not `submit`.
1197
- */
1198
- cancelled = output();
1199
- /** rtId-style id of the picked template, or empty until the operator picks one. */
1200
- selectedTemplateId = signal('', /* @ts-ignore */
1201
- ...(ngDevMode ? [{ debugName: "selectedTemplateId" }] : /* istanbul ignore next */ []));
1202
- projectName = signal('', /* @ts-ignore */
1203
- ...(ngDevMode ? [{ debugName: "projectName" }] : /* istanbul ignore next */ []));
1204
- primaryEntity = signal('', /* @ts-ignore */
1205
- ...(ngDevMode ? [{ debugName: "primaryEntity" }] : /* istanbul ignore next */ []));
1206
- selectedTemplate = computed(() => {
1207
- const id = this.selectedTemplateId();
1208
- return this.templates().find((t) => t.id === id) ?? null;
1209
- }, /* @ts-ignore */
1210
- ...(ngDevMode ? [{ debugName: "selectedTemplate" }] : /* istanbul ignore next */ []));
1211
- /**
1212
- * Rendered Goal string the operator sees in the preview block. Stays empty
1213
- * until a template is picked AND every required placeholder has a value, so
1214
- * the operator never sees a half-interpolated string.
1215
- */
1216
- renderedGoal = computed(() => {
1217
- const template = this.selectedTemplate();
1218
- if (!template) {
1219
- return '';
1220
- }
1221
- if (!this.allRequiredFilled()) {
1222
- return '';
1223
- }
1224
- return this.interpolate(template.goalTemplate);
1225
- }, /* @ts-ignore */
1226
- ...(ngDevMode ? [{ debugName: "renderedGoal" }] : /* istanbul ignore next */ []));
1227
- /** True when every placeholder the picked template declares has a non-empty value. */
1228
- allRequiredFilled = computed(() => {
1229
- const template = this.selectedTemplate();
1230
- if (!template) {
1231
- return false;
1232
- }
1233
- return template.requiredPlaceholders.every((key) => {
1234
- const value = this.valueFor(key);
1235
- return value !== null && value.trim().length > 0;
1236
- });
1237
- }, /* @ts-ignore */
1238
- ...(ngDevMode ? [{ debugName: "allRequiredFilled" }] : /* istanbul ignore next */ []));
1239
- onSubmit() {
1240
- const template = this.selectedTemplate();
1241
- if (!template || !this.allRequiredFilled()) {
1242
- return;
1243
- }
1244
- this.confirmed.emit({
1245
- templateId: template.id,
1246
- jobKind: template.jobKind,
1247
- projectName: this.projectName().trim(),
1248
- primaryEntity: this.primaryEntity().trim(),
1249
- goal: this.interpolate(template.goalTemplate),
1250
- });
1251
- }
1252
- onCancel() {
1253
- this.cancelled.emit();
1254
- }
1255
- /** Read the signal that backs the named placeholder, or `null` if unknown. */
1256
- valueFor(placeholder) {
1257
- switch (placeholder) {
1258
- case 'projectName':
1259
- return this.projectName();
1260
- case 'primaryEntity':
1261
- return this.primaryEntity();
1262
- default:
1263
- return null;
1264
- }
1265
- }
1266
- interpolate(template) {
1267
- return template.replace(/{{\s*(\w+)\s*}}/g, (full, key) => {
1268
- const value = this.valueFor(key);
1269
- // Unknown placeholders survive verbatim so a typo in the catalogue
1270
- // surfaces in the preview rather than silently disappearing.
1271
- return value !== null ? value.trim() : full;
1272
- });
1273
- }
1274
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiNewAppDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1275
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AiNewAppDialogComponent, isStandalone: true, selector: "mm-ai-new-app-dialog", inputs: { templates: { classPropertyName: "templates", publicName: "templates", isSignal: true, isRequired: true, transformFunction: null }, tenantName: { classPropertyName: "tenantName", publicName: "tenantName", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { confirmed: "confirmed", cancelled: "cancelled" }, ngImport: i0, template: "<div class=\"mm-ai-new-app\">\n <header class=\"mm-ai-new-app__header\">\n <h3 class=\"mm-ai-new-app__title\">\n New App\n @if (tenantName(); as tenant) {\n <span class=\"mm-ai-new-app__tenant\"> \u00B7 {{ tenant }}</span>\n }\n </h3>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__close\"\n (click)=\"onCancel()\"\n aria-label=\"Dismiss\"\n >\n \u00D7\n </button>\n </header>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Template</h4>\n <ul class=\"mm-ai-new-app__templates\" role=\"radiogroup\" aria-label=\"Template\">\n @for (template of templates(); track template.id) {\n <li>\n <label\n class=\"mm-ai-new-app__template\"\n [class.mm-ai-new-app__template--active]=\"\n selectedTemplateId() === template.id\n \"\n >\n <input\n type=\"radio\"\n name=\"mm-ai-new-app-template\"\n [value]=\"template.id\"\n [checked]=\"selectedTemplateId() === template.id\"\n (change)=\"selectedTemplateId.set(template.id)\"\n />\n <span class=\"mm-ai-new-app__template-body\">\n <strong class=\"mm-ai-new-app__template-name\">{{ template.name }}</strong>\n <span class=\"mm-ai-new-app__template-description\">\n {{ template.description }}\n </span>\n </span>\n </label>\n </li>\n }\n </ul>\n </div>\n\n @if (selectedTemplate(); as template) {\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Parameters</h4>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-project-name\">Project name</label>\n <input\n id=\"mm-ai-new-app-project-name\"\n type=\"text\"\n [ngModel]=\"projectName()\"\n (ngModelChange)=\"projectName.set($event)\"\n placeholder=\"e.g. customer-list\"\n autocomplete=\"off\"\n />\n </div>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-primary-entity\">Primary entity (CK type)</label>\n <input\n id=\"mm-ai-new-app-primary-entity\"\n type=\"text\"\n [ngModel]=\"primaryEntity()\"\n (ngModelChange)=\"primaryEntity.set($event)\"\n placeholder=\"e.g. Customer\"\n autocomplete=\"off\"\n />\n </div>\n </div>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">\n Generated Goal <span>(this is what Claude will see)</span>\n </h4>\n <pre class=\"mm-ai-new-app__preview\">{{\n renderedGoal() ||\n 'Fill in every field above to preview the Goal that will be sent.'\n }}</pre>\n </div>\n }\n\n <footer class=\"mm-ai-new-app__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--cancel\"\n (click)=\"onCancel()\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--submit\"\n [disabled]=\"!allRequiredFilled()\"\n (click)=\"onSubmit()\"\n >\n Create App Session\n </button>\n </footer>\n</div>\n", styles: [":host{display:block;--mm-ai-new-app-bg: #1f2227;--mm-ai-new-app-border: #2f343b;--mm-ai-new-app-text: #e6e6e6;--mm-ai-new-app-muted: #9aa0a6;--mm-ai-new-app-accent: #2ea44f;--mm-ai-new-app-accent-soft: rgba(46, 164, 79, .15);--mm-ai-new-app-cancel: #44494f;--mm-ai-new-app-code-bg: #16191d}.mm-ai-new-app{background:var(--mm-ai-new-app-bg);color:var(--mm-ai-new-app-text);border:1px solid var(--mm-ai-new-app-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(40rem,100%)}.mm-ai-new-app__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-new-app__title{margin:0;font-size:1rem}.mm-ai-new-app__tenant{color:var(--mm-ai-new-app-muted);font-weight:400}.mm-ai-new-app__close{background:transparent;color:var(--mm-ai-new-app-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-new-app__close:hover{color:var(--mm-ai-new-app-text)}.mm-ai-new-app__section{margin-bottom:.75rem}.mm-ai-new-app__heading{margin:0 0 .35rem;font-size:.75rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__heading span{text-transform:none;opacity:.6}.mm-ai-new-app__templates{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}.mm-ai-new-app__template{display:flex;gap:.6rem;padding:.55rem .7rem;border:1px solid var(--mm-ai-new-app-border);border-radius:.35rem;cursor:pointer;align-items:flex-start}.mm-ai-new-app__template--active{background:var(--mm-ai-new-app-accent-soft);border-color:var(--mm-ai-new-app-accent)}.mm-ai-new-app__template input[type=radio]{margin-top:.2rem}.mm-ai-new-app__template-body{display:grid;gap:.2rem}.mm-ai-new-app__template-name{font-size:.9rem}.mm-ai-new-app__template-description{font-size:.8rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field{display:grid;gap:.25rem;margin-bottom:.5rem;font-size:.85rem}.mm-ai-new-app__field label{color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field input{padding:.45rem .55rem;background:var(--mm-ai-new-app-code-bg);color:inherit;border:1px solid var(--mm-ai-new-app-border);border-radius:.3rem;font-family:inherit;font-size:.9rem}.mm-ai-new-app__preview{margin:0;padding:.5rem .6rem;background:var(--mm-ai-new-app-code-bg);border-radius:.3rem;font-size:.8rem;white-space:pre-wrap;word-break:break-word;max-height:12rem;overflow-y:auto}.mm-ai-new-app__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-new-app__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-new-app__btn--submit{background:var(--mm-ai-new-app-accent);color:#fff}.mm-ai-new-app__btn--submit:disabled{opacity:.5;cursor:not-allowed}.mm-ai-new-app__btn--cancel{background:var(--mm-ai-new-app-cancel);color:#fff}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1276
- }
1277
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AiNewAppDialogComponent, decorators: [{
1278
- type: Component,
1279
- args: [{ selector: 'mm-ai-new-app-dialog', imports: [FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mm-ai-new-app\">\n <header class=\"mm-ai-new-app__header\">\n <h3 class=\"mm-ai-new-app__title\">\n New App\n @if (tenantName(); as tenant) {\n <span class=\"mm-ai-new-app__tenant\"> \u00B7 {{ tenant }}</span>\n }\n </h3>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__close\"\n (click)=\"onCancel()\"\n aria-label=\"Dismiss\"\n >\n \u00D7\n </button>\n </header>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Template</h4>\n <ul class=\"mm-ai-new-app__templates\" role=\"radiogroup\" aria-label=\"Template\">\n @for (template of templates(); track template.id) {\n <li>\n <label\n class=\"mm-ai-new-app__template\"\n [class.mm-ai-new-app__template--active]=\"\n selectedTemplateId() === template.id\n \"\n >\n <input\n type=\"radio\"\n name=\"mm-ai-new-app-template\"\n [value]=\"template.id\"\n [checked]=\"selectedTemplateId() === template.id\"\n (change)=\"selectedTemplateId.set(template.id)\"\n />\n <span class=\"mm-ai-new-app__template-body\">\n <strong class=\"mm-ai-new-app__template-name\">{{ template.name }}</strong>\n <span class=\"mm-ai-new-app__template-description\">\n {{ template.description }}\n </span>\n </span>\n </label>\n </li>\n }\n </ul>\n </div>\n\n @if (selectedTemplate(); as template) {\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Parameters</h4>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-project-name\">Project name</label>\n <input\n id=\"mm-ai-new-app-project-name\"\n type=\"text\"\n [ngModel]=\"projectName()\"\n (ngModelChange)=\"projectName.set($event)\"\n placeholder=\"e.g. customer-list\"\n autocomplete=\"off\"\n />\n </div>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-primary-entity\">Primary entity (CK type)</label>\n <input\n id=\"mm-ai-new-app-primary-entity\"\n type=\"text\"\n [ngModel]=\"primaryEntity()\"\n (ngModelChange)=\"primaryEntity.set($event)\"\n placeholder=\"e.g. Customer\"\n autocomplete=\"off\"\n />\n </div>\n </div>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">\n Generated Goal <span>(this is what Claude will see)</span>\n </h4>\n <pre class=\"mm-ai-new-app__preview\">{{\n renderedGoal() ||\n 'Fill in every field above to preview the Goal that will be sent.'\n }}</pre>\n </div>\n }\n\n <footer class=\"mm-ai-new-app__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--cancel\"\n (click)=\"onCancel()\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--submit\"\n [disabled]=\"!allRequiredFilled()\"\n (click)=\"onSubmit()\"\n >\n Create App Session\n </button>\n </footer>\n</div>\n", styles: [":host{display:block;--mm-ai-new-app-bg: #1f2227;--mm-ai-new-app-border: #2f343b;--mm-ai-new-app-text: #e6e6e6;--mm-ai-new-app-muted: #9aa0a6;--mm-ai-new-app-accent: #2ea44f;--mm-ai-new-app-accent-soft: rgba(46, 164, 79, .15);--mm-ai-new-app-cancel: #44494f;--mm-ai-new-app-code-bg: #16191d}.mm-ai-new-app{background:var(--mm-ai-new-app-bg);color:var(--mm-ai-new-app-text);border:1px solid var(--mm-ai-new-app-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(40rem,100%)}.mm-ai-new-app__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-new-app__title{margin:0;font-size:1rem}.mm-ai-new-app__tenant{color:var(--mm-ai-new-app-muted);font-weight:400}.mm-ai-new-app__close{background:transparent;color:var(--mm-ai-new-app-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-new-app__close:hover{color:var(--mm-ai-new-app-text)}.mm-ai-new-app__section{margin-bottom:.75rem}.mm-ai-new-app__heading{margin:0 0 .35rem;font-size:.75rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__heading span{text-transform:none;opacity:.6}.mm-ai-new-app__templates{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}.mm-ai-new-app__template{display:flex;gap:.6rem;padding:.55rem .7rem;border:1px solid var(--mm-ai-new-app-border);border-radius:.35rem;cursor:pointer;align-items:flex-start}.mm-ai-new-app__template--active{background:var(--mm-ai-new-app-accent-soft);border-color:var(--mm-ai-new-app-accent)}.mm-ai-new-app__template input[type=radio]{margin-top:.2rem}.mm-ai-new-app__template-body{display:grid;gap:.2rem}.mm-ai-new-app__template-name{font-size:.9rem}.mm-ai-new-app__template-description{font-size:.8rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field{display:grid;gap:.25rem;margin-bottom:.5rem;font-size:.85rem}.mm-ai-new-app__field label{color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field input{padding:.45rem .55rem;background:var(--mm-ai-new-app-code-bg);color:inherit;border:1px solid var(--mm-ai-new-app-border);border-radius:.3rem;font-family:inherit;font-size:.9rem}.mm-ai-new-app__preview{margin:0;padding:.5rem .6rem;background:var(--mm-ai-new-app-code-bg);border-radius:.3rem;font-size:.8rem;white-space:pre-wrap;word-break:break-word;max-height:12rem;overflow-y:auto}.mm-ai-new-app__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-new-app__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-new-app__btn--submit{background:var(--mm-ai-new-app-accent);color:#fff}.mm-ai-new-app__btn--submit:disabled{opacity:.5;cursor:not-allowed}.mm-ai-new-app__btn--cancel{background:var(--mm-ai-new-app-cancel);color:#fff}\n"] }]
1280
- }], propDecorators: { templates: [{ type: i0.Input, args: [{ isSignal: true, alias: "templates", required: true }] }], tenantName: [{ type: i0.Input, args: [{ isSignal: true, alias: "tenantName", required: false }] }], confirmed: [{ type: i0.Output, args: ["confirmed"] }], cancelled: [{ type: i0.Output, args: ["cancelled"] }] } });
1281
-
1282
- /*
1283
- * Public API Surface of @meshmakers/octo-ai-console
1284
- *
1285
- * Reusable Angular building blocks for the OctoMesh AI Adapter session console
1286
- * (ADR-21, issue #4121). Host applications import individual standalone
1287
- * components or call `provideOctoAiConsole({...})` to wire the services.
1288
- */
1289
-
1290
- /**
1291
- * Generated bundle index. Do not edit.
1292
- */
1293
-
633
+ var AiChatStreamComponent = class AiChatStreamComponent {
634
+ events = input.required(...ngDevMode ? [{ debugName: "events" }] : /* istanbul ignore next */ []);
635
+ parsedEvents = computed(() => parseAndOrder(this.events()), ...ngDevMode ? [{ debugName: "parsedEvents" }] : /* istanbul ignore next */ []);
636
+ expandedSet = signal(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "expandedSet" }] : /* istanbul ignore next */ []);
637
+ isExpanded(sequence) {
638
+ return this.expandedSet().has(sequence);
639
+ }
640
+ toggleRaw(sequence) {
641
+ this.expandedSet.update((prev) => {
642
+ const next = new Set(prev);
643
+ if (next.has(sequence)) next.delete(sequence);
644
+ else next.add(sequence);
645
+ return next;
646
+ });
647
+ }
648
+ formatTime(iso) {
649
+ const d = new Date(iso);
650
+ if (Number.isNaN(d.getTime())) return iso;
651
+ return d.toLocaleTimeString("de-AT", { hour12: false });
652
+ }
653
+ formatTokenCount(n) {
654
+ if (n >= 1e3) return `${(n / 1e3).toFixed(1)} ktok`;
655
+ return `${n} tok`;
656
+ }
657
+ formatDuration(ms) {
658
+ if (ms < 1e3) return `${Math.round(ms)} ms`;
659
+ return `${(ms / 1e3).toFixed(2)} s`;
660
+ }
661
+ formatCost(usd) {
662
+ if (usd == null || usd === 0) return "—";
663
+ return `$${usd.toFixed(4)}`;
664
+ }
665
+ formatRaw(value) {
666
+ if (value === void 0 || value === null) return "";
667
+ if (typeof value === "string") return value;
668
+ try {
669
+ return JSON.stringify(value, null, 2);
670
+ } catch {
671
+ return String(value);
672
+ }
673
+ }
674
+ static ɵfac = i0.ɵɵngDeclareFactory({
675
+ minVersion: "12.0.0",
676
+ version: "22.3.0",
677
+ ngImport: i0,
678
+ type: AiChatStreamComponent,
679
+ deps: [],
680
+ target: i0.ɵɵFactoryTarget.Component
681
+ });
682
+ static ɵcmp = i0.ɵɵngDeclareComponent({
683
+ minVersion: "17.0.0",
684
+ version: "22.3.0",
685
+ type: AiChatStreamComponent,
686
+ isStandalone: true,
687
+ selector: "mm-ai-chat-stream",
688
+ inputs: { events: {
689
+ classPropertyName: "events",
690
+ publicName: "events",
691
+ isSignal: true,
692
+ isRequired: true,
693
+ transformFunction: null
694
+ } },
695
+ ngImport: i0,
696
+ template: "<div class=\"mm-ai-chat\">\n @for (parsed of parsedEvents(); track parsed.event.sequence) {\n @switch (parsed.view.kind) {\n @case ('assistant') {\n <article class=\"mm-ai-chat__bubble mm-ai-chat__bubble--assistant\">\n <header class=\"mm-ai-chat__bubble-header\">\n <span class=\"mm-ai-chat__role\">Assistant</span>\n @if (parsed.view.model; as model) {\n <span class=\"mm-ai-chat__meta\">{{ model }}</span>\n }\n @if (parsed.view.usage; as usage) {\n <span class=\"mm-ai-chat__meta\">\n {{ formatTokenCount(usage.input + usage.output) }}\n </span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @for (part of parsed.view.parts; track $index) {\n @switch (part.type) {\n @case ('text') {\n <p class=\"mm-ai-chat__text\">{{ part.text }}</p>\n }\n @case ('tool_use') {\n <div class=\"mm-ai-chat__tool-use\">\n <header class=\"mm-ai-chat__tool-use-header\">\n <span class=\"mm-ai-chat__tool-badge\">tool</span>\n <span class=\"mm-ai-chat__tool-name\">{{ part.toolName }}</span>\n </header>\n <pre class=\"mm-ai-chat__tool-input\">{{ formatRaw(part.input) }}</pre>\n </div>\n }\n }\n }\n </article>\n }\n\n @case ('tool-result') {\n <article\n class=\"mm-ai-chat__tool-result\"\n [class.mm-ai-chat__tool-result--error]=\"parsed.view.isError\"\n >\n <header class=\"mm-ai-chat__tool-result-header\">\n <span class=\"mm-ai-chat__role\">Tool result</span>\n @if (parsed.view.isError) {\n <span class=\"mm-ai-chat__error-badge\">error</span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n <pre class=\"mm-ai-chat__tool-result-body\">{{ parsed.view.content }}</pre>\n </article>\n }\n\n @case ('result') {\n <article class=\"mm-ai-chat__result\"\n [class.mm-ai-chat__result--error]=\"parsed.view.isError\">\n <header class=\"mm-ai-chat__result-header\">\n <span class=\"mm-ai-chat__role\">{{ parsed.view.reason }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @if (parsed.view.text) {\n <p class=\"mm-ai-chat__result-text\">{{ parsed.view.text }}</p>\n }\n <dl class=\"mm-ai-chat__result-stats\">\n <div>\n <dt>Duration</dt>\n <dd>{{ formatDuration(parsed.view.durationMs) }}</dd>\n </div>\n <div>\n <dt>Tokens (in/out)</dt>\n <dd>\n @if (parsed.view.usage) {\n {{ formatTokenCount(parsed.view.usage.input) }}\n /\n {{ formatTokenCount(parsed.view.usage.output) }}\n } @else {\n —\n }\n </dd>\n </div>\n <div>\n <dt>Cost</dt>\n <dd>{{ formatCost(parsed.view.costUsd) }}</dd>\n </div>\n </dl>\n </article>\n }\n\n @case ('system') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system\"\n [class.mm-ai-chat__system--init]=\"parsed.view.subKind === 'init'\"\n [class.mm-ai-chat__system--hook]=\"parsed.view.subKind === 'hook'\"\n [class.mm-ai-chat__system--rate]=\"parsed.view.subKind === 'rate-limit'\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '▾' : '▸' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n\n @case ('status-change') {\n <div class=\"mm-ai-chat__status\">\n <span class=\"mm-ai-chat__status-label\">Status</span>\n <span class=\"mm-ai-chat__status-value\">{{ parsed.view.status }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </div>\n }\n\n @case ('unknown') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system mm-ai-chat__system--unknown\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '▾' : '▸' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n }\n } @empty {\n <div class=\"mm-ai-chat__empty\">\n No events yet — the worker hasn't emitted anything.\n </div>\n }\n</div>\n",
697
+ styles: [":host{display:block;--mm-ai-chat-bg: transparent;--mm-ai-chat-card-bg: rgba(31, 46, 64, .55);--mm-ai-chat-card-bg-elevated: rgba(31, 46, 64, .85);--mm-ai-chat-border: rgba(100, 206, 185, .18);--mm-ai-chat-border-strong: rgba(100, 206, 185, .4);--mm-ai-chat-text: #e6e6e6;--mm-ai-chat-muted: #9292a6;--mm-ai-chat-accent-assistant: #64ceb9;--mm-ai-chat-accent-tool: #00a8dc;--mm-ai-chat-accent-tool-result: #00a8dc;--mm-ai-chat-accent-system: #6c4da8;--mm-ai-chat-accent-rate-limit: #da9162;--mm-ai-chat-accent-result: #64ceb9;--mm-ai-chat-accent-error: #ec658f}.mm-ai-chat{display:flex;flex-direction:column;gap:.5rem;padding:.25rem;background:var(--mm-ai-chat-bg);color:var(--mm-ai-chat-text);font-size:.85rem;line-height:1.45}.mm-ai-chat__empty{color:var(--mm-ai-chat-muted);text-align:center;padding:1.5rem;font-style:italic}.mm-ai-chat__bubble{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-assistant);border-radius:.5rem;padding:.6rem .75rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__bubble-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__role{font-weight:700;color:var(--mm-ai-chat-accent-assistant)}.mm-ai-chat__meta{font-family:Roboto Mono,monospace;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__time{margin-left:auto;font-variant-numeric:tabular-nums;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__text{margin:0;white-space:pre-wrap;word-break:break-word}.mm-ai-chat__tool-use{border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-tool);border-radius:.35rem;background:var(--mm-ai-chat-card-bg-elevated);padding:.4rem .5rem}.mm-ai-chat__tool-use-header{display:flex;align-items:baseline;gap:.4rem;font-size:.7rem}.mm-ai-chat__tool-badge{background:var(--mm-ai-chat-accent-tool);color:#07172b;padding:0 6px;border-radius:.25rem;font-weight:700;font-size:.65rem}.mm-ai-chat__tool-name{font-family:Roboto Mono,monospace;color:var(--mm-ai-chat-text);font-weight:600}.mm-ai-chat__tool-input{margin:.35rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;color:var(--mm-ai-chat-muted);max-height:14rem;overflow-y:auto}.mm-ai-chat__tool-result{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-tool-result);border-radius:.5rem;padding:.55rem .75rem;margin-left:1.25rem}.mm-ai-chat__tool-result--error{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__tool-result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__tool-result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-tool-result)}.mm-ai-chat__error-badge{background:var(--mm-ai-chat-accent-error);color:#07172b;padding:0 6px;border-radius:.25rem;font-size:.6rem;font-weight:700}.mm-ai-chat__tool-result-body{margin:.4rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;max-height:18rem;overflow-y:auto}.mm-ai-chat__result{background:var(--mm-ai-chat-card-bg-elevated);border:1px solid var(--mm-ai-chat-border-strong);border-top:3px solid var(--mm-ai-chat-accent-result);border-radius:.5rem;padding:.7rem .85rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__result--error{border-top-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-result)}.mm-ai-chat__result-text{margin:0;white-space:pre-wrap;word-break:break-word;font-style:italic;color:var(--mm-ai-chat-text)}.mm-ai-chat__result-stats{margin:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(7rem,1fr));gap:.5rem;font-family:Roboto Mono,monospace;font-size:.75rem}.mm-ai-chat__result-stats div{display:flex;flex-direction:column;gap:.2rem;padding:.4rem .5rem;background:#64ceb90f;border-radius:.3rem}.mm-ai-chat__result-stats dt{font-size:.62rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-stats dd{margin:0;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system{all:unset;cursor:pointer;display:flex;align-items:center;gap:.5rem;padding:.35rem .6rem;background:#64ceb908;border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-system);border-radius:.4rem;font-size:.78rem;color:var(--mm-ai-chat-muted);transition:background-color .15s ease}.mm-ai-chat__system:hover{background:#64ceb90f}.mm-ai-chat__system:focus-visible{outline:2px solid var(--mm-ai-chat-accent-assistant);outline-offset:1px}.mm-ai-chat__system--init{border-left-color:var(--mm-ai-chat-accent-tool)}.mm-ai-chat__system--hook{border-left-color:var(--mm-ai-chat-accent-system)}.mm-ai-chat__system--rate{border-left-color:var(--mm-ai-chat-accent-rate-limit)}.mm-ai-chat__system--unknown{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__system-chevron{font-size:.7rem;width:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__system-summary{flex:1;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system-detail{margin:-.25rem 0 0 1.5rem;padding:.5rem .6rem;background:#00000040;border-radius:.35rem;font-family:Roboto Mono,monospace;font-size:.7rem;white-space:pre-wrap;word-break:break-word;max-height:22rem;overflow-y:auto;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status{display:flex;align-items:baseline;gap:.5rem;padding:.25rem .5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-label{color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-value{color:var(--mm-ai-chat-text);font-weight:600}\n"],
698
+ dependencies: [{
699
+ kind: "ngmodule",
700
+ type: CommonModule
701
+ }],
702
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
703
+ });
704
+ };
705
+ i0.ɵɵngDeclareClassMetadata({
706
+ minVersion: "12.0.0",
707
+ version: "22.3.0",
708
+ ngImport: i0,
709
+ type: AiChatStreamComponent,
710
+ decorators: [{
711
+ type: Component,
712
+ args: [{
713
+ selector: "mm-ai-chat-stream",
714
+ standalone: true,
715
+ imports: [CommonModule],
716
+ changeDetection: ChangeDetectionStrategy.OnPush,
717
+ template: "<div class=\"mm-ai-chat\">\n @for (parsed of parsedEvents(); track parsed.event.sequence) {\n @switch (parsed.view.kind) {\n @case ('assistant') {\n <article class=\"mm-ai-chat__bubble mm-ai-chat__bubble--assistant\">\n <header class=\"mm-ai-chat__bubble-header\">\n <span class=\"mm-ai-chat__role\">Assistant</span>\n @if (parsed.view.model; as model) {\n <span class=\"mm-ai-chat__meta\">{{ model }}</span>\n }\n @if (parsed.view.usage; as usage) {\n <span class=\"mm-ai-chat__meta\">\n {{ formatTokenCount(usage.input + usage.output) }}\n </span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @for (part of parsed.view.parts; track $index) {\n @switch (part.type) {\n @case ('text') {\n <p class=\"mm-ai-chat__text\">{{ part.text }}</p>\n }\n @case ('tool_use') {\n <div class=\"mm-ai-chat__tool-use\">\n <header class=\"mm-ai-chat__tool-use-header\">\n <span class=\"mm-ai-chat__tool-badge\">tool</span>\n <span class=\"mm-ai-chat__tool-name\">{{ part.toolName }}</span>\n </header>\n <pre class=\"mm-ai-chat__tool-input\">{{ formatRaw(part.input) }}</pre>\n </div>\n }\n }\n }\n </article>\n }\n\n @case ('tool-result') {\n <article\n class=\"mm-ai-chat__tool-result\"\n [class.mm-ai-chat__tool-result--error]=\"parsed.view.isError\"\n >\n <header class=\"mm-ai-chat__tool-result-header\">\n <span class=\"mm-ai-chat__role\">Tool result</span>\n @if (parsed.view.isError) {\n <span class=\"mm-ai-chat__error-badge\">error</span>\n }\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n <pre class=\"mm-ai-chat__tool-result-body\">{{ parsed.view.content }}</pre>\n </article>\n }\n\n @case ('result') {\n <article class=\"mm-ai-chat__result\"\n [class.mm-ai-chat__result--error]=\"parsed.view.isError\">\n <header class=\"mm-ai-chat__result-header\">\n <span class=\"mm-ai-chat__role\">{{ parsed.view.reason }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </header>\n @if (parsed.view.text) {\n <p class=\"mm-ai-chat__result-text\">{{ parsed.view.text }}</p>\n }\n <dl class=\"mm-ai-chat__result-stats\">\n <div>\n <dt>Duration</dt>\n <dd>{{ formatDuration(parsed.view.durationMs) }}</dd>\n </div>\n <div>\n <dt>Tokens (in/out)</dt>\n <dd>\n @if (parsed.view.usage) {\n {{ formatTokenCount(parsed.view.usage.input) }}\n /\n {{ formatTokenCount(parsed.view.usage.output) }}\n } @else {\n —\n }\n </dd>\n </div>\n <div>\n <dt>Cost</dt>\n <dd>{{ formatCost(parsed.view.costUsd) }}</dd>\n </div>\n </dl>\n </article>\n }\n\n @case ('system') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system\"\n [class.mm-ai-chat__system--init]=\"parsed.view.subKind === 'init'\"\n [class.mm-ai-chat__system--hook]=\"parsed.view.subKind === 'hook'\"\n [class.mm-ai-chat__system--rate]=\"parsed.view.subKind === 'rate-limit'\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '▾' : '▸' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n\n @case ('status-change') {\n <div class=\"mm-ai-chat__status\">\n <span class=\"mm-ai-chat__status-label\">Status</span>\n <span class=\"mm-ai-chat__status-value\">{{ parsed.view.status }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </div>\n }\n\n @case ('unknown') {\n <button\n type=\"button\"\n class=\"mm-ai-chat__system mm-ai-chat__system--unknown\"\n [attr.aria-expanded]=\"isExpanded(parsed.event.sequence)\"\n (click)=\"toggleRaw(parsed.event.sequence)\"\n >\n <span class=\"mm-ai-chat__system-chevron\">\n {{ isExpanded(parsed.event.sequence) ? '▾' : '▸' }}\n </span>\n <span class=\"mm-ai-chat__system-summary\">{{ parsed.view.summary }}</span>\n <time class=\"mm-ai-chat__time\">{{ formatTime(parsed.event.at) }}</time>\n </button>\n @if (isExpanded(parsed.event.sequence)) {\n <pre class=\"mm-ai-chat__system-detail\">{{ formatRaw(parsed.view.raw) }}</pre>\n }\n }\n }\n } @empty {\n <div class=\"mm-ai-chat__empty\">\n No events yet — the worker hasn't emitted anything.\n </div>\n }\n</div>\n",
718
+ styles: [":host{display:block;--mm-ai-chat-bg: transparent;--mm-ai-chat-card-bg: rgba(31, 46, 64, .55);--mm-ai-chat-card-bg-elevated: rgba(31, 46, 64, .85);--mm-ai-chat-border: rgba(100, 206, 185, .18);--mm-ai-chat-border-strong: rgba(100, 206, 185, .4);--mm-ai-chat-text: #e6e6e6;--mm-ai-chat-muted: #9292a6;--mm-ai-chat-accent-assistant: #64ceb9;--mm-ai-chat-accent-tool: #00a8dc;--mm-ai-chat-accent-tool-result: #00a8dc;--mm-ai-chat-accent-system: #6c4da8;--mm-ai-chat-accent-rate-limit: #da9162;--mm-ai-chat-accent-result: #64ceb9;--mm-ai-chat-accent-error: #ec658f}.mm-ai-chat{display:flex;flex-direction:column;gap:.5rem;padding:.25rem;background:var(--mm-ai-chat-bg);color:var(--mm-ai-chat-text);font-size:.85rem;line-height:1.45}.mm-ai-chat__empty{color:var(--mm-ai-chat-muted);text-align:center;padding:1.5rem;font-style:italic}.mm-ai-chat__bubble{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-assistant);border-radius:.5rem;padding:.6rem .75rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__bubble-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__role{font-weight:700;color:var(--mm-ai-chat-accent-assistant)}.mm-ai-chat__meta{font-family:Roboto Mono,monospace;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__time{margin-left:auto;font-variant-numeric:tabular-nums;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__text{margin:0;white-space:pre-wrap;word-break:break-word}.mm-ai-chat__tool-use{border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-tool);border-radius:.35rem;background:var(--mm-ai-chat-card-bg-elevated);padding:.4rem .5rem}.mm-ai-chat__tool-use-header{display:flex;align-items:baseline;gap:.4rem;font-size:.7rem}.mm-ai-chat__tool-badge{background:var(--mm-ai-chat-accent-tool);color:#07172b;padding:0 6px;border-radius:.25rem;font-weight:700;font-size:.65rem}.mm-ai-chat__tool-name{font-family:Roboto Mono,monospace;color:var(--mm-ai-chat-text);font-weight:600}.mm-ai-chat__tool-input{margin:.35rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;color:var(--mm-ai-chat-muted);max-height:14rem;overflow-y:auto}.mm-ai-chat__tool-result{background:var(--mm-ai-chat-card-bg);border:1px solid var(--mm-ai-chat-border);border-left:3px solid var(--mm-ai-chat-accent-tool-result);border-radius:.5rem;padding:.55rem .75rem;margin-left:1.25rem}.mm-ai-chat__tool-result--error{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__tool-result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__tool-result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-tool-result)}.mm-ai-chat__error-badge{background:var(--mm-ai-chat-accent-error);color:#07172b;padding:0 6px;border-radius:.25rem;font-size:.6rem;font-weight:700}.mm-ai-chat__tool-result-body{margin:.4rem 0 0;font-family:Roboto Mono,monospace;font-size:.75rem;white-space:pre-wrap;word-break:break-word;max-height:18rem;overflow-y:auto}.mm-ai-chat__result{background:var(--mm-ai-chat-card-bg-elevated);border:1px solid var(--mm-ai-chat-border-strong);border-top:3px solid var(--mm-ai-chat-accent-result);border-radius:.5rem;padding:.7rem .85rem;display:flex;flex-direction:column;gap:.5rem}.mm-ai-chat__result--error{border-top-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__result-header{display:flex;align-items:baseline;gap:.5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-header .mm-ai-chat__role{color:var(--mm-ai-chat-accent-result)}.mm-ai-chat__result-text{margin:0;white-space:pre-wrap;word-break:break-word;font-style:italic;color:var(--mm-ai-chat-text)}.mm-ai-chat__result-stats{margin:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(7rem,1fr));gap:.5rem;font-family:Roboto Mono,monospace;font-size:.75rem}.mm-ai-chat__result-stats div{display:flex;flex-direction:column;gap:.2rem;padding:.4rem .5rem;background:#64ceb90f;border-radius:.3rem}.mm-ai-chat__result-stats dt{font-size:.62rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__result-stats dd{margin:0;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system{all:unset;cursor:pointer;display:flex;align-items:center;gap:.5rem;padding:.35rem .6rem;background:#64ceb908;border:1px solid var(--mm-ai-chat-border);border-left:2px solid var(--mm-ai-chat-accent-system);border-radius:.4rem;font-size:.78rem;color:var(--mm-ai-chat-muted);transition:background-color .15s ease}.mm-ai-chat__system:hover{background:#64ceb90f}.mm-ai-chat__system:focus-visible{outline:2px solid var(--mm-ai-chat-accent-assistant);outline-offset:1px}.mm-ai-chat__system--init{border-left-color:var(--mm-ai-chat-accent-tool)}.mm-ai-chat__system--hook{border-left-color:var(--mm-ai-chat-accent-system)}.mm-ai-chat__system--rate{border-left-color:var(--mm-ai-chat-accent-rate-limit)}.mm-ai-chat__system--unknown{border-left-color:var(--mm-ai-chat-accent-error)}.mm-ai-chat__system-chevron{font-size:.7rem;width:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__system-summary{flex:1;color:var(--mm-ai-chat-text);font-variant-numeric:tabular-nums}.mm-ai-chat__system-detail{margin:-.25rem 0 0 1.5rem;padding:.5rem .6rem;background:#00000040;border-radius:.35rem;font-family:Roboto Mono,monospace;font-size:.7rem;white-space:pre-wrap;word-break:break-word;max-height:22rem;overflow-y:auto;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status{display:flex;align-items:baseline;gap:.5rem;padding:.25rem .5rem;font-size:.7rem;color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-label{color:var(--mm-ai-chat-muted)}.mm-ai-chat__status-value{color:var(--mm-ai-chat-text);font-weight:600}\n"]
719
+ }]
720
+ }],
721
+ propDecorators: { events: [{
722
+ type: i0.Input,
723
+ args: [{
724
+ isSignal: true,
725
+ alias: "events",
726
+ required: true
727
+ }]
728
+ }] }
729
+ });
730
+ var AiToolCallComponent = class AiToolCallComponent {
731
+ call = input.required(...ngDevMode ? [{ debugName: "call" }] : /* istanbul ignore next */ []);
732
+ expanded = signal(false, ...ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []);
733
+ statusVariant = computed(() => {
734
+ switch (this.call().status) {
735
+ case "Succeeded": return "succeeded";
736
+ case "Failed": return "failed";
737
+ case "Rejected": return "rejected";
738
+ case "Approved":
739
+ case "Pending": return "pending";
740
+ default: return "pending";
741
+ }
742
+ }, ...ngDevMode ? [{ debugName: "statusVariant" }] : /* istanbul ignore next */ []);
743
+ argumentsJson = computed(() => this.format(this.call().arguments), ...ngDevMode ? [{ debugName: "argumentsJson" }] : /* istanbul ignore next */ []);
744
+ resultJson = computed(() => {
745
+ const result = this.call().result;
746
+ return result === void 0 ? null : this.format(result);
747
+ }, ...ngDevMode ? [{ debugName: "resultJson" }] : /* istanbul ignore next */ []);
748
+ toggleExpanded() {
749
+ this.expanded.update((v) => !v);
750
+ }
751
+ format(value) {
752
+ if (value === null || value === void 0) return "";
753
+ try {
754
+ return JSON.stringify(value, null, 2);
755
+ } catch {
756
+ return String(value);
757
+ }
758
+ }
759
+ static ɵfac = i0.ɵɵngDeclareFactory({
760
+ minVersion: "12.0.0",
761
+ version: "22.3.0",
762
+ ngImport: i0,
763
+ type: AiToolCallComponent,
764
+ deps: [],
765
+ target: i0.ɵɵFactoryTarget.Component
766
+ });
767
+ static ɵcmp = i0.ɵɵngDeclareComponent({
768
+ minVersion: "17.0.0",
769
+ version: "22.3.0",
770
+ type: AiToolCallComponent,
771
+ isStandalone: true,
772
+ selector: "mm-ai-tool-call",
773
+ inputs: { call: {
774
+ classPropertyName: "call",
775
+ publicName: "call",
776
+ isSignal: true,
777
+ isRequired: true,
778
+ transformFunction: null
779
+ } },
780
+ ngImport: i0,
781
+ template: "<div class=\"mm-ai-tool-call mm-ai-tool-call--{{ statusVariant() }}\">\n <button\n type=\"button\"\n class=\"mm-ai-tool-call__header\"\n (click)=\"toggleExpanded()\"\n [attr.aria-expanded]=\"expanded()\"\n >\n <span class=\"mm-ai-tool-call__chevron\">\n {{ expanded() ? '▾' : '▸' }}\n </span>\n <span class=\"mm-ai-tool-call__name\">{{ call().toolName }}</span>\n <span class=\"mm-ai-tool-call__status\">{{ call().status }}</span>\n @if (call().durationMs != null) {\n <span class=\"mm-ai-tool-call__duration\">\n {{ call().durationMs }}ms\n </span>\n }\n </button>\n\n @if (expanded()) {\n <div class=\"mm-ai-tool-call__body\">\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Arguments</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ argumentsJson() }}</pre>\n </div>\n\n @if (resultJson() !== null) {\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Result</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ resultJson() }}</pre>\n </div>\n }\n </div>\n }\n</div>\n",
782
+ styles: [":host{display:block;--mm-ai-tool-bg: #1f2227;--mm-ai-tool-border: #2f343b;--mm-ai-tool-text: #e6e6e6;--mm-ai-tool-muted: #9aa0a6;--mm-ai-tool-success: #2ea44f;--mm-ai-tool-failed: #d73a49;--mm-ai-tool-rejected: #d29922;--mm-ai-tool-pending: #6e7681;--mm-ai-tool-code-bg: #16191d}.mm-ai-tool-call{border:1px solid var(--mm-ai-tool-border);border-radius:.5rem;background:var(--mm-ai-tool-bg);color:var(--mm-ai-tool-text);margin:.4rem 0;overflow:hidden}.mm-ai-tool-call--succeeded{border-left:3px solid var(--mm-ai-tool-success)}.mm-ai-tool-call--failed{border-left:3px solid var(--mm-ai-tool-failed)}.mm-ai-tool-call--rejected{border-left:3px solid var(--mm-ai-tool-rejected)}.mm-ai-tool-call--pending{border-left:3px solid var(--mm-ai-tool-pending)}.mm-ai-tool-call__header{width:100%;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;background:transparent;color:inherit;border:none;cursor:pointer;text-align:left;font-family:inherit;font-size:.9rem}.mm-ai-tool-call__header:hover{background:#ffffff0a}.mm-ai-tool-call__chevron{width:1rem;text-align:center;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__name{font-weight:600;flex:1}.mm-ai-tool-call__status,.mm-ai-tool-call__duration{font-size:.75rem;color:var(--mm-ai-tool-muted);font-variant-numeric:tabular-nums}.mm-ai-tool-call__body{border-top:1px solid var(--mm-ai-tool-border);padding:.5rem .75rem}.mm-ai-tool-call__section+.mm-ai-tool-call__section{margin-top:.75rem}.mm-ai-tool-call__heading{margin:0 0 .25rem;font-size:.75rem;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-tool-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word}\n"],
783
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
784
+ });
785
+ };
786
+ i0.ɵɵngDeclareClassMetadata({
787
+ minVersion: "12.0.0",
788
+ version: "22.3.0",
789
+ ngImport: i0,
790
+ type: AiToolCallComponent,
791
+ decorators: [{
792
+ type: Component,
793
+ args: [{
794
+ selector: "mm-ai-tool-call",
795
+ imports: [],
796
+ changeDetection: ChangeDetectionStrategy.OnPush,
797
+ template: "<div class=\"mm-ai-tool-call mm-ai-tool-call--{{ statusVariant() }}\">\n <button\n type=\"button\"\n class=\"mm-ai-tool-call__header\"\n (click)=\"toggleExpanded()\"\n [attr.aria-expanded]=\"expanded()\"\n >\n <span class=\"mm-ai-tool-call__chevron\">\n {{ expanded() ? '▾' : '▸' }}\n </span>\n <span class=\"mm-ai-tool-call__name\">{{ call().toolName }}</span>\n <span class=\"mm-ai-tool-call__status\">{{ call().status }}</span>\n @if (call().durationMs != null) {\n <span class=\"mm-ai-tool-call__duration\">\n {{ call().durationMs }}ms\n </span>\n }\n </button>\n\n @if (expanded()) {\n <div class=\"mm-ai-tool-call__body\">\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Arguments</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ argumentsJson() }}</pre>\n </div>\n\n @if (resultJson() !== null) {\n <div class=\"mm-ai-tool-call__section\">\n <h4 class=\"mm-ai-tool-call__heading\">Result</h4>\n <pre class=\"mm-ai-tool-call__code\">{{ resultJson() }}</pre>\n </div>\n }\n </div>\n }\n</div>\n",
798
+ styles: [":host{display:block;--mm-ai-tool-bg: #1f2227;--mm-ai-tool-border: #2f343b;--mm-ai-tool-text: #e6e6e6;--mm-ai-tool-muted: #9aa0a6;--mm-ai-tool-success: #2ea44f;--mm-ai-tool-failed: #d73a49;--mm-ai-tool-rejected: #d29922;--mm-ai-tool-pending: #6e7681;--mm-ai-tool-code-bg: #16191d}.mm-ai-tool-call{border:1px solid var(--mm-ai-tool-border);border-radius:.5rem;background:var(--mm-ai-tool-bg);color:var(--mm-ai-tool-text);margin:.4rem 0;overflow:hidden}.mm-ai-tool-call--succeeded{border-left:3px solid var(--mm-ai-tool-success)}.mm-ai-tool-call--failed{border-left:3px solid var(--mm-ai-tool-failed)}.mm-ai-tool-call--rejected{border-left:3px solid var(--mm-ai-tool-rejected)}.mm-ai-tool-call--pending{border-left:3px solid var(--mm-ai-tool-pending)}.mm-ai-tool-call__header{width:100%;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;background:transparent;color:inherit;border:none;cursor:pointer;text-align:left;font-family:inherit;font-size:.9rem}.mm-ai-tool-call__header:hover{background:#ffffff0a}.mm-ai-tool-call__chevron{width:1rem;text-align:center;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__name{font-weight:600;flex:1}.mm-ai-tool-call__status,.mm-ai-tool-call__duration{font-size:.75rem;color:var(--mm-ai-tool-muted);font-variant-numeric:tabular-nums}.mm-ai-tool-call__body{border-top:1px solid var(--mm-ai-tool-border);padding:.5rem .75rem}.mm-ai-tool-call__section+.mm-ai-tool-call__section{margin-top:.75rem}.mm-ai-tool-call__heading{margin:0 0 .25rem;font-size:.75rem;color:var(--mm-ai-tool-muted)}.mm-ai-tool-call__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-tool-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word}\n"]
799
+ }]
800
+ }],
801
+ propDecorators: { call: [{
802
+ type: i0.Input,
803
+ args: [{
804
+ isSignal: true,
805
+ alias: "call",
806
+ required: true
807
+ }]
808
+ }] }
809
+ });
810
+ var AiApprovalModalComponent = class AiApprovalModalComponent {
811
+ request = input.required(...ngDevMode ? [{ debugName: "request" }] : /* istanbul ignore next */ []);
812
+ decide = output();
813
+ dismiss = output();
814
+ comment = signal("", ...ngDevMode ? [{ debugName: "comment" }] : /* istanbul ignore next */ []);
815
+ prettyPayload = computed(() => {
816
+ try {
817
+ return JSON.stringify(JSON.parse(this.request().payload), null, 2);
818
+ } catch {
819
+ return this.request().payload;
820
+ }
821
+ }, ...ngDevMode ? [{ debugName: "prettyPayload" }] : /* istanbul ignore next */ []);
822
+ approve() {
823
+ this.decide.emit({
824
+ outcome: "Approved",
825
+ comment: this.commentOrUndefined()
826
+ });
827
+ }
828
+ reject() {
829
+ this.decide.emit({
830
+ outcome: "Rejected",
831
+ comment: this.commentOrUndefined()
832
+ });
833
+ }
834
+ onDismiss() {
835
+ this.dismiss.emit();
836
+ }
837
+ commentOrUndefined() {
838
+ const trimmed = this.comment().trim();
839
+ return trimmed.length > 0 ? trimmed : void 0;
840
+ }
841
+ static ɵfac = i0.ɵɵngDeclareFactory({
842
+ minVersion: "12.0.0",
843
+ version: "22.3.0",
844
+ ngImport: i0,
845
+ type: AiApprovalModalComponent,
846
+ deps: [],
847
+ target: i0.ɵɵFactoryTarget.Component
848
+ });
849
+ static ɵcmp = i0.ɵɵngDeclareComponent({
850
+ minVersion: "17.1.0",
851
+ version: "22.3.0",
852
+ type: AiApprovalModalComponent,
853
+ isStandalone: true,
854
+ selector: "mm-ai-approval-modal",
855
+ inputs: { request: {
856
+ classPropertyName: "request",
857
+ publicName: "request",
858
+ isSignal: true,
859
+ isRequired: true,
860
+ transformFunction: null
861
+ } },
862
+ outputs: {
863
+ decide: "decide",
864
+ dismiss: "dismiss"
865
+ },
866
+ ngImport: i0,
867
+ template: "<div class=\"mm-ai-approval\">\n <header class=\"mm-ai-approval__header\">\n <h3 class=\"mm-ai-approval__title\">Approve tool call</h3>\n <button\n type=\"button\"\n class=\"mm-ai-approval__close\"\n (click)=\"onDismiss()\"\n aria-label=\"Dismiss\"\n >\n ×\n </button>\n </header>\n\n <div class=\"mm-ai-approval__meta\">\n <div><span>Tool:</span> <code>{{ request().toolName }}</code></div>\n <div><span>Reason:</span> <code>{{ request().reason }}</code></div>\n <div><span>Session:</span> <code>{{ request().sessionId }}</code></div>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Payload</h4>\n <pre class=\"mm-ai-approval__code\">{{ prettyPayload() }}</pre>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Comment <span>(optional)</span></h4>\n <textarea\n class=\"mm-ai-approval__comment\"\n [ngModel]=\"comment()\"\n (ngModelChange)=\"comment.set($event)\"\n rows=\"3\"\n placeholder=\"Why is this approved or rejected?\"\n ></textarea>\n </div>\n\n <footer class=\"mm-ai-approval__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--reject\"\n (click)=\"reject()\"\n >\n Reject\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--approve\"\n (click)=\"approve()\"\n >\n Approve\n </button>\n </footer>\n</div>\n",
868
+ styles: [":host{display:block;--mm-ai-approval-bg: #1f2227;--mm-ai-approval-border: #2f343b;--mm-ai-approval-text: #e6e6e6;--mm-ai-approval-muted: #9aa0a6;--mm-ai-approval-approve: #2ea44f;--mm-ai-approval-reject: #d73a49;--mm-ai-approval-code-bg: #16191d}.mm-ai-approval{background:var(--mm-ai-approval-bg);color:var(--mm-ai-approval-text);border:1px solid var(--mm-ai-approval-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(36rem,100%)}.mm-ai-approval__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-approval__title{margin:0;font-size:1rem}.mm-ai-approval__close{background:transparent;color:var(--mm-ai-approval-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-approval__close:hover{color:var(--mm-ai-approval-text)}.mm-ai-approval__meta{display:grid;gap:.25rem;font-size:.85rem;margin-bottom:.75rem}.mm-ai-approval__meta span{color:var(--mm-ai-approval-muted);margin-right:.35rem}.mm-ai-approval__meta code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.mm-ai-approval__section{margin-bottom:.75rem}.mm-ai-approval__heading{margin:0 0 .3rem;font-size:.75rem;color:var(--mm-ai-approval-muted)}.mm-ai-approval__heading span{text-transform:none;opacity:.6}.mm-ai-approval__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word;max-height:14rem}.mm-ai-approval__comment{width:100%;box-sizing:border-box;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);color:inherit;border:1px solid var(--mm-ai-approval-border);border-radius:.3rem;font-family:inherit;font-size:.85rem;resize:vertical}.mm-ai-approval__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-approval__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-approval__btn--approve{background:var(--mm-ai-approval-approve);color:#fff}.mm-ai-approval__btn--reject{background:var(--mm-ai-approval-reject);color:#fff}\n"],
869
+ dependencies: [
870
+ {
871
+ kind: "ngmodule",
872
+ type: FormsModule
873
+ },
874
+ {
875
+ kind: "directive",
876
+ type: i1.DefaultValueAccessor,
877
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
878
+ },
879
+ {
880
+ kind: "directive",
881
+ type: i1.NgControlStatus,
882
+ selector: "[formControlName],[ngModel],[formControl]"
883
+ },
884
+ {
885
+ kind: "directive",
886
+ type: i1.NgModel,
887
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
888
+ inputs: [
889
+ "name",
890
+ "disabled",
891
+ "ngModel",
892
+ "ngModelOptions"
893
+ ],
894
+ outputs: ["ngModelChange"],
895
+ exportAs: ["ngModel"]
896
+ }
897
+ ],
898
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
899
+ });
900
+ };
901
+ i0.ɵɵngDeclareClassMetadata({
902
+ minVersion: "12.0.0",
903
+ version: "22.3.0",
904
+ ngImport: i0,
905
+ type: AiApprovalModalComponent,
906
+ decorators: [{
907
+ type: Component,
908
+ args: [{
909
+ selector: "mm-ai-approval-modal",
910
+ imports: [FormsModule],
911
+ changeDetection: ChangeDetectionStrategy.OnPush,
912
+ template: "<div class=\"mm-ai-approval\">\n <header class=\"mm-ai-approval__header\">\n <h3 class=\"mm-ai-approval__title\">Approve tool call</h3>\n <button\n type=\"button\"\n class=\"mm-ai-approval__close\"\n (click)=\"onDismiss()\"\n aria-label=\"Dismiss\"\n >\n ×\n </button>\n </header>\n\n <div class=\"mm-ai-approval__meta\">\n <div><span>Tool:</span> <code>{{ request().toolName }}</code></div>\n <div><span>Reason:</span> <code>{{ request().reason }}</code></div>\n <div><span>Session:</span> <code>{{ request().sessionId }}</code></div>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Payload</h4>\n <pre class=\"mm-ai-approval__code\">{{ prettyPayload() }}</pre>\n </div>\n\n <div class=\"mm-ai-approval__section\">\n <h4 class=\"mm-ai-approval__heading\">Comment <span>(optional)</span></h4>\n <textarea\n class=\"mm-ai-approval__comment\"\n [ngModel]=\"comment()\"\n (ngModelChange)=\"comment.set($event)\"\n rows=\"3\"\n placeholder=\"Why is this approved or rejected?\"\n ></textarea>\n </div>\n\n <footer class=\"mm-ai-approval__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--reject\"\n (click)=\"reject()\"\n >\n Reject\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-approval__btn mm-ai-approval__btn--approve\"\n (click)=\"approve()\"\n >\n Approve\n </button>\n </footer>\n</div>\n",
913
+ styles: [":host{display:block;--mm-ai-approval-bg: #1f2227;--mm-ai-approval-border: #2f343b;--mm-ai-approval-text: #e6e6e6;--mm-ai-approval-muted: #9aa0a6;--mm-ai-approval-approve: #2ea44f;--mm-ai-approval-reject: #d73a49;--mm-ai-approval-code-bg: #16191d}.mm-ai-approval{background:var(--mm-ai-approval-bg);color:var(--mm-ai-approval-text);border:1px solid var(--mm-ai-approval-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(36rem,100%)}.mm-ai-approval__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-approval__title{margin:0;font-size:1rem}.mm-ai-approval__close{background:transparent;color:var(--mm-ai-approval-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-approval__close:hover{color:var(--mm-ai-approval-text)}.mm-ai-approval__meta{display:grid;gap:.25rem;font-size:.85rem;margin-bottom:.75rem}.mm-ai-approval__meta span{color:var(--mm-ai-approval-muted);margin-right:.35rem}.mm-ai-approval__meta code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.mm-ai-approval__section{margin-bottom:.75rem}.mm-ai-approval__heading{margin:0 0 .3rem;font-size:.75rem;color:var(--mm-ai-approval-muted)}.mm-ai-approval__heading span{text-transform:none;opacity:.6}.mm-ai-approval__code{margin:0;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);border-radius:.3rem;font-size:.8rem;overflow-x:auto;white-space:pre-wrap;word-break:break-word;max-height:14rem}.mm-ai-approval__comment{width:100%;box-sizing:border-box;padding:.5rem .6rem;background:var(--mm-ai-approval-code-bg);color:inherit;border:1px solid var(--mm-ai-approval-border);border-radius:.3rem;font-family:inherit;font-size:.85rem;resize:vertical}.mm-ai-approval__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-approval__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-approval__btn--approve{background:var(--mm-ai-approval-approve);color:#fff}.mm-ai-approval__btn--reject{background:var(--mm-ai-approval-reject);color:#fff}\n"]
914
+ }]
915
+ }],
916
+ propDecorators: {
917
+ request: [{
918
+ type: i0.Input,
919
+ args: [{
920
+ isSignal: true,
921
+ alias: "request",
922
+ required: true
923
+ }]
924
+ }],
925
+ decide: [{
926
+ type: i0.Output,
927
+ args: ["decide"]
928
+ }],
929
+ dismiss: [{
930
+ type: i0.Output,
931
+ args: ["dismiss"]
932
+ }]
933
+ }
934
+ });
935
+ var AiQuotaIndicatorComponent = class AiQuotaIndicatorComponent {
936
+ dailyConsumed = input.required(...ngDevMode ? [{ debugName: "dailyConsumed" }] : /* istanbul ignore next */ []);
937
+ dailyCap = input.required(...ngDevMode ? [{ debugName: "dailyCap" }] : /* istanbul ignore next */ []);
938
+ monthlyConsumed = input(null, ...ngDevMode ? [{ debugName: "monthlyConsumed" }] : /* istanbul ignore next */ []);
939
+ monthlyCap = input(null, ...ngDevMode ? [{ debugName: "monthlyCap" }] : /* istanbul ignore next */ []);
940
+ dailyPercent = computed(() => this.percent(this.dailyConsumed(), this.dailyCap()), ...ngDevMode ? [{ debugName: "dailyPercent" }] : /* istanbul ignore next */ []);
941
+ monthlyPercent = computed(() => {
942
+ const consumed = this.monthlyConsumed();
943
+ const cap = this.monthlyCap();
944
+ if (consumed == null || cap == null) return null;
945
+ return this.percent(consumed, cap);
946
+ }, ...ngDevMode ? [{ debugName: "monthlyPercent" }] : /* istanbul ignore next */ []);
947
+ dailyState = computed(() => this.toState(this.dailyPercent()), ...ngDevMode ? [{ debugName: "dailyState" }] : /* istanbul ignore next */ []);
948
+ monthlyState = computed(() => {
949
+ const pct = this.monthlyPercent();
950
+ return pct == null ? null : this.toState(pct);
951
+ }, ...ngDevMode ? [{ debugName: "monthlyState" }] : /* istanbul ignore next */ []);
952
+ percent(consumed, cap) {
953
+ if (cap <= 0) return 0;
954
+ return Math.min(100, Math.round(consumed / cap * 100));
955
+ }
956
+ toState(percent) {
957
+ if (percent >= 100) return "critical";
958
+ if (percent >= 80) return "warning";
959
+ return "ok";
960
+ }
961
+ static ɵfac = i0.ɵɵngDeclareFactory({
962
+ minVersion: "12.0.0",
963
+ version: "22.3.0",
964
+ ngImport: i0,
965
+ type: AiQuotaIndicatorComponent,
966
+ deps: [],
967
+ target: i0.ɵɵFactoryTarget.Component
968
+ });
969
+ static ɵcmp = i0.ɵɵngDeclareComponent({
970
+ minVersion: "17.0.0",
971
+ version: "22.3.0",
972
+ type: AiQuotaIndicatorComponent,
973
+ isStandalone: true,
974
+ selector: "mm-ai-quota-indicator",
975
+ inputs: {
976
+ dailyConsumed: {
977
+ classPropertyName: "dailyConsumed",
978
+ publicName: "dailyConsumed",
979
+ isSignal: true,
980
+ isRequired: true,
981
+ transformFunction: null
982
+ },
983
+ dailyCap: {
984
+ classPropertyName: "dailyCap",
985
+ publicName: "dailyCap",
986
+ isSignal: true,
987
+ isRequired: true,
988
+ transformFunction: null
989
+ },
990
+ monthlyConsumed: {
991
+ classPropertyName: "monthlyConsumed",
992
+ publicName: "monthlyConsumed",
993
+ isSignal: true,
994
+ isRequired: false,
995
+ transformFunction: null
996
+ },
997
+ monthlyCap: {
998
+ classPropertyName: "monthlyCap",
999
+ publicName: "monthlyCap",
1000
+ isSignal: true,
1001
+ isRequired: false,
1002
+ transformFunction: null
1003
+ }
1004
+ },
1005
+ ngImport: i0,
1006
+ template: "<div class=\"mm-ai-quota\">\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Daily</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ dailyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"dailyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ dailyConsumed() }} / {{ dailyCap() }} ({{ dailyPercent() }}%)\n </span>\n </div>\n\n @if (monthlyPercent() !== null) {\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Monthly</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ monthlyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"monthlyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ monthlyConsumed() }} / {{ monthlyCap() }} ({{ monthlyPercent() }}%)\n </span>\n </div>\n }\n</div>\n",
1007
+ styles: [":host{display:block;--mm-ai-quota-track-bg: #2a2a2a;--mm-ai-quota-ok: #2ea44f;--mm-ai-quota-warning: #d29922;--mm-ai-quota-critical: #d73a49}.mm-ai-quota{display:flex;flex-direction:column;gap:.5rem;font-size:.85rem}.mm-ai-quota__row{display:grid;grid-template-columns:4.5rem 1fr auto;align-items:center;gap:.5rem}.mm-ai-quota__label{font-weight:600;opacity:.7}.mm-ai-quota__bar{height:.5rem;border-radius:9999px;background:var(--mm-ai-quota-track-bg);overflow:hidden}.mm-ai-quota__bar--ok .mm-ai-quota__fill{background:var(--mm-ai-quota-ok)}.mm-ai-quota__bar--warning .mm-ai-quota__fill{background:var(--mm-ai-quota-warning)}.mm-ai-quota__bar--critical .mm-ai-quota__fill{background:var(--mm-ai-quota-critical)}.mm-ai-quota__fill{height:100%;transition:width .2s ease}.mm-ai-quota__count{font-variant-numeric:tabular-nums;opacity:.8}\n"],
1008
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1009
+ });
1010
+ };
1011
+ i0.ɵɵngDeclareClassMetadata({
1012
+ minVersion: "12.0.0",
1013
+ version: "22.3.0",
1014
+ ngImport: i0,
1015
+ type: AiQuotaIndicatorComponent,
1016
+ decorators: [{
1017
+ type: Component,
1018
+ args: [{
1019
+ selector: "mm-ai-quota-indicator",
1020
+ imports: [],
1021
+ changeDetection: ChangeDetectionStrategy.OnPush,
1022
+ template: "<div class=\"mm-ai-quota\">\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Daily</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ dailyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"dailyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ dailyConsumed() }} / {{ dailyCap() }} ({{ dailyPercent() }}%)\n </span>\n </div>\n\n @if (monthlyPercent() !== null) {\n <div class=\"mm-ai-quota__row\">\n <span class=\"mm-ai-quota__label\">Monthly</span>\n <div class=\"mm-ai-quota__bar mm-ai-quota__bar--{{ monthlyState() }}\">\n <div class=\"mm-ai-quota__fill\" [style.width.%]=\"monthlyPercent()\"></div>\n </div>\n <span class=\"mm-ai-quota__count\">\n {{ monthlyConsumed() }} / {{ monthlyCap() }} ({{ monthlyPercent() }}%)\n </span>\n </div>\n }\n</div>\n",
1023
+ styles: [":host{display:block;--mm-ai-quota-track-bg: #2a2a2a;--mm-ai-quota-ok: #2ea44f;--mm-ai-quota-warning: #d29922;--mm-ai-quota-critical: #d73a49}.mm-ai-quota{display:flex;flex-direction:column;gap:.5rem;font-size:.85rem}.mm-ai-quota__row{display:grid;grid-template-columns:4.5rem 1fr auto;align-items:center;gap:.5rem}.mm-ai-quota__label{font-weight:600;opacity:.7}.mm-ai-quota__bar{height:.5rem;border-radius:9999px;background:var(--mm-ai-quota-track-bg);overflow:hidden}.mm-ai-quota__bar--ok .mm-ai-quota__fill{background:var(--mm-ai-quota-ok)}.mm-ai-quota__bar--warning .mm-ai-quota__fill{background:var(--mm-ai-quota-warning)}.mm-ai-quota__bar--critical .mm-ai-quota__fill{background:var(--mm-ai-quota-critical)}.mm-ai-quota__fill{height:100%;transition:width .2s ease}.mm-ai-quota__count{font-variant-numeric:tabular-nums;opacity:.8}\n"]
1024
+ }]
1025
+ }],
1026
+ propDecorators: {
1027
+ dailyConsumed: [{
1028
+ type: i0.Input,
1029
+ args: [{
1030
+ isSignal: true,
1031
+ alias: "dailyConsumed",
1032
+ required: true
1033
+ }]
1034
+ }],
1035
+ dailyCap: [{
1036
+ type: i0.Input,
1037
+ args: [{
1038
+ isSignal: true,
1039
+ alias: "dailyCap",
1040
+ required: true
1041
+ }]
1042
+ }],
1043
+ monthlyConsumed: [{
1044
+ type: i0.Input,
1045
+ args: [{
1046
+ isSignal: true,
1047
+ alias: "monthlyConsumed",
1048
+ required: false
1049
+ }]
1050
+ }],
1051
+ monthlyCap: [{
1052
+ type: i0.Input,
1053
+ args: [{
1054
+ isSignal: true,
1055
+ alias: "monthlyCap",
1056
+ required: false
1057
+ }]
1058
+ }]
1059
+ }
1060
+ });
1061
+ var AiCredentialTicketIssueComponent = class AiCredentialTicketIssueComponent {
1062
+ client = inject(AiAdapterClientService);
1063
+ scope = signal("CredentialRegister", ...ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []);
1064
+ ttlMinutes = signal(5, ...ngDevMode ? [{ debugName: "ttlMinutes" }] : /* istanbul ignore next */ []);
1065
+ issuing = signal(false, ...ngDevMode ? [{ debugName: "issuing" }] : /* istanbul ignore next */ []);
1066
+ issued = signal(null, ...ngDevMode ? [{ debugName: "issued" }] : /* istanbul ignore next */ []);
1067
+ error = signal(null, ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
1068
+ copied = signal(false, ...ngDevMode ? [{ debugName: "copied" }] : /* istanbul ignore next */ []);
1069
+ scopes = [{
1070
+ value: "CredentialRegister",
1071
+ label: "Subscription token",
1072
+ hint: "For the bastion CLI to register an Anthropic OAuth pair on this tenant."
1073
+ }, {
1074
+ value: "DevSshKeyRegister",
1075
+ label: "Developer SSH key",
1076
+ hint: "For a developer to register their own SSH public key on this tenant."
1077
+ }];
1078
+ onIssue() {
1079
+ if (this.issuing()) return;
1080
+ const ttl = this.normalizedTtl();
1081
+ this.issuing.set(true);
1082
+ this.error.set(null);
1083
+ this.copied.set(false);
1084
+ this.issued.set(null);
1085
+ this.client.issueCredentialTicket({
1086
+ scope: this.scope(),
1087
+ ttlMinutes: ttl
1088
+ }).subscribe({
1089
+ next: (response) => {
1090
+ this.issued.set(response);
1091
+ this.issuing.set(false);
1092
+ },
1093
+ error: (err) => {
1094
+ this.error.set(this.formatError(err));
1095
+ this.issuing.set(false);
1096
+ }
1097
+ });
1098
+ }
1099
+ onCopy() {
1100
+ const code = this.issued()?.code;
1101
+ if (!code) return;
1102
+ if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(code).then(() => this.copied.set(true), () => this.copied.set(false));
1103
+ }
1104
+ onClear() {
1105
+ this.issued.set(null);
1106
+ this.copied.set(false);
1107
+ }
1108
+ normalizedTtl() {
1109
+ const v = Math.trunc(this.ttlMinutes());
1110
+ if (Number.isNaN(v) || v < 1) return 1;
1111
+ if (v > 60) return 60;
1112
+ return v;
1113
+ }
1114
+ formatError(err) {
1115
+ if (typeof err === "object" && err !== null && "status" in err && typeof err.status === "number") {
1116
+ const status = err.status;
1117
+ if (status === 401 || status === 403) return "Not authorised — only tenant admins can issue tickets.";
1118
+ if (status === 400) return "Invalid request — check the scope value.";
1119
+ return `Server returned HTTP ${status}.`;
1120
+ }
1121
+ return "Failed to reach the AI Adapter — check the network.";
1122
+ }
1123
+ static ɵfac = i0.ɵɵngDeclareFactory({
1124
+ minVersion: "12.0.0",
1125
+ version: "22.3.0",
1126
+ ngImport: i0,
1127
+ type: AiCredentialTicketIssueComponent,
1128
+ deps: [],
1129
+ target: i0.ɵɵFactoryTarget.Component
1130
+ });
1131
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1132
+ minVersion: "17.0.0",
1133
+ version: "22.3.0",
1134
+ type: AiCredentialTicketIssueComponent,
1135
+ isStandalone: true,
1136
+ selector: "mm-ai-credential-ticket-issue",
1137
+ ngImport: i0,
1138
+ template: "<section class=\"mm-ai-ticket\">\n <header class=\"mm-ai-ticket__header\">\n <div class=\"mm-ai-ticket__title\">Issue credential ticket</div>\n <div class=\"mm-ai-ticket__subtitle\">\n Mint a one-time code an operator redeems on their own machine.\n </div>\n </header>\n\n @if (!issued()) {\n <form\n class=\"mm-ai-ticket__form\"\n (ngSubmit)=\"onIssue()\"\n #issueForm=\"ngForm\"\n >\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">Scope</span>\n <select\n class=\"mm-ai-ticket__select\"\n [ngModel]=\"scope()\"\n (ngModelChange)=\"scope.set($event)\"\n name=\"scope\"\n [disabled]=\"issuing()\"\n >\n @for (s of scopes; track s.value) {\n <option [value]=\"s.value\">{{ s.label }}</option>\n }\n </select>\n </label>\n <p class=\"mm-ai-ticket__hint\">\n @for (s of scopes; track s.value) {\n @if (s.value === scope()) {\n {{ s.hint }}\n }\n }\n </p>\n\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">TTL (minutes)</span>\n <input\n class=\"mm-ai-ticket__input\"\n type=\"number\"\n min=\"1\"\n max=\"60\"\n step=\"1\"\n [ngModel]=\"ttlMinutes()\"\n (ngModelChange)=\"ttlMinutes.set(+$event)\"\n name=\"ttlMinutes\"\n [disabled]=\"issuing()\"\n />\n </label>\n <p class=\"mm-ai-ticket__hint\">\n Default 5 minutes. Server clamps to 60 — long TTLs leak.\n </p>\n\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--primary\"\n type=\"submit\"\n [disabled]=\"issuing()\"\n >\n @if (issuing()) {\n Issuing…\n } @else {\n Issue ticket\n }\n </button>\n </div>\n\n @if (error()) {\n <p class=\"mm-ai-ticket__error\">{{ error() }}</p>\n }\n </form>\n } @else {\n <div class=\"mm-ai-ticket__result\">\n <p class=\"mm-ai-ticket__result-label\">\n One-time code (copy now — not shown again):\n </p>\n <div class=\"mm-ai-ticket__code-row\">\n <code class=\"mm-ai-ticket__code\">{{ issued()!.code }}</code>\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--secondary\"\n type=\"button\"\n (click)=\"onCopy()\"\n >\n @if (copied()) {\n Copied\n } @else {\n Copy\n }\n </button>\n </div>\n <dl class=\"mm-ai-ticket__meta\">\n <div>\n <dt>Scope</dt>\n <dd>{{ issued()!.scope }}</dd>\n </div>\n <div>\n <dt>Expires at</dt>\n <dd>{{ issued()!.expiresAt }}</dd>\n </div>\n <div>\n <dt>Ticket rtId</dt>\n <dd><code>{{ issued()!.rtId }}</code></dd>\n </div>\n </dl>\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button\"\n type=\"button\"\n (click)=\"onClear()\"\n >\n Issue another\n </button>\n </div>\n </div>\n }\n</section>\n",
1139
+ styles: [":host{display:block;--mm-ai-ticket-bg: #16191d;--mm-ai-ticket-surface: #1f2227;--mm-ai-ticket-border: #2f343b;--mm-ai-ticket-text: #e6e6e6;--mm-ai-ticket-muted: #9aa0a6;--mm-ai-ticket-accent: #64ceb9;--mm-ai-ticket-error: #ec658f;--mm-ai-ticket-code-bg: #0f1115}.mm-ai-ticket{background:var(--mm-ai-ticket-bg);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.5rem;padding:1rem 1.25rem;display:flex;flex-direction:column;gap:.85rem;font-family:inherit}.mm-ai-ticket__header{display:flex;flex-direction:column;gap:.15rem}.mm-ai-ticket__title{font-size:1rem;font-weight:600}.mm-ai-ticket__subtitle{font-size:.8rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__form,.mm-ai-ticket__result{display:flex;flex-direction:column;gap:.6rem}.mm-ai-ticket__field{display:flex;flex-direction:column;gap:.25rem}.mm-ai-ticket__label{font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__select,.mm-ai-ticket__input{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .55rem;font-family:inherit;font-size:.9rem}.mm-ai-ticket__select:focus,.mm-ai-ticket__input:focus{outline:2px solid var(--mm-ai-ticket-accent);outline-offset:1px}.mm-ai-ticket__select:disabled,.mm-ai-ticket__input:disabled{opacity:.6;cursor:not-allowed}.mm-ai-ticket__hint{margin:0;font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__actions{display:flex;gap:.5rem;margin-top:.25rem}.mm-ai-ticket__button{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .85rem;font-family:inherit;font-size:.85rem;cursor:pointer}.mm-ai-ticket__button:hover:not(:disabled){border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__button:disabled{opacity:.5;cursor:not-allowed}.mm-ai-ticket__button--primary{background:var(--mm-ai-ticket-accent);color:#0a0c0f;border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__error{margin:0;font-size:.8rem;color:var(--mm-ai-ticket-error)}.mm-ai-ticket__result-label{margin:0;font-size:.85rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__code-row{display:flex;align-items:center;gap:.5rem}.mm-ai-ticket__code{flex:1;background:var(--mm-ai-ticket-code-bg);color:var(--mm-ai-ticket-accent);padding:.5rem .75rem;border-radius:.3rem;font-family:Roboto Mono,ui-monospace,monospace;font-size:1.05rem;-webkit-user-select:all;user-select:all}.mm-ai-ticket__meta{display:grid;grid-template-columns:max-content 1fr;gap:.2rem .75rem;margin:0;font-size:.8rem}.mm-ai-ticket__meta>div{display:contents}.mm-ai-ticket__meta dt{color:var(--mm-ai-ticket-muted);font-size:.7rem}.mm-ai-ticket__meta dd{margin:0;font-family:Roboto Mono,ui-monospace,monospace}\n"],
1140
+ dependencies: [
1141
+ {
1142
+ kind: "ngmodule",
1143
+ type: CommonModule
1144
+ },
1145
+ {
1146
+ kind: "ngmodule",
1147
+ type: FormsModule
1148
+ },
1149
+ {
1150
+ kind: "directive",
1151
+ type: i1.ɵNgNoValidate,
1152
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
1153
+ },
1154
+ {
1155
+ kind: "directive",
1156
+ type: i1.NgSelectOption,
1157
+ selector: "option",
1158
+ inputs: ["ngValue", "value"]
1159
+ },
1160
+ {
1161
+ kind: "directive",
1162
+ type: i1.ɵNgSelectMultipleOption,
1163
+ selector: "option",
1164
+ inputs: ["ngValue", "value"]
1165
+ },
1166
+ {
1167
+ kind: "directive",
1168
+ type: i1.DefaultValueAccessor,
1169
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1170
+ },
1171
+ {
1172
+ kind: "directive",
1173
+ type: i1.NumberValueAccessor,
1174
+ selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]"
1175
+ },
1176
+ {
1177
+ kind: "directive",
1178
+ type: i1.SelectControlValueAccessor,
1179
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
1180
+ inputs: ["compareWith"]
1181
+ },
1182
+ {
1183
+ kind: "directive",
1184
+ type: i1.NgControlStatus,
1185
+ selector: "[formControlName],[ngModel],[formControl]"
1186
+ },
1187
+ {
1188
+ kind: "directive",
1189
+ type: i1.NgControlStatusGroup,
1190
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
1191
+ },
1192
+ {
1193
+ kind: "directive",
1194
+ type: i1.MinValidator,
1195
+ selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]",
1196
+ inputs: ["min"]
1197
+ },
1198
+ {
1199
+ kind: "directive",
1200
+ type: i1.MaxValidator,
1201
+ selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]",
1202
+ inputs: ["max"]
1203
+ },
1204
+ {
1205
+ kind: "directive",
1206
+ type: i1.NgModel,
1207
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
1208
+ inputs: [
1209
+ "name",
1210
+ "disabled",
1211
+ "ngModel",
1212
+ "ngModelOptions"
1213
+ ],
1214
+ outputs: ["ngModelChange"],
1215
+ exportAs: ["ngModel"]
1216
+ },
1217
+ {
1218
+ kind: "directive",
1219
+ type: i1.NgForm,
1220
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
1221
+ inputs: ["ngFormOptions"],
1222
+ outputs: ["ngSubmit"],
1223
+ exportAs: ["ngForm"]
1224
+ }
1225
+ ],
1226
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1227
+ });
1228
+ };
1229
+ i0.ɵɵngDeclareClassMetadata({
1230
+ minVersion: "12.0.0",
1231
+ version: "22.3.0",
1232
+ ngImport: i0,
1233
+ type: AiCredentialTicketIssueComponent,
1234
+ decorators: [{
1235
+ type: Component,
1236
+ args: [{
1237
+ selector: "mm-ai-credential-ticket-issue",
1238
+ imports: [CommonModule, FormsModule],
1239
+ changeDetection: ChangeDetectionStrategy.OnPush,
1240
+ template: "<section class=\"mm-ai-ticket\">\n <header class=\"mm-ai-ticket__header\">\n <div class=\"mm-ai-ticket__title\">Issue credential ticket</div>\n <div class=\"mm-ai-ticket__subtitle\">\n Mint a one-time code an operator redeems on their own machine.\n </div>\n </header>\n\n @if (!issued()) {\n <form\n class=\"mm-ai-ticket__form\"\n (ngSubmit)=\"onIssue()\"\n #issueForm=\"ngForm\"\n >\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">Scope</span>\n <select\n class=\"mm-ai-ticket__select\"\n [ngModel]=\"scope()\"\n (ngModelChange)=\"scope.set($event)\"\n name=\"scope\"\n [disabled]=\"issuing()\"\n >\n @for (s of scopes; track s.value) {\n <option [value]=\"s.value\">{{ s.label }}</option>\n }\n </select>\n </label>\n <p class=\"mm-ai-ticket__hint\">\n @for (s of scopes; track s.value) {\n @if (s.value === scope()) {\n {{ s.hint }}\n }\n }\n </p>\n\n <label class=\"mm-ai-ticket__field\">\n <span class=\"mm-ai-ticket__label\">TTL (minutes)</span>\n <input\n class=\"mm-ai-ticket__input\"\n type=\"number\"\n min=\"1\"\n max=\"60\"\n step=\"1\"\n [ngModel]=\"ttlMinutes()\"\n (ngModelChange)=\"ttlMinutes.set(+$event)\"\n name=\"ttlMinutes\"\n [disabled]=\"issuing()\"\n />\n </label>\n <p class=\"mm-ai-ticket__hint\">\n Default 5 minutes. Server clamps to 60 — long TTLs leak.\n </p>\n\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--primary\"\n type=\"submit\"\n [disabled]=\"issuing()\"\n >\n @if (issuing()) {\n Issuing…\n } @else {\n Issue ticket\n }\n </button>\n </div>\n\n @if (error()) {\n <p class=\"mm-ai-ticket__error\">{{ error() }}</p>\n }\n </form>\n } @else {\n <div class=\"mm-ai-ticket__result\">\n <p class=\"mm-ai-ticket__result-label\">\n One-time code (copy now — not shown again):\n </p>\n <div class=\"mm-ai-ticket__code-row\">\n <code class=\"mm-ai-ticket__code\">{{ issued()!.code }}</code>\n <button\n class=\"mm-ai-ticket__button mm-ai-ticket__button--secondary\"\n type=\"button\"\n (click)=\"onCopy()\"\n >\n @if (copied()) {\n Copied\n } @else {\n Copy\n }\n </button>\n </div>\n <dl class=\"mm-ai-ticket__meta\">\n <div>\n <dt>Scope</dt>\n <dd>{{ issued()!.scope }}</dd>\n </div>\n <div>\n <dt>Expires at</dt>\n <dd>{{ issued()!.expiresAt }}</dd>\n </div>\n <div>\n <dt>Ticket rtId</dt>\n <dd><code>{{ issued()!.rtId }}</code></dd>\n </div>\n </dl>\n <div class=\"mm-ai-ticket__actions\">\n <button\n class=\"mm-ai-ticket__button\"\n type=\"button\"\n (click)=\"onClear()\"\n >\n Issue another\n </button>\n </div>\n </div>\n }\n</section>\n",
1241
+ styles: [":host{display:block;--mm-ai-ticket-bg: #16191d;--mm-ai-ticket-surface: #1f2227;--mm-ai-ticket-border: #2f343b;--mm-ai-ticket-text: #e6e6e6;--mm-ai-ticket-muted: #9aa0a6;--mm-ai-ticket-accent: #64ceb9;--mm-ai-ticket-error: #ec658f;--mm-ai-ticket-code-bg: #0f1115}.mm-ai-ticket{background:var(--mm-ai-ticket-bg);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.5rem;padding:1rem 1.25rem;display:flex;flex-direction:column;gap:.85rem;font-family:inherit}.mm-ai-ticket__header{display:flex;flex-direction:column;gap:.15rem}.mm-ai-ticket__title{font-size:1rem;font-weight:600}.mm-ai-ticket__subtitle{font-size:.8rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__form,.mm-ai-ticket__result{display:flex;flex-direction:column;gap:.6rem}.mm-ai-ticket__field{display:flex;flex-direction:column;gap:.25rem}.mm-ai-ticket__label{font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__select,.mm-ai-ticket__input{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .55rem;font-family:inherit;font-size:.9rem}.mm-ai-ticket__select:focus,.mm-ai-ticket__input:focus{outline:2px solid var(--mm-ai-ticket-accent);outline-offset:1px}.mm-ai-ticket__select:disabled,.mm-ai-ticket__input:disabled{opacity:.6;cursor:not-allowed}.mm-ai-ticket__hint{margin:0;font-size:.75rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__actions{display:flex;gap:.5rem;margin-top:.25rem}.mm-ai-ticket__button{background:var(--mm-ai-ticket-surface);color:var(--mm-ai-ticket-text);border:1px solid var(--mm-ai-ticket-border);border-radius:.3rem;padding:.4rem .85rem;font-family:inherit;font-size:.85rem;cursor:pointer}.mm-ai-ticket__button:hover:not(:disabled){border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__button:disabled{opacity:.5;cursor:not-allowed}.mm-ai-ticket__button--primary{background:var(--mm-ai-ticket-accent);color:#0a0c0f;border-color:var(--mm-ai-ticket-accent)}.mm-ai-ticket__error{margin:0;font-size:.8rem;color:var(--mm-ai-ticket-error)}.mm-ai-ticket__result-label{margin:0;font-size:.85rem;color:var(--mm-ai-ticket-muted)}.mm-ai-ticket__code-row{display:flex;align-items:center;gap:.5rem}.mm-ai-ticket__code{flex:1;background:var(--mm-ai-ticket-code-bg);color:var(--mm-ai-ticket-accent);padding:.5rem .75rem;border-radius:.3rem;font-family:Roboto Mono,ui-monospace,monospace;font-size:1.05rem;-webkit-user-select:all;user-select:all}.mm-ai-ticket__meta{display:grid;grid-template-columns:max-content 1fr;gap:.2rem .75rem;margin:0;font-size:.8rem}.mm-ai-ticket__meta>div{display:contents}.mm-ai-ticket__meta dt{color:var(--mm-ai-ticket-muted);font-size:.7rem}.mm-ai-ticket__meta dd{margin:0;font-family:Roboto Mono,ui-monospace,monospace}\n"]
1242
+ }]
1243
+ }]
1244
+ });
1245
+ var AiNewAppDialogComponent = class AiNewAppDialogComponent {
1246
+ templates = input.required(...ngDevMode ? [{ debugName: "templates" }] : /* istanbul ignore next */ []);
1247
+ tenantName = input("", ...ngDevMode ? [{ debugName: "tenantName" }] : /* istanbul ignore next */ []);
1248
+ confirmed = output();
1249
+ cancelled = output();
1250
+ selectedTemplateId = signal("", ...ngDevMode ? [{ debugName: "selectedTemplateId" }] : /* istanbul ignore next */ []);
1251
+ projectName = signal("", ...ngDevMode ? [{ debugName: "projectName" }] : /* istanbul ignore next */ []);
1252
+ primaryEntity = signal("", ...ngDevMode ? [{ debugName: "primaryEntity" }] : /* istanbul ignore next */ []);
1253
+ selectedTemplate = computed(() => {
1254
+ const id = this.selectedTemplateId();
1255
+ return this.templates().find((t) => t.id === id) ?? null;
1256
+ }, ...ngDevMode ? [{ debugName: "selectedTemplate" }] : /* istanbul ignore next */ []);
1257
+ renderedGoal = computed(() => {
1258
+ const template = this.selectedTemplate();
1259
+ if (!template) return "";
1260
+ if (!this.allRequiredFilled()) return "";
1261
+ return this.interpolate(template.goalTemplate);
1262
+ }, ...ngDevMode ? [{ debugName: "renderedGoal" }] : /* istanbul ignore next */ []);
1263
+ allRequiredFilled = computed(() => {
1264
+ const template = this.selectedTemplate();
1265
+ if (!template) return false;
1266
+ return template.requiredPlaceholders.every((key) => {
1267
+ const value = this.valueFor(key);
1268
+ return value !== null && value.trim().length > 0;
1269
+ });
1270
+ }, ...ngDevMode ? [{ debugName: "allRequiredFilled" }] : /* istanbul ignore next */ []);
1271
+ onSubmit() {
1272
+ const template = this.selectedTemplate();
1273
+ if (!template || !this.allRequiredFilled()) return;
1274
+ this.confirmed.emit({
1275
+ templateId: template.id,
1276
+ jobKind: template.jobKind,
1277
+ projectName: this.projectName().trim(),
1278
+ primaryEntity: this.primaryEntity().trim(),
1279
+ goal: this.interpolate(template.goalTemplate)
1280
+ });
1281
+ }
1282
+ onCancel() {
1283
+ this.cancelled.emit();
1284
+ }
1285
+ valueFor(placeholder) {
1286
+ switch (placeholder) {
1287
+ case "projectName": return this.projectName();
1288
+ case "primaryEntity": return this.primaryEntity();
1289
+ default: return null;
1290
+ }
1291
+ }
1292
+ interpolate(template) {
1293
+ return template.replace(/{{\s*(\w+)\s*}}/g, (full, key) => {
1294
+ const value = this.valueFor(key);
1295
+ return value !== null ? value.trim() : full;
1296
+ });
1297
+ }
1298
+ static ɵfac = i0.ɵɵngDeclareFactory({
1299
+ minVersion: "12.0.0",
1300
+ version: "22.3.0",
1301
+ ngImport: i0,
1302
+ type: AiNewAppDialogComponent,
1303
+ deps: [],
1304
+ target: i0.ɵɵFactoryTarget.Component
1305
+ });
1306
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1307
+ minVersion: "17.0.0",
1308
+ version: "22.3.0",
1309
+ type: AiNewAppDialogComponent,
1310
+ isStandalone: true,
1311
+ selector: "mm-ai-new-app-dialog",
1312
+ inputs: {
1313
+ templates: {
1314
+ classPropertyName: "templates",
1315
+ publicName: "templates",
1316
+ isSignal: true,
1317
+ isRequired: true,
1318
+ transformFunction: null
1319
+ },
1320
+ tenantName: {
1321
+ classPropertyName: "tenantName",
1322
+ publicName: "tenantName",
1323
+ isSignal: true,
1324
+ isRequired: false,
1325
+ transformFunction: null
1326
+ }
1327
+ },
1328
+ outputs: {
1329
+ confirmed: "confirmed",
1330
+ cancelled: "cancelled"
1331
+ },
1332
+ ngImport: i0,
1333
+ template: "<div class=\"mm-ai-new-app\">\n <header class=\"mm-ai-new-app__header\">\n <h3 class=\"mm-ai-new-app__title\">\n New App\n @if (tenantName(); as tenant) {\n <span class=\"mm-ai-new-app__tenant\"> · {{ tenant }}</span>\n }\n </h3>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__close\"\n (click)=\"onCancel()\"\n aria-label=\"Dismiss\"\n >\n ×\n </button>\n </header>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Template</h4>\n <ul class=\"mm-ai-new-app__templates\" role=\"radiogroup\" aria-label=\"Template\">\n @for (template of templates(); track template.id) {\n <li>\n <label\n class=\"mm-ai-new-app__template\"\n [class.mm-ai-new-app__template--active]=\"\n selectedTemplateId() === template.id\n \"\n >\n <input\n type=\"radio\"\n name=\"mm-ai-new-app-template\"\n [value]=\"template.id\"\n [checked]=\"selectedTemplateId() === template.id\"\n (change)=\"selectedTemplateId.set(template.id)\"\n />\n <span class=\"mm-ai-new-app__template-body\">\n <strong class=\"mm-ai-new-app__template-name\">{{ template.name }}</strong>\n <span class=\"mm-ai-new-app__template-description\">\n {{ template.description }}\n </span>\n </span>\n </label>\n </li>\n }\n </ul>\n </div>\n\n @if (selectedTemplate(); as template) {\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Parameters</h4>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-project-name\">Project name</label>\n <input\n id=\"mm-ai-new-app-project-name\"\n type=\"text\"\n [ngModel]=\"projectName()\"\n (ngModelChange)=\"projectName.set($event)\"\n placeholder=\"e.g. customer-list\"\n autocomplete=\"off\"\n />\n </div>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-primary-entity\">Primary entity (CK type)</label>\n <input\n id=\"mm-ai-new-app-primary-entity\"\n type=\"text\"\n [ngModel]=\"primaryEntity()\"\n (ngModelChange)=\"primaryEntity.set($event)\"\n placeholder=\"e.g. Customer\"\n autocomplete=\"off\"\n />\n </div>\n </div>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">\n Generated Goal <span>(this is what Claude will see)</span>\n </h4>\n <pre class=\"mm-ai-new-app__preview\">{{\n renderedGoal() ||\n 'Fill in every field above to preview the Goal that will be sent.'\n }}</pre>\n </div>\n }\n\n <footer class=\"mm-ai-new-app__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--cancel\"\n (click)=\"onCancel()\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--submit\"\n [disabled]=\"!allRequiredFilled()\"\n (click)=\"onSubmit()\"\n >\n Create App Session\n </button>\n </footer>\n</div>\n",
1334
+ styles: [":host{display:block;--mm-ai-new-app-bg: #1f2227;--mm-ai-new-app-border: #2f343b;--mm-ai-new-app-text: #e6e6e6;--mm-ai-new-app-muted: #9aa0a6;--mm-ai-new-app-accent: #2ea44f;--mm-ai-new-app-accent-soft: rgba(46, 164, 79, .15);--mm-ai-new-app-cancel: #44494f;--mm-ai-new-app-code-bg: #16191d}.mm-ai-new-app{background:var(--mm-ai-new-app-bg);color:var(--mm-ai-new-app-text);border:1px solid var(--mm-ai-new-app-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(40rem,100%)}.mm-ai-new-app__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-new-app__title{margin:0;font-size:1rem}.mm-ai-new-app__tenant{color:var(--mm-ai-new-app-muted);font-weight:400}.mm-ai-new-app__close{background:transparent;color:var(--mm-ai-new-app-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-new-app__close:hover{color:var(--mm-ai-new-app-text)}.mm-ai-new-app__section{margin-bottom:.75rem}.mm-ai-new-app__heading{margin:0 0 .35rem;font-size:.75rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__heading span{text-transform:none;opacity:.6}.mm-ai-new-app__templates{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}.mm-ai-new-app__template{display:flex;gap:.6rem;padding:.55rem .7rem;border:1px solid var(--mm-ai-new-app-border);border-radius:.35rem;cursor:pointer;align-items:flex-start}.mm-ai-new-app__template--active{background:var(--mm-ai-new-app-accent-soft);border-color:var(--mm-ai-new-app-accent)}.mm-ai-new-app__template input[type=radio]{margin-top:.2rem}.mm-ai-new-app__template-body{display:grid;gap:.2rem}.mm-ai-new-app__template-name{font-size:.9rem}.mm-ai-new-app__template-description{font-size:.8rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field{display:grid;gap:.25rem;margin-bottom:.5rem;font-size:.85rem}.mm-ai-new-app__field label{color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field input{padding:.45rem .55rem;background:var(--mm-ai-new-app-code-bg);color:inherit;border:1px solid var(--mm-ai-new-app-border);border-radius:.3rem;font-family:inherit;font-size:.9rem}.mm-ai-new-app__preview{margin:0;padding:.5rem .6rem;background:var(--mm-ai-new-app-code-bg);border-radius:.3rem;font-size:.8rem;white-space:pre-wrap;word-break:break-word;max-height:12rem;overflow-y:auto}.mm-ai-new-app__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-new-app__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-new-app__btn--submit{background:var(--mm-ai-new-app-accent);color:#fff}.mm-ai-new-app__btn--submit:disabled{opacity:.5;cursor:not-allowed}.mm-ai-new-app__btn--cancel{background:var(--mm-ai-new-app-cancel);color:#fff}\n"],
1335
+ dependencies: [
1336
+ {
1337
+ kind: "ngmodule",
1338
+ type: FormsModule
1339
+ },
1340
+ {
1341
+ kind: "directive",
1342
+ type: i1.DefaultValueAccessor,
1343
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1344
+ },
1345
+ {
1346
+ kind: "directive",
1347
+ type: i1.NgControlStatus,
1348
+ selector: "[formControlName],[ngModel],[formControl]"
1349
+ },
1350
+ {
1351
+ kind: "directive",
1352
+ type: i1.NgModel,
1353
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
1354
+ inputs: [
1355
+ "name",
1356
+ "disabled",
1357
+ "ngModel",
1358
+ "ngModelOptions"
1359
+ ],
1360
+ outputs: ["ngModelChange"],
1361
+ exportAs: ["ngModel"]
1362
+ }
1363
+ ],
1364
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1365
+ });
1366
+ };
1367
+ i0.ɵɵngDeclareClassMetadata({
1368
+ minVersion: "12.0.0",
1369
+ version: "22.3.0",
1370
+ ngImport: i0,
1371
+ type: AiNewAppDialogComponent,
1372
+ decorators: [{
1373
+ type: Component,
1374
+ args: [{
1375
+ selector: "mm-ai-new-app-dialog",
1376
+ imports: [FormsModule],
1377
+ changeDetection: ChangeDetectionStrategy.OnPush,
1378
+ template: "<div class=\"mm-ai-new-app\">\n <header class=\"mm-ai-new-app__header\">\n <h3 class=\"mm-ai-new-app__title\">\n New App\n @if (tenantName(); as tenant) {\n <span class=\"mm-ai-new-app__tenant\"> · {{ tenant }}</span>\n }\n </h3>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__close\"\n (click)=\"onCancel()\"\n aria-label=\"Dismiss\"\n >\n ×\n </button>\n </header>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Template</h4>\n <ul class=\"mm-ai-new-app__templates\" role=\"radiogroup\" aria-label=\"Template\">\n @for (template of templates(); track template.id) {\n <li>\n <label\n class=\"mm-ai-new-app__template\"\n [class.mm-ai-new-app__template--active]=\"\n selectedTemplateId() === template.id\n \"\n >\n <input\n type=\"radio\"\n name=\"mm-ai-new-app-template\"\n [value]=\"template.id\"\n [checked]=\"selectedTemplateId() === template.id\"\n (change)=\"selectedTemplateId.set(template.id)\"\n />\n <span class=\"mm-ai-new-app__template-body\">\n <strong class=\"mm-ai-new-app__template-name\">{{ template.name }}</strong>\n <span class=\"mm-ai-new-app__template-description\">\n {{ template.description }}\n </span>\n </span>\n </label>\n </li>\n }\n </ul>\n </div>\n\n @if (selectedTemplate(); as template) {\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">Parameters</h4>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-project-name\">Project name</label>\n <input\n id=\"mm-ai-new-app-project-name\"\n type=\"text\"\n [ngModel]=\"projectName()\"\n (ngModelChange)=\"projectName.set($event)\"\n placeholder=\"e.g. customer-list\"\n autocomplete=\"off\"\n />\n </div>\n <div class=\"mm-ai-new-app__field\">\n <label for=\"mm-ai-new-app-primary-entity\">Primary entity (CK type)</label>\n <input\n id=\"mm-ai-new-app-primary-entity\"\n type=\"text\"\n [ngModel]=\"primaryEntity()\"\n (ngModelChange)=\"primaryEntity.set($event)\"\n placeholder=\"e.g. Customer\"\n autocomplete=\"off\"\n />\n </div>\n </div>\n\n <div class=\"mm-ai-new-app__section\">\n <h4 class=\"mm-ai-new-app__heading\">\n Generated Goal <span>(this is what Claude will see)</span>\n </h4>\n <pre class=\"mm-ai-new-app__preview\">{{\n renderedGoal() ||\n 'Fill in every field above to preview the Goal that will be sent.'\n }}</pre>\n </div>\n }\n\n <footer class=\"mm-ai-new-app__actions\">\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--cancel\"\n (click)=\"onCancel()\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n class=\"mm-ai-new-app__btn mm-ai-new-app__btn--submit\"\n [disabled]=\"!allRequiredFilled()\"\n (click)=\"onSubmit()\"\n >\n Create App Session\n </button>\n </footer>\n</div>\n",
1379
+ styles: [":host{display:block;--mm-ai-new-app-bg: #1f2227;--mm-ai-new-app-border: #2f343b;--mm-ai-new-app-text: #e6e6e6;--mm-ai-new-app-muted: #9aa0a6;--mm-ai-new-app-accent: #2ea44f;--mm-ai-new-app-accent-soft: rgba(46, 164, 79, .15);--mm-ai-new-app-cancel: #44494f;--mm-ai-new-app-code-bg: #16191d}.mm-ai-new-app{background:var(--mm-ai-new-app-bg);color:var(--mm-ai-new-app-text);border:1px solid var(--mm-ai-new-app-border);border-radius:.6rem;padding:1rem 1.25rem;width:min(40rem,100%)}.mm-ai-new-app__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.mm-ai-new-app__title{margin:0;font-size:1rem}.mm-ai-new-app__tenant{color:var(--mm-ai-new-app-muted);font-weight:400}.mm-ai-new-app__close{background:transparent;color:var(--mm-ai-new-app-muted);border:none;font-size:1.4rem;cursor:pointer;line-height:1;padding:0 .25rem}.mm-ai-new-app__close:hover{color:var(--mm-ai-new-app-text)}.mm-ai-new-app__section{margin-bottom:.75rem}.mm-ai-new-app__heading{margin:0 0 .35rem;font-size:.75rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__heading span{text-transform:none;opacity:.6}.mm-ai-new-app__templates{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}.mm-ai-new-app__template{display:flex;gap:.6rem;padding:.55rem .7rem;border:1px solid var(--mm-ai-new-app-border);border-radius:.35rem;cursor:pointer;align-items:flex-start}.mm-ai-new-app__template--active{background:var(--mm-ai-new-app-accent-soft);border-color:var(--mm-ai-new-app-accent)}.mm-ai-new-app__template input[type=radio]{margin-top:.2rem}.mm-ai-new-app__template-body{display:grid;gap:.2rem}.mm-ai-new-app__template-name{font-size:.9rem}.mm-ai-new-app__template-description{font-size:.8rem;color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field{display:grid;gap:.25rem;margin-bottom:.5rem;font-size:.85rem}.mm-ai-new-app__field label{color:var(--mm-ai-new-app-muted)}.mm-ai-new-app__field input{padding:.45rem .55rem;background:var(--mm-ai-new-app-code-bg);color:inherit;border:1px solid var(--mm-ai-new-app-border);border-radius:.3rem;font-family:inherit;font-size:.9rem}.mm-ai-new-app__preview{margin:0;padding:.5rem .6rem;background:var(--mm-ai-new-app-code-bg);border-radius:.3rem;font-size:.8rem;white-space:pre-wrap;word-break:break-word;max-height:12rem;overflow-y:auto}.mm-ai-new-app__actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.75rem}.mm-ai-new-app__btn{padding:.45rem 1rem;border-radius:.3rem;font-weight:600;border:none;cursor:pointer;font-size:.85rem}.mm-ai-new-app__btn--submit{background:var(--mm-ai-new-app-accent);color:#fff}.mm-ai-new-app__btn--submit:disabled{opacity:.5;cursor:not-allowed}.mm-ai-new-app__btn--cancel{background:var(--mm-ai-new-app-cancel);color:#fff}\n"]
1380
+ }]
1381
+ }],
1382
+ propDecorators: {
1383
+ templates: [{
1384
+ type: i0.Input,
1385
+ args: [{
1386
+ isSignal: true,
1387
+ alias: "templates",
1388
+ required: true
1389
+ }]
1390
+ }],
1391
+ tenantName: [{
1392
+ type: i0.Input,
1393
+ args: [{
1394
+ isSignal: true,
1395
+ alias: "tenantName",
1396
+ required: false
1397
+ }]
1398
+ }],
1399
+ confirmed: [{
1400
+ type: i0.Output,
1401
+ args: ["confirmed"]
1402
+ }],
1403
+ cancelled: [{
1404
+ type: i0.Output,
1405
+ args: ["cancelled"]
1406
+ }]
1407
+ }
1408
+ });
1294
1409
  export { AI_ADAPTER_OPTIONS, AI_SESSION_STREAM_CONNECTION_FACTORY, AiAdapterClientService, AiApprovalModalComponent, AiChatStreamComponent, AiCredentialTicketIssueComponent, AiJobStatusBadgeComponent, AiNewAppDialogComponent, AiQuotaIndicatorComponent, AiSessionListComponent, AiSessionStreamService, AiToolCallComponent, provideOctoAiConsole };
1295
- //# sourceMappingURL=meshmakers-octo-ai-console.mjs.map
1410
+
1411
+ //# sourceMappingURL=meshmakers-octo-ai-console.mjs.map