blink 0.1.25 → 0.1.26

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,24 +1,7 @@
1
1
  import { AsyncIterableStream, InferUIMessageChunk, UIMessage } from "ai";
2
2
 
3
- //#region src/api/chat.d.ts
4
- interface Chat {
5
- readonly id: string;
6
- }
7
- interface CreateChatOptions {
8
- readonly messages: ReadonlyArray<UIMessage>;
9
- readonly labels?: ReadonlyArray<string>;
10
- readonly title?: string;
11
- }
12
- interface MessageOptions {
13
- readonly behavior?: "interrupt" | "queue";
14
- }
15
- declare const chat: Readonly<{
16
- find(labels: ReadonlyArray<string>): Promise<Chat | undefined>;
17
- create(options: CreateChatOptions): Promise<Chat>;
18
- message(chat: string, message: UIMessage, options?: MessageOptions): Promise<void>;
19
- }>;
20
- //#endregion
21
3
  //#region src/api/index.d.ts
4
+
22
5
  /**
23
6
  * SendMessagesResponse is the response of the sendMessages function.
24
7
  * It can be a stream of messages or an arbitrary response.
@@ -32,6 +15,7 @@ type SendMessagesResponse = {
32
15
  interface SendMessagesOptions {
33
16
  readonly messages: UIMessage[];
34
17
  readonly abortSignal?: AbortSignal;
18
+ readonly request: Request;
35
19
  }
36
20
  interface Agent {
37
21
  sendMessages(options: SendMessagesOptions): Promise<SendMessagesResponse> | SendMessagesResponse;
@@ -62,4 +46,4 @@ declare const StreamResponseFormatHeader = "x-blink-stream-response-format";
62
46
  type StreamResponseFormat = "ui-message" | "openai-chat" | "openai-response" | "anthropic" | "google" | "xai";
63
47
  declare function withResponseFormat(response: Response, format: StreamResponseFormat): Response;
64
48
  //#endregion
65
- export { Agent, AgentDefaultExport, Chat, CreateChatOptions, MessageOptions, SendMessagesOptions, SendMessagesRequest, SendMessagesResponse, StreamResponseFormat, StreamResponseFormatHeader, agent, chat, withResponseFormat };
49
+ export { Agent, AgentDefaultExport, SendMessagesOptions, SendMessagesRequest, SendMessagesResponse, StreamResponseFormat, StreamResponseFormatHeader, agent, withResponseFormat };
@@ -1,24 +1,7 @@
1
1
  import { AsyncIterableStream, InferUIMessageChunk, UIMessage } from "ai";
2
2
 
3
- //#region src/api/chat.d.ts
4
- interface Chat {
5
- readonly id: string;
6
- }
7
- interface CreateChatOptions {
8
- readonly messages: ReadonlyArray<UIMessage>;
9
- readonly labels?: ReadonlyArray<string>;
10
- readonly title?: string;
11
- }
12
- interface MessageOptions {
13
- readonly behavior?: "interrupt" | "queue";
14
- }
15
- declare const chat: Readonly<{
16
- find(labels: ReadonlyArray<string>): Promise<Chat | undefined>;
17
- create(options: CreateChatOptions): Promise<Chat>;
18
- message(chat: string, message: UIMessage, options?: MessageOptions): Promise<void>;
19
- }>;
20
- //#endregion
21
3
  //#region src/api/index.d.ts
4
+
22
5
  /**
23
6
  * SendMessagesResponse is the response of the sendMessages function.
24
7
  * It can be a stream of messages or an arbitrary response.
@@ -32,6 +15,7 @@ type SendMessagesResponse = {
32
15
  interface SendMessagesOptions {
33
16
  readonly messages: UIMessage[];
34
17
  readonly abortSignal?: AbortSignal;
18
+ readonly request: Request;
35
19
  }
36
20
  interface Agent {
37
21
  sendMessages(options: SendMessagesOptions): Promise<SendMessagesResponse> | SendMessagesResponse;
@@ -62,4 +46,4 @@ declare const StreamResponseFormatHeader = "x-blink-stream-response-format";
62
46
  type StreamResponseFormat = "ui-message" | "openai-chat" | "openai-response" | "anthropic" | "google" | "xai";
63
47
  declare function withResponseFormat(response: Response, format: StreamResponseFormat): Response;
64
48
  //#endregion
65
- export { Agent, AgentDefaultExport, Chat, CreateChatOptions, MessageOptions, SendMessagesOptions, SendMessagesRequest, SendMessagesResponse, StreamResponseFormat, StreamResponseFormatHeader, agent, chat, withResponseFormat };
49
+ export { Agent, AgentDefaultExport, SendMessagesOptions, SendMessagesRequest, SendMessagesResponse, StreamResponseFormat, StreamResponseFormatHeader, agent, withResponseFormat };
@@ -1,4 +1,4 @@
1
- import { AgentDefaultExport } from "../index-Hwp0nvOG.cjs";
1
+ import { AgentDefaultExport } from "../index-BACRosVA.cjs";
2
2
  import * as _whatwg_node_server0 from "@whatwg-node/server";
3
3
 
4
4
  //#region src/runtime/node.d.ts
@@ -1,4 +1,4 @@
1
- import { AgentDefaultExport } from "../index-C29YiDK4.js";
1
+ import { AgentDefaultExport } from "../index-CAMDiyg3.js";
2
2
  import * as _whatwg_node_server0 from "@whatwg-node/server";
3
3
 
4
4
  //#region src/runtime/node.d.ts
package/dist/test.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./chunk-hhQzssFb.cjs`),t=require(`./client-pr8z4xo-.cjs`);require(`./api-DhKQVJLF.cjs`);const n=require(`./node-mY3TV99H.cjs`);let r=require(`fs/promises`);r=e.__toESM(r);let i=require(`path`);i=e.__toESM(i);async function a(e,{outdir:t}={}){t||=await s(e);let n=(0,i.join)(t,`agent.js`),r=u(),a=await r.build({...l,entryPoints:[e],outfile:n});if(a.errors.length>0)throw Error(`Failed to build agent!`);return{outfile:n}}async function o(e){let t=await c(e,`package.json`);if(!t)throw Error(`No package.json found in ${e}`);let n=JSON.parse(await(0,r.readFile)(t,`utf-8`)),a=n.main;if(!a)throw Error(`"main" is not set in ${(0,i.relative)(process.cwd(),t)}. It should be set to the entrypoint of your agent.`);let o=(0,i.join)((0,i.dirname)(t),a),s=await(0,r.stat)(o);if(!s.isFile())throw Error(`${o} is not a file.`);return o}async function s(e){let t=await c(e,`node_modules`);if(!t){let t=await(0,r.stat)(e);return t.isDirectory()?(0,i.join)(e,`.blink`):(0,i.join)((0,i.dirname)(e),`.blink`)}let n=(0,i.join)(t,`.blink`);return await(0,r.mkdir)(n,{recursive:!0}),n}async function c(e,t){let n=e;for(;n!==(0,i.dirname)(n);){let e=(0,i.join)(n,t);try{return await(0,r.stat)(e),e}catch{}n=(0,i.dirname)(n)}}const l={bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:`inline`},u=()=>{try{return require(`esbuild`)}catch{throw Error("esbuild is not installed. Please install it with `bun add esbuild`.")}};async function d(e){let r=e?.entrypoint??await o(e?.cwd??process.cwd());if(!r)throw Error(`Unable to locate the entrypoint of the agent. Please specify it manually.`);let i;if(typeof Bun<`u`)i=n.requireAsCommonJS(r);else{let{outfile:e}=await a(r);i=n.requireAsCommonJS(e)}return t.createClientFromAgent(i)}exports.create=d;
1
+ const e=require(`./chunk-hhQzssFb.cjs`),t=require(`./client-C_eHD6hz.cjs`);require(`./api-wEN9yX1N.cjs`);const n=require(`./node-mY3TV99H.cjs`);let r=require(`fs/promises`);r=e.__toESM(r);let i=require(`path`);i=e.__toESM(i);async function a(e,{outdir:t}={}){t||=await s(e);let n=(0,i.join)(t,`agent.js`),r=u(),a=await r.build({...l,entryPoints:[e],outfile:n});if(a.errors.length>0)throw Error(`Failed to build agent!`);return{outfile:n}}async function o(e){let t=await c(e,`package.json`);if(!t)throw Error(`No package.json found in ${e}`);let n=JSON.parse(await(0,r.readFile)(t,`utf-8`)),a=n.main;if(!a)throw Error(`"main" is not set in ${(0,i.relative)(process.cwd(),t)}. It should be set to the entrypoint of your agent.`);let o=(0,i.join)((0,i.dirname)(t),a),s=await(0,r.stat)(o);if(!s.isFile())throw Error(`${o} is not a file.`);return o}async function s(e){let t=await c(e,`node_modules`);if(!t){let t=await(0,r.stat)(e);return t.isDirectory()?(0,i.join)(e,`.blink`):(0,i.join)((0,i.dirname)(e),`.blink`)}let n=(0,i.join)(t,`.blink`);return await(0,r.mkdir)(n,{recursive:!0}),n}async function c(e,t){let n=e;for(;n!==(0,i.dirname)(n);){let e=(0,i.join)(n,t);try{return await(0,r.stat)(e),e}catch{}n=(0,i.dirname)(n)}}const l={bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:`inline`},u=()=>{try{return require(`esbuild`)}catch{throw Error("esbuild is not installed. Please install it with `bun add esbuild`.")}};async function d(e){let r=e?.entrypoint??await o(e?.cwd??process.cwd());if(!r)throw Error(`Unable to locate the entrypoint of the agent. Please specify it manually.`);let i;if(typeof Bun<`u`)i=n.requireAsCommonJS(r);else{let{outfile:e}=await a(r);i=n.requireAsCommonJS(e)}return t.createClientFromAgent(i)}exports.create=d;
package/dist/test.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import "./index-Hwp0nvOG.cjs";
2
- import { AgentClient } from "./client-BmidwoTD.cjs";
1
+ import "./index-BACRosVA.cjs";
2
+ import { AgentClient } from "./client-D_o9I3Zc.cjs";
3
3
 
4
4
  //#region src/test.d.ts
5
5
  interface CreateOptions {
package/dist/test.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import "./index-C29YiDK4.js";
2
- import { AgentClient } from "./client-cnNP66Da.js";
1
+ import "./index-CAMDiyg3.js";
2
+ import { AgentClient } from "./client-CogUxWuS.js";
3
3
 
4
4
  //#region src/test.d.ts
5
5
  interface CreateOptions {
package/dist/test.js CHANGED
@@ -1 +1 @@
1
- import{__require as e,requireAsCommonJS as t}from"./node-Cu3BjO-f.js";import{createClientFromAgent as n}from"./client-C1l580Un.js";import"./api-Bl9kCFAZ.js";import{mkdir as r,readFile as i,stat as a}from"fs/promises";import{dirname as o,join as s,relative as c}from"path";async function l(e,{outdir:t}={}){t||=await d(e);let n=s(t,`agent.js`),r=m(),i=await r.build({...p,entryPoints:[e],outfile:n});if(i.errors.length>0)throw Error(`Failed to build agent!`);return{outfile:n}}async function u(e){let t=await f(e,`package.json`);if(!t)throw Error(`No package.json found in ${e}`);let n=JSON.parse(await i(t,`utf-8`)),r=n.main;if(!r)throw Error(`"main" is not set in ${c(process.cwd(),t)}. It should be set to the entrypoint of your agent.`);let l=s(o(t),r),u=await a(l);if(!u.isFile())throw Error(`${l} is not a file.`);return l}async function d(e){let t=await f(e,`node_modules`);if(!t){let t=await a(e);return t.isDirectory()?s(e,`.blink`):s(o(e),`.blink`)}let n=s(t,`.blink`);return await r(n,{recursive:!0}),n}async function f(e,t){let n=e;for(;n!==o(n);){let e=s(n,t);try{return await a(e),e}catch{}n=o(n)}}const p={bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:`inline`},m=()=>{try{return e(`esbuild`)}catch{throw Error("esbuild is not installed. Please install it with `bun add esbuild`.")}};async function h(e){let r=e?.entrypoint??await u(e?.cwd??process.cwd());if(!r)throw Error(`Unable to locate the entrypoint of the agent. Please specify it manually.`);let i;if(typeof Bun<`u`)i=t(r);else{let{outfile:e}=await l(r);i=t(e)}return n(i)}export{h as create};
1
+ import{__require as e,requireAsCommonJS as t}from"./node-Cu3BjO-f.js";import{createClientFromAgent as n}from"./client-BK6aCqTs.js";import"./api-vofIX7P2.js";import{mkdir as r,readFile as i,stat as a}from"fs/promises";import{dirname as o,join as s,relative as c}from"path";async function l(e,{outdir:t}={}){t||=await d(e);let n=s(t,`agent.js`),r=m(),i=await r.build({...p,entryPoints:[e],outfile:n});if(i.errors.length>0)throw Error(`Failed to build agent!`);return{outfile:n}}async function u(e){let t=await f(e,`package.json`);if(!t)throw Error(`No package.json found in ${e}`);let n=JSON.parse(await i(t,`utf-8`)),r=n.main;if(!r)throw Error(`"main" is not set in ${c(process.cwd(),t)}. It should be set to the entrypoint of your agent.`);let l=s(o(t),r),u=await a(l);if(!u.isFile())throw Error(`${l} is not a file.`);return l}async function d(e){let t=await f(e,`node_modules`);if(!t){let t=await a(e);return t.isDirectory()?s(e,`.blink`):s(o(e),`.blink`)}let n=s(t,`.blink`);return await r(n,{recursive:!0}),n}async function f(e,t){let n=e;for(;n!==o(n);){let e=s(n,t);try{return await a(e),e}catch{}n=o(n)}}const p={bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:`inline`},m=()=>{try{return e(`esbuild`)}catch{throw Error("esbuild is not installed. Please install it with `bun add esbuild`.")}};async function h(e){let r=e?.entrypoint??await u(e?.cwd??process.cwd());if(!r)throw Error(`Unable to locate the entrypoint of the agent. Please specify it manually.`);let i;if(typeof Bun<`u`)i=t(r);else{let{outfile:e}=await l(r);i=t(e)}return n(i)}export{h as create};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blink",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Blink is a JavaScript runtime for building and deploying AI agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,6 +22,11 @@
22
22
  "import": "./dist/client.js",
23
23
  "require": "./dist/client.cjs"
24
24
  },
25
+ "./cloud": {
26
+ "types": "./dist/cloud.d.ts",
27
+ "import": "./dist/cloud.js",
28
+ "require": "./dist/cloud.cjs"
29
+ },
25
30
  "./runtime/node": {
26
31
  "types": "./dist/runtime/node.d.ts",
27
32
  "import": "./dist/runtime/node.js",
@@ -44,6 +49,7 @@
44
49
  "@blink.so/api": "^0.0.3",
45
50
  "@clack/prompts": "^0.11.0",
46
51
  "@hugodutka/gemini-cli": "^0.6.0-nightly-20250912-5",
52
+ "@mswjs/interceptors": "^0.39.6",
47
53
  "@types/marked-terminal": "^6.1.1",
48
54
  "@whatwg-node/server": "^0.10.12",
49
55
  "ai": "^5.0.34",
@@ -1 +0,0 @@
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`,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};
@@ -1 +0,0 @@
1
- const e=require(`./chunk-hhQzssFb.cjs`);let t=require(`util`);t=e.__toESM(t);const n=Object.freeze({find(e){throw Error(`Not implemented`)},create(e){throw Error(`Not implemented`)},message(e,t,n){throw Error(`Not implemented`)}});function r(e){return{version:`v0`,fetch:async t=>{let n=new URL(t.url);switch(n.pathname){case`/sendMessages`:return a(t,e);case`/webhook`:return o(t,e);default:return new Response(`Not found`,{status:404})}}}}let i;async function a(e,n){if(e.method!==`POST`)return new Response(`Method not allowed`,{status:405});let r;try{r=await e.json()}catch{return new Response(`Invalid request`,{status:400})}let a;try{a=await n.sendMessages({messages:r.messages})}catch(e){return new Response(JSON.stringify({error:t.default.inspect(e)}),{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.`);i||=new TextEncoder;let o=new TransformStream({transform(e,t){t.enqueue(i.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 o(e,n){if(!n.webhook)return new Response(`No webhook function provided`,{status:501});try{let t=await n.webhook(e);return t||new Response(`OK`,{status:200})}catch(e){return new Response(JSON.stringify({error:t.default.inspect(e)}),{status:500})}}const s=`x-blink-stream-response-format`;function c(e,t){return e.headers.set(s,t),e}Object.defineProperty(exports,`StreamResponseFormatHeader`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`agent`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`chat`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`withResponseFormat`,{enumerable:!0,get:function(){return c}});