@inkeep/agents-manage-api 0.22.9 → 0.22.12

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/index.cjs CHANGED
@@ -13,6 +13,7 @@ var factory = require('hono/factory');
13
13
  var zod = require('zod');
14
14
  var swaggerUi = require('@hono/swagger-ui');
15
15
  var nanoid = require('nanoid');
16
+ var streaming = require('hono/streaming');
16
17
 
17
18
  var __defProp = Object.defineProperty;
18
19
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -22,6 +23,7 @@ var envSchema = zod.z.object({
22
23
  NODE_ENV: zod.z.enum(["development", "production", "test"]).optional(),
23
24
  ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
24
25
  AGENTS_MANAGE_API_URL: zod.z.string().optional().default("http://localhost:3002"),
26
+ AGENTS_RUN_API_URL: zod.z.string().optional().default("http://localhost:3003"),
25
27
  DB_FILE_NAME: zod.z.string().optional(),
26
28
  TURSO_DATABASE_URL: zod.z.string().optional(),
27
29
  TURSO_AUTH_TOKEN: zod.z.string().optional(),
@@ -1946,6 +1948,89 @@ app8.openapi(
1946
1948
  return c.body(null, 204);
1947
1949
  }
1948
1950
  );
1951
+ app8.openapi(
1952
+ zodOpenapi.createRoute({
1953
+ method: "post",
1954
+ path: "/{id}/generate-preview",
1955
+ summary: "Generate Component Preview",
1956
+ operationId: "generate-component-preview",
1957
+ tags: ["Data Component"],
1958
+ request: {
1959
+ params: agentsCore.TenantProjectIdParamsSchema
1960
+ },
1961
+ responses: {
1962
+ 200: {
1963
+ description: "Streaming component code generation",
1964
+ content: {
1965
+ "text/plain": {
1966
+ schema: { type: "string" }
1967
+ }
1968
+ }
1969
+ },
1970
+ ...agentsCore.commonGetErrorResponses
1971
+ }
1972
+ }),
1973
+ async (c) => {
1974
+ const { tenantId, projectId, id } = c.req.valid("param");
1975
+ const runApiUrl = env.AGENTS_RUN_API_URL;
1976
+ const url = `${runApiUrl}/v1/${tenantId}/projects/${projectId}/data-components/${id}/generate-preview`;
1977
+ try {
1978
+ const response = await fetch(url, {
1979
+ method: "POST",
1980
+ headers: {
1981
+ "Content-Type": "application/json"
1982
+ }
1983
+ });
1984
+ if (!response.ok) {
1985
+ throw agentsCore.createApiError({
1986
+ code: "internal_server_error",
1987
+ message: `Failed to generate preview: ${response.statusText}`
1988
+ });
1989
+ }
1990
+ if (!response.body) {
1991
+ throw agentsCore.createApiError({
1992
+ code: "internal_server_error",
1993
+ message: "No response body from preview generation"
1994
+ });
1995
+ }
1996
+ c.header("Content-Type", "text/plain; charset=utf-8");
1997
+ c.header("Cache-Control", "no-cache");
1998
+ c.header("Connection", "keep-alive");
1999
+ return streaming.stream(c, async (stream2) => {
2000
+ const responseBody = response.body;
2001
+ if (!responseBody) {
2002
+ throw agentsCore.createApiError({
2003
+ code: "internal_server_error",
2004
+ message: "Response body is null"
2005
+ });
2006
+ }
2007
+ const reader = responseBody.getReader();
2008
+ const decoder = new TextDecoder();
2009
+ try {
2010
+ while (true) {
2011
+ const { done, value } = await reader.read();
2012
+ if (done) break;
2013
+ const text = decoder.decode(value, { stream: true });
2014
+ await stream2.write(text);
2015
+ }
2016
+ } catch {
2017
+ throw agentsCore.createApiError({
2018
+ code: "internal_server_error",
2019
+ message: "Error streaming preview generation"
2020
+ });
2021
+ }
2022
+ });
2023
+ } catch (error) {
2024
+ if (error instanceof Error && "code" in error) {
2025
+ throw error;
2026
+ }
2027
+ throw agentsCore.createApiError({
2028
+ code: "internal_server_error",
2029
+ message: "Failed to generate component preview"
2030
+ });
2031
+ }
2032
+ }
2033
+ );
1949
2034
  var dataComponents_default = app8;
1950
2035
  var app9 = new zodOpenapi.OpenAPIHono();
1951
2036
  app9.openapi(
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import { createMiddleware } from 'hono/factory';
9
9
  import { z } from 'zod';
10
10
  import { swaggerUI } from '@hono/swagger-ui';
11
11
  import { nanoid } from 'nanoid';
12
+ import { stream } from 'hono/streaming';
12
13
 
13
14
  var __defProp = Object.defineProperty;
14
15
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -18,6 +19,7 @@ var envSchema = z.object({
18
19
  NODE_ENV: z.enum(["development", "production", "test"]).optional(),
19
20
  ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional(),
20
21
  AGENTS_MANAGE_API_URL: z.string().optional().default("http://localhost:3002"),
22
+ AGENTS_RUN_API_URL: z.string().optional().default("http://localhost:3003"),
21
23
  DB_FILE_NAME: z.string().optional(),
22
24
  TURSO_DATABASE_URL: z.string().optional(),
23
25
  TURSO_AUTH_TOKEN: z.string().optional(),
@@ -1942,6 +1944,89 @@ app8.openapi(
1942
1944
  return c.body(null, 204);
1943
1945
  }
1944
1946
  );
1947
+ app8.openapi(
1948
+ createRoute({
1949
+ method: "post",
1950
+ path: "/{id}/generate-preview",
1951
+ summary: "Generate Component Preview",
1952
+ operationId: "generate-component-preview",
1953
+ tags: ["Data Component"],
1954
+ request: {
1955
+ params: TenantProjectIdParamsSchema
1956
+ },
1957
+ responses: {
1958
+ 200: {
1959
+ description: "Streaming component code generation",
1960
+ content: {
1961
+ "text/plain": {
1962
+ schema: { type: "string" }
1963
+ }
1964
+ }
1965
+ },
1966
+ ...commonGetErrorResponses
1967
+ }
1968
+ }),
1969
+ async (c) => {
1970
+ const { tenantId, projectId, id } = c.req.valid("param");
1971
+ const runApiUrl = env.AGENTS_RUN_API_URL;
1972
+ const url = `${runApiUrl}/v1/${tenantId}/projects/${projectId}/data-components/${id}/generate-preview`;
1973
+ try {
1974
+ const response = await fetch(url, {
1975
+ method: "POST",
1976
+ headers: {
1977
+ "Content-Type": "application/json"
1978
+ }
1979
+ });
1980
+ if (!response.ok) {
1981
+ throw createApiError({
1982
+ code: "internal_server_error",
1983
+ message: `Failed to generate preview: ${response.statusText}`
1984
+ });
1985
+ }
1986
+ if (!response.body) {
1987
+ throw createApiError({
1988
+ code: "internal_server_error",
1989
+ message: "No response body from preview generation"
1990
+ });
1991
+ }
1992
+ c.header("Content-Type", "text/plain; charset=utf-8");
1993
+ c.header("Cache-Control", "no-cache");
1994
+ c.header("Connection", "keep-alive");
1995
+ return stream(c, async (stream2) => {
1996
+ const responseBody = response.body;
1997
+ if (!responseBody) {
1998
+ throw createApiError({
1999
+ code: "internal_server_error",
2000
+ message: "Response body is null"
2001
+ });
2002
+ }
2003
+ const reader = responseBody.getReader();
2004
+ const decoder = new TextDecoder();
2005
+ try {
2006
+ while (true) {
2007
+ const { done, value } = await reader.read();
2008
+ if (done) break;
2009
+ const text = decoder.decode(value, { stream: true });
2010
+ await stream2.write(text);
2011
+ }
2012
+ } catch {
2013
+ throw createApiError({
2014
+ code: "internal_server_error",
2015
+ message: "Error streaming preview generation"
2016
+ });
2017
+ }
2018
+ });
2019
+ } catch (error) {
2020
+ if (error instanceof Error && "code" in error) {
2021
+ throw error;
2022
+ }
2023
+ throw createApiError({
2024
+ code: "internal_server_error",
2025
+ message: "Failed to generate component preview"
2026
+ });
2027
+ }
2028
+ }
2029
+ );
1945
2030
  var dataComponents_default = app8;
1946
2031
  var app9 = new OpenAPIHono();
1947
2032
  app9.openapi(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-manage-api",
3
- "version": "0.22.9",
3
+ "version": "0.22.12",
4
4
  "description": "Agents Manage API for Inkeep Agent Framework - handles CRUD operations and OAuth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "openid-client": "^6.6.4",
24
24
  "pino": "^9.7.0",
25
25
  "zod": "^4.1.11",
26
- "@inkeep/agents-core": "^0.22.9"
26
+ "@inkeep/agents-core": "^0.22.12"
27
27
  },
28
28
  "optionalDependencies": {
29
29
  "keytar": "^7.9.0"