@d4y/agent-runtime-nuxt 0.1.4 → 0.1.8
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/dist/module.d.mts +15 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +9 -2
- package/dist/runtime/components/AgentRuntimeMarkdown.d.vue.ts +10 -0
- package/dist/runtime/components/AgentRuntimeMarkdown.vue +17 -7
- package/dist/runtime/components/AgentRuntimeMarkdown.vue.d.ts +10 -0
- package/dist/runtime/composables/useAgentRuntime.d.ts +118 -1
- package/dist/runtime/composables/useAgentRuntime.js +220 -44
- package/dist/runtime/composables/useAgentRuntimeMarkdown.d.ts +5 -0
- package/dist/runtime/composables/useAgentRuntimeMarkdown.js +11 -8
- package/dist/runtime/server/api/app.get.d.ts +3 -0
- package/dist/runtime/server/api/app.get.js +5 -3
- package/dist/runtime/server/api/conversations/[id]/abort.post.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/env.post.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/files/preview/[...path].get.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/files/raw/[...path].get.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/files.get.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/files.post.d.ts +2 -0
- package/dist/runtime/server/api/conversations/[id]/files.post.js +34 -0
- package/dist/runtime/server/api/conversations/[id]/history.get.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/messages.post.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/runs/[runId].get.d.ts +2 -0
- package/dist/runtime/server/api/conversations/[id]/runs/[runId].get.js +19 -0
- package/dist/runtime/server/api/conversations/[id]/runs.get.d.ts +2 -0
- package/dist/runtime/server/api/conversations/[id]/runs.get.js +17 -0
- package/dist/runtime/server/api/conversations/[id]/stream.get.js +1 -1
- package/dist/runtime/server/api/conversations/[id]/workflow.get.d.ts +2 -0
- package/dist/runtime/server/api/conversations/[id]/workflow.get.js +17 -0
- package/dist/runtime/server/api/conversations/[id]/workflows.post.d.ts +2 -0
- package/dist/runtime/server/api/conversations/[id]/workflows.post.js +27 -0
- package/dist/runtime/server/api/conversations/[id].delete.js +1 -1
- package/dist/runtime/server/api/conversations.post.js +9 -2
- package/dist/runtime/server/utils/agent-runtime.d.ts +2 -7
- package/dist/runtime/server/utils/agent-runtime.js +11 -3
- package/dist/runtime/shared.d.ts +6 -0
- package/dist/runtime/shared.js +8 -4
- package/dist/types.d.mts +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
import { agentRuntime } from "../../../utils/agent-runtime.js";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const cfg = agentRuntime(event);
|
|
5
|
+
const id = getRouterParam(event, "id");
|
|
6
|
+
if (!id) throw createError({ statusCode: 400, statusMessage: "missing conversation id" });
|
|
7
|
+
const response = await fetch(`${cfg.baseUrl}/v1/conversations/${id}/runs`, {
|
|
8
|
+
headers: { "X-Agent-Runtime-App-Key": cfg.appKey }
|
|
9
|
+
});
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
throw createError({
|
|
12
|
+
statusCode: response.status,
|
|
13
|
+
statusMessage: await response.text()
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return await response.json();
|
|
17
|
+
});
|
|
@@ -2,7 +2,7 @@ import { Readable } from "node:stream";
|
|
|
2
2
|
import { createError, defineEventHandler, getRouterParam, sendStream, setHeader } from "h3";
|
|
3
3
|
import { agentRuntime } from "../../../utils/agent-runtime.js";
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const cfg = agentRuntime();
|
|
5
|
+
const cfg = agentRuntime(event);
|
|
6
6
|
const id = getRouterParam(event, "id");
|
|
7
7
|
if (!id) throw createError({ statusCode: 400, statusMessage: "missing conversation id" });
|
|
8
8
|
const controller = new AbortController();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
import { agentRuntime } from "../../../utils/agent-runtime.js";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const cfg = agentRuntime(event);
|
|
5
|
+
const id = getRouterParam(event, "id");
|
|
6
|
+
if (!id) throw createError({ statusCode: 400, statusMessage: "missing conversation id" });
|
|
7
|
+
const response = await fetch(`${cfg.baseUrl}/v1/conversations/${id}/workflow`, {
|
|
8
|
+
headers: { "X-Agent-Runtime-App-Key": cfg.appKey }
|
|
9
|
+
});
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
throw createError({
|
|
12
|
+
statusCode: response.status,
|
|
13
|
+
statusMessage: await response.text()
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return await response.json();
|
|
17
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getRouterParam, readBody } from "h3";
|
|
2
|
+
import { agentRuntime, agentRuntimeHeaders } from "../../../utils/agent-runtime.js";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const cfg = agentRuntime(event);
|
|
5
|
+
const id = getRouterParam(event, "id");
|
|
6
|
+
if (!id) throw createError({ statusCode: 400, statusMessage: "missing conversation id" });
|
|
7
|
+
const body = await readBody(event);
|
|
8
|
+
if (!body?.workflow) throw createError({ statusCode: 400, statusMessage: "missing workflow" });
|
|
9
|
+
const response = await fetch(`${cfg.baseUrl}/v1/conversations/${id}/workflows`, {
|
|
10
|
+
method: "POST",
|
|
11
|
+
headers: agentRuntimeHeaders(cfg),
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
workflow: body.workflow,
|
|
14
|
+
initialPrompt: body.initialPrompt,
|
|
15
|
+
requestOptions: body.requestOptions,
|
|
16
|
+
language: body.language,
|
|
17
|
+
model: body.model
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw createError({
|
|
22
|
+
statusCode: response.status,
|
|
23
|
+
statusMessage: await response.text()
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return await response.json();
|
|
27
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getRouterParam, setResponseStatus } from "h3";
|
|
2
2
|
import { agentRuntime } from "../../utils/agent-runtime.js";
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
|
-
const cfg = agentRuntime();
|
|
4
|
+
const cfg = agentRuntime(event);
|
|
5
5
|
const id = getRouterParam(event, "id");
|
|
6
6
|
if (!id) throw createError({ statusCode: 400, statusMessage: "missing conversation id" });
|
|
7
7
|
const response = await fetch(`${cfg.baseUrl}/v1/conversations/${id}`, {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createError, defineEventHandler, readBody } from "h3";
|
|
2
2
|
import { agentRuntime, agentRuntimeHeaders } from "../utils/agent-runtime.js";
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
|
-
const cfg = agentRuntime();
|
|
5
4
|
const body = await readBody(event).catch(() => ({}));
|
|
5
|
+
const cfg = agentRuntime(event, body.appId);
|
|
6
6
|
const response = await fetch(`${cfg.baseUrl}/v1/conversations`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: agentRuntimeHeaders(cfg),
|
|
@@ -10,8 +10,15 @@ export default defineEventHandler(async (event) => {
|
|
|
10
10
|
appId: cfg.appId,
|
|
11
11
|
env: body.env ?? {},
|
|
12
12
|
model: body.model,
|
|
13
|
+
chatType: body.chatType,
|
|
14
|
+
initialPrompt: body.initialPrompt,
|
|
15
|
+
workflow: body.workflow,
|
|
16
|
+
parentConversationId: body.parentConversationId,
|
|
17
|
+
parentContextMode: body.parentContextMode,
|
|
13
18
|
requestOptions: body.requestOptions,
|
|
14
|
-
language: body.language
|
|
19
|
+
language: body.language,
|
|
20
|
+
systemPromptAppend: body.systemPromptAppend,
|
|
21
|
+
metadata: body.metadata
|
|
15
22
|
})
|
|
16
23
|
});
|
|
17
24
|
if (!response.ok) {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { type H3Event } from 'h3';
|
|
1
2
|
import { type AgentRuntimeResolvedConfig } from '../../shared.js';
|
|
2
3
|
/** Resolved server-side configuration for talking to agent-runtime. */
|
|
3
4
|
export type AgentRuntimeRuntime = AgentRuntimeResolvedConfig;
|
|
4
|
-
|
|
5
|
-
* Read the agent-runtime section of `runtimeConfig`, validating that the app key
|
|
6
|
-
* has been provided. Throws a typed Nitro 500 otherwise so the proxy routes
|
|
7
|
-
* surface a clear error instead of silently forwarding an unauthenticated
|
|
8
|
-
* request.
|
|
9
|
-
*/
|
|
10
|
-
export declare const agentRuntime: () => AgentRuntimeRuntime;
|
|
5
|
+
export declare const agentRuntime: (event?: H3Event, appId?: string | null) => AgentRuntimeRuntime;
|
|
11
6
|
/** Build the standard JSON request headers, including the app key. */
|
|
12
7
|
export declare const agentRuntimeHeaders: (cfg: AgentRuntimeRuntime, extra?: Record<string, string>) => Record<string, string>;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#imports";
|
|
2
|
-
import { createError } from "h3";
|
|
2
|
+
import { createError, getQuery } from "h3";
|
|
3
3
|
import { createAgentRuntimeRequestHeaders, resolveAgentRuntimeConfig } from "../../shared.js";
|
|
4
|
-
|
|
4
|
+
const queryAppId = (event) => {
|
|
5
|
+
if (!event) return void 0;
|
|
6
|
+
const raw = getQuery(event).appId;
|
|
7
|
+
if (Array.isArray(raw)) return raw[0] ? String(raw[0]) : void 0;
|
|
8
|
+
return raw ? String(raw) : void 0;
|
|
9
|
+
};
|
|
10
|
+
export const agentRuntime = (event, appId) => {
|
|
5
11
|
try {
|
|
6
|
-
return resolveAgentRuntimeConfig(useRuntimeConfig().agentRuntime
|
|
12
|
+
return resolveAgentRuntimeConfig(useRuntimeConfig().agentRuntime, {
|
|
13
|
+
appId: appId || queryAppId(event)
|
|
14
|
+
});
|
|
7
15
|
} catch (error) {
|
|
8
16
|
throw createError({
|
|
9
17
|
statusCode: 500,
|
package/dist/runtime/shared.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ export interface AgentRuntimeConfigInput {
|
|
|
2
2
|
baseUrl?: string | null;
|
|
3
3
|
appKey?: string | null;
|
|
4
4
|
appId?: string | null;
|
|
5
|
+
apps?: Record<string, {
|
|
6
|
+
baseUrl?: string | null;
|
|
7
|
+
appKey?: string | null;
|
|
8
|
+
appId?: string | null;
|
|
9
|
+
}> | null;
|
|
5
10
|
}
|
|
6
11
|
export interface AgentRuntimeResolvedConfig {
|
|
7
12
|
baseUrl: string;
|
|
@@ -11,6 +16,7 @@ export interface AgentRuntimeResolvedConfig {
|
|
|
11
16
|
export declare const normalizeAgentRuntimeBaseUrl: (value: string | null | undefined) => string;
|
|
12
17
|
export declare const createScopeFingerprint: (parts: Array<string | null | undefined>) => string;
|
|
13
18
|
export declare const resolveAgentRuntimeConfig: (config: AgentRuntimeConfigInput | null | undefined, options?: {
|
|
19
|
+
appId?: string | null;
|
|
14
20
|
defaultAppId?: string;
|
|
15
21
|
}) => AgentRuntimeResolvedConfig;
|
|
16
22
|
export declare const createAgentRuntimeRequestHeaders: (config: Pick<AgentRuntimeResolvedConfig, "appKey">, extra?: Record<string, string>) => Record<string, string>;
|
package/dist/runtime/shared.js
CHANGED
|
@@ -5,14 +5,18 @@ export const createScopeFingerprint = (parts) => {
|
|
|
5
5
|
return createHash("sha256").update(normalized).digest("hex").slice(0, 12);
|
|
6
6
|
};
|
|
7
7
|
export const resolveAgentRuntimeConfig = (config, options) => {
|
|
8
|
-
const
|
|
8
|
+
const requestedAppId = String(options?.appId || "").trim();
|
|
9
|
+
const defaultAppId = String(config?.appId || options?.defaultAppId || "omnisearch").trim();
|
|
10
|
+
const selectedAppId = requestedAppId || defaultAppId;
|
|
11
|
+
const appConfig = selectedAppId ? config?.apps?.[selectedAppId] : void 0;
|
|
12
|
+
const appKey = String(appConfig?.appKey || (!requestedAppId || selectedAppId === config?.appId ? config?.appKey : "") || "").trim();
|
|
9
13
|
if (!appKey) {
|
|
10
|
-
throw new Error(
|
|
14
|
+
throw new Error(`[agent-runtime] AGENT_RUNTIME_APP_KEY is not configured for app "${selectedAppId}"`);
|
|
11
15
|
}
|
|
12
16
|
return {
|
|
13
|
-
baseUrl: normalizeAgentRuntimeBaseUrl(config?.baseUrl),
|
|
17
|
+
baseUrl: normalizeAgentRuntimeBaseUrl(appConfig?.baseUrl || config?.baseUrl),
|
|
14
18
|
appKey,
|
|
15
|
-
appId: String(
|
|
19
|
+
appId: String(appConfig?.appId || selectedAppId)
|
|
16
20
|
};
|
|
17
21
|
};
|
|
18
22
|
export const createAgentRuntimeRequestHeaders = (config, extra = {}) => ({
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type AppAuth, type AppEnvField, type AppInfo, type ChatStatus, type FileEntry, type SendOptions, type UIMessage, type UiAction, type UseAgentRuntime } from '../dist/runtime/composables/useAgentRuntime.js'
|
|
1
|
+
export { type AppAuth, type AppEnvField, type AppInfo, type AppStartField, type AppStartSpec, type ChatStatus, type FileEntry, type RunKind, type RunRecord, type RunStatus, type SendOptions, type UIMessage, type UiAction, type UploadFilesOptions, type UseAgentRuntime, type UseAgentRuntimeOptions, type WorkflowStartOptions } from '../dist/runtime/composables/useAgentRuntime.js'
|
|
2
2
|
|
|
3
3
|
export { type AgentRuntimeMarkdownRenderOptions } from '../dist/runtime/composables/useAgentRuntimeMarkdown.js'
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d4y/agent-runtime-nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Headless Nuxt module that connects a Nuxt app to an agent-runtime server. Ships server-side proxy routes (so your X-Agent-Runtime-App-Key never leaves the server) and a single composable, useAgentRuntime(), that exposes a typed chat client.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -52,25 +52,25 @@
|
|
|
52
52
|
"agent"
|
|
53
53
|
],
|
|
54
54
|
"scripts": {
|
|
55
|
-
"prepack": "nuxt-module-build build",
|
|
56
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
|
|
55
|
+
"prepack": "./node_modules/.bin/nuxt-module-build build",
|
|
56
|
+
"dev:prepare": "./node_modules/.bin/nuxt-module-build build --stub && ./node_modules/.bin/nuxt-module-build prepare",
|
|
57
57
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@nuxt/kit": "
|
|
61
|
-
"ai": "
|
|
62
|
-
"defu": "
|
|
63
|
-
"h3": "
|
|
64
|
-
"markdown-it": "
|
|
60
|
+
"@nuxt/kit": "4.4.4",
|
|
61
|
+
"ai": "6.0.175",
|
|
62
|
+
"defu": "6.1.7",
|
|
63
|
+
"h3": "1.15.11",
|
|
64
|
+
"markdown-it": "14.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@nuxt/module-builder": "
|
|
68
|
-
"@nuxt/schema": "
|
|
69
|
-
"@types/markdown-it": "
|
|
70
|
-
"nuxt": "
|
|
71
|
-
"typescript": "
|
|
72
|
-
"vue": "
|
|
73
|
-
"vue-tsc": "
|
|
67
|
+
"@nuxt/module-builder": "1.0.2",
|
|
68
|
+
"@nuxt/schema": "4.4.4",
|
|
69
|
+
"@types/markdown-it": "14.1.2",
|
|
70
|
+
"nuxt": "4.4.4",
|
|
71
|
+
"typescript": "6.0.3",
|
|
72
|
+
"vue": "3.5.34",
|
|
73
|
+
"vue-tsc": "3.2.8"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"nuxt": "^3.13.0 || ^4.0.0"
|