@wawjs/ai-ngx 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +53 -2
- package/fesm2022/wawjs-ai-ngx.mjs +1093 -0
- package/fesm2022/wawjs-ai-ngx.mjs.map +1 -0
- package/package.json +47 -4
- package/types/wawjs-ai-ngx.d.ts +266 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wawjs-ai-ngx.mjs","names":[],"sources":["../../../projects/ai-ngx/src/lib/agent-store.ts","../../../projects/ai-ngx/src/lib/chat/chat.component.ts","../../../projects/ai-ngx/src/lib/chat/chat.component.html","../../../projects/ai-ngx/src/lib/projects/projects.component.ts","../../../projects/ai-ngx/src/lib/projects/projects.component.html","../../../projects/ai-ngx/src/lib/connect/connect.component.ts","../../../projects/ai-ngx/src/lib/connect/connect.component.html","../../../projects/ai-ngx/src/lib/i18n.ts"],"sourcesContent":["import { computed, inject, Injectable, InjectionToken, signal, type Provider } from '@angular/core';\nimport { type CanActivateFn, Router } from '@angular/router';\nimport { AgentClient, type AgentInfo, type Connection } from '@wawjs/ai-client';\n\nexport interface AiAgentConfig {\n\t/** Names the saved connection in this device's storage: `<storageKey>.connection`. Use your app id. */\n\tstorageKey: string;\n\t/** The address the connect form suggests, such as http://127.0.0.1:53011 or /agents/my-agent. */\n\tdefaultUrl?: string;\n\t/** Where aiConnectedGuard sends a visitor without a connection. Default /connect. */\n\tconnectPath?: string;\n}\n\nexport const AI_AGENT_CONFIG = new InjectionToken<AiAgentConfig>('AI_AGENT_CONFIG', {\n\tfactory: () => ({ storageKey: 'ai-app' }),\n});\n\n/** Sets the storage key, default address and connect page of the agent connection. */\nexport function provideAiAgent(config: AiAgentConfig): Provider {\n\treturn { provide: AI_AGENT_CONFIG, useValue: config };\n}\n\ninterface SavedConnection {\n\turl: string;\n\ttoken: string;\n}\n\n/**\n * The agent the app talks to: the saved connection, its client and the agent's info. The token is kept\n * in this device's storage only and is sent nowhere but to the agent.\n */\n@Injectable({ providedIn: 'root' })\nexport class AiAgentStore {\n\treadonly config = inject(AI_AGENT_CONFIG);\n\tprivate readonly key = `${this.config.storageKey}.connection`;\n\tprivate readonly saved = signal<SavedConnection | null>(this.load());\n\tprivate readonly agentInfo = signal<AgentInfo | null>(null);\n\n\t/** The remembered connection, to fill the connect form. */\n\treadonly connection = this.saved.asReadonly();\n\t/** The agent's info, once a connection was checked in this run. */\n\treadonly info = this.agentInfo.asReadonly();\n\treadonly connected = computed(() => this.agentInfo() !== null);\n\treadonly client = computed(() => {\n\t\tconst connection = this.saved();\n\t\treturn connection && this.agentInfo() ? new AgentClient(connection) : null;\n\t});\n\n\t/** Checks a connection with GET /v1/info and remembers it when the agent answers compatibly. */\n\tasync connect(connection: Connection & { token?: string }): Promise<AgentInfo> {\n\t\tconst client = new AgentClient(connection);\n\t\tconst info = await client.info();\n\t\tconst normalized = { url: client.url, token: (connection.token ?? '').trim() };\n\t\tthis.store(normalized);\n\t\tthis.saved.set(normalized);\n\t\tthis.agentInfo.set(info);\n\t\treturn info;\n\t}\n\n\t/** Reconnects with the remembered connection, for a reload on a deep link. */\n\tasync resume(): Promise<boolean> {\n\t\tconst connection = this.saved();\n\t\tif (!connection) return false;\n\t\ttry {\n\t\t\tawait this.connect(connection);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Leaves the agent but keeps the saved connection to fill the form. */\n\tdisconnect(): void {\n\t\tthis.agentInfo.set(null);\n\t}\n\n\t/** Forgets the saved address and token on this device. */\n\tforget(): void {\n\t\tthis.store(null);\n\t\tthis.saved.set(null);\n\t\tthis.agentInfo.set(null);\n\t}\n\n\tprivate load(): SavedConnection | null {\n\t\ttry {\n\t\t\tconst raw = globalThis.localStorage?.getItem(this.key);\n\t\t\tif (!raw) return null;\n\t\t\tconst value = JSON.parse(raw) as Partial<SavedConnection>;\n\t\t\treturn typeof value.url === 'string' && typeof value.token === 'string' ? { url: value.url, token: value.token } : null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate store(connection: SavedConnection | null): void {\n\t\ttry {\n\t\t\tif (connection) globalThis.localStorage?.setItem(this.key, JSON.stringify(connection));\n\t\t\telse globalThis.localStorage?.removeItem(this.key);\n\t\t} catch {\n\t\t\t// Storage can be blocked (private windows, some webviews): the app still works for this run.\n\t\t}\n\t}\n}\n\n/** Pages that talk to the agent need a checked connection; a reload resumes the saved one. */\nexport const aiConnectedGuard: CanActivateFn = async (_route, state) => {\n\tconst agent = inject(AiAgentStore);\n\tif (agent.connected() || (await agent.resume())) return true;\n\treturn inject(Router).createUrlTree([agent.config.connectPath ?? '/connect'], { queryParams: { next: state.url } });\n};\n","import { NgTemplateOutlet } from '@angular/common';\nimport {\n\tafterNextRender,\n\tComponent,\n\tcomputed,\n\tDestroyRef,\n\teffect,\n\tElementRef,\n\tinject,\n\tInjector,\n\tinput,\n\toutput,\n\tsignal,\n\tuntracked,\n\tviewChild,\n} from '@angular/core';\nimport { form, FormField } from '@angular/forms/signals';\nimport {\n\taddError,\n\taddUserMessage,\n\tAgentApiError,\n\ttype AgentClient,\n\tapplyEvent,\n\tcompactInput,\n\tContractError,\n\tdescribeError,\n\ttype DoneEvent,\n\temptyTranscript,\n\tfromSession,\n\ttype Session,\n\tsetApproval,\n\ttype StopItem,\n\ttype ToolItem,\n\ttype Transcript,\n} from '@wawjs/ai-client';\nimport { TranslateDirective, TranslateService } from '@wawjs/ngx-translate';\nimport { ButtonDirective } from '@wawjs/ngx-ui';\n\ntype Decision = 'approve' | 'remember' | 'deny';\n\nconst STOP_TEXT = {\n\tcancelled: 'Stopped. The reply above is incomplete.',\n\terror: 'The turn ended with an error.',\n\tmax_steps: 'Stopped at the step limit. Send a message to continue.',\n} as const;\n\n/**\n * The chat of one session: the saved transcript, streamed replies, tool calls, approvals (Deny, Always\n * for this session, Approve), Stop (or Esc) and a queued message. The page around it shows the title\n * and the way back; this component only needs the client and the session id.\n */\n@Component({\n\tselector: 'ai-chat',\n\timports: [FormField, NgTemplateOutlet, ButtonDirective, TranslateDirective],\n\ttemplateUrl: './chat.component.html',\n\tstyleUrl: './chat.component.scss',\n\thost: { '(document:keydown.escape)': 'stop()' },\n})\nexport class AiChatComponent {\n\t/** The agent, usually AiAgentStore.client(). */\n\treadonly client = input.required<AgentClient>();\n\treadonly sessionId = input.required<string>();\n\t/** The name shown over the agent's messages. */\n\treadonly agentName = input('Agent');\n\n\t/** The session once loaded, for the page title. */\n\treadonly loaded = output<Session>();\n\t/** A turn ended (after its done event or a failure), for refreshing lists. */\n\treadonly turnEnded = output<DoneEvent['stopReason'] | 'failed'>();\n\n\tprivate readonly translate = inject(TranslateService);\n\tprivate readonly injector = inject(Injector);\n\tprivate readonly scroller = viewChild<ElementRef<HTMLElement>>('scroller');\n\tprivate readonly textarea = viewChild<ElementRef<HTMLTextAreaElement>>('textarea');\n\n\tprotected readonly placeholder = computed(() => this.translate.translate('Message the agent')());\n\tprotected readonly loading = signal(true);\n\tprotected readonly loadError = signal<string | null>(null);\n\tprotected readonly transcript = signal<Transcript>(emptyTranscript);\n\tprotected readonly running = signal(false);\n\tprotected readonly stopping = signal(false);\n\n\tprivate readonly draft = signal({ text: '' });\n\tprotected readonly composer = form(this.draft);\n\t/** A message written while a turn runs; the API takes one turn at a time, so it waits. */\n\tprotected readonly queued = signal<string | null>(null);\n\t/** True once a turn has run for ten seconds without asking anything. */\n\tprotected readonly slow = signal(false);\n\tprotected readonly canSend = computed(\n\t\t() => !this.loading() && !this.loadError() && this.queued() === null && this.draft().text.trim().length > 0,\n\t);\n\t/** The first agent item of every turn carries the agent's name, so its output is marked. */\n\tprotected readonly authorKeys = computed(() => {\n\t\tconst keys = new Set<string>();\n\t\tlet previous: string | undefined;\n\t\tfor (const item of this.transcript().items) {\n\t\t\tif (item.kind !== 'user' && (previous === undefined || previous === 'user')) keys.add(item.key);\n\t\t\tprevious = item.kind;\n\t\t}\n\t\treturn keys;\n\t});\n\tprotected readonly waitingApproval = computed(() =>\n\t\tthis.transcript().items.some((item) => item.kind === 'tool' && item.approval?.state === 'waiting'),\n\t);\n\n\t/** Index of the first item of the turn sent from this screen, and the height that turn fills. */\n\tprotected readonly turnStart = signal<number | null>(null);\n\tprotected readonly turnHeight = signal(0);\n\tprotected readonly history = computed(() => {\n\t\tconst start = this.turnStart();\n\t\tconst items = this.transcript().items;\n\t\treturn start === null ? items : items.slice(0, start);\n\t});\n\tprotected readonly latest = computed(() => {\n\t\tconst start = this.turnStart();\n\t\treturn start === null ? [] : this.transcript().items.slice(start);\n\t});\n\tprotected readonly lastKey = computed(() => this.transcript().items.at(-1)?.key);\n\n\tprivate stream: AbortController | null = null;\n\n\tconstructor() {\n\t\t// Leaving the screen closes the stream; the agent then stops the turn, as for a lost client.\n\t\tinject(DestroyRef).onDestroy(() => this.stream?.abort());\n\t\teffect(() => {\n\t\t\tconst id = this.sessionId();\n\t\t\tconst client = this.client();\n\t\t\tuntracked(() => void this.load(client, id));\n\t\t});\n\t}\n\n\tprotected stopLabel(item: StopItem): string {\n\t\treturn this.translate.translate(STOP_TEXT[item.reason])();\n\t}\n\n\tprotected compact(input: Record<string, unknown>): string {\n\t\treturn compactInput(input);\n\t}\n\n\tprivate async load(client: AgentClient, id: string): Promise<void> {\n\t\tthis.stream?.abort();\n\t\tthis.loading.set(true);\n\t\tthis.loadError.set(null);\n\t\tthis.turnStart.set(null);\n\t\ttry {\n\t\t\tconst session = await client.getSession(id);\n\t\t\tthis.transcript.set(fromSession(session));\n\t\t\tthis.loaded.emit(session);\n\t\t\tthis.scrollToEnd();\n\t\t} catch (error) {\n\t\t\tthis.loadError.set(describeError(error));\n\t\t} finally {\n\t\t\tthis.loading.set(false);\n\t\t}\n\t}\n\n\tprotected onKeydown(event: KeyboardEvent): void {\n\t\tif (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n\t\t\tevent.preventDefault();\n\t\t\tvoid this.send();\n\t\t}\n\t}\n\n\tprotected send(event?: SubmitEvent): void {\n\t\tevent?.preventDefault();\n\t\tconst text = this.draft().text.trim();\n\t\tif (!text || !this.canSend()) return;\n\t\tthis.composer.text().value.set('');\n\t\tif (this.running()) this.queued.set(text);\n\t\telse void this.runTurn(text);\n\t}\n\n\t/** Puts a queued message back into the composer. */\n\tprotected unqueue(): void {\n\t\tconst text = this.queued();\n\t\tthis.queued.set(null);\n\t\tif (text && !this.draft().text.trim()) this.composer.text().value.set(text);\n\t\tthis.textarea()?.nativeElement.focus();\n\t}\n\n\tprivate async runTurn(text: string): Promise<void> {\n\t\tconst client = this.client();\n\t\t// The new turn fills at least the visible height, so the sent message can sit at the top.\n\t\tthis.turnStart.set(this.transcript().items.length);\n\t\tthis.turnHeight.set(this.scroller()?.nativeElement.clientHeight ?? 0);\n\t\tthis.transcript.update((state) => addUserMessage(state, text));\n\t\tthis.running.set(true);\n\t\tthis.scrollToLatestUser();\n\n\t\tconst controller = new AbortController();\n\t\tthis.stream = controller;\n\t\tlet stopReason: DoneEvent['stopReason'] | 'failed' = 'failed';\n\t\tthis.slow.set(false);\n\t\tconst slowTimer = setTimeout(() => this.slow.set(true), 10_000);\n\t\ttry {\n\t\t\tfor await (const event of client.sendMessage(this.sessionId(), text, controller.signal)) {\n\t\t\t\tthis.transcript.update((state) => applyEvent(state, event));\n\t\t\t\tif (event.type === 'done') stopReason = event.stopReason;\n\t\t\t}\n\t\t\tif (stopReason === 'failed') {\n\t\t\t\tthis.transcript.update((state) => addError(state, 'network', 'The connection closed before the turn ended.'));\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!controller.signal.aborted) {\n\t\t\t\tconst code = error instanceof ContractError ? 'contract' : error instanceof AgentApiError ? error.code : 'network';\n\t\t\t\tthis.transcript.update((state) => addError(state, code, describeError(error)));\n\t\t\t}\n\t\t} finally {\n\t\t\tclearTimeout(slowTimer);\n\t\t\tif (this.stream === controller) this.stream = null;\n\t\t\tconst stopped = this.stopping();\n\t\t\tthis.running.set(false);\n\t\t\tthis.stopping.set(false);\n\t\t\tthis.slow.set(false);\n\t\t\tthis.turnEnded.emit(stopReason);\n\t\t\tconst next = this.queued();\n\t\t\tif (next !== null && !stopped && !controller.signal.aborted) {\n\t\t\t\tthis.queued.set(null);\n\t\t\t\tvoid this.runTurn(next);\n\t\t\t} else {\n\t\t\t\t// After a stop the queued message goes back to the composer instead of running.\n\t\t\t\tif (next !== null) this.unqueue();\n\t\t\t\tafterNextRender(() => this.textarea()?.nativeElement.focus(), { injector: this.injector });\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Stops the running turn on the agent; its stream then ends with a cancelled done event. */\n\tprotected async stop(): Promise<void> {\n\t\tif (!this.running() || this.stopping()) return;\n\t\tthis.stopping.set(true);\n\t\ttry {\n\t\t\tawait this.client().cancel(this.sessionId());\n\t\t} catch {\n\t\t\t// The agent did not take the cancel: close the stream here so the app stops waiting.\n\t\t\tthis.stream?.abort();\n\t\t\tthis.transcript.update((state) => addError(state, 'network', 'The agent did not confirm the stop.'));\n\t\t}\n\t}\n\n\tprotected async decide(item: ToolItem, decision: Decision): Promise<void> {\n\t\tif (item.approval?.state !== 'waiting') return;\n\t\tthis.transcript.update((state) => setApproval(state, item.callId, 'sending'));\n\t\ttry {\n\t\t\tawait this.client().approve(this.sessionId(), {\n\t\t\t\tcallId: item.callId,\n\t\t\t\tapproved: decision !== 'deny',\n\t\t\t\tremember: decision === 'remember' ? true : undefined,\n\t\t\t});\n\t\t\tconst result = decision === 'deny' ? 'denied' : decision === 'remember' ? 'remembered' : 'approved';\n\t\t\tthis.transcript.update((state) => setApproval(state, item.callId, result));\n\t\t} catch (error) {\n\t\t\tthis.transcript.update((state) => addError(setApproval(state, item.callId, 'waiting'), 'network', describeError(error)));\n\t\t}\n\t}\n\n\tprivate scrollToEnd(): void {\n\t\tafterNextRender(\n\t\t\t() => {\n\t\t\t\tconst element = this.scroller()?.nativeElement;\n\t\t\t\tif (element) element.scrollTop = element.scrollHeight;\n\t\t\t},\n\t\t\t{ injector: this.injector },\n\t\t);\n\t}\n\n\t/** Puts the message just sent at the top of the view; the reply then grows under it. */\n\tprivate scrollToLatestUser(): void {\n\t\tafterNextRender(\n\t\t\t() => {\n\t\t\t\tconst scroller = this.scroller()?.nativeElement;\n\t\t\t\tconst turn = scroller?.querySelector<HTMLElement>('.turn-latest');\n\t\t\t\tif (!scroller || !turn) return;\n\t\t\t\tconst reduce = globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches;\n\t\t\t\tconst top = turn.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;\n\t\t\t\tscroller.scrollTo({ top: top - 8, behavior: reduce ? 'auto' : 'smooth' });\n\t\t\t},\n\t\t\t{ injector: this.injector },\n\t\t);\n\t}\n}\n","<div class=\"chat\">\n\t<div class=\"scroller\" #scroller>\n\t\t<div class=\"transcript\" [attr.aria-busy]=\"running()\">\n\t\t\t@if (loadError(); as message) {\n\t\t\t\t<div class=\"ai-alert\" role=\"alert\">\n\t\t\t\t\t<span class=\"material-symbols-outlined ai-icon\" aria-hidden=\"true\"\n\t\t\t\t\t\t>error</span\n\t\t\t\t\t>\n\t\t\t\t\t<p>{{ message }}</p>\n\t\t\t\t</div>\n\t\t\t} @else if (!loading() && transcript().items.length === 0) {\n\t\t\t\t<div class=\"opening\">\n\t\t\t\t\t<p class=\"opening-title\" translate>Tell the agent what to do</p>\n\t\t\t\t\t<p class=\"ai-hint\" translate>\n\t\t\t\t\t\tIt asks before any tool that changes something.\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t}\n\n\t\t\t@for (item of history(); track item.key) {\n\t\t\t\t<ng-container *ngTemplateOutlet=\"itemTpl; context: { $implicit: item }\" />\n\t\t\t}\n\t\t\t@if (latest().length) {\n\t\t\t\t<div class=\"turn-latest\" [style.min-height.px]=\"turnHeight() - 16\">\n\t\t\t\t\t@for (item of latest(); track item.key) {\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"itemTpl; context: { $implicit: item }\" />\n\t\t\t\t\t}\n\t\t\t\t</div>\n\t\t\t}\n\t\t</div>\n\t</div>\n\n\t<form class=\"composer\" novalidate (submit)=\"send($event)\">\n\t\t@if (queued(); as next) {\n\t\t\t<p class=\"queued\">\n\t\t\t\t<span class=\"ai-visually-hidden\" translate>Queued message:</span> {{ next }}\n\t\t\t</p>\n\t\t}\n\t\t<label class=\"ai-visually-hidden\" for=\"message\" translate>Message to the agent</label>\n\t\t<div class=\"composer-box\">\n\t\t\t<textarea\n\t\t\t\t#textarea\n\t\t\t\tid=\"message\"\n\t\t\t\tclass=\"composer-input\"\n\t\t\t\trows=\"2\"\n\t\t\t\t[placeholder]=\"placeholder()\"\n\t\t\t\taria-describedby=\"composer-status\"\n\t\t\t\t[formField]=\"composer.text\"\n\t\t\t\t(keydown)=\"onKeydown($event)\"\n\t\t\t></textarea>\n\t\t\t<div class=\"composer-actions\">\n\t\t\t\t@if (running()) {\n\t\t\t\t\t<button\n\t\t\t\t\t\twbutton\n\t\t\t\t\t\ttype=\"secondary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon=\"stop\"\n\t\t\t\t\t\t[outlined]=\"true\"\n\t\t\t\t\t\t[disableSubmit]=\"true\"\n\t\t\t\t\t\t[loading]=\"stopping()\"\n\t\t\t\t\t\t(wClick)=\"stop()\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span translate>Stop</span>\n\t\t\t\t\t</button>\n\t\t\t\t}\n\t\t\t\t<button wbutton size=\"small\" icon=\"arrow_upward\" [disabled]=\"!canSend()\">\n\t\t\t\t\t<span translate>Send</span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t\t<p id=\"composer-status\" class=\"composer-status\" role=\"status\">\n\t\t\t@if (queued() !== null) {\n\t\t\t\t<span translate>Your next message sends when this turn ends.</span>\n\t\t\t\t<button type=\"button\" class=\"ai-link-btn\" (click)=\"unqueue()\" translate>\n\t\t\t\t\tEdit it\n\t\t\t\t</button>\n\t\t\t} @else if (waitingApproval()) {\n\t\t\t\t<span translate>The agent waits for your answer above.</span>\n\t\t\t} @else if (running()) {\n\t\t\t\t<span class=\"pulse\" aria-hidden=\"true\"></span>\n\t\t\t\t<span\n\t\t\t\t\t[translate]=\"\n\t\t\t\t\t\tslow() ? 'Still working, this turn takes longer than usual.' : 'Working.'\n\t\t\t\t\t\"\n\t\t\t\t></span>\n\t\t\t\t<span translate>Press Esc to stop.</span>\n\t\t\t} @else {\n\t\t\t\t<span translate>Enter sends, Shift + Enter adds a line.</span>\n\t\t\t}\n\t\t</p>\n\t</form>\n</div>\n\n<ng-template #itemTpl let-item>\n\t<div class=\"item\">\n\t\t@if (authorKeys().has(item.key)) {\n\t\t\t<p class=\"author\">{{ agentName() }}</p>\n\t\t}\n\t\t@switch (item.kind) {\n\t\t\t@case ('user') {\n\t\t\t\t<div class=\"msg-user\">\n\t\t\t\t\t<p class=\"bubble\">\n\t\t\t\t\t\t<span class=\"ai-visually-hidden\" translate>You:</span> {{ item.text }}\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t}\n\t\t\t@case ('text') {\n\t\t\t\t<div class=\"msg-agent\">\n\t\t\t\t\t<p class=\"reply\" [class.streaming]=\"running() && item.key === lastKey()\">\n\t\t\t\t\t\t{{ item.text }}\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t}\n\t\t\t@case ('tool') {\n\t\t\t\t<div class=\"tool\" [class.tool-error]=\"item.result?.isError\">\n\t\t\t\t\t<div class=\"tool-line\">\n\t\t\t\t\t\t<span class=\"material-symbols-outlined ai-icon-sm\" aria-hidden=\"true\"\n\t\t\t\t\t\t\t>build</span\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"tool-name ai-mono\">{{ item.tool }}</span>\n\t\t\t\t\t\t<span class=\"tool-input ai-mono\" [title]=\"compact(item.input)\">{{\n\t\t\t\t\t\t\tcompact(item.input)\n\t\t\t\t\t\t}}</span>\n\t\t\t\t\t\t@if (item.result; as result) {\n\t\t\t\t\t\t\t@if (result.isError) {\n\t\t\t\t\t\t\t\t<span class=\"ai-badge ai-badge--danger state\">\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclass=\"material-symbols-outlined ai-icon-sm\"\n\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t>close</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t[translate]=\"\n\t\t\t\t\t\t\t\t\t\t\titem.approval?.state === 'denied' ? 'Denied' : 'Failed'\n\t\t\t\t\t\t\t\t\t\t\"\n\t\t\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t\t<span class=\"ai-badge ai-badge--success state\">\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclass=\"material-symbols-outlined ai-icon-sm\"\n\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t>check</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span translate>Done</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} @else if (item.approval?.state !== 'waiting') {\n\t\t\t\t\t\t\t<span class=\"ai-badge state\" translate>Running</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t@if (item.approval; as approval) {\n\t\t\t\t\t\t@if (approval.state === 'waiting' || approval.state === 'sending') {\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"approval\"\n\t\t\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\t\t\t[attr.aria-label]=\"'Allow ' + item.tool + '?'\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<p class=\"approval-asker\">\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclass=\"material-symbols-outlined ai-icon-sm\"\n\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t>shield</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span translate>The agent asks to run this tool</span>\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t<p class=\"approval-summary\">{{ approval.summary }}</p>\n\t\t\t\t\t\t\t\t<p class=\"approval-access\">\n\t\t\t\t\t\t\t\t\t@for (access of approval.access; track access) {\n\t\t\t\t\t\t\t\t\t\t<span class=\"ai-badge ai-badge--warning\">{{\n\t\t\t\t\t\t\t\t\t\t\taccess\n\t\t\t\t\t\t\t\t\t\t}}</span>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t<div class=\"approval-actions\">\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\twbutton\n\t\t\t\t\t\t\t\t\t\ttype=\"danger\"\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t[disableSubmit]=\"true\"\n\t\t\t\t\t\t\t\t\t\t[disabled]=\"approval.state === 'sending'\"\n\t\t\t\t\t\t\t\t\t\t(wClick)=\"decide(item, 'deny')\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span translate>Deny</span>\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\twbutton\n\t\t\t\t\t\t\t\t\t\ttype=\"secondary\"\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t[outlined]=\"true\"\n\t\t\t\t\t\t\t\t\t\t[disableSubmit]=\"true\"\n\t\t\t\t\t\t\t\t\t\t[disabled]=\"approval.state === 'sending'\"\n\t\t\t\t\t\t\t\t\t\t(wClick)=\"decide(item, 'remember')\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span translate>Always for this session</span>\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\twbutton\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t[disableSubmit]=\"true\"\n\t\t\t\t\t\t\t\t\t\t[disabled]=\"approval.state === 'sending'\"\n\t\t\t\t\t\t\t\t\t\t(wClick)=\"decide(item, 'approve')\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span translate>Approve</span>\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t<p class=\"decision\" role=\"status\">\n\t\t\t\t\t\t\t\t@switch (approval.state) {\n\t\t\t\t\t\t\t\t\t@case ('approved') {\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclass=\"material-symbols-outlined ai-icon-sm\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t\t>check</span\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span translate>Approved</span>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t@case ('remembered') {\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclass=\"material-symbols-outlined ai-icon-sm\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t\t>check</span\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span translate>Approved for this session</span>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t@default {\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclass=\"material-symbols-outlined ai-icon-sm\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t\t>close</span\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span translate>Denied</span>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t@if (item.result?.output; as output) {\n\t\t\t\t\t\t<pre class=\"tool-output\">{{ output }}</pre>\n\t\t\t\t\t}\n\t\t\t\t</div>\n\t\t\t}\n\t\t\t@case ('error') {\n\t\t\t\t<div class=\"ai-alert\" role=\"alert\">\n\t\t\t\t\t<span class=\"material-symbols-outlined ai-icon\" aria-hidden=\"true\"\n\t\t\t\t\t\t>error</span\n\t\t\t\t\t>\n\t\t\t\t\t<p>{{ item.message }}</p>\n\t\t\t\t</div>\n\t\t\t}\n\t\t\t@case ('stop') {\n\t\t\t\t<p class=\"stopped\">{{ stopLabel(item) }}</p>\n\t\t\t}\n\t\t}\n\t</div>\n</ng-template>\n","import { DatePipe, NgTemplateOutlet } from '@angular/common';\nimport { Component, computed, effect, inject, input, output, signal, untracked } from '@angular/core';\nimport { form, FormField, maxLength, required, submit } from '@angular/forms/signals';\nimport { type AgentClient, describeError, type Project, type SessionSummary } from '@wawjs/ai-client';\nimport { TranslateDirective, TranslateService } from '@wawjs/ngx-translate';\nimport { ButtonDirective, ConfirmService, InputComponent } from '@wawjs/ngx-ui';\n\n/** The longest project name the agent accepts. */\nexport const PROJECT_NAME_MAX = 120;\n\nexport interface ProjectGroup {\n\tproject: Project;\n\tsessions: SessionSummary[];\n}\n\nconst byUpdatedDesc = (a: SessionSummary, b: SessionSummary) => b.updatedAt.localeCompare(a.updatedAt);\n\n/** Splits sessions into their projects (by name) and the sessions in no project. */\nexport function groupSessions(projects: readonly Project[], sessions: readonly SessionSummary[]): { groups: ProjectGroup[]; unsorted: SessionSummary[] } {\n\tconst known = new Set(projects.map((p) => p.id));\n\tconst groups = [...projects]\n\t\t.sort((a, b) => a.name.localeCompare(b.name))\n\t\t.map((project) => ({ project, sessions: sessions.filter((s) => s.projectId === project.id).sort(byUpdatedDesc) }));\n\tconst unsorted = sessions.filter((s) => !s.projectId || !known.has(s.projectId)).sort(byUpdatedDesc);\n\treturn { groups, unsorted };\n}\n\n/** Which project form is open: a new project, or renaming one. */\ntype Editing = { kind: 'new' } | { kind: 'rename'; projectId: string } | null;\n\n/**\n * The agent's projects with their sessions: new project, rename, delete (its sessions stay), new\n * session in a project, move a session, delete a session. Projects live on the agent, so the terminal\n * and every app see the same ones.\n */\n@Component({\n\tselector: 'ai-projects',\n\timports: [DatePipe, NgTemplateOutlet, FormField, ButtonDirective, InputComponent, TranslateDirective],\n\ttemplateUrl: './projects.component.html',\n\tstyleUrl: './projects.component.scss',\n})\nexport class AiProjectsComponent {\n\treadonly client = input.required<AgentClient>();\n\t/** Shown under the heading. */\n\treadonly agentName = input('');\n\t/** Session links point at sessionPath + id; a plain click emits open instead, for the app's router. */\n\treadonly sessionPath = input('/session/');\n\n\t/** A session to open: an existing one clicked, or a new one just created. */\n\treadonly open = output<string>();\n\n\tprivate readonly confirm = inject(ConfirmService);\n\tprivate readonly translate = inject(TranslateService);\n\n\tprotected readonly projects = signal<Project[] | null>(null);\n\tprotected readonly sessions = signal<SessionSummary[] | null>(null);\n\tprotected readonly loadError = signal<string | null>(null);\n\tprotected readonly actionError = signal<string | null>(null);\n\t/** The project a new session is being created in ('' for none). */\n\tprotected readonly creatingIn = signal<string | null>(null);\n\tprotected readonly saving = signal(false);\n\tprotected readonly editing = signal<Editing>(null);\n\tprotected readonly renamingId = computed(() => {\n\t\tconst editing = this.editing();\n\t\treturn editing?.kind === 'rename' ? editing.projectId : null;\n\t});\n\tprotected readonly loading = computed(() => (this.sessions() === null || this.projects() === null) && !this.loadError());\n\tprotected readonly grouped = computed(() => groupSessions(this.projects() ?? [], this.sessions() ?? []));\n\tprotected readonly empty = computed(() => this.grouped().groups.length === 0 && this.grouped().unsorted.length === 0);\n\n\tprivate readonly nameModel = signal({ name: '' });\n\tprotected readonly nameForm = form(this.nameModel, (path) => {\n\t\trequired(path.name, { message: 'Give the project a name.' });\n\t\tmaxLength(path.name, PROJECT_NAME_MAX, { message: `Use up to ${PROJECT_NAME_MAX} characters.` });\n\t});\n\n\tconstructor() {\n\t\teffect(() => {\n\t\t\tthis.client();\n\t\t\tuntracked(() => void this.reload());\n\t\t});\n\t}\n\n\t/** Reads projects and sessions again, for example after a turn or a change elsewhere. */\n\tasync reload(): Promise<void> {\n\t\tthis.loadError.set(null);\n\t\ttry {\n\t\t\tconst client = this.client();\n\t\t\tconst [projects, sessions] = await Promise.all([client.listProjects(), client.listSessions()]);\n\t\t\tthis.projects.set(projects.projects);\n\t\t\tthis.sessions.set(sessions.sessions);\n\t\t} catch (error) {\n\t\t\tthis.loadError.set(describeError(error));\n\t\t}\n\t}\n\n\tprotected startNew(): void {\n\t\tthis.nameModel.set({ name: '' });\n\t\tthis.editing.set({ kind: 'new' });\n\t}\n\n\tprotected startRename(project: Project): void {\n\t\tthis.nameModel.set({ name: project.name });\n\t\tthis.editing.set({ kind: 'rename', projectId: project.id });\n\t}\n\n\tprotected cancelEdit(): void {\n\t\tthis.editing.set(null);\n\t}\n\n\tprotected async saveName(event: SubmitEvent): Promise<void> {\n\t\tevent.preventDefault();\n\t\tconst editing = this.editing();\n\t\tif (!editing) return;\n\t\tawait submit(this.nameForm, async (fields) => {\n\t\t\tconst name = fields().value().name.trim();\n\t\t\tawait this.run(async () => {\n\t\t\t\tif (editing.kind === 'new') await this.client().createProject({ name });\n\t\t\t\telse await this.client().updateProject(editing.projectId, { name });\n\t\t\t\tthis.editing.set(null);\n\t\t\t});\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\tprotected remove(project: Project): void {\n\t\tthis.confirm.confirm({\n\t\t\theader: this.t('Delete project?'),\n\t\t\tmessage: `${project.name}: ${this.t(project.sessionCount ? 'its sessions stay on the agent and move to \"Not in a project\".' : 'it has no sessions.')}`,\n\t\t\tacceptLabel: this.t('Delete'),\n\t\t\trejectLabel: this.t('Cancel'),\n\t\t\tacceptType: 'danger',\n\t\t\taccept: () => void this.run(() => this.client().deleteProject(project.id)),\n\t\t});\n\t}\n\n\tprotected removeSession(session: SessionSummary): void {\n\t\tthis.confirm.confirm({\n\t\t\theader: this.t('Delete session?'),\n\t\t\tmessage: `${session.title || this.t('Untitled session')}: ${this.t('its messages are deleted on the agent.')}`,\n\t\t\tacceptLabel: this.t('Delete'),\n\t\t\trejectLabel: this.t('Cancel'),\n\t\t\tacceptType: 'danger',\n\t\t\taccept: () => void this.run(() => this.client().deleteSession(session.id)),\n\t\t});\n\t}\n\n\t/** Creates a session on the agent, in the project, and opens it. */\n\tprotected async newSession(projectId: string | null): Promise<void> {\n\t\tif (this.creatingIn() !== null) return;\n\t\tthis.creatingIn.set(projectId ?? '');\n\t\tthis.actionError.set(null);\n\t\ttry {\n\t\t\tconst session = await this.client().createSession(projectId ? { projectId } : {});\n\t\t\tthis.open.emit(session.id);\n\t\t} catch (error) {\n\t\t\tthis.actionError.set(describeError(error));\n\t\t} finally {\n\t\t\tthis.creatingIn.set(null);\n\t\t}\n\t}\n\n\tprotected move(session: SessionSummary, event: Event): void {\n\t\tconst value = (event.target as HTMLSelectElement).value;\n\t\tvoid this.run(() => this.client().updateSession(session.id, { projectId: value || null }));\n\t}\n\n\tprotected openLink(id: string, event: MouseEvent): void {\n\t\tif (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;\n\t\tevent.preventDefault();\n\t\tthis.open.emit(id);\n\t}\n\n\tprotected t(text: string): string {\n\t\treturn this.translate.translate(text)();\n\t}\n\n\tprotected sessionCount(count: number): string {\n\t\treturn count === 1 ? this.t('1 session') : `${count} ${this.t('sessions')}`;\n\t}\n\n\tprotected messages(count: number): string {\n\t\treturn count === 1 ? this.t('1 message') : `${count} ${this.t('messages')}`;\n\t}\n\n\tprivate async run(action: () => Promise<unknown>): Promise<void> {\n\t\tthis.saving.set(true);\n\t\tthis.actionError.set(null);\n\t\ttry {\n\t\t\tawait action();\n\t\t\tawait this.reload();\n\t\t} catch (error) {\n\t\t\tthis.actionError.set(describeError(error));\n\t\t} finally {\n\t\t\tthis.saving.set(false);\n\t\t}\n\t}\n}\n","<div class=\"head\">\n\t<div>\n\t\t<h1 class=\"title\" translate>Projects</h1>\n\t\t@if (agentName()) {\n\t\t\t<p class=\"subtitle\">\n\t\t\t\t<span translate>Sessions with</span> <strong>{{ agentName() }}</strong>,\n\t\t\t\t<span translate>grouped the way you work.</span>\n\t\t\t</p>\n\t\t}\n\t</div>\n\t<div class=\"actions\">\n\t\t<button wbutton type=\"secondary\" size=\"small\" icon=\"add_comment\" [outlined]=\"true\" [loading]=\"creatingIn() === ''\" (wClick)=\"newSession(null)\">\n\t\t\t<span translate>New session</span>\n\t\t</button>\n\t\t@if (editing()?.kind !== 'new') {\n\t\t\t<button wbutton size=\"small\" icon=\"add\" (wClick)=\"startNew()\">\n\t\t\t\t<span translate>New project</span>\n\t\t\t</button>\n\t\t}\n\t</div>\n</div>\n\n@if (editing()?.kind === 'new') {\n\t<ng-container [ngTemplateOutlet]=\"nameFormTpl\" [ngTemplateOutletContext]=\"{ title: 'New project' }\" />\n}\n\n@if (actionError(); as message) {\n\t<div class=\"ai-alert gap-top\" role=\"alert\">\n\t\t<span class=\"material-symbols-outlined ai-icon\" aria-hidden=\"true\">error</span>\n\t\t<p>{{ message }}</p>\n\t</div>\n}\n@if (loadError(); as message) {\n\t<div class=\"ai-alert gap-top center\" role=\"alert\">\n\t\t<span class=\"material-symbols-outlined ai-icon\" aria-hidden=\"true\">error</span>\n\t\t<p class=\"grow\">{{ message }}</p>\n\t\t<button wbutton type=\"secondary\" size=\"small\" [outlined]=\"true\" (wClick)=\"reload()\">\n\t\t\t<span translate>Try again</span>\n\t\t</button>\n\t</div>\n}\n\n@if (loading()) {\n\t<p class=\"ai-hint gap-top\" role=\"status\" translate>Loading projects...</p>\n} @else if (empty() && !loadError()) {\n\t<div class=\"ai-card empty\">\n\t\t<p class=\"empty-title\" translate>No projects yet</p>\n\t\t<p class=\"ai-hint\" translate>Create a project, then start sessions in it to chat with the agent.</p>\n\t</div>\n} @else {\n\t<div class=\"groups\">\n\t\t@for (group of grouped().groups; track group.project.id) {\n\t\t\t<section class=\"ai-card\" [attr.aria-labelledby]=\"'ai-project-' + group.project.id\">\n\t\t\t\t@if (renamingId() === group.project.id) {\n\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"nameFormTpl\" [ngTemplateOutletContext]=\"{ title: 'Rename project', inCard: true }\" />\n\t\t\t\t} @else {\n\t\t\t\t\t<header class=\"project-head\">\n\t\t\t\t\t\t<div class=\"project-text\">\n\t\t\t\t\t\t\t<h2 class=\"project-name\" [id]=\"'ai-project-' + group.project.id\">{{ group.project.name }}</h2>\n\t\t\t\t\t\t\t<p class=\"ai-hint\">\n\t\t\t\t\t\t\t\t{{ sessionCount(group.sessions.length) }}\n\t\t\t\t\t\t\t\t@if (group.project.folder) {\n\t\t\t\t\t\t\t\t\t<span aria-hidden=\"true\"> · </span><span class=\"ai-mono\">{{ group.project.folder }}</span>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"actions\">\n\t\t\t\t\t\t\t<button wbutton size=\"small\" icon=\"add_comment\" [loading]=\"creatingIn() === group.project.id\" (wClick)=\"newSession(group.project.id)\">\n\t\t\t\t\t\t\t\t<span translate>New session</span>\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button wbutton type=\"secondary\" size=\"small\" icon=\"edit\" [text]=\"true\" [ariaLabel]=\"t('Rename') + ' ' + group.project.name\" (wClick)=\"startRename(group.project)\"></button>\n\t\t\t\t\t\t\t<button wbutton type=\"danger\" size=\"small\" icon=\"delete\" [text]=\"true\" [ariaLabel]=\"t('Delete') + ' ' + group.project.name\" (wClick)=\"remove(group.project)\"></button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</header>\n\t\t\t\t}\n\n\t\t\t\t@if (group.sessions.length) {\n\t\t\t\t\t<ul class=\"session-list\" role=\"list\">\n\t\t\t\t\t\t@for (session of group.sessions; track session.id) {\n\t\t\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"sessionTpl\" [ngTemplateOutletContext]=\"{ $implicit: session, projectId: group.project.id }\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t</ul>\n\t\t\t\t} @else {\n\t\t\t\t\t<p class=\"ai-hint none\" translate>No sessions yet. Start one to chat with the agent.</p>\n\t\t\t\t}\n\t\t\t</section>\n\t\t}\n\n\t\t@if (grouped().unsorted.length) {\n\t\t\t<section class=\"ai-card\" aria-labelledby=\"ai-project-none\">\n\t\t\t\t<header class=\"project-head\">\n\t\t\t\t\t<div class=\"project-text\">\n\t\t\t\t\t\t<h2 class=\"project-name\" id=\"ai-project-none\" translate>Not in a project</h2>\n\t\t\t\t\t\t<p class=\"ai-hint\" translate>Sessions started without a project. Move them into one.</p>\n\t\t\t\t\t</div>\n\t\t\t\t</header>\n\t\t\t\t<ul class=\"session-list\" role=\"list\">\n\t\t\t\t\t@for (session of grouped().unsorted; track session.id) {\n\t\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"sessionTpl\" [ngTemplateOutletContext]=\"{ $implicit: session, projectId: '' }\" />\n\t\t\t\t\t}\n\t\t\t\t</ul>\n\t\t\t</section>\n\t\t}\n\t</div>\n}\n\n<ng-template #sessionTpl let-session let-projectId=\"projectId\">\n\t<li class=\"session-row\">\n\t\t<a class=\"session-link ai-focus\" [href]=\"sessionPath() + session.id\" (click)=\"openLink(session.id, $event)\">\n\t\t\t<span class=\"session-title\">{{ session.title || t('Untitled session') }}</span>\n\t\t\t<span class=\"session-meta\">\n\t\t\t\t{{ messages(session.messageCount) }}<span aria-hidden=\"true\"> · </span>\n\t\t\t\t<time [attr.datetime]=\"session.updatedAt\">{{ session.updatedAt | date: 'MMM d, HH:mm' }}</time>\n\t\t\t\t<span aria-hidden=\"true\"> · </span><span class=\"ai-mono\">{{ session.model }}</span>\n\t\t\t</span>\n\t\t</a>\n\t\t<label class=\"ai-visually-hidden\" [for]=\"'ai-move-' + session.id\" translate>Project of this session</label>\n\t\t<select class=\"session-move ai-focus\" [id]=\"'ai-move-' + session.id\" [disabled]=\"saving()\" (change)=\"move(session, $event)\">\n\t\t\t<option value=\"\" [selected]=\"!projectId\" translate>Not in a project</option>\n\t\t\t@for (group of grouped().groups; track group.project.id) {\n\t\t\t\t<option [value]=\"group.project.id\" [selected]=\"group.project.id === projectId\">{{ group.project.name }}</option>\n\t\t\t}\n\t\t</select>\n\t\t<button wbutton type=\"danger\" size=\"small\" icon=\"delete\" [text]=\"true\" [ariaLabel]=\"t('Delete') + ' ' + (session.title || t('Untitled session'))\" (wClick)=\"removeSession(session)\"></button>\n\t</li>\n</ng-template>\n\n<ng-template #nameFormTpl let-title=\"title\" let-inCard=\"inCard\">\n\t<form class=\"name-form\" [class.ai-card]=\"!inCard\" [class.gap-top]=\"!inCard\" novalidate (submit)=\"saveName($event)\">\n\t\t<h2 class=\"form-title\" [translate]=\"title\">{{ title }}</h2>\n\t\t<winput label=\"Project name\" name=\"project-name\" [required]=\"true\" [formField]=\"nameForm.name\" />\n\t\t<div class=\"actions\">\n\t\t\t<button wbutton [loading]=\"saving()\"><span translate>Save</span></button>\n\t\t\t<button wbutton type=\"secondary\" [outlined]=\"true\" [disableSubmit]=\"true\" (wClick)=\"cancelEdit()\">\n\t\t\t\t<span translate>Cancel</span>\n\t\t\t</button>\n\t\t</div>\n\t</form>\n</ng-template>\n","import { Component, inject, input, output, signal } from '@angular/core';\nimport { form, FormField, required, submit, validate } from '@angular/forms/signals';\nimport { type AgentInfo, describeError } from '@wawjs/ai-client';\nimport { TranslateDirective } from '@wawjs/ngx-translate';\nimport { ButtonDirective, InputComponent } from '@wawjs/ngx-ui';\nimport { AiAgentStore } from '../agent-store';\n\ninterface ConnectModel {\n\turl: string;\n\ttoken: string;\n}\n\n/** A full http(s) address, or a path on this site such as /agents/my-agent. */\nexport function isAgentAddress(value: string): boolean {\n\tconst trimmed = value.trim();\n\tif (/^\\/(?!\\/)/.test(trimmed)) return true;\n\ttry {\n\t\tconst url = new URL(trimmed);\n\t\treturn url.protocol === 'http:' || url.protocol === 'https:';\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Connects to an agent with its address and token (checked with GET /v1/info), then shows the agent,\n * its model and its tools. Put a hint on how to start the agent inside the element.\n */\n@Component({\n\tselector: 'ai-connect',\n\timports: [FormField, ButtonDirective, InputComponent, TranslateDirective],\n\ttemplateUrl: './connect.component.html',\n\tstyleUrl: './connect.component.scss',\n})\nexport class AiConnectComponent {\n\t/** Ask for a token. Turn off for agents behind a server that authorizes another way. */\n\treadonly tokenRequired = input(true);\n\n\t/** The agent answered; it is now AiAgentStore.client(). */\n\treadonly connected = output<AgentInfo>();\n\t/** \"Open projects\" on the connected card. */\n\treadonly continue = output<void>();\n\n\tprotected readonly agent = inject(AiAgentStore);\n\tprotected readonly error = signal<string | null>(null);\n\tprotected readonly busy = signal(false);\n\n\tprivate readonly model = signal<ConnectModel>({\n\t\turl: this.agent.connection()?.url ?? this.agent.config.defaultUrl ?? 'http://127.0.0.1:53011',\n\t\ttoken: this.agent.connection()?.token ?? '',\n\t});\n\n\tprotected readonly connectForm = form(this.model, (path) => {\n\t\trequired(path.url, { message: 'Enter the agent address.' });\n\t\tvalidate(path.url, ({ value }) =>\n\t\t\tvalue() && !isAgentAddress(value()) ? { kind: 'url', message: 'Use a full address, such as http://127.0.0.1:53011.' } : undefined,\n\t\t);\n\t\trequired(path.token, { message: 'Paste the token the agent printed.', when: () => this.tokenRequired() });\n\t});\n\n\tprotected async connect(event: SubmitEvent): Promise<void> {\n\t\tevent.preventDefault();\n\t\tthis.error.set(null);\n\t\tawait submit(this.connectForm, async (fields) => {\n\t\t\tthis.busy.set(true);\n\t\t\ttry {\n\t\t\t\tthis.connected.emit(await this.agent.connect(fields().value()));\n\t\t\t} catch (error) {\n\t\t\t\tthis.error.set(describeError(error));\n\t\t\t} finally {\n\t\t\t\tthis.busy.set(false);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\tprotected change(): void {\n\t\tthis.agent.disconnect();\n\t}\n\n\tprotected forget(): void {\n\t\tthis.agent.forget();\n\t\tthis.model.set({ url: this.agent.config.defaultUrl ?? 'http://127.0.0.1:53011', token: '' });\n\t}\n}\n","@if (agent.info(); as info) {\n\t<section class=\"ai-card box\" aria-labelledby=\"ai-agent-title\">\n\t\t<p class=\"eyebrow\" translate>Connected agent</p>\n\t\t<h1 id=\"ai-agent-title\" class=\"title\">{{ info.agent.name }}</h1>\n\t\t<p class=\"meta\">\n\t\t\t<span translate>Version</span> {{ info.agent.version }} · <span class=\"ai-mono\">{{ info.model }}</span> ·\n\t\t\t<span class=\"ai-mono\">{{ agent.connection()?.url }}</span>\n\t\t</p>\n\t\t@if (info.agent.description) {\n\t\t\t<p class=\"description\">{{ info.agent.description }}</p>\n\t\t}\n\n\t\t<h2 class=\"tools-title\">\n\t\t\t{{ info.tools.length }} <span [translate]=\"info.tools.length === 1 ? 'tool' : 'tools'\"></span>\n\t\t</h2>\n\t\t@if (info.tools.length) {\n\t\t\t<ul class=\"tools\" role=\"list\">\n\t\t\t\t@for (tool of info.tools; track tool.name) {\n\t\t\t\t\t<li class=\"tool\">\n\t\t\t\t\t\t<div class=\"tool-line\">\n\t\t\t\t\t\t\t<span class=\"ai-mono tool-name\">{{ tool.name }}</span>\n\t\t\t\t\t\t\t@for (access of tool.access; track access) {\n\t\t\t\t\t\t\t\t<span class=\"ai-badge\" [class.ai-badge--warning]=\"access !== 'read'\">{{ access }}</span>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<p class=\"tool-description\">{{ tool.description }}</p>\n\t\t\t\t\t</li>\n\t\t\t\t}\n\t\t\t</ul>\n\t\t}\n\n\t\t<div class=\"actions\">\n\t\t\t<button wbutton icon=\"arrow_forward\" iconPos=\"right\" (wClick)=\"continue.emit()\">\n\t\t\t\t<span translate>Open projects</span>\n\t\t\t</button>\n\t\t\t<button wbutton type=\"secondary\" [outlined]=\"true\" (wClick)=\"change()\">\n\t\t\t\t<span translate>Change agent</span>\n\t\t\t</button>\n\t\t</div>\n\t</section>\n} @else {\n\t<section class=\"ai-card box\" aria-labelledby=\"ai-connect-title\">\n\t\t<h1 id=\"ai-connect-title\" class=\"title\" translate>Connect to an agent</h1>\n\t\t<p class=\"description\" translate>Use the address and token the agent prints when it starts.</p>\n\n\t\t<form class=\"form\" novalidate (submit)=\"connect($event)\">\n\t\t\t<winput label=\"Agent address\" type=\"text\" name=\"agent-url\" autocomplete=\"url\" [required]=\"true\" [formField]=\"connectForm.url\" />\n\t\t\t<winput label=\"Token\" type=\"password\" name=\"agent-token\" autocomplete=\"off\" [required]=\"tokenRequired()\" [formField]=\"connectForm.token\" />\n\n\t\t\t@if (error(); as message) {\n\t\t\t\t<div class=\"ai-alert\" role=\"alert\">\n\t\t\t\t\t<span class=\"material-symbols-outlined ai-icon\" aria-hidden=\"true\">error</span>\n\t\t\t\t\t<p>{{ message }}</p>\n\t\t\t\t</div>\n\t\t\t}\n\n\t\t\t<div>\n\t\t\t\t<button wbutton [loading]=\"busy()\"><span translate>Connect</span></button>\n\t\t\t</div>\n\t\t</form>\n\n\t\t<div class=\"ai-hint hint\">\n\t\t\t<ng-content />\n\t\t\t<span translate>The token stays on this device.</span>\n\t\t\t@if (agent.connection()) {\n\t\t\t\t<button type=\"button\" class=\"ai-link-btn\" (click)=\"forget()\" translate>Forget saved token</button>\n\t\t\t}\n\t\t</div>\n\t</section>\n}\n","/**\n * Ukrainian for every English string the ai-ngx components show. Merge it into the app's translations:\n * provideTranslate({ translations: { ua: { ...AI_NGX_UA, ...ua }, en: {} } }).\n */\nexport const AI_NGX_UA: Readonly<Record<string, string>> = {\n\t\"1 message\": \"1 повідомлення\",\n\t\"1 session\": \"1 сесія\",\n\t\"Agent\": \"Агент\",\n\t\"Agent address\": \"Адреса агента\",\n\t\"Always for this session\": \"Завжди в цій сесії\",\n\t\"Approve\": \"Дозволити\",\n\t\"Approved\": \"Дозволено\",\n\t\"Approved for this session\": \"Дозволено для цієї сесії\",\n\t\"Cancel\": \"Скасувати\",\n\t\"Change agent\": \"Змінити агента\",\n\t\"Connect\": \"Підключитися\",\n\t\"Connect to an agent\": \"Підключитися до агента\",\n\t\"Connected agent\": \"Підключений агент\",\n\t\"Create a project, then start sessions in it to chat with the agent.\": \"Створіть проєкт, потім починайте в ньому сесії, щоб спілкуватися з агентом.\",\n\t\"Delete\": \"Видалити\",\n\t\"Delete project?\": \"Видалити проєкт?\",\n\t\"Delete session?\": \"Видалити сесію?\",\n\t\"Denied\": \"Відхилено\",\n\t\"Deny\": \"Відхилити\",\n\t\"Done\": \"Готово\",\n\t\"Edit it\": \"Змінити його\",\n\t\"Enter sends, Shift + Enter adds a line.\": \"Enter надсилає, Shift + Enter додає рядок.\",\n\t\"Enter the agent address.\": \"Введіть адресу агента.\",\n\t\"Failed\": \"Помилка\",\n\t\"Forget saved token\": \"Забути збережений токен\",\n\t\"Give the project a name.\": \"Дайте проєкту назву.\",\n\t\"grouped the way you work.\": \"згруповані так, як ви працюєте.\",\n\t\"It asks before any tool that changes something.\": \"Він питає дозволу перед кожним інструментом, який щось змінює.\",\n\t\"it has no sessions.\": \"у ньому немає сесій.\",\n\t\"its messages are deleted on the agent.\": \"її повідомлення буде видалено на агенті.\",\n\t\"its sessions stay on the agent and move to \\\"Not in a project\\\".\": \"його сесії залишаються в агента й переходять до «Поза проєктами».\",\n\t\"Loading projects...\": \"Завантаження проєктів...\",\n\t\"Message the agent\": \"Напишіть агентові\",\n\t\"Message to the agent\": \"Повідомлення агентові\",\n\t\"messages\": \"повідомлень\",\n\t\"New project\": \"Новий проєкт\",\n\t\"New session\": \"Нова сесія\",\n\t\"No projects yet\": \"Проєктів ще немає\",\n\t\"No sessions yet. Start one to chat with the agent.\": \"Сесій ще немає. Почніть одну, щоб спілкуватися з агентом.\",\n\t\"Not in a project\": \"Поза проєктами\",\n\t\"Open projects\": \"Відкрити проєкти\",\n\t\"Paste the token the agent printed.\": \"Вставте токен, який показав агент.\",\n\t\"Press Esc to stop.\": \"Натисніть Esc, щоб зупинити.\",\n\t\"Project name\": \"Назва проєкту\",\n\t\"Project of this session\": \"Проєкт цієї сесії\",\n\t\"Projects\": \"Проєкти\",\n\t\"Queued message:\": \"Повідомлення в черзі:\",\n\t\"Rename\": \"Перейменувати\",\n\t\"Running\": \"Виконується\",\n\t\"Save\": \"Зберегти\",\n\t\"Send\": \"Надіслати\",\n\t\"sessions\": \"сесій\",\n\t\"Sessions started without a project. Move them into one.\": \"Сесії, початі без проєкту. Перенесіть їх у проєкт.\",\n\t\"Sessions with\": \"Сесії з\",\n\t\"Still working, this turn takes longer than usual.\": \"Ще працює, цей хід триває довше, ніж зазвичай.\",\n\t\"Stop\": \"Зупинити\",\n\t\"Stopped at the step limit. Send a message to continue.\": \"Зупинено на межі кроків. Надішліть повідомлення, щоб продовжити.\",\n\t\"Stopped. The reply above is incomplete.\": \"Зупинено. Відповідь вище неповна.\",\n\t\"Tell the agent what to do\": \"Скажіть агентові, що зробити\",\n\t\"The agent asks to run this tool\": \"Агент просить запустити цей інструмент\",\n\t\"The agent waits for your answer above.\": \"Агент чекає на вашу відповідь вище.\",\n\t\"The token stays on this device.\": \"Токен залишається на цьому пристрої.\",\n\t\"The turn ended with an error.\": \"Хід завершився з помилкою.\",\n\t\"Token\": \"Токен\",\n\t\"tool\": \"інструмент\",\n\t\"tools\": \"інструментів\",\n\t\"Try again\": \"Спробувати ще раз\",\n\t\"Untitled session\": \"Сесія без назви\",\n\t\"Use a full address, such as http://127.0.0.1:53011.\": \"Вкажіть повну адресу, наприклад http://127.0.0.1:53011.\",\n\t\"Use the address and token the agent prints when it starts.\": \"Використайте адресу й токен, які агент виводить під час запуску.\",\n\t\"Use up to 120 characters.\": \"Не більше 120 символів.\",\n\t\"Version\": \"Версія\",\n\t\"Working.\": \"Працює.\",\n\t\"You:\": \"Ви:\",\n\t\"Your next message sends when this turn ends.\": \"Наступне повідомлення надішлеться, коли цей хід завершиться.\",\n};\n"],"mappings":";;;;;;;;AAaA,MAAa,kBAAkB,IAAI,eAA8B,mBAAmB,EACnF,gBAAgB,EAAE,YAAY,SAAQ,GACtC,CAAA;AAGD,SAAgB,eAAe,QAAqB;CACnD,OAAO;EAAE,SAAS;EAAiB,UAAU;CAAM;AACpD;AAYA,IAAa,eAAb,MAAa,aAAY;CADzB,cAAA;EAEU,KAAA,SAAS,OAAO,eAAe;EACvB,KAAA,MAAM,GAAG,KAAK,OAAO,WAAU;EAC/B,KAAA,QAAQ,OAA+B,KAAK,KAAI,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EACnD,KAAA,YAAY,OAAyB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;EAGlD,KAAA,aAAa,KAAK,MAAM,WAAU;EAElC,KAAA,OAAO,KAAK,UAAU,WAAU;EAChC,KAAA,YAAY,eAAe,KAAK,UAAS,MAAO,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;EACrD,KAAA,SAAS,eAAc;GAC/B,MAAM,aAAa,KAAK,MAAK;GAC7B,OAAO,cAAc,KAAK,UAAS,IAAK,IAAI,YAAY,UAAU,IAAI;EACvE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAwDF;CArDA,MAAM,QAAQ,YAA2C;EACxD,MAAM,SAAS,IAAI,YAAY,UAAU;EACzC,MAAM,OAAO,MAAM,OAAO,KAAI;EAC9B,MAAM,a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ACrB,wBAAwB;CACxB,YAAY;CACZ,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,sDAAsD;CACtD,oBAAoB;CACpB,iBAAiB;CACjB,sCAAsC;CACtC,sBAAsB;CACtB,gBAAgB;CAChB,2BAA2B;CAC3B,YAAY;CACZ,mBAAmB;CACnB,UAAU;CACV,WAAW;CACX,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,2DAA2D;CAC3D,iBAAiB;CACjB,qDAAqD;CACrD,QAAQ;CACR,0DAA0D;CAC1D,2CAA2C;CAC3C,6BAA6B;CAC7B,mCAAmC;CACnC,0CAA0C;CAC1C,mCAAmC;CACnC,iCAAiC;CACjC,SAAS;CACT,QAAQ;CACR,SAAS;CACT,aAAa;CACb,oBAAoB;CACpB,uDAAuD;CACvD,8DAA8D;CAC9D,6BAA6B;CAC7B,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,gDAAgD;AAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
+
"description": "Angular components of the IT Kamianets AI Framework: agent connection, projects and sessions, and the chat with tool calls and approvals, on @wawjs/ai-client.",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/IT-Kamianets/ai-ngx.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://ai.itkamianets.com/packages/ai-ngx",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"angular",
|
|
11
|
+
"agent",
|
|
12
|
+
"ai",
|
|
13
|
+
"chat",
|
|
14
|
+
"itkamianets",
|
|
15
|
+
"ai-itkp"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"tslib": "^2.9.0"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@angular/common": ">=22.0.0",
|
|
22
|
+
"@angular/core": ">=22.0.0",
|
|
23
|
+
"@angular/forms": ">=22.0.0",
|
|
24
|
+
"@angular/router": ">=22.0.0",
|
|
25
|
+
"@wawjs/ai-client": "^0.1.0",
|
|
26
|
+
"@wawjs/ngx-translate": ">=22.0.17",
|
|
27
|
+
"@wawjs/ngx-ui": ">=22.0.17"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"sideEffects": false,
|
|
2
33
|
"name": "@wawjs/ai-ngx",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
34
|
+
"type": "module",
|
|
35
|
+
"main": "./fesm2022/wawjs-ai-ngx.mjs",
|
|
36
|
+
"module": "./fesm2022/wawjs-ai-ngx.mjs",
|
|
37
|
+
"typings": "./types/wawjs-ai-ngx.d.ts",
|
|
38
|
+
"types": "./types/wawjs-ai-ngx.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./types/wawjs-ai-ngx.d.ts",
|
|
42
|
+
"default": "./fesm2022/wawjs-ai-ngx.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": {
|
|
45
|
+
"default": "./package.json"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"version": "0.1.0"
|
|
49
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { InjectionToken, Provider } from "@angular/core";
|
|
3
|
+
import { CanActivateFn } from "@angular/router";
|
|
4
|
+
import { AgentClient, AgentInfo, Connection, Project, Session, SessionSummary, StopItem, ToolItem, Transcript } from "@wawjs/ai-client";
|
|
5
|
+
interface AiAgentConfig {
|
|
6
|
+
/** Names the saved connection in this device's storage: `<storageKey>.connection`. Use your app id. */
|
|
7
|
+
storageKey: string;
|
|
8
|
+
/** The address the connect form suggests, such as http://127.0.0.1:53011 or /agents/my-agent. */
|
|
9
|
+
defaultUrl?: string;
|
|
10
|
+
/** Where aiConnectedGuard sends a visitor without a connection. Default /connect. */
|
|
11
|
+
connectPath?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const AI_AGENT_CONFIG: InjectionToken<AiAgentConfig>;
|
|
14
|
+
/** Sets the storage key, default address and connect page of the agent connection. */
|
|
15
|
+
export declare function provideAiAgent(config: AiAgentConfig): Provider;
|
|
16
|
+
interface SavedConnection {
|
|
17
|
+
url: string;
|
|
18
|
+
token: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The agent the app talks to: the saved connection, its client and the agent's info. The token is kept
|
|
22
|
+
* in this device's storage only and is sent nowhere but to the agent.
|
|
23
|
+
*/
|
|
24
|
+
export declare class AiAgentStore {
|
|
25
|
+
readonly config: AiAgentConfig;
|
|
26
|
+
private readonly key;
|
|
27
|
+
private readonly saved;
|
|
28
|
+
private readonly agentInfo;
|
|
29
|
+
/** The remembered connection, to fill the connect form. */
|
|
30
|
+
readonly connection: import("@angular/core").Signal<SavedConnection | null>;
|
|
31
|
+
/** The agent's info, once a connection was checked in this run. */
|
|
32
|
+
readonly info: import("@angular/core").Signal<AgentInfo | null>;
|
|
33
|
+
readonly connected: import("@angular/core").Signal<boolean>;
|
|
34
|
+
readonly client: import("@angular/core").Signal<AgentClient | null>;
|
|
35
|
+
/** Checks a connection with GET /v1/info and remembers it when the agent answers compatibly. */
|
|
36
|
+
connect(connection: Connection & {
|
|
37
|
+
token?: string;
|
|
38
|
+
}): Promise<AgentInfo>;
|
|
39
|
+
/** Reconnects with the remembered connection, for a reload on a deep link. */
|
|
40
|
+
resume(): Promise<boolean>;
|
|
41
|
+
/** Leaves the agent but keeps the saved connection to fill the form. */
|
|
42
|
+
disconnect(): void;
|
|
43
|
+
/** Forgets the saved address and token on this device. */
|
|
44
|
+
forget(): void;
|
|
45
|
+
private load;
|
|
46
|
+
private store;
|
|
47
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiAgentStore, never>;
|
|
48
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
49
|
+
}
|
|
50
|
+
/** Pages that talk to the agent need a checked connection; a reload resumes the saved one. */
|
|
51
|
+
export declare const aiConnectedGuard: CanActivateFn;
|
|
52
|
+
type Decision = 'approve' | 'remember' | 'deny';
|
|
53
|
+
/**
|
|
54
|
+
* The chat of one session: the saved transcript, streamed replies, tool calls, approvals (Deny, Always
|
|
55
|
+
* for this session, Approve), Stop (or Esc) and a queued message. The page around it shows the title
|
|
56
|
+
* and the way back; this component only needs the client and the session id.
|
|
57
|
+
*/
|
|
58
|
+
export declare class AiChatComponent {
|
|
59
|
+
/** The agent, usually AiAgentStore.client(). */
|
|
60
|
+
readonly client: import("@angular/core").InputSignal<AgentClient>;
|
|
61
|
+
readonly sessionId: import("@angular/core").InputSignal<string>;
|
|
62
|
+
/** The name shown over the agent's messages. */
|
|
63
|
+
readonly agentName: import("@angular/core").InputSignal<string>;
|
|
64
|
+
/** The session once loaded, for the page title. */
|
|
65
|
+
readonly loaded: import("@angular/core").OutputEmitterRef<Session>;
|
|
66
|
+
/** A turn ended (after its done event or a failure), for refreshing lists. */
|
|
67
|
+
readonly turnEnded: import("@angular/core").OutputEmitterRef<"end" | "cancelled" | "error" | "max_steps" | "failed">;
|
|
68
|
+
private readonly translate;
|
|
69
|
+
private readonly injector;
|
|
70
|
+
private readonly scroller;
|
|
71
|
+
private readonly textarea;
|
|
72
|
+
protected readonly placeholder: import("@angular/core").Signal<string>;
|
|
73
|
+
protected readonly loading: import("@angular/core").WritableSignal<boolean>;
|
|
74
|
+
protected readonly loadError: import("@angular/core").WritableSignal<string | null>;
|
|
75
|
+
protected readonly transcript: import("@angular/core").WritableSignal<Transcript>;
|
|
76
|
+
protected readonly running: import("@angular/core").WritableSignal<boolean>;
|
|
77
|
+
protected readonly stopping: import("@angular/core").WritableSignal<boolean>;
|
|
78
|
+
private readonly draft;
|
|
79
|
+
protected readonly composer: import("@angular/forms/signals").FieldTree<{
|
|
80
|
+
text: string;
|
|
81
|
+
}, string | number, "writable">;
|
|
82
|
+
/** A message written while a turn runs; the API takes one turn at a time, so it waits. */
|
|
83
|
+
protected readonly queued: import("@angular/core").WritableSignal<string | null>;
|
|
84
|
+
/** True once a turn has run for ten seconds without asking anything. */
|
|
85
|
+
protected readonly slow: import("@angular/core").WritableSignal<boolean>;
|
|
86
|
+
protected readonly canSend: import("@angular/core").Signal<boolean>;
|
|
87
|
+
/** The first agent item of every turn carries the agent's name, so its output is marked. */
|
|
88
|
+
protected readonly authorKeys: import("@angular/core").Signal<Set<string>>;
|
|
89
|
+
protected readonly waitingApproval: import("@angular/core").Signal<boolean>;
|
|
90
|
+
/** Index of the first item of the turn sent from this screen, and the height that turn fills. */
|
|
91
|
+
protected readonly turnStart: import("@angular/core").WritableSignal<number | null>;
|
|
92
|
+
protected readonly turnHeight: import("@angular/core").WritableSignal<number>;
|
|
93
|
+
protected readonly history: import("@angular/core").Signal<import("@wawjs/ai-client").Item[]>;
|
|
94
|
+
protected readonly latest: import("@angular/core").Signal<import("@wawjs/ai-client").Item[]>;
|
|
95
|
+
protected readonly lastKey: import("@angular/core").Signal<string | undefined>;
|
|
96
|
+
private stream;
|
|
97
|
+
constructor();
|
|
98
|
+
protected stopLabel(item: StopItem): string;
|
|
99
|
+
protected compact(input: Record<string, unknown>): string;
|
|
100
|
+
private load;
|
|
101
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
102
|
+
protected send(event?: SubmitEvent): void;
|
|
103
|
+
/** Puts a queued message back into the composer. */
|
|
104
|
+
protected unqueue(): void;
|
|
105
|
+
private runTurn;
|
|
106
|
+
/** Stops the running turn on the agent; its stream then ends with a cancelled done event. */
|
|
107
|
+
protected stop(): Promise<void>;
|
|
108
|
+
protected decide(item: ToolItem, decision: Decision): Promise<void>;
|
|
109
|
+
private scrollToEnd;
|
|
110
|
+
/** Puts the message just sent at the top of the view; the reply then grows under it. */
|
|
111
|
+
private scrollToLatestUser;
|
|
112
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiChatComponent, never>;
|
|
113
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AiChatComponent, "ai-chat", never, {
|
|
114
|
+
"client": {
|
|
115
|
+
"alias": "client";
|
|
116
|
+
"required": true;
|
|
117
|
+
"isSignal": true;
|
|
118
|
+
};
|
|
119
|
+
"sessionId": {
|
|
120
|
+
"alias": "sessionId";
|
|
121
|
+
"required": true;
|
|
122
|
+
"isSignal": true;
|
|
123
|
+
};
|
|
124
|
+
"agentName": {
|
|
125
|
+
"alias": "agentName";
|
|
126
|
+
"required": false;
|
|
127
|
+
"isSignal": true;
|
|
128
|
+
};
|
|
129
|
+
}, {
|
|
130
|
+
"loaded": "loaded";
|
|
131
|
+
"turnEnded": "turnEnded";
|
|
132
|
+
}, never, never, true, never>;
|
|
133
|
+
}
|
|
134
|
+
/** The longest project name the agent accepts. */
|
|
135
|
+
export declare const PROJECT_NAME_MAX = 120;
|
|
136
|
+
interface ProjectGroup {
|
|
137
|
+
project: Project;
|
|
138
|
+
sessions: SessionSummary[];
|
|
139
|
+
}
|
|
140
|
+
/** Splits sessions into their projects (by name) and the sessions in no project. */
|
|
141
|
+
export declare function groupSessions(projects: readonly Project[], sessions: readonly SessionSummary[]): {
|
|
142
|
+
groups: ProjectGroup[];
|
|
143
|
+
unsorted: SessionSummary[];
|
|
144
|
+
};
|
|
145
|
+
/** Which project form is open: a new project, or renaming one. */
|
|
146
|
+
type Editing = {
|
|
147
|
+
kind: 'new';
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'rename';
|
|
150
|
+
projectId: string;
|
|
151
|
+
} | null;
|
|
152
|
+
/**
|
|
153
|
+
* The agent's projects with their sessions: new project, rename, delete (its sessions stay), new
|
|
154
|
+
* session in a project, move a session, delete a session. Projects live on the agent, so the terminal
|
|
155
|
+
* and every app see the same ones.
|
|
156
|
+
*/
|
|
157
|
+
export declare class AiProjectsComponent {
|
|
158
|
+
readonly client: import("@angular/core").InputSignal<AgentClient>;
|
|
159
|
+
/** Shown under the heading. */
|
|
160
|
+
readonly agentName: import("@angular/core").InputSignal<string>;
|
|
161
|
+
/** Session links point at sessionPath + id; a plain click emits open instead, for the app's router. */
|
|
162
|
+
readonly sessionPath: import("@angular/core").InputSignal<string>;
|
|
163
|
+
/** A session to open: an existing one clicked, or a new one just created. */
|
|
164
|
+
readonly open: import("@angular/core").OutputEmitterRef<string>;
|
|
165
|
+
private readonly confirm;
|
|
166
|
+
private readonly translate;
|
|
167
|
+
protected readonly projects: import("@angular/core").WritableSignal<Project[] | null>;
|
|
168
|
+
protected readonly sessions: import("@angular/core").WritableSignal<SessionSummary[] | null>;
|
|
169
|
+
protected readonly loadError: import("@angular/core").WritableSignal<string | null>;
|
|
170
|
+
protected readonly actionError: import("@angular/core").WritableSignal<string | null>;
|
|
171
|
+
/** The project a new session is being created in ('' for none). */
|
|
172
|
+
protected readonly creatingIn: import("@angular/core").WritableSignal<string | null>;
|
|
173
|
+
protected readonly saving: import("@angular/core").WritableSignal<boolean>;
|
|
174
|
+
protected readonly editing: import("@angular/core").WritableSignal<Editing>;
|
|
175
|
+
protected readonly renamingId: import("@angular/core").Signal<string | null>;
|
|
176
|
+
protected readonly loading: import("@angular/core").Signal<boolean>;
|
|
177
|
+
protected readonly grouped: import("@angular/core").Signal<{
|
|
178
|
+
groups: ProjectGroup[];
|
|
179
|
+
unsorted: SessionSummary[];
|
|
180
|
+
}>;
|
|
181
|
+
protected readonly empty: import("@angular/core").Signal<boolean>;
|
|
182
|
+
private readonly nameModel;
|
|
183
|
+
protected readonly nameForm: import("@angular/forms/signals").FieldTree<{
|
|
184
|
+
name: string;
|
|
185
|
+
}, string | number, "writable">;
|
|
186
|
+
constructor();
|
|
187
|
+
/** Reads projects and sessions again, for example after a turn or a change elsewhere. */
|
|
188
|
+
reload(): Promise<void>;
|
|
189
|
+
protected startNew(): void;
|
|
190
|
+
protected startRename(project: Project): void;
|
|
191
|
+
protected cancelEdit(): void;
|
|
192
|
+
protected saveName(event: SubmitEvent): Promise<void>;
|
|
193
|
+
protected remove(project: Project): void;
|
|
194
|
+
protected removeSession(session: SessionSummary): void;
|
|
195
|
+
/** Creates a session on the agent, in the project, and opens it. */
|
|
196
|
+
protected newSession(projectId: string | null): Promise<void>;
|
|
197
|
+
protected move(session: SessionSummary, event: Event): void;
|
|
198
|
+
protected openLink(id: string, event: MouseEvent): void;
|
|
199
|
+
protected t(text: string): string;
|
|
200
|
+
protected sessionCount(count: number): string;
|
|
201
|
+
protected messages(count: number): string;
|
|
202
|
+
private run;
|
|
203
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiProjectsComponent, never>;
|
|
204
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AiProjectsComponent, "ai-projects", never, {
|
|
205
|
+
"client": {
|
|
206
|
+
"alias": "client";
|
|
207
|
+
"required": true;
|
|
208
|
+
"isSignal": true;
|
|
209
|
+
};
|
|
210
|
+
"agentName": {
|
|
211
|
+
"alias": "agentName";
|
|
212
|
+
"required": false;
|
|
213
|
+
"isSignal": true;
|
|
214
|
+
};
|
|
215
|
+
"sessionPath": {
|
|
216
|
+
"alias": "sessionPath";
|
|
217
|
+
"required": false;
|
|
218
|
+
"isSignal": true;
|
|
219
|
+
};
|
|
220
|
+
}, {
|
|
221
|
+
"open": "open";
|
|
222
|
+
}, never, never, true, never>;
|
|
223
|
+
}
|
|
224
|
+
interface ConnectModel {
|
|
225
|
+
url: string;
|
|
226
|
+
token: string;
|
|
227
|
+
}
|
|
228
|
+
/** A full http(s) address, or a path on this site such as /agents/my-agent. */
|
|
229
|
+
export declare function isAgentAddress(value: string): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Connects to an agent with its address and token (checked with GET /v1/info), then shows the agent,
|
|
232
|
+
* its model and its tools. Put a hint on how to start the agent inside the element.
|
|
233
|
+
*/
|
|
234
|
+
export declare class AiConnectComponent {
|
|
235
|
+
/** Ask for a token. Turn off for agents behind a server that authorizes another way. */
|
|
236
|
+
readonly tokenRequired: import("@angular/core").InputSignal<boolean>;
|
|
237
|
+
/** The agent answered; it is now AiAgentStore.client(). */
|
|
238
|
+
readonly connected: import("@angular/core").OutputEmitterRef<AgentInfo>;
|
|
239
|
+
/** "Open projects" on the connected card. */
|
|
240
|
+
readonly continue: import("@angular/core").OutputEmitterRef<void>;
|
|
241
|
+
protected readonly agent: AiAgentStore;
|
|
242
|
+
protected readonly error: import("@angular/core").WritableSignal<string | null>;
|
|
243
|
+
protected readonly busy: import("@angular/core").WritableSignal<boolean>;
|
|
244
|
+
private readonly model;
|
|
245
|
+
protected readonly connectForm: import("@angular/forms/signals").FieldTree<ConnectModel, string | number, "writable">;
|
|
246
|
+
protected connect(event: SubmitEvent): Promise<void>;
|
|
247
|
+
protected change(): void;
|
|
248
|
+
protected forget(): void;
|
|
249
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiConnectComponent, never>;
|
|
250
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AiConnectComponent, "ai-connect", never, {
|
|
251
|
+
"tokenRequired": {
|
|
252
|
+
"alias": "tokenRequired";
|
|
253
|
+
"required": false;
|
|
254
|
+
"isSignal": true;
|
|
255
|
+
};
|
|
256
|
+
}, {
|
|
257
|
+
"connected": "connected";
|
|
258
|
+
"continue": "continue";
|
|
259
|
+
}, never, ["*"], true, never>;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Ukrainian for every English string the ai-ngx components show. Merge it into the app's translations:
|
|
263
|
+
* provideTranslate({ translations: { ua: { ...AI_NGX_UA, ...ua }, en: {} } }).
|
|
264
|
+
*/
|
|
265
|
+
export declare const AI_NGX_UA: Readonly<Record<string, string>>;
|
|
266
|
+
export type { AiAgentConfig, ProjectGroup };
|