blink 0.1.54 → 0.1.55

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.
Files changed (48) hide show
  1. package/dist/api/index.cjs +16 -9
  2. package/dist/api/index.d.cts +2 -265
  3. package/dist/api/index.d.ts +2 -265
  4. package/dist/api/index.js +15 -8
  5. package/dist/build/index.cjs +7 -0
  6. package/dist/build/index.d.cts +107 -0
  7. package/dist/build/index.d.ts +107 -0
  8. package/dist/build/index.js +7 -0
  9. package/dist/chunk-___ucjiX.js +1 -0
  10. package/dist/chunk-hhQzssFb.cjs +1 -0
  11. package/dist/cli/auth-Dw-wJ1IM.js +30 -0
  12. package/dist/cli/{chat-VT2y0Ejx.js → chat-CvTLq5E0.js} +1 -1
  13. package/dist/cli/connect-BHyGYU8L.js +1 -0
  14. package/dist/cli/connect-Cxa-uIEb.js +26 -0
  15. package/dist/cli/{dev-DWe1-Qrm.js → dev-Kje8z9kN.js} +415 -340
  16. package/dist/cli/devtools-BS9tk1Y9.js +14 -14
  17. package/dist/cli/dist-CN69Y-yA.js +1 -1
  18. package/dist/cli/esm-CeJfCMPI.js +1 -1
  19. package/dist/cli/index.js +10 -10
  20. package/dist/cli/{init-CyILyaVn.js → init-x07jlFqm.js} +2 -2
  21. package/dist/cli/login-KHDcJ0iZ.js +1 -0
  22. package/dist/cli/undici-BG07ys6c.js +6 -6
  23. package/dist/cli/util-cVEGIV3r.js +9 -0
  24. package/dist/cli/wrapper-B4vDwpOq.js +2 -2
  25. package/dist/http/index.cjs +1 -0
  26. package/dist/http/index.d.cts +3 -0
  27. package/dist/http/index.d.ts +3 -0
  28. package/dist/http/index.js +1 -0
  29. package/dist/http-BAfeJhFm.js +53 -0
  30. package/dist/http-DS8vmbQx.cjs +53 -0
  31. package/dist/index-BgJpZoBy.d.cts +102 -0
  32. package/dist/index-IWju3eNc.d.cts +286 -0
  33. package/dist/index-auvvMWNH.d.ts +102 -0
  34. package/dist/index-tvf1rglX.d.ts +286 -0
  35. package/dist/test.cjs +1 -4
  36. package/dist/test.d.cts +4 -1
  37. package/dist/test.d.ts +4 -1
  38. package/dist/test.js +1 -4
  39. package/package.json +12 -8
  40. package/dist/cli/auth-BP6XsB4o.js +0 -30
  41. package/dist/cli/connect-CUOPse6P.js +0 -1
  42. package/dist/cli/connect-CswVxp7Y.js +0 -26
  43. package/dist/cli/login-JR8bA13P.js +0 -1
  44. package/dist/cli/main-DqOlaYW2.js +0 -6
  45. package/dist/cli/serve-CEeYlO7w.js +0 -60
  46. package/dist/cli/serve-DY71nMqp.js +0 -1
  47. package/dist/cookie-CB9k3Awr.js +0 -11
  48. package/dist/cookie-Dx2Kx4Zh.cjs +0 -11
@@ -0,0 +1,107 @@
1
+ import * as esbuild from "esbuild";
2
+
3
+ //#region src/build/types.d.ts
4
+ interface BuildLog {
5
+ readonly message: string;
6
+ readonly file?: string;
7
+ }
8
+ type BuildResult = {
9
+ readonly entry: string;
10
+ readonly outdir: string;
11
+ readonly warnings: BuildLog[];
12
+ /**
13
+ * duration is the duration of the build in milliseconds.
14
+ */
15
+ readonly duration: number;
16
+ } | {
17
+ readonly error: BuildLog;
18
+ };
19
+ /**
20
+ * BuildContext is context passed to the build function.
21
+ *
22
+ * It is the implementors responsibility to handle `watch`
23
+ * and to appropriately call `onStart` and `onEnd`.
24
+ */
25
+ interface BuildContext {
26
+ readonly entry: string;
27
+ readonly outdir: string;
28
+ readonly cwd: string;
29
+ readonly dev?: boolean;
30
+ readonly watch?: boolean;
31
+ readonly signal?: AbortSignal;
32
+ readonly onStart: () => void;
33
+ readonly onResult: (result: BuildResult) => void;
34
+ }
35
+ //#endregion
36
+ //#region src/build/esbuild.d.ts
37
+ declare function buildWithEsbuild(options?: esbuild.BuildOptions): (context: BuildContext) => Promise<void>;
38
+ //#endregion
39
+ //#region src/build/index.d.ts
40
+ interface Config {
41
+ /**
42
+ * entry is the path to the entry point of the agent.
43
+ * Defaults to `src/agent.ts` or `agent.ts` in the current working directory.
44
+ */
45
+ entry?: string;
46
+ /**
47
+ * outdir is the directory to write the build output to.
48
+ * Defaults to `.blink/build` in the current working directory.
49
+ */
50
+ outdir?: string;
51
+ /**
52
+ * build is invoked when the build starts.
53
+ * This is triggered by `blink dev` or `blink build`.
54
+ *
55
+ * By default, this uses the `buildWithEsbuild` function.
56
+ *
57
+ * @param context - The build context.
58
+ * @returns
59
+ * @example
60
+ * ```ts
61
+ * import { defineConfig } from "blink/build";
62
+ *
63
+ * export default defineConfig({
64
+ * entry: "src/agent.ts",
65
+ * outdir: "dist",
66
+ * build: ({ entry, outdir, watch, onStart, onEnd }) => {
67
+ * await onStart();
68
+ * // ... perform build ...
69
+ * await onEnd({
70
+ * entry: "dist/agent.js",
71
+ * outdir: "dist",
72
+ * warnings: [],
73
+ * });
74
+ * }
75
+ * })
76
+ * ```
77
+ */
78
+ build?: (context: BuildContext) => Promise<void>;
79
+ }
80
+ type ResolvedConfig = Required<Config>;
81
+ /**
82
+ * defineConfig is a helper function for typing the config object.
83
+ *
84
+ * @param config - The config object.
85
+ * @returns The config object.
86
+ * @example
87
+ * ```ts
88
+ * import { defineConfig } from "blink/build";
89
+ *
90
+ * export default defineConfig({
91
+ * entry: "src/agent.ts",
92
+ * outdir: "dist",
93
+ * build: ({ entry, outdir, onBuildStart, onBuildEnd }) => {
94
+ *
95
+ * }
96
+ * })
97
+ */
98
+ declare function defineConfig(config?: Config): Config;
99
+ /**
100
+ * resolveConfig resolves the Blink config for a given directory.
101
+ *
102
+ * @param directory - The directory to resolve the config for.
103
+ * @returns The resolved config.
104
+ */
105
+ declare function resolveConfig(directory: string): ResolvedConfig;
106
+ //#endregion
107
+ export { BuildContext, BuildLog, BuildResult, Config, ResolvedConfig, buildWithEsbuild, defineConfig, resolveConfig };
@@ -0,0 +1,107 @@
1
+ import * as esbuild from "esbuild";
2
+
3
+ //#region src/build/types.d.ts
4
+ interface BuildLog {
5
+ readonly message: string;
6
+ readonly file?: string;
7
+ }
8
+ type BuildResult = {
9
+ readonly entry: string;
10
+ readonly outdir: string;
11
+ readonly warnings: BuildLog[];
12
+ /**
13
+ * duration is the duration of the build in milliseconds.
14
+ */
15
+ readonly duration: number;
16
+ } | {
17
+ readonly error: BuildLog;
18
+ };
19
+ /**
20
+ * BuildContext is context passed to the build function.
21
+ *
22
+ * It is the implementors responsibility to handle `watch`
23
+ * and to appropriately call `onStart` and `onEnd`.
24
+ */
25
+ interface BuildContext {
26
+ readonly entry: string;
27
+ readonly outdir: string;
28
+ readonly cwd: string;
29
+ readonly dev?: boolean;
30
+ readonly watch?: boolean;
31
+ readonly signal?: AbortSignal;
32
+ readonly onStart: () => void;
33
+ readonly onResult: (result: BuildResult) => void;
34
+ }
35
+ //#endregion
36
+ //#region src/build/esbuild.d.ts
37
+ declare function buildWithEsbuild(options?: esbuild.BuildOptions): (context: BuildContext) => Promise<void>;
38
+ //#endregion
39
+ //#region src/build/index.d.ts
40
+ interface Config {
41
+ /**
42
+ * entry is the path to the entry point of the agent.
43
+ * Defaults to `src/agent.ts` or `agent.ts` in the current working directory.
44
+ */
45
+ entry?: string;
46
+ /**
47
+ * outdir is the directory to write the build output to.
48
+ * Defaults to `.blink/build` in the current working directory.
49
+ */
50
+ outdir?: string;
51
+ /**
52
+ * build is invoked when the build starts.
53
+ * This is triggered by `blink dev` or `blink build`.
54
+ *
55
+ * By default, this uses the `buildWithEsbuild` function.
56
+ *
57
+ * @param context - The build context.
58
+ * @returns
59
+ * @example
60
+ * ```ts
61
+ * import { defineConfig } from "blink/build";
62
+ *
63
+ * export default defineConfig({
64
+ * entry: "src/agent.ts",
65
+ * outdir: "dist",
66
+ * build: ({ entry, outdir, watch, onStart, onEnd }) => {
67
+ * await onStart();
68
+ * // ... perform build ...
69
+ * await onEnd({
70
+ * entry: "dist/agent.js",
71
+ * outdir: "dist",
72
+ * warnings: [],
73
+ * });
74
+ * }
75
+ * })
76
+ * ```
77
+ */
78
+ build?: (context: BuildContext) => Promise<void>;
79
+ }
80
+ type ResolvedConfig = Required<Config>;
81
+ /**
82
+ * defineConfig is a helper function for typing the config object.
83
+ *
84
+ * @param config - The config object.
85
+ * @returns The config object.
86
+ * @example
87
+ * ```ts
88
+ * import { defineConfig } from "blink/build";
89
+ *
90
+ * export default defineConfig({
91
+ * entry: "src/agent.ts",
92
+ * outdir: "dist",
93
+ * build: ({ entry, outdir, onBuildStart, onBuildEnd }) => {
94
+ *
95
+ * }
96
+ * })
97
+ */
98
+ declare function defineConfig(config?: Config): Config;
99
+ /**
100
+ * resolveConfig resolves the Blink config for a given directory.
101
+ *
102
+ * @param directory - The directory to resolve the config for.
103
+ * @returns The resolved config.
104
+ */
105
+ declare function resolveConfig(directory: string): ResolvedConfig;
106
+ //#endregion
107
+ export { BuildContext, BuildLog, BuildResult, Config, ResolvedConfig, buildWithEsbuild, defineConfig, resolveConfig };
@@ -0,0 +1,7 @@
1
+ import{__require as e}from"../chunk-___ucjiX.js";import t from"path";import{existsSync as n}from"fs";import{builtinModules as r}from"module";import{mkdir as i,writeFile as a}from"fs/promises";function o(e){return async n=>{let o=await import(`esbuild`),s=await o.context({entryPoints:[n.entry],outdir:n.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,i=RegExp(`\\b__require\\("(${r.join(`|`)})"\\)`,`gm`);if(t=t.replace(i,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
2
+ `);t=e+`
3
+
4
+ `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{n.onStart(),r=performance.now()}),e.onEnd(async e=>{await i(n.outdir,{recursive:!0});let o=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];o.push({path:t.resolve(n.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of o)await a(e.path,e.contents);e.errors.length>0?n.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
+ `)}}):n.onResult({entry:t.resolve(n.outdir,t.basename(n.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:n.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),n.watch||(s.dispose(),s.cancel())})}}],...e});await s.watch()}}function s(e){return e??{}}function c(r){let i=[`blink.config.ts`],a;for(let o of i){let i=t.resolve(r,o);if(n(i)){let t=e(i);if(t.default){a={...t.default};break}}}if(a||={},!a.entry){let e=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let i of e){let e=t.resolve(r,i);if(n(e)){a.entry=e;break}}if(!a.entry)throw Error(`Agent entrypoint not found.
6
+
7
+ Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return a.outdir||=t.resolve(r,`.blink/build`),a.build||=o(),a}export{o as buildWithEsbuild,s as defineConfig,c as resolveConfig};
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),f=e=>u(n({},`__esModule`,{value:!0}),e),p=e(import.meta.url);export{c as __commonJSMin,s as __esmMin,l as __export,p as __require,f as __toCommonJS,d as __toESM};
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>l(t({},`__esModule`,{value:!0}),e);Object.defineProperty(exports,`__commonJSMin`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`__esmMin`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`__export`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`__toCommonJS`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`__toESM`,{enumerable:!0,get:function(){return u}});