blink 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +1 -1
- package/dist/api-_RFSw3t6.js +1 -0
- package/dist/bundler-C418VyAO.js +1 -0
- package/dist/cli/index.js +215 -226
- package/dist/client-B4tfo0zj.js +53 -0
- package/dist/client-Cn1FcD00.d.ts +35 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +1 -0
- package/dist/index-CTDv0MO-.d.ts +71 -0
- package/dist/node-CYfjRztS.js +8 -0
- package/dist/runtime/node.d.ts +23 -0
- package/dist/runtime/node.js +1 -0
- package/dist/test.d.ts +12 -0
- package/dist/test.js +1 -0
- package/package.json +20 -4
- package/dist/api/test.d.ts +0 -15
- package/dist/api/test.js +0 -1
- package/dist/common.d.ts +0 -207
- package/dist/runtime.wasm +0 -0
- package/dist/wasm.js +0 -61
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { Agent, AgentDefaultExport, Chat, CreateChatOptions, MessageOptions, SendMessagesOptions, SendMessagesRequest, SendMessagesResponse, StreamResponseFormat, StreamResponseFormatHeader, agent, chat, withResponseFormat } from "../index-CTDv0MO-.js";
|
|
2
|
+
export { Agent, AgentDefaultExport, Chat, CreateChatOptions, MessageOptions, SendMessagesOptions, SendMessagesRequest, SendMessagesResponse, StreamResponseFormat, StreamResponseFormatHeader, agent, chat, withResponseFormat };
|
package/dist/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{StreamResponseFormatHeader as e,agent as t,chat as n,withResponseFormat as r}from"../api-_RFSw3t6.js";export{e as StreamResponseFormatHeader,t as agent,n as chat,r as withResponseFormat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"util";const t=Object.freeze({find(e){throw Error(`Not implemented`)},create(e){throw Error(`Not implemented`)},message(e,t,n){throw Error(`Not implemented`)}});function n(e){return{version:`v0`,metadata:{displayName:e.displayName,description:e.description},fetch:async t=>{let n=new URL(t.url);switch(n.pathname){case`/sendMessages`:return i(t,e);case`/webhook`:return a(t,e);default:return new Response(`Not found`,{status:404})}}}}let r;async function i(t,n){if(t.method!==`POST`)return new Response(`Method not allowed`,{status:405});let i;try{i=await t.json()}catch{return new Response(`Invalid request`,{status:400})}let a;try{a=await n.sendMessages({messages:i.messages})}catch(t){return new Response(JSON.stringify({error:e.inspect(t)}),{status:500})}if(a instanceof Response)return a;if(a instanceof ReadableStream)return new Response(a,{headers:{"Content-Type":`text/event-stream`}});if(typeof a!=`object`||typeof a==`object`&&!(`toUIMessageStream`in a))throw Error(`The agent must return a "Response", "ReadableStream", or "toUIMessageStream" function.`);r||=new TextEncoder;let o=new TransformStream({transform(e,t){t.enqueue(r.encode(`data: ${JSON.stringify(e)}\n\n`))}}),s=a.toUIMessageStream();return s.pipeTo(o.writable),new Response(o.readable,{headers:{"Content-Type":`text/event-stream`}})}async function a(t,n){if(!n.webhook)return new Response(`No webhook function provided`,{status:501});try{let e=await n.webhook(t);return e||new Response(`OK`,{status:200})}catch(t){return new Response(JSON.stringify({error:e.inspect(t)}),{status:500})}}const o=`x-blink-stream-response-format`;function s(e,t){return e.headers.set(o,t),e}export{o as StreamResponseFormatHeader,n as agent,t as chat,s as withResponseFormat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__require as e}from"./node-CYfjRztS.js";import{mkdir as t,readFile as n,stat as r}from"fs/promises";import{dirname as i,join as a,relative as o}from"path";async function s(e,{outdir:t}={}){t||=await u(e);let n=a(t,`agent.js`),r=p(),i=await r.build({...f,entryPoints:[e],outfile:n});if(i.errors.length>0)throw Error(`Failed to build agent!`);return{outfile:n}}async function c(e,{onErrors:t,onBuildStart:n,onBuildEnd:r,outdir:i}){let o=p();i||=await u(e);let s=a(i,`agent.js`),c=await o.context({...f,entryPoints:[e],logLevel:`silent`,outfile:s,plugins:[{name:`blink-dev-server`,setup(e){e.onStart(()=>{n?.()}),e.onEnd(e=>{if(e.errors.length>0){t?.(e.errors);return}r?.({outfile:s})})}}]});return await c.watch(),{dispose:()=>{c.dispose()}}}async function l(e){let t=await d(e,`package.json`);if(!t)throw Error(`No package.json found in ${e}`);let s=JSON.parse(await n(t,`utf-8`)),c=s.main;if(!c)throw Error(`"main" is not set in ${o(process.cwd(),t)}. It should be set to the entrypoint of your agent.`);let l=a(i(t),c),u=await r(l);if(!u.isFile())throw Error(`${l} is not a file.`);return l}async function u(e){let n=await d(e,`node_modules`);if(!n){let t=await r(e);return t.isDirectory()?a(e,`.blink`):a(i(e),`.blink`)}let o=a(n,`.blink`);return await t(o,{recursive:!0}),o}async function d(e,t){let n=e;for(;n!==i(n);){let e=a(n,t);try{return await r(e),e}catch{}n=i(n)}}const f={bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:`inline`},p=()=>{try{return e(`esbuild`)}catch{throw Error("esbuild is not installed. Please install it with `bun add esbuild`.")}};export{s as build,d as findNearestEntry,l as resolveEntrypoint,c as watch};
|