@jskit-ai/assistant-runtime 0.1.193 → 0.1.194
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/fixtures/canonical-conversation/App.vue +188 -0
- package/fixtures/canonical-conversation/DraftConversation.vue +32 -0
- package/fixtures/canonical-conversation/index.html +1 -0
- package/fixtures/canonical-conversation/main.js +61 -0
- package/fixtures/canonical-conversation/socket.js +50 -0
- package/fixtures/canonical-conversation/vite.config.mjs +178 -0
- package/fixtures/conversation/vite.config.mjs +12 -2
- package/package.json +23 -10
- package/src/client/components/AssistantConversationClientElement.vue +57 -0
- package/src/client/composables/useAssistantConversation.js +874 -0
- package/src/client/index.js +2 -0
- package/src/client/support/assistantRuntimeState.js +1 -1
- package/src/client/support/subscribeAssistantConversation.js +205 -0
- package/src/server/AssistantProvider.js +82 -106
- package/src/server/actionIds.js +10 -0
- package/src/server/actions.js +287 -79
- package/src/server/createAssistantRuntime.js +138 -0
- package/src/server/createAssistantSettingsActions.js +89 -0
- package/src/server/index.js +6 -0
- package/src/server/inputSchemas.js +90 -0
- package/src/server/registerConversationSubscriptions.js +163 -0
- package/src/server/registerFastifyConversations.js +76 -0
- package/src/server/registerRoutes.js +220 -198
- package/src/server/registerSettingsRoutes.js +113 -0
- package/src/server/repositories/conversationsRepository.js +12 -5
- package/src/server/repositories/messagesRepository.js +12 -0
- package/src/server/services/chatService.js +88 -694
- package/src/server/services/transcriptService.js +56 -52
- package/src/server/sqlConversationStorage.js +192 -0
- package/src/server/support/assistantRouteContext.js +91 -0
- package/src/server/support/createSurfaceAwareToolCatalog.js +6 -2
- package/src/shared/assistantSurfaces.js +14 -0
- package/src/shared/conversationRealtime.js +9 -0
- package/src/shared/index.js +1 -0
- package/test/actionDefinitions.test.js +44 -0
- package/test/aiConnections.test.js +1 -1
- package/test/assistantConversationBinding.browser.test.js +1868 -0
- package/test/assistantConversationOperations.test.js +459 -0
- package/test/assistantConversationSubscriptions.test.js +692 -0
- package/test/assistantIntegrationBoundary.test.js +103 -0
- package/test/assistantRuntimeComposition.test.js +68 -0
- package/test/assistantSurfacePattern.test.js +1 -1
- package/test/assistantSurfaces.test.js +23 -0
- package/test/chatServiceLifecycle.test.js +12 -1
- package/test/featureRuntime.test.js +238 -0
- package/test/registerFastifyConversations.test.js +169 -0
- package/test/sqlConversationStorage.test.js +205 -0
- package/test/support/memoryAssistantRows.js +51 -0
- package/test/turnRequests.test.js +11 -2
- package/src/shared/assistantResponseText.js +0 -29
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, toRef } from "vue";
|
|
3
|
+
import { AssistantConversationElement } from "@jskit-ai/assistant-core/client/conversation";
|
|
4
|
+
import { useAssistantConversation } from "../composables/useAssistantConversation.js";
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
conversationId: { type: String, required: true },
|
|
8
|
+
endpoint: { type: String, default: "" },
|
|
9
|
+
surfaceId: { type: String, default: "" },
|
|
10
|
+
hostSurfaceId: { type: String, default: "" },
|
|
11
|
+
workspaceSlug: { type: String, default: undefined },
|
|
12
|
+
actorKey: { type: String, default: undefined },
|
|
13
|
+
api: { type: Object, default: null },
|
|
14
|
+
active: { type: Boolean, default: true },
|
|
15
|
+
clearDraftOn: { type: String, default: undefined, validator: value => ["dispatch", "accepted"].includes(value) },
|
|
16
|
+
assistantLabel: { type: String, default: "Assistant" },
|
|
17
|
+
welcomeMessage: { type: String, default: "What would you like to do?" },
|
|
18
|
+
placeholder: { type: String, default: "Message the assistant…" },
|
|
19
|
+
layout: { type: String, default: "compact", validator: value => ["page", "compact"].includes(value) },
|
|
20
|
+
data: { type: Object, default: undefined },
|
|
21
|
+
attachments: { type: Object, default: null },
|
|
22
|
+
suggestions: { type: Object, default: null },
|
|
23
|
+
models: { type: Object, default: null },
|
|
24
|
+
questions: { type: [Boolean, Object], default: null },
|
|
25
|
+
goal: { type: [Boolean, Object], default: null }
|
|
26
|
+
});
|
|
27
|
+
const binding = useAssistantConversation({
|
|
28
|
+
conversationId: toRef(props, "conversationId"), endpoint: toRef(props, "endpoint"),
|
|
29
|
+
surfaceId: toRef(props, "surfaceId"), hostSurfaceId: toRef(props, "hostSurfaceId"),
|
|
30
|
+
workspaceSlug: () => props.workspaceSlug, active: toRef(props, "active"),
|
|
31
|
+
actorKey: toRef(props, "actorKey"), api: props.api, clearDraftOn: props.clearDraftOn,
|
|
32
|
+
data: toRef(props, "data"),
|
|
33
|
+
attachments: toRef(props, "attachments"), suggestions: toRef(props, "suggestions"), models: toRef(props, "models"),
|
|
34
|
+
questions: toRef(props, "questions"), goal: toRef(props, "goal"),
|
|
35
|
+
presentation: computed(() => ({ assistantLabel: props.assistantLabel, welcomeMessage: props.welcomeMessage,
|
|
36
|
+
placeholder: props.placeholder, layout: props.layout }))
|
|
37
|
+
});
|
|
38
|
+
const conversation = ref(null);
|
|
39
|
+
defineExpose({ focus: () => conversation.value?.focus(), runtime: binding.runtime });
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<AssistantConversationElement ref="conversation" :adapter="binding.adapter.value" :label="assistantLabel" class="assistant-client-conversation">
|
|
44
|
+
<template v-for="name in Object.keys($slots).filter(name => name !== 'composer-feedback')" #[name]="scope">
|
|
45
|
+
<slot :name="name" v-bind="scope" :runtime="binding.runtime.value" />
|
|
46
|
+
</template>
|
|
47
|
+
<template #composer-feedback>
|
|
48
|
+
<p v-if="binding.error.value" role="status" class="assistant-client-conversation__error">{{ binding.error.value }}</p>
|
|
49
|
+
<slot name="composer-feedback" :runtime="binding.runtime.value" />
|
|
50
|
+
</template>
|
|
51
|
+
</AssistantConversationElement>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<style scoped>
|
|
55
|
+
.assistant-client-conversation { flex: 1 1 auto; height: 100%; min-height: 0; min-width: 0; }
|
|
56
|
+
.assistant-client-conversation__error { color: rgb(var(--v-theme-error)); font-size: .85rem; margin: .25rem 0; overflow-wrap: anywhere; }
|
|
57
|
+
</style>
|