@drewswiredin/backstage-plugin-assistants 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 +201 -0
- package/README.md +113 -0
- package/dist/alpha.d.ts +64 -0
- package/dist/alpha.esm.js +35 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/api/AssistantsApi.esm.js +55 -0
- package/dist/api/AssistantsApi.esm.js.map +1 -0
- package/dist/collapsible/AssistantDetailDialog.esm.js +209 -0
- package/dist/collapsible/AssistantDetailDialog.esm.js.map +1 -0
- package/dist/collapsible/AssistantsList.esm.js +119 -0
- package/dist/collapsible/AssistantsList.esm.js.map +1 -0
- package/dist/collapsible/CollapsiblePage.esm.js +724 -0
- package/dist/collapsible/CollapsiblePage.esm.js.map +1 -0
- package/dist/collapsible/ConversationsPanel.esm.js +198 -0
- package/dist/collapsible/ConversationsPanel.esm.js.map +1 -0
- package/dist/collapsible/FullHeightRegion.esm.js +54 -0
- package/dist/collapsible/FullHeightRegion.esm.js.map +1 -0
- package/dist/collapsible/SidePane.esm.js +89 -0
- package/dist/collapsible/SidePane.esm.js.map +1 -0
- package/dist/collapsible/surface/AssistantAvatar.esm.js +98 -0
- package/dist/collapsible/surface/AssistantAvatar.esm.js.map +1 -0
- package/dist/collapsible/surface/BackstageLogo.esm.js +24 -0
- package/dist/collapsible/surface/BackstageLogo.esm.js.map +1 -0
- package/dist/collapsible/surface/ConversationSurface.esm.js +268 -0
- package/dist/collapsible/surface/ConversationSurface.esm.js.map +1 -0
- package/dist/collapsible/surface/MarkdownText.esm.js +24 -0
- package/dist/collapsible/surface/MarkdownText.esm.js.map +1 -0
- package/dist/collapsible/surface/MermaidDiagram.esm.js +245 -0
- package/dist/collapsible/surface/MermaidDiagram.esm.js.map +1 -0
- package/dist/collapsible/surface/parts.esm.js +216 -0
- package/dist/collapsible/surface/parts.esm.js.map +1 -0
- package/dist/collapsible/surface/styles/assistant-ui-markdown.css.esm.js +5 -0
- package/dist/collapsible/surface/styles/assistant-ui-markdown.css.esm.js.map +1 -0
- package/dist/collapsible/surface/styles/assistant-ui.css.esm.js +5 -0
- package/dist/collapsible/surface/styles/assistant-ui.css.esm.js.map +1 -0
- package/dist/collapsible/unreadStore.esm.js +79 -0
- package/dist/collapsible/unreadStore.esm.js.map +1 -0
- package/dist/collapsible/useConversations.esm.js +171 -0
- package/dist/collapsible/useConversations.esm.js.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.esm.js +3 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js +29 -0
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -0
- package/dist/routes.esm.js +8 -0
- package/dist/routes.esm.js.map +1 -0
- package/package.json +107 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 drewswiredin
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @drewswiredin/backstage-plugin-assistants
|
|
2
|
+
|
|
3
|
+
AI Assistants for Backstage — a polished, configurable chat experience for your
|
|
4
|
+
developer portal. Define one or more assistants in `app-config.yaml` (each with
|
|
5
|
+
its own prompt, tools, models, access policy, and color); users chat with them
|
|
6
|
+
in a collapsible, multi-conversation UI with streaming responses, tool calls,
|
|
7
|
+
Markdown/Mermaid rendering, per-conversation model selection, and background
|
|
8
|
+
(concurrent) conversations with unread indicators.
|
|
9
|
+
|
|
10
|
+
This is the **frontend** plugin (new frontend system). It pairs with:
|
|
11
|
+
|
|
12
|
+
- [`@drewswiredin/backstage-plugin-assistants-backend`](https://www.npmjs.com/package/@drewswiredin/backstage-plugin-assistants-backend) — the backend (required)
|
|
13
|
+
- [`@drewswiredin/backstage-plugin-assistants-common`](https://www.npmjs.com/package/@drewswiredin/backstage-plugin-assistants-common) — shared types (installed transitively)
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Backstage running the **new frontend system** (`@backstage/frontend-defaults` /
|
|
18
|
+
`createApp`) and the **new backend system** (`@backstage/backend-defaults`).
|
|
19
|
+
- A model provider and API key (e.g. an [OpenRouter](https://openrouter.ai) key,
|
|
20
|
+
or any OpenAI-compatible / OpenAI / Anthropic / Azure endpoint).
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
From your Backstage repo root:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# in the app package
|
|
28
|
+
yarn --cwd packages/app add @drewswiredin/backstage-plugin-assistants
|
|
29
|
+
|
|
30
|
+
# in the backend package
|
|
31
|
+
yarn --cwd packages/backend add @drewswiredin/backstage-plugin-assistants-backend
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
(The `-common` package is pulled in transitively; you don't add it directly.)
|
|
35
|
+
|
|
36
|
+
## Wire up the frontend
|
|
37
|
+
|
|
38
|
+
Add the plugin to your app's features. Its **"Assistants" nav item is registered
|
|
39
|
+
automatically** — no extra nav code needed.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// packages/app/src/App.tsx
|
|
43
|
+
import { createApp } from '@backstage/frontend-defaults';
|
|
44
|
+
import assistantsPlugin from '@drewswiredin/backstage-plugin-assistants/alpha';
|
|
45
|
+
|
|
46
|
+
export default createApp({
|
|
47
|
+
features: [
|
|
48
|
+
assistantsPlugin,
|
|
49
|
+
// ...your other features
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The page mounts at `/assistants`.
|
|
55
|
+
|
|
56
|
+
> Using a custom `NavContentBlueprint` to lay out your sidebar? The plugin's nav
|
|
57
|
+
> entry has the id `page:assistants` — `take()` it to place it yourself.
|
|
58
|
+
|
|
59
|
+
## Wire up the backend
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// packages/backend/src/index.ts
|
|
63
|
+
backend.add(import('@drewswiredin/backstage-plugin-assistants-backend'));
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Configure
|
|
67
|
+
|
|
68
|
+
Add an `assistants` block to `app-config.yaml`. Minimal working example
|
|
69
|
+
(OpenRouter + one assistant open to all signed-in users, with the built-in
|
|
70
|
+
catalog/TechDocs read tools):
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
assistants:
|
|
74
|
+
defaultModel: openrouter:google/gemini-2.5-flash
|
|
75
|
+
registerCoreActions: true # registers the built-in search/read tools
|
|
76
|
+
providers:
|
|
77
|
+
openrouter:
|
|
78
|
+
type: openai-compatible
|
|
79
|
+
apiKey: ${OPENROUTER_API_KEY}
|
|
80
|
+
baseUrl: https://openrouter.ai/api/v1
|
|
81
|
+
models:
|
|
82
|
+
- google/gemini-2.5-flash
|
|
83
|
+
profiles:
|
|
84
|
+
general:
|
|
85
|
+
title: General Assistant
|
|
86
|
+
description: Catalog + TechDocs helper for your developer portal.
|
|
87
|
+
prompt: |
|
|
88
|
+
You are a Backstage developer-portal assistant. Use your tools to look
|
|
89
|
+
up systems, services, teams, APIs, and documentation before answering.
|
|
90
|
+
access:
|
|
91
|
+
allowAuthenticated: true
|
|
92
|
+
actions:
|
|
93
|
+
- search-catalog
|
|
94
|
+
- search-techdocs
|
|
95
|
+
- read-techdocs
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Set the key in your environment (never commit it):
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
export OPENROUTER_API_KEY=sk-or-...
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
See the
|
|
105
|
+
[backend README](https://www.npmjs.com/package/@drewswiredin/backstage-plugin-assistants-backend)
|
|
106
|
+
for the full configuration reference (providers, per-assistant access policies,
|
|
107
|
+
model allowlists, additional tools, and UI options). Tool/action availability
|
|
108
|
+
depends on which action-providing plugins are installed in your backend; the
|
|
109
|
+
three tools above are provided by `registerCoreActions`.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
Apache-2.0
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
3
|
+
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The Backstage AI Assistants frontend plugin (new frontend system).
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin<{
|
|
11
|
+
root: _backstage_core_plugin_api.RouteRef<undefined>;
|
|
12
|
+
}, {}, {
|
|
13
|
+
"api:assistants": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
|
|
14
|
+
kind: "api";
|
|
15
|
+
name: undefined;
|
|
16
|
+
config: {};
|
|
17
|
+
configInput: {};
|
|
18
|
+
output: _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.AnyApiFactory, "core.api.factory", {}>;
|
|
19
|
+
inputs: {};
|
|
20
|
+
params: <TApi, TImpl extends TApi, TDeps extends { [name in string]: unknown; }>(params: _backstage_frontend_plugin_api.ApiFactory<TApi, TImpl, TDeps>) => _backstage_frontend_plugin_api.ExtensionBlueprintParams<_backstage_frontend_plugin_api.AnyApiFactory>;
|
|
21
|
+
}>;
|
|
22
|
+
"page:assistants": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
|
|
23
|
+
kind: "page";
|
|
24
|
+
name: undefined;
|
|
25
|
+
config: {
|
|
26
|
+
path: string | undefined;
|
|
27
|
+
title: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
configInput: {
|
|
30
|
+
path?: string | undefined;
|
|
31
|
+
title?: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
output: _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
|
|
34
|
+
optional: true;
|
|
35
|
+
}> | _backstage_frontend_plugin_api.ExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.title", {
|
|
36
|
+
optional: true;
|
|
37
|
+
}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.IconElement, "core.icon", {
|
|
38
|
+
optional: true;
|
|
39
|
+
}>;
|
|
40
|
+
inputs: {
|
|
41
|
+
pages: _backstage_frontend_plugin_api.ExtensionInput<_backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
|
|
42
|
+
optional: true;
|
|
43
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.title", {
|
|
44
|
+
optional: true;
|
|
45
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_frontend_plugin_api.IconElement, "core.icon", {
|
|
46
|
+
optional: true;
|
|
47
|
+
}>, {
|
|
48
|
+
singleton: false;
|
|
49
|
+
optional: false;
|
|
50
|
+
internal: false;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
params: {
|
|
54
|
+
path: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
icon?: _backstage_frontend_plugin_api.IconElement;
|
|
57
|
+
loader?: () => Promise<react.JSX.Element>;
|
|
58
|
+
routeRef?: _backstage_frontend_plugin_api.RouteRef;
|
|
59
|
+
noHeader?: boolean;
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
}>;
|
|
63
|
+
|
|
64
|
+
export { _default as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ApiBlueprint, fetchApiRef, discoveryApiRef, PageBlueprint, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
3
|
+
import { RiRobot2Line } from '@remixicon/react';
|
|
4
|
+
import { rootRouteRef } from './routes.esm.js';
|
|
5
|
+
import { AssistantsClient, assistantsApiRef } from './api/AssistantsApi.esm.js';
|
|
6
|
+
|
|
7
|
+
const assistantsApi = ApiBlueprint.make({
|
|
8
|
+
params: (defineParams) => defineParams({
|
|
9
|
+
api: assistantsApiRef,
|
|
10
|
+
deps: {
|
|
11
|
+
discoveryApi: discoveryApiRef,
|
|
12
|
+
fetchApi: fetchApiRef
|
|
13
|
+
},
|
|
14
|
+
factory: ({ discoveryApi, fetchApi }) => new AssistantsClient({ discoveryApi, fetchApi })
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
const assistantsPage = PageBlueprint.make({
|
|
18
|
+
params: {
|
|
19
|
+
path: "/assistants",
|
|
20
|
+
routeRef: rootRouteRef,
|
|
21
|
+
loader: () => import('./collapsible/CollapsiblePage.esm.js').then((m) => /* @__PURE__ */ jsx(m.CollapsiblePage, {}))
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var alpha = createFrontendPlugin({
|
|
25
|
+
pluginId: "assistants",
|
|
26
|
+
title: "Assistants",
|
|
27
|
+
icon: /* @__PURE__ */ jsx(RiRobot2Line, {}),
|
|
28
|
+
extensions: [assistantsApi, assistantsPage],
|
|
29
|
+
routes: {
|
|
30
|
+
root: rootRouteRef
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export { alpha as default };
|
|
35
|
+
//# sourceMappingURL=alpha.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["import {\n ApiBlueprint,\n createFrontendPlugin,\n discoveryApiRef,\n fetchApiRef,\n PageBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport { RiRobot2Line } from '@remixicon/react';\nimport { rootRouteRef } from './routes';\nimport { assistantsApiRef, AssistantsClient } from './api';\n\n/** Backend client (`/status`, `/title`, base url + authed fetch). */\nconst assistantsApi = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: assistantsApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) =>\n new AssistantsClient({ discoveryApi, fetchApi }),\n }),\n});\n\n/** The Assistants chat page (collapsible sidebar). Mounted at `/assistants`. */\nconst assistantsPage = PageBlueprint.make({\n params: {\n path: '/assistants',\n routeRef: rootRouteRef,\n loader: () =>\n import('./collapsible/CollapsiblePage').then(m => <m.CollapsiblePage />),\n },\n});\n\n/**\n * The Backstage AI Assistants frontend plugin (new frontend system).\n *\n * @public\n */\nexport default createFrontendPlugin({\n pluginId: 'assistants',\n title: 'Assistants',\n icon: <RiRobot2Line />,\n extensions: [assistantsApi, assistantsPage],\n routes: {\n root: rootRouteRef,\n },\n});\n"],"names":[],"mappings":";;;;;;AAYA,MAAM,aAAA,GAAgB,aAAa,IAAA,CAAK;AAAA,EACtC,MAAA,EAAQ,kBACN,YAAA,CAAa;AAAA,IACX,GAAA,EAAK,gBAAA;AAAA,IACL,IAAA,EAAM;AAAA,MACJ,YAAA,EAAc,eAAA;AAAA,MACd,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,QAAA,EAAS,KACjC,IAAI,gBAAA,CAAiB,EAAE,YAAA,EAAc,QAAA,EAAU;AAAA,GAClD;AACL,CAAC,CAAA;AAGD,MAAM,cAAA,GAAiB,cAAc,IAAA,CAAK;AAAA,EACxC,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,aAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,MACN,OAAO,sCAA+B,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAAK,GAAA,CAAC,CAAA,CAAE,eAAA,EAAF,EAAkB,CAAE;AAAA;AAE7E,CAAC,CAAA;AAOD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,YAAA;AAAA,EACV,KAAA,EAAO,YAAA;AAAA,EACP,IAAA,sBAAO,YAAA,EAAA,EAAa,CAAA;AAAA,EACpB,UAAA,EAAY,CAAC,aAAA,EAAe,cAAc,CAAA;AAAA,EAC1C,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA;AAEV,CAAC,CAAA;;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
|
|
3
|
+
const assistantsApiRef = createApiRef({
|
|
4
|
+
id: "plugin.assistants.client"
|
|
5
|
+
});
|
|
6
|
+
class AssistantsClient {
|
|
7
|
+
discoveryApi;
|
|
8
|
+
fetchApi;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.discoveryApi = options.discoveryApi;
|
|
11
|
+
this.fetchApi = options.fetchApi;
|
|
12
|
+
}
|
|
13
|
+
get fetch() {
|
|
14
|
+
return this.fetchApi.fetch.bind(this.fetchApi);
|
|
15
|
+
}
|
|
16
|
+
async getBaseUrl() {
|
|
17
|
+
return this.discoveryApi.getBaseUrl("assistants");
|
|
18
|
+
}
|
|
19
|
+
async getStatus() {
|
|
20
|
+
const baseUrl = await this.getBaseUrl();
|
|
21
|
+
const response = await this.fetchApi.fetch(`${baseUrl}/status`);
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
throw await this.toError(response);
|
|
24
|
+
}
|
|
25
|
+
return await response.json();
|
|
26
|
+
}
|
|
27
|
+
async getTitle(request) {
|
|
28
|
+
const baseUrl = await this.getBaseUrl();
|
|
29
|
+
const response = await this.fetchApi.fetch(`${baseUrl}/title`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: { "Content-Type": "application/json" },
|
|
32
|
+
body: JSON.stringify(request)
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw await this.toError(response);
|
|
36
|
+
}
|
|
37
|
+
const body = await response.json();
|
|
38
|
+
return typeof body.title === "string" && body.title ? body.title : "New Chat";
|
|
39
|
+
}
|
|
40
|
+
async toError(response) {
|
|
41
|
+
let detail = "";
|
|
42
|
+
try {
|
|
43
|
+
const body = await response.json();
|
|
44
|
+
detail = body?.error?.message ?? body?.message ?? "";
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
const suffix = detail ? `: ${detail}` : "";
|
|
48
|
+
return new Error(
|
|
49
|
+
`Request failed with ${response.status} ${response.statusText}${suffix}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { AssistantsClient, assistantsApiRef };
|
|
55
|
+
//# sourceMappingURL=AssistantsApi.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssistantsApi.esm.js","sources":["../../src/api/AssistantsApi.ts"],"sourcesContent":["import {\n createApiRef,\n DiscoveryApi,\n FetchApi,\n} from '@backstage/core-plugin-api';\nimport {\n AssistantId,\n ModelId,\n StatusResponse,\n} from '@drewswiredin/backstage-plugin-assistants-common';\n\n/**\n * Arguments for {@link AssistantsApi.getTitle}. Mirrors the backend `POST /title`\n * body (the shared `ChatRequest` schema): the assistant + model to title with\n * and the opening conversation messages.\n *\n * @public\n */\nexport interface GetTitleRequest {\n assistantId: AssistantId;\n modelId: ModelId;\n /** Opening UI messages; the backend builds the title prompt from these. */\n messages: unknown[];\n}\n\n/**\n * Client for the AI Assistants backend.\n *\n * Resolves the backend base URL via `discoveryApi.getBaseUrl('assistants')` and\n * issues authenticated requests via `fetchApi.fetch`. Components must never read\n * `config 'backend.baseUrl'` or fetch in-component — they go through this API.\n *\n * @public\n */\nexport interface AssistantsApi {\n /** Fetch the browser-safe plugin status (accessible assistants, models, default). */\n getStatus(): Promise<StatusResponse>;\n\n /**\n * Resolve the backend base URL (`.../api/assistants`). Used by the chat\n * transport to build the `/chat` and `/title` URLs.\n */\n getBaseUrl(): Promise<string>;\n\n /**\n * The authenticated `fetch`. The chat transport needs the raw authed fetch to\n * wire the AI SDK `DefaultChatTransport`.\n */\n fetch: typeof fetch;\n\n /**\n * Generate a short conversation title via the backend `POST /title`.\n * Best-effort by contract — the backend already falls back to a default title\n * on generation failure; callers should additionally tolerate a rejected\n * promise (network error) without breaking the conversation list.\n */\n getTitle(request: GetTitleRequest): Promise<string>;\n}\n\n/**\n * API ref for the AI Assistants backend client.\n *\n * @public\n */\nexport const assistantsApiRef = createApiRef<AssistantsApi>({\n id: 'plugin.assistants.client',\n});\n\n/**\n * Default {@link AssistantsApi} implementation backed by `discoveryApi` +\n * `fetchApi`.\n *\n * @public\n */\nexport class AssistantsClient implements AssistantsApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: { discoveryApi: DiscoveryApi; fetchApi: FetchApi }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n get fetch(): typeof fetch {\n // Bind so callers (e.g. the chat transport) can destructure/pass it freely\n // without losing the FetchApi `this` context.\n return this.fetchApi.fetch.bind(this.fetchApi);\n }\n\n async getBaseUrl(): Promise<string> {\n return this.discoveryApi.getBaseUrl('assistants');\n }\n\n async getStatus(): Promise<StatusResponse> {\n const baseUrl = await this.getBaseUrl();\n const response = await this.fetchApi.fetch(`${baseUrl}/status`);\n if (!response.ok) {\n throw await this.toError(response);\n }\n return (await response.json()) as StatusResponse;\n }\n\n async getTitle(request: GetTitleRequest): Promise<string> {\n const baseUrl = await this.getBaseUrl();\n const response = await this.fetchApi.fetch(`${baseUrl}/title`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(request),\n });\n if (!response.ok) {\n throw await this.toError(response);\n }\n const body = (await response.json()) as { title?: unknown };\n return typeof body.title === 'string' && body.title ? body.title : 'New Chat';\n }\n\n private async toError(response: Response): Promise<Error> {\n let detail = '';\n try {\n const body = await response.json();\n detail = body?.error?.message ?? body?.message ?? '';\n } catch {\n // non-JSON body; fall back to status text\n }\n const suffix = detail ? `: ${detail}` : '';\n return new Error(\n `Request failed with ${response.status} ${response.statusText}${suffix}`,\n );\n }\n}\n"],"names":[],"mappings":";;AAgEO,MAAM,mBAAmB,YAAA,CAA4B;AAAA,EAC1D,EAAA,EAAI;AACN,CAAC;AAQM,MAAM,gBAAA,CAA0C;AAAA,EACpC,YAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,OAAA,EAA6D;AACvE,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AAAA,EAC1B;AAAA,EAEA,IAAI,KAAA,GAAsB;AAGxB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,KAAK,QAAQ,CAAA;AAAA,EAC/C;AAAA,EAEA,MAAM,UAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,YAAA,CAAa,UAAA,CAAW,YAAY,CAAA;AAAA,EAClD;AAAA,EAEA,MAAM,SAAA,GAAqC;AACzC,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,UAAA,EAAW;AACtC,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,SAAS,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,OAAA,CAAS,CAAA;AAC9D,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,MAAM,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAAA,IACnC;AACA,IAAA,OAAQ,MAAM,SAAS,IAAA,EAAK;AAAA,EAC9B;AAAA,EAEA,MAAM,SAAS,OAAA,EAA2C;AACxD,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,UAAA,EAAW;AACtC,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,SAAS,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,MAAA,CAAA,EAAU;AAAA,MAC7D,MAAA,EAAQ,MAAA;AAAA,MACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,MAC9C,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,OAAO;AAAA,KAC7B,CAAA;AACD,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,MAAM,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAAA,IACnC;AACA,IAAA,MAAM,IAAA,GAAQ,MAAM,QAAA,CAAS,IAAA,EAAK;AAClC,IAAA,OAAO,OAAO,IAAA,CAAK,KAAA,KAAU,YAAY,IAAA,CAAK,KAAA,GAAQ,KAAK,KAAA,GAAQ,UAAA;AAAA,EACrE;AAAA,EAEA,MAAc,QAAQ,QAAA,EAAoC;AACxD,IAAA,IAAI,MAAA,GAAS,EAAA;AACb,IAAA,IAAI;AACF,MAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AACjC,MAAA,MAAA,GAAS,IAAA,EAAM,KAAA,EAAO,OAAA,IAAW,IAAA,EAAM,OAAA,IAAW,EAAA;AAAA,IACpD,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,MAAM,MAAA,GAAS,MAAA,GAAS,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,GAAK,EAAA;AACxC,IAAA,OAAO,IAAI,KAAA;AAAA,MACT,uBAAuB,QAAA,CAAS,MAAM,IAAI,QAAA,CAAS,UAAU,GAAG,MAAM,CAAA;AAAA,KACxE;AAAA,EACF;AACF;;;;"}
|