@geoffai/geoff 0.1.0
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/README.md +9 -0
- package/dist/clients/index.cjs +4 -0
- package/dist/clients/index.d.cts +114 -0
- package/dist/clients/index.d.ts +114 -0
- package/dist/clients/index.js +4 -0
- package/dist/coder-BwKJFaCZ.d.cts +229 -0
- package/dist/coder-BwKJFaCZ.d.ts +229 -0
- package/dist/index-fVOkaOIE.d.cts +170 -0
- package/dist/index-fVOkaOIE.d.ts +170 -0
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +318 -0
- package/dist/index.d.ts +318 -0
- package/dist/index.js +17 -0
- package/dist/points-BXIt899Y.d.ts +579 -0
- package/dist/points-Blo2T9MP.d.cts +579 -0
- package/dist/points-CGAg3YZi.d.cts +777 -0
- package/dist/points-CGAg3YZi.d.ts +777 -0
- package/dist/proxy/index.cjs +2 -0
- package/dist/proxy/index.d.cts +1 -0
- package/dist/proxy/index.d.ts +1 -0
- package/dist/proxy/index.js +2 -0
- package/dist/scouts-CvzLWYpj.d.cts +166 -0
- package/dist/scouts-CvzLWYpj.d.ts +166 -0
- package/dist/streaming/index.cjs +13 -0
- package/dist/streaming/index.d.cts +145 -0
- package/dist/streaming/index.d.ts +145 -0
- package/dist/streaming/index.js +13 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +0 -0
- package/package.json +76 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var g="http://localhost:3000";async function m(i,o={},e={}){let t=e.baseUrl||g,{method:s="GET",headers:a={},body:n,searchParams:r,stream:d}=o,p=`${t}${i}`;if(r){let l=new URLSearchParams;Object.entries(r).forEach(([T,w])=>{w!==void 0&&l.set(T,w);});let h=l.toString();h&&(p+=`?${h}`);}let R={method:s,headers:{...e.defaultHeaders,...a}};n&&s!=="GET"&&(R.headers={...R.headers,"Content-Type":"application/json"},R.body=JSON.stringify(n));let u=await fetch(p,R);return d&&u.body,u}async function c(i,o={},e={}){let t=await m(i,o,e);return {data:await t.json(),status:t.status}}function y(i,o={}){return async e=>{let t=new URL(e.url),s=typeof i=="function"?i(e):i,a={};t.searchParams.forEach((u,l)=>{a[l]=u;});let n;if(e.method!=="GET"&&e.method!=="HEAD")try{n=await e.json();}catch{}let r={};e.headers.forEach((u,l)=>{r[l]=u;});let d=await m(s,{method:e.method,headers:r,body:n,searchParams:a},o);if((d.headers.get("content-type")||"").includes("text/event-stream"))return new Response(d.body,{status:d.status,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}});let R=await d.json();return Response.json(R,{status:d.status})}}function U(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("userMid"),a=t.searchParams.get("visibility"),n=s?`/agents?creator_mid=${encodeURIComponent(s)}`:a?`/agents?visibility=${a}`:"/agents",{data:r,status:d}=await c(n,{},{baseUrl:o}),p=r;return i.enrichResponse&&(p=await i.enrichResponse(r)),Response.json(p,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/agents",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}function f(i={}){let o=i.baseUrl;return {GET:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/agents/${s}`,{},{baseUrl:o}),r=a;return i.enrichResponse&&(r=await i.enrichResponse(a)),Response.json(r,{status:n})},POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/agents/${s}`,{method:"POST",body:a},{baseUrl:o});return Response.json(n,{status:r})},PUT:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/agents/${s}`,{method:"PUT",body:a},{baseUrl:o});return Response.json(n,{status:r})},DELETE:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/agents/${s}`,{method:"DELETE"},{baseUrl:o});return Response.json(a,{status:n})}}}function P(i={}){let o=i.baseUrl;return {POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").slice(-2)[0],a=await e.json(),n=await m(`/agents/${s}/execute`,{method:"POST",body:a,stream:true},{baseUrl:o});if((n.headers.get("content-type")||"").includes("text/event-stream")&&n.body)return new Response(n.body,{status:n.status,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}});let d=await n.json();return Response.json(d,{status:n.status})}}}function b(i={}){let o=i.baseUrl;return {enable:{POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").slice(-2)[0],{data:a,status:n}=await c(`/agents/${s}/enable`,{method:"POST"},{baseUrl:o});return Response.json(a,{status:n})}},disable:{POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").slice(-2)[0],{data:a,status:n}=await c(`/agents/${s}/disable`,{method:"POST"},{baseUrl:o});return Response.json(a,{status:n})}}}}function C(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("scope"),a=t.searchParams.get("creator_mid"),n="/skills";s?n+=`?scope=${encodeURIComponent(s)}`:a&&(n+=`?creator_mid=${encodeURIComponent(a)}`);let{data:r,status:d}=await c(n,{},{baseUrl:o});return Response.json(r,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/skills",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}function E(i={}){let o=i.baseUrl;return {GET:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/skills/${s}`,{},{baseUrl:o});return Response.json(a,{status:n})},POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/skills/${s}`,{method:"POST",body:a},{baseUrl:o});return Response.json(n,{status:r})},PUT:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/skills/${s}`,{method:"PUT",body:a},{baseUrl:o});return Response.json(n,{status:r})},DELETE:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/skills/${s}`,{method:"DELETE"},{baseUrl:o});return Response.json(a,{status:n})}}}function S(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("scope"),a=t.searchParams.get("creator_mid"),n="/widgets";s?n+=`?scope=${encodeURIComponent(s)}`:a&&(n+=`?creator_mid=${encodeURIComponent(a)}`);let{data:r,status:d}=await c(n,{},{baseUrl:o});return Response.json(r,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/widgets",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}function x(i={}){let o=i.baseUrl;return {GET:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/widgets/${s}`,{},{baseUrl:o});return Response.json(a,{status:n})},POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/widgets/${s}`,{method:"POST",body:a},{baseUrl:o});return Response.json(n,{status:r})},PUT:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/widgets/${s}`,{method:"PUT",body:a},{baseUrl:o});return Response.json(n,{status:r})},DELETE:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/widgets/${s}`,{method:"DELETE"},{baseUrl:o});return Response.json(a,{status:n})}}}function j(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("id"),a=t.searchParams.get("creator_mid"),n="/imaginations";s?n=`/imaginations/${s}`:a&&(n+=`?creator_mid=${encodeURIComponent(a)}`);let{data:r,status:d}=await c(n,{},{baseUrl:o});return Response.json(r,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/imaginations",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}
|
|
2
|
+
exports.createAgentDetailRoutes=f;exports.createAgentExecuteRoute=P;exports.createAgentRoutes=U;exports.createAgentToggleRoutes=b;exports.createImaginationRoutes=j;exports.createProxyHandler=y;exports.createSkillDetailRoutes=E;exports.createSkillRoutes=C;exports.createWidgetDetailRoutes=x;exports.createWidgetRoutes=S;exports.forwardJSON=c;exports.forwardRequest=m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { C as CRUDRouteHandlers, F as ForwarderConfig, R as RequestOptions, u as RouteHandler, t as RouteHandlerConfig, d as createAgentDetailRoutes, e as createAgentExecuteRoute, b as createAgentRoutes, g as createAgentToggleRoutes, l as createImaginationRoutes, c as createProxyHandler, i as createSkillDetailRoutes, h as createSkillRoutes, k as createWidgetDetailRoutes, j as createWidgetRoutes, a as forwardJSON, f as forwardRequest } from '../index-fVOkaOIE.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { C as CRUDRouteHandlers, F as ForwarderConfig, R as RequestOptions, u as RouteHandler, t as RouteHandlerConfig, d as createAgentDetailRoutes, e as createAgentExecuteRoute, b as createAgentRoutes, g as createAgentToggleRoutes, l as createImaginationRoutes, c as createProxyHandler, i as createSkillDetailRoutes, h as createSkillRoutes, k as createWidgetDetailRoutes, j as createWidgetRoutes, a as forwardJSON, f as forwardRequest } from '../index-fVOkaOIE.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g="http://localhost:3000";async function m(i,o={},e={}){let t=e.baseUrl||g,{method:s="GET",headers:a={},body:n,searchParams:r,stream:d}=o,p=`${t}${i}`;if(r){let l=new URLSearchParams;Object.entries(r).forEach(([T,w])=>{w!==void 0&&l.set(T,w);});let h=l.toString();h&&(p+=`?${h}`);}let R={method:s,headers:{...e.defaultHeaders,...a}};n&&s!=="GET"&&(R.headers={...R.headers,"Content-Type":"application/json"},R.body=JSON.stringify(n));let u=await fetch(p,R);return d&&u.body,u}async function c(i,o={},e={}){let t=await m(i,o,e);return {data:await t.json(),status:t.status}}function y(i,o={}){return async e=>{let t=new URL(e.url),s=typeof i=="function"?i(e):i,a={};t.searchParams.forEach((u,l)=>{a[l]=u;});let n;if(e.method!=="GET"&&e.method!=="HEAD")try{n=await e.json();}catch{}let r={};e.headers.forEach((u,l)=>{r[l]=u;});let d=await m(s,{method:e.method,headers:r,body:n,searchParams:a},o);if((d.headers.get("content-type")||"").includes("text/event-stream"))return new Response(d.body,{status:d.status,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}});let R=await d.json();return Response.json(R,{status:d.status})}}function U(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("userMid"),a=t.searchParams.get("visibility"),n=s?`/agents?creator_mid=${encodeURIComponent(s)}`:a?`/agents?visibility=${a}`:"/agents",{data:r,status:d}=await c(n,{},{baseUrl:o}),p=r;return i.enrichResponse&&(p=await i.enrichResponse(r)),Response.json(p,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/agents",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}function f(i={}){let o=i.baseUrl;return {GET:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/agents/${s}`,{},{baseUrl:o}),r=a;return i.enrichResponse&&(r=await i.enrichResponse(a)),Response.json(r,{status:n})},POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/agents/${s}`,{method:"POST",body:a},{baseUrl:o});return Response.json(n,{status:r})},PUT:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/agents/${s}`,{method:"PUT",body:a},{baseUrl:o});return Response.json(n,{status:r})},DELETE:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/agents/${s}`,{method:"DELETE"},{baseUrl:o});return Response.json(a,{status:n})}}}function P(i={}){let o=i.baseUrl;return {POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").slice(-2)[0],a=await e.json(),n=await m(`/agents/${s}/execute`,{method:"POST",body:a,stream:true},{baseUrl:o});if((n.headers.get("content-type")||"").includes("text/event-stream")&&n.body)return new Response(n.body,{status:n.status,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}});let d=await n.json();return Response.json(d,{status:n.status})}}}function b(i={}){let o=i.baseUrl;return {enable:{POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").slice(-2)[0],{data:a,status:n}=await c(`/agents/${s}/enable`,{method:"POST"},{baseUrl:o});return Response.json(a,{status:n})}},disable:{POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").slice(-2)[0],{data:a,status:n}=await c(`/agents/${s}/disable`,{method:"POST"},{baseUrl:o});return Response.json(a,{status:n})}}}}function C(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("scope"),a=t.searchParams.get("creator_mid"),n="/skills";s?n+=`?scope=${encodeURIComponent(s)}`:a&&(n+=`?creator_mid=${encodeURIComponent(a)}`);let{data:r,status:d}=await c(n,{},{baseUrl:o});return Response.json(r,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/skills",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}function E(i={}){let o=i.baseUrl;return {GET:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/skills/${s}`,{},{baseUrl:o});return Response.json(a,{status:n})},POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/skills/${s}`,{method:"POST",body:a},{baseUrl:o});return Response.json(n,{status:r})},PUT:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/skills/${s}`,{method:"PUT",body:a},{baseUrl:o});return Response.json(n,{status:r})},DELETE:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/skills/${s}`,{method:"DELETE"},{baseUrl:o});return Response.json(a,{status:n})}}}function S(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("scope"),a=t.searchParams.get("creator_mid"),n="/widgets";s?n+=`?scope=${encodeURIComponent(s)}`:a&&(n+=`?creator_mid=${encodeURIComponent(a)}`);let{data:r,status:d}=await c(n,{},{baseUrl:o});return Response.json(r,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/widgets",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}function x(i={}){let o=i.baseUrl;return {GET:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/widgets/${s}`,{},{baseUrl:o});return Response.json(a,{status:n})},POST:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/widgets/${s}`,{method:"POST",body:a},{baseUrl:o});return Response.json(n,{status:r})},PUT:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),a=await e.json(),{data:n,status:r}=await c(`/widgets/${s}`,{method:"PUT",body:a},{baseUrl:o});return Response.json(n,{status:r})},DELETE:async(e,t)=>{let s=t?.params?.id||new URL(e.url).pathname.split("/").pop(),{data:a,status:n}=await c(`/widgets/${s}`,{method:"DELETE"},{baseUrl:o});return Response.json(a,{status:n})}}}function j(i={}){let o=i.baseUrl;return {GET:async e=>{let t=new URL(e.url),s=t.searchParams.get("id"),a=t.searchParams.get("creator_mid"),n="/imaginations";s?n=`/imaginations/${s}`:a&&(n+=`?creator_mid=${encodeURIComponent(a)}`);let{data:r,status:d}=await c(n,{},{baseUrl:o});return Response.json(r,{status:d})},POST:async e=>{let t=await e.json(),{data:s,status:a}=await c("/imaginations",{method:"POST",body:t},{baseUrl:o});return Response.json(s,{status:a})}}}
|
|
2
|
+
export{f as createAgentDetailRoutes,P as createAgentExecuteRoute,U as createAgentRoutes,b as createAgentToggleRoutes,j as createImaginationRoutes,y as createProxyHandler,E as createSkillDetailRoutes,C as createSkillRoutes,x as createWidgetDetailRoutes,S as createWidgetRoutes,c as forwardJSON,m as forwardRequest};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Types
|
|
3
|
+
* Type definitions for the GeoffNet notifications system.
|
|
4
|
+
*/
|
|
5
|
+
type NotificationType = 'info' | 'warning' | 'error' | 'success' | 'scout_alert' | 'task_update';
|
|
6
|
+
type NotificationPriority = 0 | 1 | 2;
|
|
7
|
+
interface Notification {
|
|
8
|
+
id: string;
|
|
9
|
+
user_mid: string;
|
|
10
|
+
type: NotificationType;
|
|
11
|
+
title: string;
|
|
12
|
+
message: string;
|
|
13
|
+
source: string;
|
|
14
|
+
source_id?: string;
|
|
15
|
+
priority: NotificationPriority;
|
|
16
|
+
is_read: boolean;
|
|
17
|
+
is_dismissed: boolean;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
expires_at?: number;
|
|
20
|
+
created_at: number;
|
|
21
|
+
}
|
|
22
|
+
interface CreateNotificationInput {
|
|
23
|
+
user_mid: string;
|
|
24
|
+
type: NotificationType;
|
|
25
|
+
title: string;
|
|
26
|
+
message: string;
|
|
27
|
+
source?: string;
|
|
28
|
+
source_id?: string;
|
|
29
|
+
priority?: NotificationPriority;
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
expires_at?: number;
|
|
32
|
+
}
|
|
33
|
+
interface NotificationsListFilters {
|
|
34
|
+
user_mid: string;
|
|
35
|
+
unread_only?: boolean;
|
|
36
|
+
type?: NotificationType;
|
|
37
|
+
source?: string;
|
|
38
|
+
limit?: number;
|
|
39
|
+
offset?: number;
|
|
40
|
+
}
|
|
41
|
+
interface NotificationsListResponse {
|
|
42
|
+
notifications: Notification[];
|
|
43
|
+
total: number;
|
|
44
|
+
unread_count: number;
|
|
45
|
+
}
|
|
46
|
+
interface NotificationResponse {
|
|
47
|
+
id: string;
|
|
48
|
+
created?: boolean;
|
|
49
|
+
is_read?: boolean;
|
|
50
|
+
dismissed?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface MarkAllReadResponse {
|
|
53
|
+
updated: number;
|
|
54
|
+
}
|
|
55
|
+
interface UnreadCountResponse {
|
|
56
|
+
count: number;
|
|
57
|
+
}
|
|
58
|
+
interface NotificationsClientConfig {
|
|
59
|
+
baseUrl?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Scouts Types
|
|
64
|
+
* Type definitions for the GeoffNet scouts (web monitoring) system.
|
|
65
|
+
*/
|
|
66
|
+
interface NotificationConfig {
|
|
67
|
+
on_change?: boolean;
|
|
68
|
+
on_error?: boolean;
|
|
69
|
+
min_significance?: 'low' | 'medium' | 'high';
|
|
70
|
+
}
|
|
71
|
+
interface Scout {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
owner_mid: string;
|
|
76
|
+
sources: string[];
|
|
77
|
+
schema?: Record<string, unknown>;
|
|
78
|
+
schedule: string;
|
|
79
|
+
is_active: boolean;
|
|
80
|
+
notification_config?: NotificationConfig;
|
|
81
|
+
last_run?: number;
|
|
82
|
+
last_snapshot_hash?: string;
|
|
83
|
+
created_at: number;
|
|
84
|
+
updated_at: number;
|
|
85
|
+
}
|
|
86
|
+
interface ScoutSnapshot {
|
|
87
|
+
id: string;
|
|
88
|
+
scout_id: string;
|
|
89
|
+
source_url: string;
|
|
90
|
+
content_hash: string;
|
|
91
|
+
content?: string;
|
|
92
|
+
extracted_data?: Record<string, unknown>;
|
|
93
|
+
diff_summary?: DiffAnalysis;
|
|
94
|
+
has_changed: boolean;
|
|
95
|
+
created_at: number;
|
|
96
|
+
}
|
|
97
|
+
interface DiffAnalysis {
|
|
98
|
+
summary: string;
|
|
99
|
+
key_differences: string[];
|
|
100
|
+
significance: 'low' | 'medium' | 'high';
|
|
101
|
+
should_alert: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface CreateScoutInput {
|
|
104
|
+
name: string;
|
|
105
|
+
sources: string[];
|
|
106
|
+
schedule: string;
|
|
107
|
+
owner_mid: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
schema?: Record<string, unknown>;
|
|
110
|
+
notification_config?: NotificationConfig;
|
|
111
|
+
}
|
|
112
|
+
interface UpdateScoutInput {
|
|
113
|
+
name?: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
sources?: string[];
|
|
116
|
+
schema?: Record<string, unknown>;
|
|
117
|
+
schedule?: string;
|
|
118
|
+
is_active?: boolean;
|
|
119
|
+
notification_config?: NotificationConfig;
|
|
120
|
+
}
|
|
121
|
+
interface ScoutsListFilters {
|
|
122
|
+
owner_mid?: string;
|
|
123
|
+
active_only?: boolean;
|
|
124
|
+
}
|
|
125
|
+
interface ScoutsListResponse {
|
|
126
|
+
scouts: Scout[];
|
|
127
|
+
total: number;
|
|
128
|
+
}
|
|
129
|
+
interface ScoutResponse {
|
|
130
|
+
scout: Scout;
|
|
131
|
+
recent_snapshots?: ScoutSnapshot[];
|
|
132
|
+
message?: string;
|
|
133
|
+
}
|
|
134
|
+
interface ScoutHistoryResponse {
|
|
135
|
+
scout_id: string;
|
|
136
|
+
snapshots: ScoutSnapshot[];
|
|
137
|
+
total: number;
|
|
138
|
+
limit: number;
|
|
139
|
+
offset: number;
|
|
140
|
+
}
|
|
141
|
+
interface TriggerScoutResult {
|
|
142
|
+
source_url: string;
|
|
143
|
+
status: 'success' | 'error';
|
|
144
|
+
has_changed?: boolean;
|
|
145
|
+
content_hash?: string;
|
|
146
|
+
diff_analysis?: DiffAnalysis;
|
|
147
|
+
error?: string;
|
|
148
|
+
}
|
|
149
|
+
interface TriggerScoutResponse {
|
|
150
|
+
scout_id: string;
|
|
151
|
+
scout_name: string;
|
|
152
|
+
run_time: number;
|
|
153
|
+
sources_checked: number;
|
|
154
|
+
changes_detected: boolean;
|
|
155
|
+
results: TriggerScoutResult[];
|
|
156
|
+
}
|
|
157
|
+
interface DeleteScoutResponse {
|
|
158
|
+
deleted: boolean;
|
|
159
|
+
scout_id: string;
|
|
160
|
+
scout_name: string;
|
|
161
|
+
}
|
|
162
|
+
interface ScoutsClientConfig {
|
|
163
|
+
baseUrl?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type { CreateNotificationInput as C, DiffAnalysis as D, MarkAllReadResponse as M, NotificationType as N, Scout as S, TriggerScoutResult as T, UnreadCountResponse as U, NotificationPriority as a, Notification as b, NotificationsListFilters as c, NotificationsListResponse as d, NotificationResponse as e, NotificationsClientConfig as f, NotificationConfig as g, ScoutSnapshot as h, CreateScoutInput as i, UpdateScoutInput as j, ScoutsListFilters as k, ScoutsListResponse as l, ScoutResponse as m, ScoutHistoryResponse as n, TriggerScoutResponse as o, DeleteScoutResponse as p, ScoutsClientConfig as q };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Types
|
|
3
|
+
* Type definitions for the GeoffNet notifications system.
|
|
4
|
+
*/
|
|
5
|
+
type NotificationType = 'info' | 'warning' | 'error' | 'success' | 'scout_alert' | 'task_update';
|
|
6
|
+
type NotificationPriority = 0 | 1 | 2;
|
|
7
|
+
interface Notification {
|
|
8
|
+
id: string;
|
|
9
|
+
user_mid: string;
|
|
10
|
+
type: NotificationType;
|
|
11
|
+
title: string;
|
|
12
|
+
message: string;
|
|
13
|
+
source: string;
|
|
14
|
+
source_id?: string;
|
|
15
|
+
priority: NotificationPriority;
|
|
16
|
+
is_read: boolean;
|
|
17
|
+
is_dismissed: boolean;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
expires_at?: number;
|
|
20
|
+
created_at: number;
|
|
21
|
+
}
|
|
22
|
+
interface CreateNotificationInput {
|
|
23
|
+
user_mid: string;
|
|
24
|
+
type: NotificationType;
|
|
25
|
+
title: string;
|
|
26
|
+
message: string;
|
|
27
|
+
source?: string;
|
|
28
|
+
source_id?: string;
|
|
29
|
+
priority?: NotificationPriority;
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
expires_at?: number;
|
|
32
|
+
}
|
|
33
|
+
interface NotificationsListFilters {
|
|
34
|
+
user_mid: string;
|
|
35
|
+
unread_only?: boolean;
|
|
36
|
+
type?: NotificationType;
|
|
37
|
+
source?: string;
|
|
38
|
+
limit?: number;
|
|
39
|
+
offset?: number;
|
|
40
|
+
}
|
|
41
|
+
interface NotificationsListResponse {
|
|
42
|
+
notifications: Notification[];
|
|
43
|
+
total: number;
|
|
44
|
+
unread_count: number;
|
|
45
|
+
}
|
|
46
|
+
interface NotificationResponse {
|
|
47
|
+
id: string;
|
|
48
|
+
created?: boolean;
|
|
49
|
+
is_read?: boolean;
|
|
50
|
+
dismissed?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface MarkAllReadResponse {
|
|
53
|
+
updated: number;
|
|
54
|
+
}
|
|
55
|
+
interface UnreadCountResponse {
|
|
56
|
+
count: number;
|
|
57
|
+
}
|
|
58
|
+
interface NotificationsClientConfig {
|
|
59
|
+
baseUrl?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Scouts Types
|
|
64
|
+
* Type definitions for the GeoffNet scouts (web monitoring) system.
|
|
65
|
+
*/
|
|
66
|
+
interface NotificationConfig {
|
|
67
|
+
on_change?: boolean;
|
|
68
|
+
on_error?: boolean;
|
|
69
|
+
min_significance?: 'low' | 'medium' | 'high';
|
|
70
|
+
}
|
|
71
|
+
interface Scout {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
owner_mid: string;
|
|
76
|
+
sources: string[];
|
|
77
|
+
schema?: Record<string, unknown>;
|
|
78
|
+
schedule: string;
|
|
79
|
+
is_active: boolean;
|
|
80
|
+
notification_config?: NotificationConfig;
|
|
81
|
+
last_run?: number;
|
|
82
|
+
last_snapshot_hash?: string;
|
|
83
|
+
created_at: number;
|
|
84
|
+
updated_at: number;
|
|
85
|
+
}
|
|
86
|
+
interface ScoutSnapshot {
|
|
87
|
+
id: string;
|
|
88
|
+
scout_id: string;
|
|
89
|
+
source_url: string;
|
|
90
|
+
content_hash: string;
|
|
91
|
+
content?: string;
|
|
92
|
+
extracted_data?: Record<string, unknown>;
|
|
93
|
+
diff_summary?: DiffAnalysis;
|
|
94
|
+
has_changed: boolean;
|
|
95
|
+
created_at: number;
|
|
96
|
+
}
|
|
97
|
+
interface DiffAnalysis {
|
|
98
|
+
summary: string;
|
|
99
|
+
key_differences: string[];
|
|
100
|
+
significance: 'low' | 'medium' | 'high';
|
|
101
|
+
should_alert: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface CreateScoutInput {
|
|
104
|
+
name: string;
|
|
105
|
+
sources: string[];
|
|
106
|
+
schedule: string;
|
|
107
|
+
owner_mid: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
schema?: Record<string, unknown>;
|
|
110
|
+
notification_config?: NotificationConfig;
|
|
111
|
+
}
|
|
112
|
+
interface UpdateScoutInput {
|
|
113
|
+
name?: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
sources?: string[];
|
|
116
|
+
schema?: Record<string, unknown>;
|
|
117
|
+
schedule?: string;
|
|
118
|
+
is_active?: boolean;
|
|
119
|
+
notification_config?: NotificationConfig;
|
|
120
|
+
}
|
|
121
|
+
interface ScoutsListFilters {
|
|
122
|
+
owner_mid?: string;
|
|
123
|
+
active_only?: boolean;
|
|
124
|
+
}
|
|
125
|
+
interface ScoutsListResponse {
|
|
126
|
+
scouts: Scout[];
|
|
127
|
+
total: number;
|
|
128
|
+
}
|
|
129
|
+
interface ScoutResponse {
|
|
130
|
+
scout: Scout;
|
|
131
|
+
recent_snapshots?: ScoutSnapshot[];
|
|
132
|
+
message?: string;
|
|
133
|
+
}
|
|
134
|
+
interface ScoutHistoryResponse {
|
|
135
|
+
scout_id: string;
|
|
136
|
+
snapshots: ScoutSnapshot[];
|
|
137
|
+
total: number;
|
|
138
|
+
limit: number;
|
|
139
|
+
offset: number;
|
|
140
|
+
}
|
|
141
|
+
interface TriggerScoutResult {
|
|
142
|
+
source_url: string;
|
|
143
|
+
status: 'success' | 'error';
|
|
144
|
+
has_changed?: boolean;
|
|
145
|
+
content_hash?: string;
|
|
146
|
+
diff_analysis?: DiffAnalysis;
|
|
147
|
+
error?: string;
|
|
148
|
+
}
|
|
149
|
+
interface TriggerScoutResponse {
|
|
150
|
+
scout_id: string;
|
|
151
|
+
scout_name: string;
|
|
152
|
+
run_time: number;
|
|
153
|
+
sources_checked: number;
|
|
154
|
+
changes_detected: boolean;
|
|
155
|
+
results: TriggerScoutResult[];
|
|
156
|
+
}
|
|
157
|
+
interface DeleteScoutResponse {
|
|
158
|
+
deleted: boolean;
|
|
159
|
+
scout_id: string;
|
|
160
|
+
scout_name: string;
|
|
161
|
+
}
|
|
162
|
+
interface ScoutsClientConfig {
|
|
163
|
+
baseUrl?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type { CreateNotificationInput as C, DiffAnalysis as D, MarkAllReadResponse as M, NotificationType as N, Scout as S, TriggerScoutResult as T, UnreadCountResponse as U, NotificationPriority as a, Notification as b, NotificationsListFilters as c, NotificationsListResponse as d, NotificationResponse as e, NotificationsClientConfig as f, NotificationConfig as g, ScoutSnapshot as h, CreateScoutInput as i, UpdateScoutInput as j, ScoutsListFilters as k, ScoutsListResponse as l, ScoutResponse as m, ScoutHistoryResponse as n, TriggerScoutResponse as o, DeleteScoutResponse as p, ScoutsClientConfig as q };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';var m={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};async function*h(i){if(!i.body)throw new Error("Response body is null");let t=i.body.getReader(),r=new TextDecoder,n="",e={};try{for(;;){let{done:a,value:o}=await t.read();if(a)break;n+=r.decode(o,{stream:!0});let s=n.split(`
|
|
2
|
+
`);n=s.pop()||"";for(let c of s){if(c===""){e.data!==void 0&&(yield e),e={};continue}if(c.startsWith(":"))continue;let u=c.indexOf(":");if(u===-1)continue;let f=c.slice(0,u),l=c.slice(u+1).trimStart();switch(f){case "event":e.event=l;break;case "data":try{e.data=JSON.parse(l);}catch{e.data=l;}break;case "id":e.id=l;break;case "retry":e.retry=parseInt(l,10);break}}}e.data!==void 0&&(yield e);}finally{t.releaseLock();}}function S(i,t){let r=new TextEncoder,n=new ReadableStream({async start(e){try{for await(let a of i){let o="";a.event&&(o+=`event: ${a.event}
|
|
3
|
+
`),a.id&&(o+=`id: ${a.id}
|
|
4
|
+
`),a.retry&&(o+=`retry: ${a.retry}
|
|
5
|
+
`);let s=typeof a.data=="string"?a.data:JSON.stringify(a.data);o+=`data: ${s}
|
|
6
|
+
|
|
7
|
+
`,e.enqueue(r.encode(o));}}catch(a){console.error("SSE stream error:",a);}finally{e.close();}}});return new Response(n,{headers:{...m,...t}})}var d=class{encoder=new TextEncoder;controller=null;stream;constructor(){this.stream=new ReadableStream({start:t=>{this.controller=t;}});}getStream(){return this.stream}getResponse(t){return new Response(this.stream,{headers:{...m,...t}})}write(t){if(!this.controller)return;let r="";t.event&&(r+=`event: ${t.event}
|
|
8
|
+
`),t.id&&(r+=`id: ${t.id}
|
|
9
|
+
`);let n=typeof t.data=="string"?t.data:JSON.stringify(t.data);r+=`data: ${n}
|
|
10
|
+
|
|
11
|
+
`,this.controller.enqueue(this.encoder.encode(r));}writeData(t){this.write({data:t});}writeComment(t){this.controller&&this.controller.enqueue(this.encoder.encode(`: ${t}
|
|
12
|
+
|
|
13
|
+
`));}close(){this.controller&&(this.controller.close(),this.controller=null);}error(t){this.controller&&(this.controller.error(t),this.controller=null);}};function g(){return new d}var p=class{constructor(t){this.dataStream=t;}processToolCalls(t){if(!(!t||t.length===0))for(let r of t)try{let n=JSON.parse(r.function.arguments),e=r.function.name;switch(e){case "create_document":this.handleCreateDocument(n,r.id);break;case "update_document":this.handleUpdateDocument(n,r.id);break;default:console.log(`[ComponentStream] Unknown tool: ${e}`);}}catch(n){console.error("[ComponentStream] Error processing tool call:",n);}}processToolResult(t){try{t.type==="artifact"?this.handleArtifactResult(t):t.type==="artifact_update"&&this.handleArtifactUpdate(t);}catch(r){console.error("[ComponentStream] Error processing tool result:",r);}}streamArtifact(t){this.dataStream.write({type:"data-kind",data:t.kind,transient:true}),this.dataStream.write({type:"data-id",data:t.id,transient:true}),this.dataStream.write({type:"data-title",data:t.title,transient:true}),this.dataStream.write({type:"data-clear",data:null,transient:true}),this.streamContent(t.content),this.dataStream.write({type:"data-finish",data:null,transient:true});}streamTextDelta(t){this.dataStream.write({type:"data-textDelta",data:t,transient:true});}streamContent(t,r=50){let n=this.splitIntoChunks(t,r);for(let e of n)this.dataStream.write({type:"data-textDelta",data:e,transient:true});}finish(){this.dataStream.write({type:"data-finish",data:null,transient:true});}handleCreateDocument(t,r){let{title:n,kind:e,content:a}=t,o=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;console.log(`[ComponentStream] Creating document: ${n} (${e})`),this.streamArtifact({id:o,kind:e,title:n,content:a}),this.dataStream.write({type:"tool-result",data:{toolCallId:r,toolName:"create_document",result:{id:o,title:n,kind:e,message:"Document created successfully"}}});}handleUpdateDocument(t,r){let{id:n,description:e,content:a}=t;console.log(`[ComponentStream] Updating document: ${n}`),this.dataStream.write({type:"data-clear",data:null,transient:true}),this.streamContent(a),this.dataStream.write({type:"data-finish",data:null,transient:true}),this.dataStream.write({type:"tool-result",data:{toolCallId:r,toolName:"update_document",result:{id:n,message:`Document updated: ${e}`}}});}handleArtifactResult(t){let{id:r,title:n,kind:e,content:a}=t;if(!r||!n||!e||!a){console.error("[ComponentStream] Invalid artifact result:",t);return}this.streamArtifact({id:r,kind:e,title:n,content:a});}handleArtifactUpdate(t){let{content:r}=t;if(!r){console.error("[ComponentStream] Invalid artifact update:",t);return}this.dataStream.write({type:"data-clear",data:null,transient:true}),this.streamContent(r),this.dataStream.write({type:"data-finish",data:null,transient:true});}splitIntoChunks(t,r){let n=[],e=t.split(" "),a="";for(let o=0;o<e.length;o++){let s=o===0?e[o]:" "+e[o];a.length+s.length>r&&a.length>0?(n.push(a),a=s.trim()):a+=s;}return a.length>0&&n.push(a),n}};function y(i){return !!(i?.tool_calls&&Array.isArray(i.tool_calls)&&i.tool_calls.length>0)}function E(i){try{let t=JSON.parse(i);if(t.type&&(t.type==="artifact"||t.type==="artifact_update"))return [t]}catch{}return []}function v(i){return new p(i)}exports.ComponentStreamAdapter=p;exports.SSEWriter=d;exports.createComponentStreamAdapter=v;exports.createSSEResponse=S;exports.createSSEWriter=g;exports.extractToolResults=E;exports.hasToolCalls=y;exports.parseSSEStream=h;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE (Server-Sent Events) streaming utilities
|
|
3
|
+
*/
|
|
4
|
+
interface SSEEvent {
|
|
5
|
+
event?: string;
|
|
6
|
+
data: unknown;
|
|
7
|
+
id?: string;
|
|
8
|
+
retry?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse SSE stream from a Response
|
|
12
|
+
*/
|
|
13
|
+
declare function parseSSEStream(response: Response): AsyncIterable<SSEEvent>;
|
|
14
|
+
/**
|
|
15
|
+
* Create an SSE Response from an async iterable
|
|
16
|
+
*/
|
|
17
|
+
declare function createSSEResponse(stream: AsyncIterable<SSEEvent>, headers?: Record<string, string>): Response;
|
|
18
|
+
/**
|
|
19
|
+
* Create an SSE writer for streaming events
|
|
20
|
+
*/
|
|
21
|
+
declare class SSEWriter {
|
|
22
|
+
private encoder;
|
|
23
|
+
private controller;
|
|
24
|
+
private stream;
|
|
25
|
+
constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Get the underlying ReadableStream
|
|
28
|
+
*/
|
|
29
|
+
getStream(): ReadableStream<Uint8Array>;
|
|
30
|
+
/**
|
|
31
|
+
* Get a Response object for this stream
|
|
32
|
+
*/
|
|
33
|
+
getResponse(headers?: Record<string, string>): Response;
|
|
34
|
+
/**
|
|
35
|
+
* Write an SSE event
|
|
36
|
+
*/
|
|
37
|
+
write(event: SSEEvent): void;
|
|
38
|
+
/**
|
|
39
|
+
* Write a data-only event
|
|
40
|
+
*/
|
|
41
|
+
writeData(data: unknown): void;
|
|
42
|
+
/**
|
|
43
|
+
* Write a comment (for keep-alive)
|
|
44
|
+
*/
|
|
45
|
+
writeComment(comment: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Close the stream
|
|
48
|
+
*/
|
|
49
|
+
close(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Signal an error
|
|
52
|
+
*/
|
|
53
|
+
error(err: Error): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create an SSE writer
|
|
57
|
+
*/
|
|
58
|
+
declare function createSSEWriter(): SSEWriter;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Component Streaming - Artifact streaming adapter
|
|
62
|
+
*
|
|
63
|
+
* Converts tool call responses to artifact data stream format
|
|
64
|
+
*/
|
|
65
|
+
interface DataStreamWriter {
|
|
66
|
+
write(data: {
|
|
67
|
+
type: string;
|
|
68
|
+
data: unknown;
|
|
69
|
+
transient?: boolean;
|
|
70
|
+
}): void;
|
|
71
|
+
}
|
|
72
|
+
interface ArtifactToolCall {
|
|
73
|
+
id: string;
|
|
74
|
+
type: 'function';
|
|
75
|
+
function: {
|
|
76
|
+
name: string;
|
|
77
|
+
arguments: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
interface ArtifactToolResult {
|
|
81
|
+
type: string;
|
|
82
|
+
id?: string;
|
|
83
|
+
title?: string;
|
|
84
|
+
kind?: string;
|
|
85
|
+
content?: string;
|
|
86
|
+
message?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Artifact streaming adapter for AI SDK integration
|
|
91
|
+
*/
|
|
92
|
+
declare class ComponentStreamAdapter {
|
|
93
|
+
private dataStream;
|
|
94
|
+
constructor(dataStream: DataStreamWriter);
|
|
95
|
+
/**
|
|
96
|
+
* Process tool calls and convert to artifact stream events
|
|
97
|
+
*/
|
|
98
|
+
processToolCalls(toolCalls: ArtifactToolCall[]): void;
|
|
99
|
+
/**
|
|
100
|
+
* Process tool results
|
|
101
|
+
*/
|
|
102
|
+
processToolResult(result: ArtifactToolResult): void;
|
|
103
|
+
/**
|
|
104
|
+
* Stream an artifact with metadata
|
|
105
|
+
*/
|
|
106
|
+
streamArtifact(artifact: {
|
|
107
|
+
id: string;
|
|
108
|
+
kind: string;
|
|
109
|
+
title: string;
|
|
110
|
+
content: string;
|
|
111
|
+
}): void;
|
|
112
|
+
/**
|
|
113
|
+
* Stream a text delta
|
|
114
|
+
*/
|
|
115
|
+
streamTextDelta(delta: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Stream content in chunks
|
|
118
|
+
*/
|
|
119
|
+
streamContent(content: string, chunkSize?: number): void;
|
|
120
|
+
/**
|
|
121
|
+
* Signal finish
|
|
122
|
+
*/
|
|
123
|
+
finish(): void;
|
|
124
|
+
private handleCreateDocument;
|
|
125
|
+
private handleUpdateDocument;
|
|
126
|
+
private handleArtifactResult;
|
|
127
|
+
private handleArtifactUpdate;
|
|
128
|
+
private splitIntoChunks;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Helper to detect tool calls in a message
|
|
132
|
+
*/
|
|
133
|
+
declare function hasToolCalls(message: {
|
|
134
|
+
tool_calls?: unknown[];
|
|
135
|
+
}): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Helper to extract tool results from content
|
|
138
|
+
*/
|
|
139
|
+
declare function extractToolResults(content: string): ArtifactToolResult[];
|
|
140
|
+
/**
|
|
141
|
+
* Factory function
|
|
142
|
+
*/
|
|
143
|
+
declare function createComponentStreamAdapter(dataStream: DataStreamWriter): ComponentStreamAdapter;
|
|
144
|
+
|
|
145
|
+
export { type ArtifactToolCall, type ArtifactToolResult, ComponentStreamAdapter, type DataStreamWriter, type SSEEvent, SSEWriter, createComponentStreamAdapter, createSSEResponse, createSSEWriter, extractToolResults, hasToolCalls, parseSSEStream };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE (Server-Sent Events) streaming utilities
|
|
3
|
+
*/
|
|
4
|
+
interface SSEEvent {
|
|
5
|
+
event?: string;
|
|
6
|
+
data: unknown;
|
|
7
|
+
id?: string;
|
|
8
|
+
retry?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse SSE stream from a Response
|
|
12
|
+
*/
|
|
13
|
+
declare function parseSSEStream(response: Response): AsyncIterable<SSEEvent>;
|
|
14
|
+
/**
|
|
15
|
+
* Create an SSE Response from an async iterable
|
|
16
|
+
*/
|
|
17
|
+
declare function createSSEResponse(stream: AsyncIterable<SSEEvent>, headers?: Record<string, string>): Response;
|
|
18
|
+
/**
|
|
19
|
+
* Create an SSE writer for streaming events
|
|
20
|
+
*/
|
|
21
|
+
declare class SSEWriter {
|
|
22
|
+
private encoder;
|
|
23
|
+
private controller;
|
|
24
|
+
private stream;
|
|
25
|
+
constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Get the underlying ReadableStream
|
|
28
|
+
*/
|
|
29
|
+
getStream(): ReadableStream<Uint8Array>;
|
|
30
|
+
/**
|
|
31
|
+
* Get a Response object for this stream
|
|
32
|
+
*/
|
|
33
|
+
getResponse(headers?: Record<string, string>): Response;
|
|
34
|
+
/**
|
|
35
|
+
* Write an SSE event
|
|
36
|
+
*/
|
|
37
|
+
write(event: SSEEvent): void;
|
|
38
|
+
/**
|
|
39
|
+
* Write a data-only event
|
|
40
|
+
*/
|
|
41
|
+
writeData(data: unknown): void;
|
|
42
|
+
/**
|
|
43
|
+
* Write a comment (for keep-alive)
|
|
44
|
+
*/
|
|
45
|
+
writeComment(comment: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Close the stream
|
|
48
|
+
*/
|
|
49
|
+
close(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Signal an error
|
|
52
|
+
*/
|
|
53
|
+
error(err: Error): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create an SSE writer
|
|
57
|
+
*/
|
|
58
|
+
declare function createSSEWriter(): SSEWriter;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Component Streaming - Artifact streaming adapter
|
|
62
|
+
*
|
|
63
|
+
* Converts tool call responses to artifact data stream format
|
|
64
|
+
*/
|
|
65
|
+
interface DataStreamWriter {
|
|
66
|
+
write(data: {
|
|
67
|
+
type: string;
|
|
68
|
+
data: unknown;
|
|
69
|
+
transient?: boolean;
|
|
70
|
+
}): void;
|
|
71
|
+
}
|
|
72
|
+
interface ArtifactToolCall {
|
|
73
|
+
id: string;
|
|
74
|
+
type: 'function';
|
|
75
|
+
function: {
|
|
76
|
+
name: string;
|
|
77
|
+
arguments: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
interface ArtifactToolResult {
|
|
81
|
+
type: string;
|
|
82
|
+
id?: string;
|
|
83
|
+
title?: string;
|
|
84
|
+
kind?: string;
|
|
85
|
+
content?: string;
|
|
86
|
+
message?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Artifact streaming adapter for AI SDK integration
|
|
91
|
+
*/
|
|
92
|
+
declare class ComponentStreamAdapter {
|
|
93
|
+
private dataStream;
|
|
94
|
+
constructor(dataStream: DataStreamWriter);
|
|
95
|
+
/**
|
|
96
|
+
* Process tool calls and convert to artifact stream events
|
|
97
|
+
*/
|
|
98
|
+
processToolCalls(toolCalls: ArtifactToolCall[]): void;
|
|
99
|
+
/**
|
|
100
|
+
* Process tool results
|
|
101
|
+
*/
|
|
102
|
+
processToolResult(result: ArtifactToolResult): void;
|
|
103
|
+
/**
|
|
104
|
+
* Stream an artifact with metadata
|
|
105
|
+
*/
|
|
106
|
+
streamArtifact(artifact: {
|
|
107
|
+
id: string;
|
|
108
|
+
kind: string;
|
|
109
|
+
title: string;
|
|
110
|
+
content: string;
|
|
111
|
+
}): void;
|
|
112
|
+
/**
|
|
113
|
+
* Stream a text delta
|
|
114
|
+
*/
|
|
115
|
+
streamTextDelta(delta: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Stream content in chunks
|
|
118
|
+
*/
|
|
119
|
+
streamContent(content: string, chunkSize?: number): void;
|
|
120
|
+
/**
|
|
121
|
+
* Signal finish
|
|
122
|
+
*/
|
|
123
|
+
finish(): void;
|
|
124
|
+
private handleCreateDocument;
|
|
125
|
+
private handleUpdateDocument;
|
|
126
|
+
private handleArtifactResult;
|
|
127
|
+
private handleArtifactUpdate;
|
|
128
|
+
private splitIntoChunks;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Helper to detect tool calls in a message
|
|
132
|
+
*/
|
|
133
|
+
declare function hasToolCalls(message: {
|
|
134
|
+
tool_calls?: unknown[];
|
|
135
|
+
}): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Helper to extract tool results from content
|
|
138
|
+
*/
|
|
139
|
+
declare function extractToolResults(content: string): ArtifactToolResult[];
|
|
140
|
+
/**
|
|
141
|
+
* Factory function
|
|
142
|
+
*/
|
|
143
|
+
declare function createComponentStreamAdapter(dataStream: DataStreamWriter): ComponentStreamAdapter;
|
|
144
|
+
|
|
145
|
+
export { type ArtifactToolCall, type ArtifactToolResult, ComponentStreamAdapter, type DataStreamWriter, type SSEEvent, SSEWriter, createComponentStreamAdapter, createSSEResponse, createSSEWriter, extractToolResults, hasToolCalls, parseSSEStream };
|