@d4y/agent-runtime-nuxt 0.1.0 → 0.1.2

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.
Files changed (48) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/frontend.d.ts +5 -0
  3. package/dist/runtime/frontend.js +14 -0
  4. package/dist/runtime/server/api/app.get.d.ts +10 -1
  5. package/dist/runtime/server/api/app.get.js +1 -0
  6. package/dist/runtime/server/api/conversations/[id]/abort.post.d.ts +1 -1
  7. package/dist/runtime/server/api/conversations/[id]/abort.post.js +1 -0
  8. package/dist/runtime/server/api/conversations/[id]/env.post.d.ts +1 -1
  9. package/dist/runtime/server/api/conversations/[id]/env.post.js +1 -0
  10. package/dist/runtime/server/api/conversations/[id]/files/raw/[...path].get.d.ts +1 -1
  11. package/dist/runtime/server/api/conversations/[id]/files/raw/[...path].get.js +2 -0
  12. package/dist/runtime/server/api/conversations/[id]/files.get.d.ts +3 -1
  13. package/dist/runtime/server/api/conversations/[id]/files.get.js +1 -0
  14. package/dist/runtime/server/api/conversations/[id]/history.get.d.ts +1 -1
  15. package/dist/runtime/server/api/conversations/[id]/history.get.js +1 -0
  16. package/dist/runtime/server/api/conversations/[id]/messages.post.d.ts +1 -1
  17. package/dist/runtime/server/api/conversations/[id]/messages.post.js +1 -0
  18. package/dist/runtime/server/api/conversations/[id]/stream.get.d.ts +1 -1
  19. package/dist/runtime/server/api/conversations/[id]/stream.get.js +1 -0
  20. package/dist/runtime/server/api/conversations/[id].delete.d.ts +1 -1
  21. package/dist/runtime/server/api/conversations/[id].delete.js +1 -0
  22. package/dist/runtime/server/api/conversations.post.d.ts +1 -1
  23. package/dist/runtime/server/api/conversations.post.js +1 -0
  24. package/dist/runtime/server/utils/agent-runtime.d.ts +1 -1
  25. package/dist/runtime/server/utils/agent-runtime.js +3 -1
  26. package/dist/runtime/shared.d.ts +16 -0
  27. package/dist/runtime/shared.js +22 -0
  28. package/package.json +23 -12
  29. package/src/frontend.ts +0 -16
  30. package/src/module.ts +0 -155
  31. package/src/nitro-globals.d.ts +0 -8
  32. package/src/runtime/components/AgentRuntimeArtifactPreview.vue +0 -192
  33. package/src/runtime/composables/useAgentRuntime.ts +0 -527
  34. package/src/runtime/composables/useAgentRuntimeMarkdown.ts +0 -145
  35. package/src/runtime/server/api/app.get.ts +0 -50
  36. package/src/runtime/server/api/conversations/[id]/abort.post.ts +0 -26
  37. package/src/runtime/server/api/conversations/[id]/env.post.ts +0 -34
  38. package/src/runtime/server/api/conversations/[id]/files/raw/[...path].get.ts +0 -48
  39. package/src/runtime/server/api/conversations/[id]/files.get.ts +0 -33
  40. package/src/runtime/server/api/conversations/[id]/history.get.ts +0 -20
  41. package/src/runtime/server/api/conversations/[id]/messages.post.ts +0 -29
  42. package/src/runtime/server/api/conversations/[id]/stream.get.ts +0 -41
  43. package/src/runtime/server/api/conversations/[id].delete.ts +0 -22
  44. package/src/runtime/server/api/conversations.post.ts +0 -26
  45. package/src/runtime/server/utils/agent-runtime.ts +0 -33
  46. package/src/runtime/utils/files.ts +0 -78
  47. package/src/shared.ts +0 -46
  48. package/src/vue-shim.d.ts +0 -6
@@ -1,192 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, onBeforeUnmount, ref, watch } from 'vue'
3
- import { getAgentRuntimeFilePreviewKind, type AgentRuntimeFileLike } from '../utils/files'
4
-
5
- const props = withDefaults(defineProps<{
6
- file: AgentRuntimeFileLike
7
- src?: string | null
8
- resolveSrc?: ((relPath: string) => string | null | undefined) | null
9
- textMaxChars?: number
10
- }>(), {
11
- src: null,
12
- resolveSrc: null,
13
- textMaxChars: 120_000,
14
- })
15
-
16
- const kind = computed(() => getAgentRuntimeFilePreviewKind(props.file))
17
- const resolvedSrc = computed(() => {
18
- if (props.src) {
19
- return props.src
20
- }
21
-
22
- if (!props.file.relPath || !props.resolveSrc) {
23
- return null
24
- }
25
-
26
- return props.resolveSrc(props.file.relPath) ?? null
27
- })
28
-
29
- const textContent = ref('')
30
- const textError = ref<string | null>(null)
31
- const textLoading = ref(false)
32
- let textAbortController: AbortController | null = null
33
-
34
- const abortTextLoad = () => {
35
- textAbortController?.abort()
36
- textAbortController = null
37
- }
38
-
39
- const loadTextPreview = async () => {
40
- abortTextLoad()
41
- textContent.value = ''
42
- textError.value = null
43
-
44
- if (kind.value !== 'text' || !resolvedSrc.value) {
45
- textLoading.value = false
46
- return
47
- }
48
-
49
- const controller = new AbortController()
50
- textAbortController = controller
51
- textLoading.value = true
52
-
53
- try {
54
- const response = await fetch(resolvedSrc.value, {
55
- signal: controller.signal,
56
- })
57
-
58
- if (!response.ok) {
59
- throw new Error(`Failed to load preview (${response.status})`)
60
- }
61
-
62
- const body = await response.text()
63
- textContent.value =
64
- body.length > props.textMaxChars
65
- ? `${body.slice(0, props.textMaxChars).trimEnd()}\n\n…`
66
- : body
67
- } catch (error) {
68
- if (controller.signal.aborted) {
69
- return
70
- }
71
-
72
- textError.value = error instanceof Error ? error.message : 'Failed to load preview'
73
- } finally {
74
- if (textAbortController === controller) {
75
- textAbortController = null
76
- }
77
- textLoading.value = false
78
- }
79
- }
80
-
81
- watch([kind, resolvedSrc], () => {
82
- void loadTextPreview()
83
- }, { immediate: true })
84
-
85
- onBeforeUnmount(() => {
86
- abortTextLoad()
87
- })
88
- </script>
89
-
90
- <template>
91
- <div class="agent-runtime-artifact-preview">
92
- <img
93
- v-if="kind === 'image' && resolvedSrc"
94
- :src="resolvedSrc"
95
- :alt="file.name ?? file.relPath ?? 'Preview image'"
96
- class="agent-runtime-artifact-preview__image">
97
-
98
- <iframe
99
- v-else-if="kind === 'pdf' && resolvedSrc"
100
- :src="resolvedSrc"
101
- :title="file.name ?? file.relPath ?? 'PDF preview'"
102
- class="agent-runtime-artifact-preview__frame" />
103
-
104
- <div v-else-if="kind === 'text'" class="agent-runtime-artifact-preview__text-shell">
105
- <div v-if="textLoading" class="agent-runtime-artifact-preview__note">
106
- Loading preview…
107
- </div>
108
- <div v-else-if="textError" class="agent-runtime-artifact-preview__note agent-runtime-artifact-preview__note--error">
109
- {{ textError }}
110
- </div>
111
- <pre v-else class="agent-runtime-artifact-preview__text">{{ textContent }}</pre>
112
- </div>
113
-
114
- <div v-else class="agent-runtime-artifact-preview__fallback">
115
- <p class="agent-runtime-artifact-preview__note">
116
- Preview unavailable for this file type.
117
- </p>
118
- <a
119
- v-if="resolvedSrc"
120
- :href="resolvedSrc"
121
- target="_blank"
122
- rel="noopener noreferrer"
123
- class="agent-runtime-artifact-preview__link">
124
- Open file
125
- </a>
126
- </div>
127
- </div>
128
- </template>
129
-
130
- <style scoped>
131
- .agent-runtime-artifact-preview {
132
- display: block;
133
- width: 100%;
134
- min-height: 12rem;
135
- }
136
-
137
- .agent-runtime-artifact-preview__image,
138
- .agent-runtime-artifact-preview__frame {
139
- display: block;
140
- width: 100%;
141
- border: 0;
142
- border-radius: 0.875rem;
143
- background: rgba(15, 23, 42, 0.04);
144
- }
145
-
146
- .agent-runtime-artifact-preview__image {
147
- max-height: min(70vh, 48rem);
148
- object-fit: contain;
149
- }
150
-
151
- .agent-runtime-artifact-preview__frame {
152
- min-height: min(78vh, 52rem);
153
- }
154
-
155
- .agent-runtime-artifact-preview__text-shell,
156
- .agent-runtime-artifact-preview__fallback {
157
- min-height: 18rem;
158
- border-radius: 0.875rem;
159
- border: 1px solid rgba(15, 23, 42, 0.1);
160
- background: rgba(15, 23, 42, 0.03);
161
- }
162
-
163
- .agent-runtime-artifact-preview__text {
164
- margin: 0;
165
- max-height: min(72vh, 52rem);
166
- overflow: auto;
167
- padding: 1rem;
168
- font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
169
- font-size: 0.8rem;
170
- line-height: 1.55;
171
- white-space: pre-wrap;
172
- word-break: break-word;
173
- }
174
-
175
- .agent-runtime-artifact-preview__note {
176
- padding: 1rem;
177
- font-size: 0.875rem;
178
- color: rgba(15, 23, 42, 0.72);
179
- }
180
-
181
- .agent-runtime-artifact-preview__note--error {
182
- color: rgb(185, 28, 28);
183
- }
184
-
185
- .agent-runtime-artifact-preview__link {
186
- display: inline-flex;
187
- margin: 0 1rem 1rem;
188
- color: inherit;
189
- text-decoration: underline;
190
- text-underline-offset: 0.18em;
191
- }
192
- </style>