@fragno-dev/chatno 0.0.5 → 0.0.6

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.
@@ -1,23 +1,40 @@
1
1
  $ tsdown
2
- ℹ tsdown v0.15.5 powered by rolldown v1.0.0-beta.40
2
+ ℹ tsdown v0.15.6 powered by rolldown v1.0.0-beta.41
3
3
  rollup
4
4
  ℹ Using tsdown config: /home/runner/work/fragno/fragno/packages/chatno/tsdown.config.ts
5
5
  ℹ entry: src/index.ts
6
6
  ℹ tsconfig: tsconfig.json
7
- ℹ entry: src/index.ts
7
+ ℹ entry: src/index.ts, src/client/react.ts, src/client/svelte.ts, src/client/vanilla.ts, src/client/vue.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ dist/browser/index.js  3.62 kB │ gzip: 1.23 kB
11
- ℹ dist/browser/index.js.map 12.00 kB │ gzip: 3.58 kB
12
- ℹ dist/browser/index.d.ts.map  0.40 kB │ gzip: 0.23 kB
13
- ℹ dist/browser/index.d.ts  2.83 kB │ gzip: 0.89 kB
14
- ℹ 4 files, total: 18.84 kB
15
- ✔ Build complete in 15780ms
16
10
  ℹ dist/node/index.js 2.42 kB │ gzip: 1.06 kB
17
11
  ℹ dist/node/server/chatno-api.js.map 6.89 kB │ gzip: 2.02 kB
18
- ℹ dist/node/index.js.map 4.61 kB │ gzip: 1.80 kB
12
+ ℹ dist/node/index.js.map 4.61 kB │ gzip: 1.81 kB
19
13
  ℹ dist/node/server/chatno-api.js 3.21 kB │ gzip: 1.06 kB
20
14
  ℹ dist/node/index.d.ts.map 0.40 kB │ gzip: 0.23 kB
21
15
  ℹ dist/node/index.d.ts 2.83 kB │ gzip: 0.89 kB
22
- ℹ 6 files, total: 20.35 kB
23
- ✔ Build complete in 15866ms
16
+ ℹ 6 files, total: 20.34 kB
17
+ ✔ Build complete in 9160ms
18
+ ℹ dist/browser/client/vanilla.js  0.32 kB │ gzip: 0.21 kB
19
+ ℹ dist/browser/client/svelte.js  0.32 kB │ gzip: 0.21 kB
20
+ ℹ dist/browser/client/react.js  0.31 kB │ gzip: 0.21 kB
21
+ ℹ dist/browser/client/vue.js  0.31 kB │ gzip: 0.21 kB
22
+ ℹ dist/browser/index.js  0.12 kB │ gzip: 0.09 kB
23
+ ℹ dist/browser/src-DITyQUrz.js.map 12.00 kB │ gzip: 3.59 kB
24
+ ℹ dist/browser/src-DITyQUrz.js  3.62 kB │ gzip: 1.24 kB
25
+ ℹ dist/browser/client/vanilla.js.map  0.59 kB │ gzip: 0.31 kB
26
+ ℹ dist/browser/client/svelte.js.map  0.59 kB │ gzip: 0.31 kB
27
+ ℹ dist/browser/client/react.js.map  0.59 kB │ gzip: 0.31 kB
28
+ ℹ dist/browser/client/vue.js.map  0.58 kB │ gzip: 0.31 kB
29
+ ℹ dist/browser/index.d.ts.map  0.40 kB │ gzip: 0.23 kB
30
+ ℹ dist/browser/client/svelte.d.ts.map  0.27 kB │ gzip: 0.19 kB
31
+ ℹ dist/browser/client/vanilla.d.ts.map  0.24 kB │ gzip: 0.18 kB
32
+ ℹ dist/browser/client/react.d.ts.map  0.23 kB │ gzip: 0.18 kB
33
+ ℹ dist/browser/client/vue.d.ts.map  0.23 kB │ gzip: 0.18 kB
34
+ ℹ dist/browser/index.d.ts  2.83 kB │ gzip: 0.89 kB
35
+ ℹ dist/browser/client/vanilla.d.ts  0.62 kB │ gzip: 0.32 kB
36
+ ℹ dist/browser/client/react.d.ts  0.61 kB │ gzip: 0.32 kB
37
+ ℹ dist/browser/client/vue.d.ts  0.61 kB │ gzip: 0.32 kB
38
+ ℹ dist/browser/client/svelte.d.ts  0.51 kB │ gzip: 0.29 kB
39
+ ℹ 21 files, total: 25.89 kB
40
+ ✔ Build complete in 9188ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @fragno-dev/chatno
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [c3ff022]
8
+ - @fragno-dev/core@0.0.6
9
+
3
10
  ## 0.0.5
4
11
 
5
12
  ### Patch Changes
@@ -0,0 +1,15 @@
1
+ import { FragnoPublicClientConfig } from "@fragno-dev/core";
2
+ import * as nanostores3 from "nanostores";
3
+ import * as _fragno_dev_core_react0 from "@fragno-dev/core/react";
4
+
5
+ //#region src/client/react.d.ts
6
+ declare function createChatnoClient(config?: FragnoPublicClientConfig): {
7
+ useSendMessage: _fragno_dev_core_react0.FragnoReactStore<{
8
+ readonly response: nanostores3.ReadableAtom<string>;
9
+ readonly responseLoading: nanostores3.ReadableAtom<boolean | undefined>;
10
+ readonly sendMessage: (message: string) => void;
11
+ }>;
12
+ };
13
+ //#endregion
14
+ export { createChatnoClient };
15
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","names":[],"sources":["../../../src/client/react.ts"],"sourcesContent":[],"mappings":";;;;;iBAIgB,kBAAA,UAA2B;;uBAA6B,WAAA,CAAA;;IAAxD,SAAA,WAAkB,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAA,CAAA,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { createChatnoClients } from "../src-DITyQUrz.js";
2
+ import { useFragno } from "@fragno-dev/core/react";
3
+
4
+ //#region src/client/react.ts
5
+ function createChatnoClient(config = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
8
+
9
+ //#endregion
10
+ export { createChatnoClient };
11
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","names":["useFragno","createChatnoClients","FragnoPublicClientConfig","createChatnoClient","config"],"sources":["../../../src/client/react.ts"],"sourcesContent":["import { useFragno } from \"@fragno-dev/core/react\";\nimport { createChatnoClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core\";\n\nexport function createChatnoClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createChatnoClients(config));\n}\n"],"mappings":";;;;AAIA,SAAgBG,mBAAmBC,SAAmC,EAAE,EAAE;AACxE,QAAOJ,UAAUC,oBAAoBG,OAAO,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { FragnoPublicClientConfig } from "@fragno-dev/core";
2
+ import * as nanostores5 from "nanostores";
3
+
4
+ //#region src/client/svelte.d.ts
5
+ declare function createChatnoClient(config?: FragnoPublicClientConfig): {
6
+ useSendMessage: {
7
+ readonly response: nanostores5.ReadableAtom<string>;
8
+ readonly responseLoading: nanostores5.ReadableAtom<boolean | undefined>;
9
+ readonly sendMessage: (message: string) => void;
10
+ };
11
+ };
12
+ //#endregion
13
+ export { createChatnoClient };
14
+ //# sourceMappingURL=svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte.d.ts","names":[],"sources":["../../../src/client/svelte.ts"],"sourcesContent":[],"mappings":";;;;iBAIgB,kBAAA,UAA2B;;uBAA6B,WAAA,CAAA;IAAxD,SAAA,eAAkB,0BAAA,CAAA,OAAA,GAAA,SAAA,CAAA;IAAA,SAAA,WAAA,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA"}
@@ -0,0 +1,11 @@
1
+ import { createChatnoClients } from "../src-DITyQUrz.js";
2
+ import { useFragno } from "@fragno-dev/core/svelte";
3
+
4
+ //#region src/client/svelte.ts
5
+ function createChatnoClient(config = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
8
+
9
+ //#endregion
10
+ export { createChatnoClient };
11
+ //# sourceMappingURL=svelte.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte.js","names":["useFragno","createChatnoClients","FragnoPublicClientConfig","createChatnoClient","config"],"sources":["../../../src/client/svelte.ts"],"sourcesContent":["import { useFragno } from \"@fragno-dev/core/svelte\";\nimport { createChatnoClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core\";\n\nexport function createChatnoClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createChatnoClients(config));\n}\n"],"mappings":";;;;AAIA,SAAgBG,mBAAmBC,SAAmC,EAAE,EAAE;AACxE,QAAOJ,UAAUC,oBAAoBG,OAAO,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { FragnoPublicClientConfig } from "@fragno-dev/core";
2
+ import * as _fragno_dev_core_client1 from "@fragno-dev/core/client";
3
+ import * as nanostores7 from "nanostores";
4
+
5
+ //#region src/client/vanilla.d.ts
6
+ declare function createChatnoClient(config?: FragnoPublicClientConfig): {
7
+ useSendMessage: _fragno_dev_core_client1.FragnoStoreData<{
8
+ readonly response: nanostores7.ReadableAtom<string>;
9
+ readonly responseLoading: nanostores7.ReadableAtom<boolean | undefined>;
10
+ readonly sendMessage: (message: string) => void;
11
+ }>;
12
+ };
13
+ //#endregion
14
+ export { createChatnoClient };
15
+ //# sourceMappingURL=vanilla.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vanilla.d.ts","names":[],"sources":["../../../src/client/vanilla.ts"],"sourcesContent":[],"mappings":";;;;;iBAIgB,kBAAA,UAA2B;;uBAA6B,WAAA,CAAA;;IAAxD,SAAA,WAAkB,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAA,CAAA,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { createChatnoClients } from "../src-DITyQUrz.js";
2
+ import { useFragno } from "@fragno-dev/core/vanilla";
3
+
4
+ //#region src/client/vanilla.ts
5
+ function createChatnoClient(config = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
8
+
9
+ //#endregion
10
+ export { createChatnoClient };
11
+ //# sourceMappingURL=vanilla.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vanilla.js","names":["useFragno","createChatnoClients","FragnoPublicClientConfig","createChatnoClient","config"],"sources":["../../../src/client/vanilla.ts"],"sourcesContent":["import { useFragno } from \"@fragno-dev/core/vanilla\";\nimport { createChatnoClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core\";\n\nexport function createChatnoClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createChatnoClients(config));\n}\n"],"mappings":";;;;AAIA,SAAgBG,mBAAmBC,SAAmC,EAAE,EAAE;AACxE,QAAOJ,UAAUC,oBAAoBG,OAAO,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { FragnoPublicClientConfig } from "@fragno-dev/core";
2
+ import * as _fragno_dev_core_client0 from "@fragno-dev/core/client";
3
+ import * as nanostores0 from "nanostores";
4
+
5
+ //#region src/client/vue.d.ts
6
+ declare function createChatnoClient(config?: FragnoPublicClientConfig): {
7
+ useSendMessage: _fragno_dev_core_client0.FragnoStoreData<{
8
+ readonly response: nanostores0.ReadableAtom<string>;
9
+ readonly responseLoading: nanostores0.ReadableAtom<boolean | undefined>;
10
+ readonly sendMessage: (message: string) => void;
11
+ }>;
12
+ };
13
+ //#endregion
14
+ export { createChatnoClient };
15
+ //# sourceMappingURL=vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.d.ts","names":[],"sources":["../../../src/client/vue.ts"],"sourcesContent":[],"mappings":";;;;;iBAIgB,kBAAA,UAA2B;;uBAA6B,WAAA,CAAA;;IAAxD,SAAA,WAAkB,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAA,CAAA,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { createChatnoClients } from "../src-DITyQUrz.js";
2
+ import { useFragno } from "@fragno-dev/core/vue";
3
+
4
+ //#region src/client/vue.ts
5
+ function createChatnoClient(config = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
8
+
9
+ //#endregion
10
+ export { createChatnoClient };
11
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.js","names":["useFragno","createChatnoClients","FragnoPublicClientConfig","createChatnoClient","config"],"sources":["../../../src/client/vue.ts"],"sourcesContent":["import { useFragno } from \"@fragno-dev/core/vue\";\nimport { createChatnoClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core\";\n\nexport function createChatnoClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createChatnoClients(config));\n}\n"],"mappings":";;;;AAIA,SAAgBG,mBAAmBC,SAAmC,EAAE,EAAE;AACxE,QAAOJ,UAAUC,oBAAoBG,OAAO,CAAC"}
@@ -3,7 +3,7 @@ import { FragnoPublicClientConfig, FragnoPublicConfig } from "@fragno-dev/core";
3
3
  import { z } from "zod";
4
4
  import * as _fragno_dev_core_client0 from "@fragno-dev/core/client";
5
5
  import OpenAI from "openai";
6
- import * as nanostores0 from "nanostores";
6
+ import * as nanostores1 from "nanostores";
7
7
  import { FragnoRouteConfig } from "@fragno-dev/core/api";
8
8
 
9
9
  //#region src/index.d.ts
@@ -61,13 +61,13 @@ declare function createChatno(chatnoConfig: ChatnoServerConfig, fragnoConfig?: F
61
61
  }, {
62
62
  getOpenAIURL: () => string;
63
63
  }>;
64
- declare function createChatnoClient(fragnoConfig?: FragnoPublicClientConfig): {
64
+ declare function createChatnoClients(fragnoConfig: FragnoPublicClientConfig): {
65
65
  useSendMessage: _fragno_dev_core_client0.FragnoStoreData<{
66
- readonly response: nanostores0.ReadableAtom<string>;
67
- readonly responseLoading: nanostores0.ReadableAtom<boolean | undefined>;
66
+ readonly response: nanostores1.ReadableAtom<string>;
67
+ readonly responseLoading: nanostores1.ReadableAtom<boolean | undefined>;
68
68
  readonly sendMessage: (message: string) => void;
69
69
  }>;
70
70
  };
71
71
  //#endregion
72
- export { ChatnoServerConfig, type FragnoRouteConfig, createChatno, createChatnoClient };
72
+ export { ChatnoServerConfig, type FragnoRouteConfig, createChatno, createChatnoClients };
73
73
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,kBAAA;;;;;iBAsDD,YAAA,eACA,mCACA,uCAAuB,8CAAA,0CAAA,CAAA,CAAA;EAxDtB,QAAA,YAAA,wBAAkB,CAAA,YAAA,CAAA;IAsDnB,IAAA,cAAY,CAAA,MAAA,CAAA;IAAA,EAAA,aAAA;IACZ,IAAA,WAAA,CAAA;MACA,IAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;OAAuB,aAAA;;;;;;;;;;;;;;;;;;;;iBAWvB,kBAAA,gBAAiC;;uBAA6B,WAAA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,kBAAA;;;;;iBAsDD,YAAA,eACA,mCACA,uCAAuB,8CAAA,0CAAA,CAAA,CAAA;EAxDtB,QAAA,YAAA,wBAAkB,CAAA,YAAA,CAAA;IAsDnB,IAAA,cAAY,CAAA,MAAA,CAAA;IAAA,EAAA,aAAA;IACZ,IAAA,WAAA,CAAA;MACA,IAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;OAAuB,aAAA;;;;;;;;;;;;;;;;;;;;iBAWvB,mBAAA,eAAkC;;uBAAwB,WAAA,CAAA"}
@@ -1,119 +1,3 @@
1
- import { createFragment, defineFragment, defineRoute, defineRoutes } from "@fragno-dev/core";
2
- import { z } from "zod";
3
- import { createClientBuilder } from "@fragno-dev/core/client";
4
- import OpenAI from "openai";
5
- import { computed } from "nanostores";
1
+ import { createChatno, createChatnoClients } from "./src-DITyQUrz.js";
6
2
 
7
- //#region src/server/chatno-api.ts
8
- const ChatMessageSchema = z.object({
9
- type: z.literal("chat"),
10
- id: z.string(),
11
- role: z.enum(["user", "assistant"]),
12
- content: z.string()
13
- });
14
- const FunctionCallMessageSchema = z.object({
15
- type: z.literal("functionCall"),
16
- id: z.string(),
17
- functionCallId: z.string(),
18
- name: z.string(),
19
- arguments: z.string()
20
- });
21
- const FunctionCallOutputMessageSchema = z.object({
22
- type: z.literal("functionCallOutput"),
23
- id: z.string(),
24
- functionCallId: z.string(),
25
- output: z.string(),
26
- status: z.enum([
27
- "inProgress",
28
- "completed",
29
- "incomplete"
30
- ])
31
- });
32
- const InputMessageSchema = z.discriminatedUnion("type", [
33
- ChatMessageSchema,
34
- FunctionCallMessageSchema,
35
- FunctionCallOutputMessageSchema
36
- ]);
37
- const ChatStreamRequestSchema = z.object({ messages: z.array(InputMessageSchema) });
38
- const ResponseTextDeltaEventSchema = z.object({
39
- type: z.literal("response.output_text.delta"),
40
- content_index: z.number(),
41
- delta: z.string(),
42
- item_id: z.string(),
43
- output_index: z.number(),
44
- sequence_number: z.number()
45
- });
46
- const ResponseTextDoneEventSchema = z.object({
47
- type: z.literal("response.output_text.done"),
48
- content_index: z.number(),
49
- item_id: z.string(),
50
- output_index: z.number(),
51
- sequence_number: z.number(),
52
- text: z.string()
53
- });
54
- const ResponseEventSchema = z.discriminatedUnion("type", [ResponseTextDeltaEventSchema, ResponseTextDoneEventSchema]);
55
- const chatRouteFactory = defineRoutes().create(({ config, deps }) => {
56
- return [defineRoute({
57
- method: "POST",
58
- path: "/chat/stream",
59
- inputSchema: ChatStreamRequestSchema,
60
- outputSchema: z.array(ResponseEventSchema),
61
- handler: () => {}
62
- })];
63
- });
64
-
65
- //#endregion
66
- //#region src/index.ts
67
- const healthRoute = defineRoute({
68
- method: "GET",
69
- path: "/health",
70
- outputSchema: z.object({ status: z.literal("ok") }),
71
- handler: () => {}
72
- });
73
- const simpleStreamRoute = defineRoute({
74
- method: "GET",
75
- path: "/simple-stream",
76
- outputSchema: z.array(z.object({ message: z.string() })),
77
- handler: () => {}
78
- });
79
- const DEFAULT_SYSTEM_PROMPT = `You are an AI assistant integrated into a dashboard.`;
80
- const chatnoDefinition = defineFragment("chatno").withDependencies(() => {}).withServices(() => {});
81
- const routes = [
82
- chatRouteFactory,
83
- healthRoute,
84
- simpleStreamRoute
85
- ];
86
- function createChatno(chatnoConfig, fragnoConfig = {}) {
87
- const config = {
88
- model: chatnoConfig.model ?? "gpt-5-nano",
89
- systemPrompt: chatnoConfig.systemPrompt ?? DEFAULT_SYSTEM_PROMPT
90
- };
91
- return createFragment(chatnoDefinition, {
92
- ...chatnoConfig,
93
- ...config
94
- }, routes, fragnoConfig);
95
- }
96
- function createChatnoClient(fragnoConfig = {}) {
97
- const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);
98
- const chatStream = cb.createMutator("POST", "/chat/stream");
99
- const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {
100
- return (data ?? []).filter((item) => item.type === "response.output_text.delta").map((item) => item.delta).join("");
101
- });
102
- function sendMessage(message) {
103
- chatStream.mutatorStore.mutate({ body: { messages: [{
104
- type: "chat",
105
- id: crypto.randomUUID(),
106
- role: "user",
107
- content: message
108
- }] } });
109
- }
110
- return { useSendMessage: cb.createStore({
111
- response: aggregatedMessage,
112
- responseLoading: computed(chatStream.mutatorStore, ({ loading }) => loading),
113
- sendMessage
114
- }) };
115
- }
116
-
117
- //#endregion
118
- export { createChatno, createChatnoClient };
119
- //# sourceMappingURL=index.js.map
3
+ export { createChatno, createChatnoClients };
@@ -0,0 +1,119 @@
1
+ import { createFragment, defineFragment, defineRoute, defineRoutes } from "@fragno-dev/core";
2
+ import { z } from "zod";
3
+ import { createClientBuilder } from "@fragno-dev/core/client";
4
+ import OpenAI from "openai";
5
+ import { computed } from "nanostores";
6
+
7
+ //#region src/server/chatno-api.ts
8
+ const ChatMessageSchema = z.object({
9
+ type: z.literal("chat"),
10
+ id: z.string(),
11
+ role: z.enum(["user", "assistant"]),
12
+ content: z.string()
13
+ });
14
+ const FunctionCallMessageSchema = z.object({
15
+ type: z.literal("functionCall"),
16
+ id: z.string(),
17
+ functionCallId: z.string(),
18
+ name: z.string(),
19
+ arguments: z.string()
20
+ });
21
+ const FunctionCallOutputMessageSchema = z.object({
22
+ type: z.literal("functionCallOutput"),
23
+ id: z.string(),
24
+ functionCallId: z.string(),
25
+ output: z.string(),
26
+ status: z.enum([
27
+ "inProgress",
28
+ "completed",
29
+ "incomplete"
30
+ ])
31
+ });
32
+ const InputMessageSchema = z.discriminatedUnion("type", [
33
+ ChatMessageSchema,
34
+ FunctionCallMessageSchema,
35
+ FunctionCallOutputMessageSchema
36
+ ]);
37
+ const ChatStreamRequestSchema = z.object({ messages: z.array(InputMessageSchema) });
38
+ const ResponseTextDeltaEventSchema = z.object({
39
+ type: z.literal("response.output_text.delta"),
40
+ content_index: z.number(),
41
+ delta: z.string(),
42
+ item_id: z.string(),
43
+ output_index: z.number(),
44
+ sequence_number: z.number()
45
+ });
46
+ const ResponseTextDoneEventSchema = z.object({
47
+ type: z.literal("response.output_text.done"),
48
+ content_index: z.number(),
49
+ item_id: z.string(),
50
+ output_index: z.number(),
51
+ sequence_number: z.number(),
52
+ text: z.string()
53
+ });
54
+ const ResponseEventSchema = z.discriminatedUnion("type", [ResponseTextDeltaEventSchema, ResponseTextDoneEventSchema]);
55
+ const chatRouteFactory = defineRoutes().create(({ config, deps }) => {
56
+ return [defineRoute({
57
+ method: "POST",
58
+ path: "/chat/stream",
59
+ inputSchema: ChatStreamRequestSchema,
60
+ outputSchema: z.array(ResponseEventSchema),
61
+ handler: () => {}
62
+ })];
63
+ });
64
+
65
+ //#endregion
66
+ //#region src/index.ts
67
+ const healthRoute = defineRoute({
68
+ method: "GET",
69
+ path: "/health",
70
+ outputSchema: z.object({ status: z.literal("ok") }),
71
+ handler: () => {}
72
+ });
73
+ const simpleStreamRoute = defineRoute({
74
+ method: "GET",
75
+ path: "/simple-stream",
76
+ outputSchema: z.array(z.object({ message: z.string() })),
77
+ handler: () => {}
78
+ });
79
+ const DEFAULT_SYSTEM_PROMPT = `You are an AI assistant integrated into a dashboard.`;
80
+ const chatnoDefinition = defineFragment("chatno").withDependencies(() => {}).withServices(() => {});
81
+ const routes = [
82
+ chatRouteFactory,
83
+ healthRoute,
84
+ simpleStreamRoute
85
+ ];
86
+ function createChatno(chatnoConfig, fragnoConfig = {}) {
87
+ const config = {
88
+ model: chatnoConfig.model ?? "gpt-5-nano",
89
+ systemPrompt: chatnoConfig.systemPrompt ?? DEFAULT_SYSTEM_PROMPT
90
+ };
91
+ return createFragment(chatnoDefinition, {
92
+ ...chatnoConfig,
93
+ ...config
94
+ }, routes, fragnoConfig);
95
+ }
96
+ function createChatnoClients(fragnoConfig) {
97
+ const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);
98
+ const chatStream = cb.createMutator("POST", "/chat/stream");
99
+ const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {
100
+ return (data ?? []).filter((item) => item.type === "response.output_text.delta").map((item) => item.delta).join("");
101
+ });
102
+ function sendMessage(message) {
103
+ chatStream.mutatorStore.mutate({ body: { messages: [{
104
+ type: "chat",
105
+ id: crypto.randomUUID(),
106
+ role: "user",
107
+ content: message
108
+ }] } });
109
+ }
110
+ return { useSendMessage: cb.createStore({
111
+ response: aggregatedMessage,
112
+ responseLoading: computed(chatStream.mutatorStore, ({ loading }) => loading),
113
+ sendMessage
114
+ }) };
115
+ }
116
+
117
+ //#endregion
118
+ export { createChatno, createChatnoClients };
119
+ //# sourceMappingURL=src-DITyQUrz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-DITyQUrz.js","names":["OpenAI","z","defineRoute","defineRoutes","ChatMessageSchema","object","type","literal","id","string","role","enum","content","FunctionCallMessageSchema","functionCallId","name","arguments","FunctionCallOutputMessageSchema","output","status","InputMessageSchema","discriminatedUnion","ChatStreamRequestSchema","messages","array","ResponseTextDeltaEventSchema","content_index","number","delta","item_id","output_index","sequence_number","ResponseTextDoneEventSchema","text","ResponseEventSchema","ChatRouteConfig","model","systemPrompt","ChatRouteDeps","openaiClient","chatRouteFactory","create","config","deps","method","path","inputSchema","outputSchema","handler","defineFragment","defineRoute","createFragment","FragnoPublicClientConfig","FragnoPublicConfig","z","createClientBuilder","chatRouteFactory","computed","ChatnoServerConfig","openaiApiKey","model","systemPrompt","healthRoute","method","path","outputSchema","object","status","literal","handler","simpleStreamRoute","array","message","string","DEFAULT_SYSTEM_PROMPT","chatnoDefinition","withDependencies","withServices","routes","const","createChatno","chatnoConfig","fragnoConfig","config","createChatnoClients","cb","chatStream","createMutator","aggregatedMessage","mutatorStore","data","filter","item","type","map","delta","join","sendMessage","mutate","body","messages","id","crypto","randomUUID","role","content","useSendMessage","createStore","response","responseLoading","loading","FragnoRouteConfig"],"sources":["../../src/server/chatno-api.ts","../../src/index.ts"],"sourcesContent":["import OpenAI from \"openai\";\nimport { z } from \"zod\";\nimport type {\n EasyInputMessage,\n ResponseFunctionToolCall,\n ResponseInputItem,\n} from \"openai/resources/responses/responses.mjs\";\nimport { defineRoute, defineRoutes } from \"@fragno-dev/core\";\n\nexport const ChatMessageSchema = z.object({\n type: z.literal(\"chat\"),\n id: z.string(),\n role: z.enum([\"user\", \"assistant\"]),\n content: z.string(),\n});\n\nexport const FunctionCallMessageSchema = z.object({\n type: z.literal(\"functionCall\"),\n id: z.string(),\n functionCallId: z.string(),\n name: z.string(),\n arguments: z.string(),\n});\n\nexport const FunctionCallOutputMessageSchema = z.object({\n type: z.literal(\"functionCallOutput\"),\n id: z.string(),\n functionCallId: z.string(),\n output: z.string(),\n status: z.enum([\"inProgress\", \"completed\", \"incomplete\"]),\n});\n\nexport const InputMessageSchema = z.discriminatedUnion(\"type\", [\n ChatMessageSchema,\n FunctionCallMessageSchema,\n FunctionCallOutputMessageSchema,\n]);\n\n// Request schema with unified messages array\nexport const ChatStreamRequestSchema = z.object({\n messages: z.array(InputMessageSchema),\n});\n\nexport const ResponseTextDeltaEventSchema = z.object({\n type: z.literal(\"response.output_text.delta\"),\n content_index: z.number(),\n delta: z.string(),\n item_id: z.string(),\n output_index: z.number(),\n sequence_number: z.number(),\n});\n\nexport const ResponseTextDoneEventSchema = z.object({\n type: z.literal(\"response.output_text.done\"),\n content_index: z.number(),\n item_id: z.string(),\n output_index: z.number(),\n sequence_number: z.number(),\n text: z.string(),\n});\n\nexport const ResponseEventSchema = z.discriminatedUnion(\"type\", [\n ResponseTextDeltaEventSchema,\n ResponseTextDoneEventSchema,\n]);\n\ntype ChatRouteConfig = {\n model: \"gpt-5-mini\" | \"4o-mini\";\n systemPrompt: string;\n};\n\ntype ChatRouteDeps = {\n openaiClient: OpenAI;\n};\n\nexport const chatRouteFactory = defineRoutes<ChatRouteConfig, ChatRouteDeps>().create(\n ({ config, deps }) => {\n const { openaiClient } = deps;\n const { model, systemPrompt } = config;\n\n return [\n defineRoute({\n method: \"POST\",\n path: \"/chat/stream\",\n inputSchema: ChatStreamRequestSchema,\n outputSchema: z.array(ResponseEventSchema),\n handler: async ({ input }, { jsonStream }) => {\n const { messages } = await input.valid();\n\n const openAIMessages: ResponseInputItem[] = messages.map((message) => {\n if (message.type === \"chat\") {\n return {\n role: message.role,\n content: message.content,\n } satisfies EasyInputMessage;\n }\n\n if (message.type === \"functionCall\") {\n return {\n type: \"function_call\",\n id: message.id,\n call_id: message.functionCallId,\n name: message.name,\n arguments: message.arguments,\n } satisfies ResponseFunctionToolCall;\n }\n\n if (message.type === \"functionCallOutput\") {\n return {\n type: \"function_call_output\",\n call_id: message.functionCallId,\n output: message.output,\n status:\n message.status === \"inProgress\"\n ? \"in_progress\"\n : message.status === \"completed\"\n ? \"completed\"\n : \"incomplete\",\n } satisfies ResponseInputItem.FunctionCallOutput;\n }\n\n throw new Error(\"unreachable\");\n });\n\n try {\n const eventStream = await openaiClient.responses.create({\n model,\n input: [\n {\n role: \"system\",\n content: systemPrompt,\n },\n ...openAIMessages,\n ],\n // tools: [],\n // tool_choice: \"auto\",\n stream: true,\n });\n\n return jsonStream(async (stream) => {\n for await (const event of eventStream) {\n if (\n event.type !== \"response.output_text.delta\" &&\n event.type !== \"response.output_text.done\"\n ) {\n continue;\n }\n\n await stream.write(event);\n }\n });\n } catch (error) {\n console.error(\"OpenAI API error:\", error);\n throw error;\n }\n },\n }),\n ];\n },\n);\n","import {\n defineFragment,\n defineRoute,\n createFragment,\n type FragnoPublicClientConfig,\n type FragnoPublicConfig,\n} from \"@fragno-dev/core\";\nimport OpenAI from \"openai\";\nimport { z } from \"zod\";\nimport { createClientBuilder } from \"@fragno-dev/core/client\";\nimport { chatRouteFactory } from \"./server/chatno-api\";\nimport { computed } from \"nanostores\";\n\nexport interface ChatnoServerConfig {\n openaiApiKey: string;\n model?: \"gpt-5-mini\" | \"4o-mini\" | \"gpt-5-nano\";\n systemPrompt?: string;\n}\n\nconst healthRoute = defineRoute({\n method: \"GET\",\n path: \"/health\",\n outputSchema: z.object({\n status: z.literal(\"ok\"),\n }),\n handler: async (_ctx, { json }) => {\n return json({ status: \"ok\" });\n },\n});\n\nconst simpleStreamRoute = defineRoute({\n method: \"GET\",\n path: \"/simple-stream\",\n outputSchema: z.array(\n z.object({\n message: z.string(),\n }),\n ),\n handler: async (_ctx, { jsonStream }) => {\n return jsonStream(async (stream) => {\n for (let i = 0; i < 10; i++) {\n await stream.sleep(500);\n await stream.write({ message: `Item ${i + 1}` });\n }\n });\n },\n});\n\nconst DEFAULT_SYSTEM_PROMPT = `You are an AI assistant integrated into a dashboard.`;\n\nconst chatnoDefinition = defineFragment<ChatnoServerConfig>(\"chatno\")\n .withDependencies((config: ChatnoServerConfig) => {\n return {\n openaiClient: new OpenAI({\n apiKey: config.openaiApiKey,\n }),\n };\n })\n .withServices((_cfg, deps) => {\n return {\n getOpenAIURL: () => deps.openaiClient.baseURL,\n };\n });\n\nconst routes = [chatRouteFactory, healthRoute, simpleStreamRoute] as const;\n\n// Server-side factory\nexport function createChatno(\n chatnoConfig: ChatnoServerConfig,\n fragnoConfig: FragnoPublicConfig = {},\n) {\n const config = {\n model: chatnoConfig.model ?? \"gpt-5-nano\",\n systemPrompt: chatnoConfig.systemPrompt ?? DEFAULT_SYSTEM_PROMPT,\n };\n\n return createFragment(chatnoDefinition, { ...chatnoConfig, ...config }, routes, fragnoConfig);\n}\n\n// Generic client-side factory\nexport function createChatnoClients(fragnoConfig: FragnoPublicClientConfig) {\n const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);\n\n const chatStream = cb.createMutator(\"POST\", \"/chat/stream\");\n\n const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {\n return (data ?? [])\n .filter((item) => item.type === \"response.output_text.delta\")\n .map((item) => item.delta)\n .join(\"\");\n });\n\n function sendMessage(message: string) {\n chatStream.mutatorStore.mutate({\n body: {\n messages: [{ type: \"chat\", id: crypto.randomUUID(), role: \"user\", content: message }],\n },\n });\n }\n\n return {\n useSendMessage: cb.createStore({\n response: aggregatedMessage,\n responseLoading: computed(chatStream.mutatorStore, ({ loading }) => loading),\n sendMessage,\n }),\n };\n}\n\nexport type { FragnoRouteConfig } from \"@fragno-dev/core/api\";\n"],"mappings":";;;;;;;AASA,MAAaI,oBAAoBH,EAAEI,OAAO;CACxCC,MAAML,EAAEM,QAAQ,OAAO;CACvBC,IAAIP,EAAEQ,QAAQ;CACdC,MAAMT,EAAEU,KAAK,CAAC,QAAQ,YAAY,CAAC;CACnCC,SAASX,EAAEQ,QAAO;CACnB,CAAC;AAEF,MAAaI,4BAA4BZ,EAAEI,OAAO;CAChDC,MAAML,EAAEM,QAAQ,eAAe;CAC/BC,IAAIP,EAAEQ,QAAQ;CACdK,gBAAgBb,EAAEQ,QAAQ;CAC1BM,MAAMd,EAAEQ,QAAQ;CAChBO,WAAWf,EAAEQ,QAAO;CACrB,CAAC;AAEF,MAAaQ,kCAAkChB,EAAEI,OAAO;CACtDC,MAAML,EAAEM,QAAQ,qBAAqB;CACrCC,IAAIP,EAAEQ,QAAQ;CACdK,gBAAgBb,EAAEQ,QAAQ;CAC1BS,QAAQjB,EAAEQ,QAAQ;CAClBU,QAAQlB,EAAEU,KAAK;EAAC;EAAc;EAAa;EAAa,CAAA;CACzD,CAAC;AAEF,MAAaS,qBAAqBnB,EAAEoB,mBAAmB,QAAQ;CAC7DjB;CACAS;CACAI;CACD,CAAC;AAGF,MAAaK,0BAA0BrB,EAAEI,OAAO,EAC9CkB,UAAUtB,EAAEuB,MAAMJ,mBAAkB,EACrC,CAAC;AAEF,MAAaK,+BAA+BxB,EAAEI,OAAO;CACnDC,MAAML,EAAEM,QAAQ,6BAA6B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E,EACrC;CACA,MAAMC,SAAS;EACbvB,OAAOqB,aAAarB,SAAS;EAC7BC,cAAcoB,aAAapB,gBAAgBa;EAC5C;AAED,QAAOvB,eAAewB,kBAAkB;EAAE,GAAGM;EAAc,GAAGE;EAAQ,EAAEL,QAAQI,aAAa;;AAI/F,SAAgBE,oBAAoBF,cAAwC;CAC1E,MAAMG,KAAK9B,oBAAoBoB,kBAAkBO,cAAcJ,OAAO;CAEtE,MAAMQ,aAAaD,GAAGE,cAAc,QAAQ,eAAe;CAE3D,MAAMC,oBAAoB/B,SAAS6B,WAAWG,eAAe,EAAEC,WAAW;AACxE,UAAQA,QAAQ,EAAE,EACfC,QAAQC,SAASA,KAAKC,SAAS,6BAA6B,CAC5DC,KAAKF,SAASA,KAAKG,MAAM,CACzBC,KAAK,GAAG;GACX;CAEF,SAASC,YAAYzB,SAAiB;AACpCc,aAAWG,aAAaS,OAAO,EAC7BC,MAAM,EACJC,UAAU,CAAC;GAAEP,MAAM;GAAQQ,IAAIC,OAAOC,YAAY;GAAEC,MAAM;GAAQC,SAASjC;GAAS,CAAA,EACtF,EACD,CAAC;;AAGJ,QAAO,EACLkC,gBAAgBrB,GAAGsB,YAAY;EAC7BC,UAAUpB;EACVqB,iBAAiBpD,SAAS6B,WAAWG,eAAe,EAAEqB,cAAcA,QAAQ;EAC5Eb;EACD,CAAA,EACF"}
@@ -61,7 +61,7 @@ declare function createChatno(chatnoConfig: ChatnoServerConfig, fragnoConfig?: F
61
61
  }, {
62
62
  getOpenAIURL: () => string;
63
63
  }>;
64
- declare function createChatnoClient(fragnoConfig?: FragnoPublicClientConfig): {
64
+ declare function createChatnoClients(fragnoConfig: FragnoPublicClientConfig): {
65
65
  useSendMessage: _fragno_dev_core_client0.FragnoStoreData<{
66
66
  readonly response: nanostores0.ReadableAtom<string>;
67
67
  readonly responseLoading: nanostores0.ReadableAtom<boolean | undefined>;
@@ -69,5 +69,5 @@ declare function createChatnoClient(fragnoConfig?: FragnoPublicClientConfig): {
69
69
  }>;
70
70
  };
71
71
  //#endregion
72
- export { ChatnoServerConfig, type FragnoRouteConfig, createChatno, createChatnoClient };
72
+ export { ChatnoServerConfig, type FragnoRouteConfig, createChatno, createChatnoClients };
73
73
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,kBAAA;;;;;iBAsDD,YAAA,eACA,mCACA,uCAAuB,8CAAA,0CAAA,CAAA,CAAA;EAxDtB,QAAA,YAAA,wBAAkB,CAAA,YAAA,CAAA;IAsDnB,IAAA,cAAY,CAAA,MAAA,CAAA;IAAA,EAAA,aAAA;IACZ,IAAA,WAAA,CAAA;MACA,IAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;OAAuB,aAAA;;;;;;;;;;;;;;;;;;;;iBAWvB,kBAAA,gBAAiC;;uBAA6B,WAAA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,kBAAA;;;;;iBAsDD,YAAA,eACA,mCACA,uCAAuB,8CAAA,0CAAA,CAAA,CAAA;EAxDtB,QAAA,YAAA,wBAAkB,CAAA,YAAA,CAAA;IAsDnB,IAAA,cAAY,CAAA,MAAA,CAAA;IAAA,EAAA,aAAA;IACZ,IAAA,WAAA,CAAA;MACA,IAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;OAAuB,aAAA;;;;;;;;;;;;;;;;;;;;iBAWvB,mBAAA,eAAkC;;uBAAwB,WAAA,CAAA"}
@@ -48,7 +48,7 @@ function createChatno(chatnoConfig, fragnoConfig = {}) {
48
48
  ...config
49
49
  }, routes, fragnoConfig);
50
50
  }
51
- function createChatnoClient(fragnoConfig = {}) {
51
+ function createChatnoClients(fragnoConfig) {
52
52
  const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);
53
53
  const chatStream = cb.createMutator("POST", "/chat/stream");
54
54
  const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {
@@ -70,5 +70,5 @@ function createChatnoClient(fragnoConfig = {}) {
70
70
  }
71
71
 
72
72
  //#endregion
73
- export { createChatno, createChatnoClient };
73
+ export { createChatno, createChatnoClients };
74
74
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import {\n defineFragment,\n defineRoute,\n createFragment,\n type FragnoPublicClientConfig,\n type FragnoPublicConfig,\n} from \"@fragno-dev/core\";\nimport OpenAI from \"openai\";\nimport { z } from \"zod\";\nimport { createClientBuilder } from \"@fragno-dev/core/client\";\nimport { chatRouteFactory } from \"./server/chatno-api\";\nimport { computed } from \"nanostores\";\n\nexport interface ChatnoServerConfig {\n openaiApiKey: string;\n model?: \"gpt-5-mini\" | \"4o-mini\" | \"gpt-5-nano\";\n systemPrompt?: string;\n}\n\nconst healthRoute = defineRoute({\n method: \"GET\",\n path: \"/health\",\n outputSchema: z.object({\n status: z.literal(\"ok\"),\n }),\n handler: async (_ctx, { json }) => {\n return json({ status: \"ok\" });\n },\n});\n\nconst simpleStreamRoute = defineRoute({\n method: \"GET\",\n path: \"/simple-stream\",\n outputSchema: z.array(\n z.object({\n message: z.string(),\n }),\n ),\n handler: async (_ctx, { jsonStream }) => {\n return jsonStream(async (stream) => {\n for (let i = 0; i < 10; i++) {\n await stream.sleep(500);\n await stream.write({ message: `Item ${i + 1}` });\n }\n });\n },\n});\n\nconst DEFAULT_SYSTEM_PROMPT = `You are an AI assistant integrated into a dashboard.`;\n\nconst chatnoDefinition = defineFragment<ChatnoServerConfig>(\"chatno\")\n .withDependencies((config: ChatnoServerConfig) => {\n return {\n openaiClient: new OpenAI({\n apiKey: config.openaiApiKey,\n }),\n };\n })\n .withServices((_cfg, deps) => {\n return {\n getOpenAIURL: () => deps.openaiClient.baseURL,\n };\n });\n\nconst routes = [chatRouteFactory, healthRoute, simpleStreamRoute] as const;\n\n// Server-side factory\nexport function createChatno(\n chatnoConfig: ChatnoServerConfig,\n fragnoConfig: FragnoPublicConfig = {},\n) {\n const config = {\n model: chatnoConfig.model ?? \"gpt-5-nano\",\n systemPrompt: chatnoConfig.systemPrompt ?? DEFAULT_SYSTEM_PROMPT,\n };\n\n return createFragment(chatnoDefinition, { ...chatnoConfig, ...config }, routes, fragnoConfig);\n}\n\n// Client-side factory\nexport function createChatnoClient(fragnoConfig: FragnoPublicClientConfig = {}) {\n const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);\n\n const chatStream = cb.createMutator(\"POST\", \"/chat/stream\");\n\n const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {\n return (data ?? [])\n .filter((item) => item.type === \"response.output_text.delta\")\n .map((item) => item.delta)\n .join(\"\");\n });\n\n function sendMessage(message: string) {\n chatStream.mutatorStore.mutate({\n body: {\n messages: [{ type: \"chat\", id: crypto.randomUUID(), role: \"user\", content: message }],\n },\n });\n }\n\n return {\n useSendMessage: cb.createStore({\n response: aggregatedMessage,\n responseLoading: computed(chatStream.mutatorStore, ({ loading }) => loading),\n sendMessage,\n }),\n };\n}\n\nexport type { FragnoRouteConfig } from \"@fragno-dev/core/api\";\n"],"mappings":";;;;;;;;AAmBA,MAAM,cAAc,YAAY;CAC9B,QAAQ;CACR,MAAM;CACN,cAAc,EAAE,OAAO,EACrB,QAAQ,EAAE,QAAQ,KAAK,EACxB,CAAC;CACF,SAAS,OAAO,MAAM,EAAE,WAAW;AACjC,SAAO,KAAK,EAAE,QAAQ,MAAM,CAAC;;CAEhC,CAAC;AAEF,MAAM,oBAAoB,YAAY;CACpC,QAAQ;CACR,MAAM;CACN,cAAc,EAAE,MACd,EAAE,OAAO,EACP,SAAS,EAAE,QAAQ,EACpB,CAAC,CACH;CACD,SAAS,OAAO,MAAM,EAAE,iBAAiB;AACvC,SAAO,WAAW,OAAO,WAAW;AAClC,QAAK,IAAI,IAAI,GAAG,IAAI,IAA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.ts"],"sourcesContent":["import {\n defineFragment,\n defineRoute,\n createFragment,\n type FragnoPublicClientConfig,\n type FragnoPublicConfig,\n} from \"@fragno-dev/core\";\nimport OpenAI from \"openai\";\nimport { z } from \"zod\";\nimport { createClientBuilder } from \"@fragno-dev/core/client\";\nimport { chatRouteFactory } from \"./server/chatno-api\";\nimport { computed } from \"nanostores\";\n\nexport interface ChatnoServerConfig {\n openaiApiKey: string;\n model?: \"gpt-5-mini\" | \"4o-mini\" | \"gpt-5-nano\";\n systemPrompt?: string;\n}\n\nconst healthRoute = defineRoute({\n method: \"GET\",\n path: \"/health\",\n outputSchema: z.object({\n status: z.literal(\"ok\"),\n }),\n handler: async (_ctx, { json }) => {\n return json({ status: \"ok\" });\n },\n});\n\nconst simpleStreamRoute = defineRoute({\n method: \"GET\",\n path: \"/simple-stream\",\n outputSchema: z.array(\n z.object({\n message: z.string(),\n }),\n ),\n handler: async (_ctx, { jsonStream }) => {\n return jsonStream(async (stream) => {\n for (let i = 0; i < 10; i++) {\n await stream.sleep(500);\n await stream.write({ message: `Item ${i + 1}` });\n }\n });\n },\n});\n\nconst DEFAULT_SYSTEM_PROMPT = `You are an AI assistant integrated into a dashboard.`;\n\nconst chatnoDefinition = defineFragment<ChatnoServerConfig>(\"chatno\")\n .withDependencies((config: ChatnoServerConfig) => {\n return {\n openaiClient: new OpenAI({\n apiKey: config.openaiApiKey,\n }),\n };\n })\n .withServices((_cfg, deps) => {\n return {\n getOpenAIURL: () => deps.openaiClient.baseURL,\n };\n });\n\nconst routes = [chatRouteFactory, healthRoute, simpleStreamRoute] as const;\n\n// Server-side factory\nexport function createChatno(\n chatnoConfig: ChatnoServerConfig,\n fragnoConfig: FragnoPublicConfig = {},\n) {\n const config = {\n model: chatnoConfig.model ?? \"gpt-5-nano\",\n systemPrompt: chatnoConfig.systemPrompt ?? DEFAULT_SYSTEM_PROMPT,\n };\n\n return createFragment(chatnoDefinition, { ...chatnoConfig, ...config }, routes, fragnoConfig);\n}\n\n// Generic client-side factory\nexport function createChatnoClients(fragnoConfig: FragnoPublicClientConfig) {\n const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);\n\n const chatStream = cb.createMutator(\"POST\", \"/chat/stream\");\n\n const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {\n return (data ?? [])\n .filter((item) => item.type === \"response.output_text.delta\")\n .map((item) => item.delta)\n .join(\"\");\n });\n\n function sendMessage(message: string) {\n chatStream.mutatorStore.mutate({\n body: {\n messages: [{ type: \"chat\", id: crypto.randomUUID(), role: \"user\", content: message }],\n },\n });\n }\n\n return {\n useSendMessage: cb.createStore({\n response: aggregatedMessage,\n responseLoading: computed(chatStream.mutatorStore, ({ loading }) => loading),\n sendMessage,\n }),\n };\n}\n\nexport type { FragnoRouteConfig } from \"@fragno-dev/core/api\";\n"],"mappings":";;;;;;;;AAmBA,MAAM,cAAc,YAAY;CAC9B,QAAQ;CACR,MAAM;CACN,cAAc,EAAE,OAAO,EACrB,QAAQ,EAAE,QAAQ,KAAK,EACxB,CAAC;CACF,SAAS,OAAO,MAAM,EAAE,WAAW;AACjC,SAAO,KAAK,EAAE,QAAQ,MAAM,CAAC;;CAEhC,CAAC;AAEF,MAAM,oBAAoB,YAAY;CACpC,QAAQ;CACR,MAAM;CACN,cAAc,EAAE,MACd,EAAE,OAAO,EACP,SAAS,EAAE,QAAQ,EACpB,CAAC,CACH;CACD,SAAS,OAAO,MAAM,EAAE,iBAAiB;AACvC,SAAO,WAAW,OAAO,WAAW;AAClC,QAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,UAAM,OAAO,MAAM,IAAI;AACvB,UAAM,OAAO,MAAM,EAAE,SAAS,QAAQ,IAAI,KAAK,CAAC;;IAElD;;CAEL,CAAC;AAEF,MAAM,wBAAwB;AAE9B,MAAM,mBAAmB,eAAmC,SAAS,CAClE,kBAAkB,WAA+B;AAChD,QAAO,EACL,cAAc,IAAI,OAAO,EACvB,QAAQ,OAAO,cAChB,CAAC,EACH;EACD,CACD,cAAc,MAAM,SAAS;AAC5B,QAAO,EACL,oBAAoB,KAAK,aAAa,SACvC;EACD;AAEJ,MAAM,SAAS;CAAC;CAAkB;CAAa;CAAkB;AAGjE,SAAgB,aACd,cACA,eAAmC,EAAE,EACrC;CACA,MAAM,SAAS;EACb,OAAO,aAAa,SAAS;EAC7B,cAAc,aAAa,gBAAgB;EAC5C;AAED,QAAO,eAAe,kBAAkB;EAAE,GAAG;EAAc,GAAG;EAAQ,EAAE,QAAQ,aAAa;;AAI/F,SAAgB,oBAAoB,cAAwC;CAC1E,MAAM,KAAK,oBAAoB,kBAAkB,cAAc,OAAO;CAEtE,MAAM,aAAa,GAAG,cAAc,QAAQ,eAAe;CAE3D,MAAM,oBAAoB,SAAS,WAAW,eAAe,EAAE,WAAW;AACxE,UAAQ,QAAQ,EAAE,EACf,QAAQ,SAAS,KAAK,SAAS,6BAA6B,CAC5D,KAAK,SAAS,KAAK,MAAM,CACzB,KAAK,GAAG;GACX;CAEF,SAAS,YAAY,SAAiB;AACpC,aAAW,aAAa,OAAO,EAC7B,MAAM,EACJ,UAAU,CAAC;GAAE,MAAM;GAAQ,IAAI,OAAO,YAAY;GAAE,MAAM;GAAQ,SAAS;GAAS,CAAC,EACtF,EACF,CAAC;;AAGJ,QAAO,EACL,gBAAgB,GAAG,YAAY;EAC7B,UAAU;EACV,iBAAiB,SAAS,WAAW,eAAe,EAAE,cAAc,QAAQ;EAC5E;EACD,CAAC,EACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragno-dev/chatno",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "exports": {
5
5
  ".": {
6
6
  "development": {
@@ -11,6 +11,38 @@
11
11
  "types": "./dist/browser/index.d.ts",
12
12
  "browser": "./dist/browser/index.js",
13
13
  "default": "./dist/node/index.js"
14
+ },
15
+ "./react": {
16
+ "development": {
17
+ "browser": "./dist/browser/client/react.js",
18
+ "default": "./src/client/react.ts"
19
+ },
20
+ "types": "./dist/browser/client/react.d.ts",
21
+ "default": "./dist/browser/client/react.js"
22
+ },
23
+ "./vue": {
24
+ "development": {
25
+ "browser": "./dist/browser/client/vue.js",
26
+ "default": "./src/client/vue.ts"
27
+ },
28
+ "types": "./dist/browser/client/vue.d.ts",
29
+ "default": "./dist/browser/client/vue.js"
30
+ },
31
+ "./svelte": {
32
+ "development": {
33
+ "browser": "./dist/browser/client/svelte.js",
34
+ "default": "./src/client/svelte.ts"
35
+ },
36
+ "types": "./dist/browser/client/svelte.d.ts",
37
+ "default": "./dist/browser/client/svelte.js"
38
+ },
39
+ "./vanilla": {
40
+ "development": {
41
+ "browser": "./dist/browser/client/vanilla.js",
42
+ "default": "./src/client/vanilla.ts"
43
+ },
44
+ "types": "./dist/browser/client/vanilla.d.ts",
45
+ "default": "./dist/browser/client/vanilla.js"
14
46
  }
15
47
  },
16
48
  "main": "./dist/node/index.js",
@@ -23,7 +55,7 @@
23
55
  },
24
56
  "type": "module",
25
57
  "dependencies": {
26
- "@fragno-dev/core": "0.0.5",
58
+ "@fragno-dev/core": "0.0.6",
27
59
  "nanostores": "^1.0.1",
28
60
  "openai": "^5.20.0",
29
61
  "zod": "^4.0.5"
@@ -0,0 +1,7 @@
1
+ import { useFragno } from "@fragno-dev/core/react";
2
+ import { createChatnoClients } from "..";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core";
4
+
5
+ export function createChatnoClient(config: FragnoPublicClientConfig = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
@@ -0,0 +1,7 @@
1
+ import { useFragno } from "@fragno-dev/core/svelte";
2
+ import { createChatnoClients } from "..";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core";
4
+
5
+ export function createChatnoClient(config: FragnoPublicClientConfig = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
@@ -0,0 +1,7 @@
1
+ import { useFragno } from "@fragno-dev/core/vanilla";
2
+ import { createChatnoClients } from "..";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core";
4
+
5
+ export function createChatnoClient(config: FragnoPublicClientConfig = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
@@ -0,0 +1,7 @@
1
+ import { useFragno } from "@fragno-dev/core/vue";
2
+ import { createChatnoClients } from "..";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core";
4
+
5
+ export function createChatnoClient(config: FragnoPublicClientConfig = {}) {
6
+ return useFragno(createChatnoClients(config));
7
+ }
package/src/index.ts CHANGED
@@ -77,8 +77,8 @@ export function createChatno(
77
77
  return createFragment(chatnoDefinition, { ...chatnoConfig, ...config }, routes, fragnoConfig);
78
78
  }
79
79
 
80
- // Client-side factory
81
- export function createChatnoClient(fragnoConfig: FragnoPublicClientConfig = {}) {
80
+ // Generic client-side factory
81
+ export function createChatnoClients(fragnoConfig: FragnoPublicClientConfig) {
82
82
  const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);
83
83
 
84
84
  const chatStream = cb.createMutator("POST", "/chat/stream");
package/tsdown.config.ts CHANGED
@@ -4,7 +4,13 @@ import unpluginFragno from "@fragno-dev/unplugin-fragno/rollup";
4
4
  export default defineConfig([
5
5
  {
6
6
  ignoreWatch: ["./dist"],
7
- entry: "./src/index.ts",
7
+ entry: [
8
+ "./src/index.ts",
9
+ "./src/client/react.ts",
10
+ "./src/client/svelte.ts",
11
+ "./src/client/vanilla.ts",
12
+ "./src/client/vue.ts",
13
+ ],
8
14
  dts: {
9
15
  sourcemap: true,
10
16
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["OpenAI","z","defineRoute","defineRoutes","ChatMessageSchema","object","type","literal","id","string","role","enum","content","FunctionCallMessageSchema","functionCallId","name","arguments","FunctionCallOutputMessageSchema","output","status","InputMessageSchema","discriminatedUnion","ChatStreamRequestSchema","messages","array","ResponseTextDeltaEventSchema","content_index","number","delta","item_id","output_index","sequence_number","ResponseTextDoneEventSchema","text","ResponseEventSchema","ChatRouteConfig","model","systemPrompt","ChatRouteDeps","openaiClient","chatRouteFactory","create","config","deps","method","path","inputSchema","outputSchema","handler","defineFragment","defineRoute","createFragment","FragnoPublicClientConfig","FragnoPublicConfig","z","createClientBuilder","chatRouteFactory","computed","ChatnoServerConfig","openaiApiKey","model","systemPrompt","healthRoute","method","path","outputSchema","object","status","literal","handler","simpleStreamRoute","array","message","string","DEFAULT_SYSTEM_PROMPT","chatnoDefinition","withDependencies","withServices","routes","const","createChatno","chatnoConfig","fragnoConfig","config","createChatnoClient","cb","chatStream","createMutator","aggregatedMessage","mutatorStore","data","filter","item","type","map","delta","join","sendMessage","mutate","body","messages","id","crypto","randomUUID","role","content","useSendMessage","createStore","response","responseLoading","loading","FragnoRouteConfig"],"sources":["../../src/server/chatno-api.ts","../../src/index.ts"],"sourcesContent":["import OpenAI from \"openai\";\nimport { z } from \"zod\";\nimport type {\n EasyInputMessage,\n ResponseFunctionToolCall,\n ResponseInputItem,\n} from \"openai/resources/responses/responses.mjs\";\nimport { defineRoute, defineRoutes } from \"@fragno-dev/core\";\n\nexport const ChatMessageSchema = z.object({\n type: z.literal(\"chat\"),\n id: z.string(),\n role: z.enum([\"user\", \"assistant\"]),\n content: z.string(),\n});\n\nexport const FunctionCallMessageSchema = z.object({\n type: z.literal(\"functionCall\"),\n id: z.string(),\n functionCallId: z.string(),\n name: z.string(),\n arguments: z.string(),\n});\n\nexport const FunctionCallOutputMessageSchema = z.object({\n type: z.literal(\"functionCallOutput\"),\n id: z.string(),\n functionCallId: z.string(),\n output: z.string(),\n status: z.enum([\"inProgress\", \"completed\", \"incomplete\"]),\n});\n\nexport const InputMessageSchema = z.discriminatedUnion(\"type\", [\n ChatMessageSchema,\n FunctionCallMessageSchema,\n FunctionCallOutputMessageSchema,\n]);\n\n// Request schema with unified messages array\nexport const ChatStreamRequestSchema = z.object({\n messages: z.array(InputMessageSchema),\n});\n\nexport const ResponseTextDeltaEventSchema = z.object({\n type: z.literal(\"response.output_text.delta\"),\n content_index: z.number(),\n delta: z.string(),\n item_id: z.string(),\n output_index: z.number(),\n sequence_number: z.number(),\n});\n\nexport const ResponseTextDoneEventSchema = z.object({\n type: z.literal(\"response.output_text.done\"),\n content_index: z.number(),\n item_id: z.string(),\n output_index: z.number(),\n sequence_number: z.number(),\n text: z.string(),\n});\n\nexport const ResponseEventSchema = z.discriminatedUnion(\"type\", [\n ResponseTextDeltaEventSchema,\n ResponseTextDoneEventSchema,\n]);\n\ntype ChatRouteConfig = {\n model: \"gpt-5-mini\" | \"4o-mini\";\n systemPrompt: string;\n};\n\ntype ChatRouteDeps = {\n openaiClient: OpenAI;\n};\n\nexport const chatRouteFactory = defineRoutes<ChatRouteConfig, ChatRouteDeps>().create(\n ({ config, deps }) => {\n const { openaiClient } = deps;\n const { model, systemPrompt } = config;\n\n return [\n defineRoute({\n method: \"POST\",\n path: \"/chat/stream\",\n inputSchema: ChatStreamRequestSchema,\n outputSchema: z.array(ResponseEventSchema),\n handler: async ({ input }, { jsonStream }) => {\n const { messages } = await input.valid();\n\n const openAIMessages: ResponseInputItem[] = messages.map((message) => {\n if (message.type === \"chat\") {\n return {\n role: message.role,\n content: message.content,\n } satisfies EasyInputMessage;\n }\n\n if (message.type === \"functionCall\") {\n return {\n type: \"function_call\",\n id: message.id,\n call_id: message.functionCallId,\n name: message.name,\n arguments: message.arguments,\n } satisfies ResponseFunctionToolCall;\n }\n\n if (message.type === \"functionCallOutput\") {\n return {\n type: \"function_call_output\",\n call_id: message.functionCallId,\n output: message.output,\n status:\n message.status === \"inProgress\"\n ? \"in_progress\"\n : message.status === \"completed\"\n ? \"completed\"\n : \"incomplete\",\n } satisfies ResponseInputItem.FunctionCallOutput;\n }\n\n throw new Error(\"unreachable\");\n });\n\n try {\n const eventStream = await openaiClient.responses.create({\n model,\n input: [\n {\n role: \"system\",\n content: systemPrompt,\n },\n ...openAIMessages,\n ],\n // tools: [],\n // tool_choice: \"auto\",\n stream: true,\n });\n\n return jsonStream(async (stream) => {\n for await (const event of eventStream) {\n if (\n event.type !== \"response.output_text.delta\" &&\n event.type !== \"response.output_text.done\"\n ) {\n continue;\n }\n\n await stream.write(event);\n }\n });\n } catch (error) {\n console.error(\"OpenAI API error:\", error);\n throw error;\n }\n },\n }),\n ];\n },\n);\n","import {\n defineFragment,\n defineRoute,\n createFragment,\n type FragnoPublicClientConfig,\n type FragnoPublicConfig,\n} from \"@fragno-dev/core\";\nimport OpenAI from \"openai\";\nimport { z } from \"zod\";\nimport { createClientBuilder } from \"@fragno-dev/core/client\";\nimport { chatRouteFactory } from \"./server/chatno-api\";\nimport { computed } from \"nanostores\";\n\nexport interface ChatnoServerConfig {\n openaiApiKey: string;\n model?: \"gpt-5-mini\" | \"4o-mini\" | \"gpt-5-nano\";\n systemPrompt?: string;\n}\n\nconst healthRoute = defineRoute({\n method: \"GET\",\n path: \"/health\",\n outputSchema: z.object({\n status: z.literal(\"ok\"),\n }),\n handler: async (_ctx, { json }) => {\n return json({ status: \"ok\" });\n },\n});\n\nconst simpleStreamRoute = defineRoute({\n method: \"GET\",\n path: \"/simple-stream\",\n outputSchema: z.array(\n z.object({\n message: z.string(),\n }),\n ),\n handler: async (_ctx, { jsonStream }) => {\n return jsonStream(async (stream) => {\n for (let i = 0; i < 10; i++) {\n await stream.sleep(500);\n await stream.write({ message: `Item ${i + 1}` });\n }\n });\n },\n});\n\nconst DEFAULT_SYSTEM_PROMPT = `You are an AI assistant integrated into a dashboard.`;\n\nconst chatnoDefinition = defineFragment<ChatnoServerConfig>(\"chatno\")\n .withDependencies((config: ChatnoServerConfig) => {\n return {\n openaiClient: new OpenAI({\n apiKey: config.openaiApiKey,\n }),\n };\n })\n .withServices((_cfg, deps) => {\n return {\n getOpenAIURL: () => deps.openaiClient.baseURL,\n };\n });\n\nconst routes = [chatRouteFactory, healthRoute, simpleStreamRoute] as const;\n\n// Server-side factory\nexport function createChatno(\n chatnoConfig: ChatnoServerConfig,\n fragnoConfig: FragnoPublicConfig = {},\n) {\n const config = {\n model: chatnoConfig.model ?? \"gpt-5-nano\",\n systemPrompt: chatnoConfig.systemPrompt ?? DEFAULT_SYSTEM_PROMPT,\n };\n\n return createFragment(chatnoDefinition, { ...chatnoConfig, ...config }, routes, fragnoConfig);\n}\n\n// Client-side factory\nexport function createChatnoClient(fragnoConfig: FragnoPublicClientConfig = {}) {\n const cb = createClientBuilder(chatnoDefinition, fragnoConfig, routes);\n\n const chatStream = cb.createMutator(\"POST\", \"/chat/stream\");\n\n const aggregatedMessage = computed(chatStream.mutatorStore, ({ data }) => {\n return (data ?? [])\n .filter((item) => item.type === \"response.output_text.delta\")\n .map((item) => item.delta)\n .join(\"\");\n });\n\n function sendMessage(message: string) {\n chatStream.mutatorStore.mutate({\n body: {\n messages: [{ type: \"chat\", id: crypto.randomUUID(), role: \"user\", content: message }],\n },\n });\n }\n\n return {\n useSendMessage: cb.createStore({\n response: aggregatedMessage,\n responseLoading: computed(chatStream.mutatorStore, ({ loading }) => loading),\n sendMessage,\n }),\n };\n}\n\nexport type { FragnoRouteConfig } from \"@fragno-dev/core/api\";\n"],"mappings":";;;;;;;AASA,MAAaI,oBAAoBH,EAAEI,OAAO;CACxCC,MAAML,EAAEM,QAAQ,OAAO;CACvBC,IAAIP,EAAEQ,QAAQ;CACdC,MAAMT,EAAEU,KAAK,CAAC,QAAQ,YAAY,CAAC;CACnCC,SAASX,EAAEQ,QAAO;CACnB,CAAC;AAEF,MAAaI,4BAA4BZ,EAAEI,OAAO;CAChDC,MAAML,EAAEM,QAAQ,eAAe;CAC/BC,IAAIP,EAAEQ,QAAQ;CACdK,gBAAgBb,EAAEQ,QAAQ;CAC1BM,MAAMd,EAAEQ,QAAQ;CAChBO,WAAWf,EAAEQ,QAAO;CACrB,CAAC;AAEF,MAAaQ,kCAAkChB,EAAEI,OAAO;CACtDC,MAAML,EAAEM,QAAQ,qBAAqB;CACrCC,IAAIP,EAAEQ,QAAQ;CACdK,gBAAgBb,EAAEQ,QAAQ;CAC1BS,QAAQjB,EAAEQ,QAAQ;CAClBU,QAA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