@junejs/server 0.1.2 → 0.2.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/assets/icon-latin.LICENSE.txt +92 -0
- package/assets/icon-latin.ttf +0 -0
- package/dist/adapter-DcZ-W1-7.d.ts +62 -0
- package/dist/adapter.d.ts +2 -56
- package/dist/adapter.js +62 -5
- package/dist/agent-compile.d.ts +38 -0
- package/dist/agent-compile.js +145 -0
- package/dist/agent-discover.d.ts +4 -4
- package/dist/agent-discover.js +30 -44
- package/dist/agent-durable.d.ts +94 -19
- package/dist/agent-durable.js +647 -32
- package/dist/agent-native.d.ts +44 -13
- package/dist/agent-native.js +264 -27
- package/dist/app.d.ts +5 -5
- package/dist/app.js +42 -10
- package/dist/blob.d.ts +4 -5
- package/dist/build.d.ts +8 -29
- package/dist/build.js +138 -289
- package/dist/client-bundle.d.ts +8 -9
- package/dist/client-bundle.js +1 -1
- package/dist/config-freeze-CyXvNqi2.d.ts +17 -0
- package/dist/config-freeze.d.ts +2 -0
- package/dist/config-freeze.js +54 -0
- package/dist/config-loader.d.ts +3 -4
- package/dist/connection-auth.d.ts +38 -0
- package/dist/connection-auth.js +31 -0
- package/dist/content-freeze-CyiW2fRK.d.ts +4 -0
- package/dist/content-freeze.d.ts +2 -0
- package/dist/content-freeze.js +83 -0
- package/dist/content.d.ts +22 -9
- package/dist/content.js +43 -3
- package/dist/core-version.d.ts +4 -0
- package/dist/core-version.js +12 -0
- package/dist/css-modules-ambient.d.ts +2 -1
- package/dist/css-modules.d.ts +10 -11
- package/dist/css.d.ts +9 -10
- package/dist/d1-migrate.d.ts +6 -7
- package/dist/d1-migrate.js +3 -2
- package/dist/db.d.ts +2 -2
- package/dist/deploy.d.ts +3 -4
- package/dist/deploy.js +3 -2
- package/dist/dev-reload.d.ts +3 -4
- package/dist/dev.d.ts +8 -5
- package/dist/dev.js +40 -9
- package/dist/favicon.d.ts +37 -0
- package/dist/favicon.js +248 -0
- package/dist/host.d.ts +6 -5
- package/dist/host.js +2 -1
- package/dist/icon-letter.d.ts +3 -0
- package/dist/icon-letter.js +8 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +9 -3
- package/dist/instrumentation.d.ts +2 -3
- package/dist/instrumentation.js +2 -1
- package/dist/island-registry.d.ts +6 -7
- package/dist/isolate-local.d.ts +5 -0
- package/dist/isolate-local.js +12 -0
- package/dist/kv.d.ts +3 -4
- package/dist/llms-links.d.ts +9 -0
- package/dist/llms-links.js +65 -0
- package/dist/manifest-CwTT1zVs.d.ts +11 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.js +113 -0
- package/dist/negotiate.d.ts +4 -3
- package/dist/negotiate.js +24 -14
- package/dist/{pipeline-CCp9idQ4.d.ts → pipeline-BHUjBO0G.d.ts} +13 -1
- package/dist/pipeline.d.ts +2 -2
- package/dist/pipeline.js +286 -35
- package/dist/resources.d.ts +5 -6
- package/dist/route-rank.d.ts +10 -0
- package/dist/route-rank.js +38 -0
- package/dist/route-scan-BMbBzPIB.d.ts +20 -0
- package/dist/route-scan.d.ts +2 -0
- package/dist/route-scan.js +100 -0
- package/dist/router.d.ts +12 -13
- package/dist/router.js +58 -44
- package/dist/rsc-build.d.ts +6 -7
- package/dist/rsc-bundle.d.ts +6 -7
- package/dist/rsc-manifest.d.ts +5 -6
- package/dist/rsc-runtime/flight-render-routes.d.ts +3 -4
- package/dist/rsc-runtime/flight-render.d.ts +2 -3
- package/dist/rsc-runtime/flight-to-html.d.ts +2 -3
- package/dist/rsc-runtime/flight-to-html.js +3 -2
- package/dist/rsc-runtime/rsc-worker.js +11 -8
- package/dist/rsc-runtime/rsdw-shims.d.ts +2 -1
- package/dist/segment.d.ts +4 -5
- package/dist/sqlite-driver.d.ts +11 -11
- package/dist/sqlite-driver.js +17 -4
- package/dist/static-files.d.ts +4 -5
- package/dist/tsconfig-jsx.d.ts +4 -4
- package/dist/tsconfig-jsx.js +1 -1
- package/dist/turn-events.d.ts +4 -0
- package/dist/turn-events.js +46 -0
- package/dist/web-manifest.d.ts +5 -0
- package/dist/web-manifest.js +42 -0
- package/dist/worker-2qbQjj2c.d.ts +64 -0
- package/dist/worker.d.ts +2 -56
- package/dist/worker.js +121 -103
- package/package.json +22 -9
- package/src/adapter.ts +84 -3
- package/src/agent-compile.ts +271 -0
- package/src/agent-discover.ts +77 -63
- package/src/agent-durable.ts +998 -30
- package/src/agent-native.ts +370 -35
- package/src/app.ts +75 -6
- package/src/build.ts +237 -444
- package/src/config-freeze.ts +109 -0
- package/src/connection-auth.ts +101 -0
- package/src/content-freeze.ts +151 -0
- package/src/content.ts +55 -4
- package/src/core-version.ts +34 -0
- package/src/dev.ts +41 -8
- package/src/favicon.ts +325 -0
- package/src/host.ts +4 -3
- package/src/icon-letter.ts +14 -0
- package/src/index.ts +22 -0
- package/src/isolate-local.ts +33 -0
- package/src/llms-links.ts +96 -0
- package/src/manifest.ts +130 -0
- package/src/negotiate.ts +39 -15
- package/src/pipeline.ts +494 -44
- package/src/route-rank.ts +60 -0
- package/src/route-scan.ts +161 -0
- package/src/router.ts +75 -58
- package/src/rsc-runtime/rsc-worker.tsx +5 -4
- package/src/sqlite-driver.ts +36 -6
- package/src/tsconfig-jsx.ts +2 -2
- package/src/turn-events.ts +43 -0
- package/src/web-manifest.ts +38 -0
- package/src/worker.ts +197 -117
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font creation
|
|
14
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
15
|
+
open framework in which fonts may be shared and improved in partnership
|
|
16
|
+
with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply
|
|
25
|
+
to any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software components as
|
|
36
|
+
distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
39
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
40
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
41
|
+
new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION AND CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
49
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
50
|
+
Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components,
|
|
53
|
+
in Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
64
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
65
|
+
presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created
|
|
77
|
+
using the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { JuneConfig } from "@junejs/core/config";
|
|
2
|
+
//#region src/adapter.d.ts
|
|
3
|
+
type AdapterCapabilities = {
|
|
4
|
+
runtime: "edge" | "node" | "serverless" | "native" | "static";
|
|
5
|
+
persistentConnections: boolean;
|
|
6
|
+
assets: "platform" | "server" | "none";
|
|
7
|
+
durableObjects?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type AdapterEntry = {
|
|
10
|
+
imports: string[];
|
|
11
|
+
wrap(pipelineVar: string): string;
|
|
12
|
+
};
|
|
13
|
+
type ResourcePlan = {
|
|
14
|
+
db?: {
|
|
15
|
+
binding: string;
|
|
16
|
+
databaseName: string;
|
|
17
|
+
};
|
|
18
|
+
agent?: {
|
|
19
|
+
binding: string;
|
|
20
|
+
className: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type AdapterEmitContext = {
|
|
24
|
+
appRoot: string;
|
|
25
|
+
outDir: string;
|
|
26
|
+
hasAssets: boolean;
|
|
27
|
+
linkHeader: string | null;
|
|
28
|
+
config: JuneConfig;
|
|
29
|
+
plan: ResourcePlan;
|
|
30
|
+
defaultName: string;
|
|
31
|
+
publicFiles?: string[];
|
|
32
|
+
};
|
|
33
|
+
interface JuneAdapter {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly capabilities: AdapterCapabilities;
|
|
36
|
+
readonly conditions: string[];
|
|
37
|
+
readonly buildExternal?: string[];
|
|
38
|
+
validate?(ctx: {
|
|
39
|
+
plan: ResourcePlan;
|
|
40
|
+
config: JuneConfig;
|
|
41
|
+
}): void;
|
|
42
|
+
entry(opts: {
|
|
43
|
+
linkHeader: string | null;
|
|
44
|
+
}): AdapterEntry;
|
|
45
|
+
emit(ctx: AdapterEmitContext): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
declare function hasDurableBinding(text: string, file: string, binding: string, className: string): boolean;
|
|
48
|
+
declare function workers(opts?: {
|
|
49
|
+
name?: string;
|
|
50
|
+
domain?: string;
|
|
51
|
+
}): JuneAdapter;
|
|
52
|
+
declare function vercel(opts?: {
|
|
53
|
+
runtime?: "node" | "edge";
|
|
54
|
+
regions?: string[];
|
|
55
|
+
}): JuneAdapter;
|
|
56
|
+
declare function deno(opts?: {
|
|
57
|
+
org?: string;
|
|
58
|
+
app?: string;
|
|
59
|
+
}): JuneAdapter;
|
|
60
|
+
declare function staticSite(): JuneAdapter;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ResourcePlan as a, staticSite as c, JuneAdapter as i, vercel as l, AdapterEmitContext as n, deno as o, AdapterEntry as r, hasDurableBinding as s, AdapterCapabilities as t, workers as u };
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,56 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type AdapterCapabilities = {
|
|
4
|
-
runtime: "edge" | "node" | "serverless" | "native" | "static";
|
|
5
|
-
persistentConnections: boolean;
|
|
6
|
-
assets: "platform" | "server" | "none";
|
|
7
|
-
};
|
|
8
|
-
type AdapterEntry = {
|
|
9
|
-
imports: string[];
|
|
10
|
-
wrap(pipelineVar: string): string;
|
|
11
|
-
};
|
|
12
|
-
type ResourcePlan = {
|
|
13
|
-
db?: {
|
|
14
|
-
binding: string;
|
|
15
|
-
databaseName: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
type AdapterEmitContext = {
|
|
19
|
-
appRoot: string;
|
|
20
|
-
outDir: string;
|
|
21
|
-
hasAssets: boolean;
|
|
22
|
-
linkHeader: string | null;
|
|
23
|
-
config: JuneConfig;
|
|
24
|
-
plan: ResourcePlan;
|
|
25
|
-
defaultName: string;
|
|
26
|
-
publicFiles?: string[];
|
|
27
|
-
};
|
|
28
|
-
interface JuneAdapter {
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly capabilities: AdapterCapabilities;
|
|
31
|
-
readonly conditions: string[];
|
|
32
|
-
readonly buildExternal?: string[];
|
|
33
|
-
validate?(ctx: {
|
|
34
|
-
plan: ResourcePlan;
|
|
35
|
-
config: JuneConfig;
|
|
36
|
-
}): void;
|
|
37
|
-
entry(opts: {
|
|
38
|
-
linkHeader: string | null;
|
|
39
|
-
}): AdapterEntry;
|
|
40
|
-
emit(ctx: AdapterEmitContext): Promise<void>;
|
|
41
|
-
}
|
|
42
|
-
declare function workers(opts?: {
|
|
43
|
-
name?: string;
|
|
44
|
-
domain?: string;
|
|
45
|
-
}): JuneAdapter;
|
|
46
|
-
declare function vercel(opts?: {
|
|
47
|
-
runtime?: "node" | "edge";
|
|
48
|
-
regions?: string[];
|
|
49
|
-
}): JuneAdapter;
|
|
50
|
-
declare function deno(opts?: {
|
|
51
|
-
org?: string;
|
|
52
|
-
app?: string;
|
|
53
|
-
}): JuneAdapter;
|
|
54
|
-
declare function staticSite(): JuneAdapter;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { AdapterCapabilities, AdapterEmitContext, AdapterEntry, JuneAdapter, ResourcePlan, deno, staticSite, vercel, workers };
|
|
1
|
+
import { a as ResourcePlan, c as staticSite, i as JuneAdapter, l as vercel, n as AdapterEmitContext, o as deno, r as AdapterEntry, s as hasDurableBinding, t as AdapterCapabilities, u as workers } from "./adapter-DcZ-W1-7.js";
|
|
2
|
+
export { AdapterCapabilities, AdapterEmitContext, AdapterEntry, JuneAdapter, ResourcePlan, deno, hasDurableBinding, staticSite, vercel, workers };
|
package/dist/adapter.js
CHANGED
|
@@ -1,14 +1,51 @@
|
|
|
1
|
+
import { stripJsonc } from "./tsconfig-jsx.js";
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { copyFile, cp, mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
3
|
+
import { copyFile, cp, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { basename, dirname, join } from "node:path";
|
|
4
5
|
//#region src/adapter.ts
|
|
6
|
+
function hasDurableBinding(text, file, binding, className) {
|
|
7
|
+
if (file.endsWith(".toml")) {
|
|
8
|
+
const lines = text.split("\n").map((line) => {
|
|
9
|
+
let inString = false;
|
|
10
|
+
for (let i = 0; i < line.length; i++) {
|
|
11
|
+
const ch = line[i];
|
|
12
|
+
if (ch === "\"" && line[i - 1] !== "\\") inString = !inString;
|
|
13
|
+
else if (ch === "#" && !inString) return line.slice(0, i);
|
|
14
|
+
}
|
|
15
|
+
return line;
|
|
16
|
+
});
|
|
17
|
+
let inBindings = false;
|
|
18
|
+
let name;
|
|
19
|
+
let cls;
|
|
20
|
+
const matches = () => name === binding && cls === className;
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
const t = line.trim();
|
|
23
|
+
if (t.startsWith("[")) {
|
|
24
|
+
if (inBindings && matches()) return true;
|
|
25
|
+
inBindings = /^\[\[\s*durable_objects\.bindings\s*\]\]$/.test(t);
|
|
26
|
+
name = cls = void 0;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (!inBindings) continue;
|
|
30
|
+
const kv = t.match(/^(name|class_name)\s*=\s*"([^"]*)"/);
|
|
31
|
+
if (kv) kv[1] === "name" ? name = kv[2] : cls = kv[2];
|
|
32
|
+
}
|
|
33
|
+
return inBindings && matches();
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return (JSON.parse(stripJsonc(text)).durable_objects?.bindings ?? []).some((b) => b.name === binding && b.class_name === className);
|
|
37
|
+
} catch {
|
|
38
|
+
return text.includes(className);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
5
41
|
function workers(opts) {
|
|
6
42
|
return {
|
|
7
43
|
name: "workers",
|
|
8
44
|
capabilities: {
|
|
9
45
|
runtime: "edge",
|
|
10
46
|
persistentConnections: true,
|
|
11
|
-
assets: "platform"
|
|
47
|
+
assets: "platform",
|
|
48
|
+
durableObjects: true
|
|
12
49
|
},
|
|
13
50
|
conditions: [
|
|
14
51
|
"source",
|
|
@@ -25,7 +62,17 @@ function workers(opts) {
|
|
|
25
62
|
};
|
|
26
63
|
},
|
|
27
64
|
async emit({ appRoot, outDir, hasAssets, config, plan, defaultName }) {
|
|
28
|
-
|
|
65
|
+
const own = ["wrangler.toml", "wrangler.jsonc"].map((f) => join(appRoot, f)).find(existsSync);
|
|
66
|
+
if (own) {
|
|
67
|
+
if (plan.agent) {
|
|
68
|
+
const cls = plan.agent.className;
|
|
69
|
+
if (!hasDurableBinding(await readFile(own, "utf8"), own, plan.agent.binding, cls)) {
|
|
70
|
+
const snippet = own.endsWith(".toml") ? `[[durable_objects.bindings]]\nname = "${plan.agent.binding}"\nclass_name = "${cls}"\n\n[[migrations]]\ntag = "v1"\nnew_sqlite_classes = ["${cls}"]` : `"durable_objects": { "bindings": [{ "name": "${plan.agent.binding}", "class_name": "${cls}" }] },\n"migrations": [{ "tag": "v1", "new_sqlite_classes": ["${cls}"] }]`;
|
|
71
|
+
console.warn(`[june build] durable agent built, but ${basename(own)} doesn't bind it — add:\n${snippet}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
29
76
|
const deployCfg = config.deploy;
|
|
30
77
|
await writeFile(join(outDir, "wrangler.jsonc"), JSON.stringify({
|
|
31
78
|
name: opts?.name ?? deployCfg?.name ?? defaultName,
|
|
@@ -42,6 +89,16 @@ function workers(opts) {
|
|
|
42
89
|
database_name: plan.db.databaseName,
|
|
43
90
|
database_id: ""
|
|
44
91
|
}] } : {},
|
|
92
|
+
...plan.agent ? {
|
|
93
|
+
durable_objects: { bindings: [{
|
|
94
|
+
name: plan.agent.binding,
|
|
95
|
+
class_name: plan.agent.className
|
|
96
|
+
}] },
|
|
97
|
+
migrations: [{
|
|
98
|
+
tag: "v1",
|
|
99
|
+
new_sqlite_classes: [plan.agent.className]
|
|
100
|
+
}]
|
|
101
|
+
} : {},
|
|
45
102
|
...opts?.domain ?? deployCfg?.domain ? { routes: [{
|
|
46
103
|
pattern: opts?.domain ?? deployCfg?.domain,
|
|
47
104
|
custom_domain: true
|
|
@@ -208,4 +265,4 @@ function staticSite() {
|
|
|
208
265
|
};
|
|
209
266
|
}
|
|
210
267
|
//#endregion
|
|
211
|
-
export { deno, staticSite, vercel, workers };
|
|
268
|
+
export { deno, hasDurableBinding, staticSite, vercel, workers };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/agent-compile.d.ts
|
|
2
|
+
export declare const AGENT_MODULE_FILE = "_agent.gen.ts";
|
|
3
|
+
export type AgentDirScan = {
|
|
4
|
+
dir: string;
|
|
5
|
+
name: string;
|
|
6
|
+
hasConfig: boolean;
|
|
7
|
+
instructions: string | null;
|
|
8
|
+
surfaceVariants: {
|
|
9
|
+
source: string;
|
|
10
|
+
raw: string;
|
|
11
|
+
}[];
|
|
12
|
+
tools: string[];
|
|
13
|
+
skills: {
|
|
14
|
+
name: string;
|
|
15
|
+
raw: string;
|
|
16
|
+
}[];
|
|
17
|
+
channels: string[];
|
|
18
|
+
channelOverlays: {
|
|
19
|
+
source: string;
|
|
20
|
+
raw: string;
|
|
21
|
+
}[];
|
|
22
|
+
connections: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function scanAgentDir(dir: string): AgentDirScan | null;
|
|
25
|
+
export type EmitOptions = {
|
|
26
|
+
tsExtensions?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare function emitAgentModule(scan: AgentDirScan, opts?: EmitOptions): string;
|
|
29
|
+
export declare function findAgentDir(root: string, dirName?: string): string | null;
|
|
30
|
+
export declare function generateAgentModule(dir: string, opts?: {
|
|
31
|
+
check?: boolean;
|
|
32
|
+
} & EmitOptions): {
|
|
33
|
+
file: string;
|
|
34
|
+
code: string;
|
|
35
|
+
stale: boolean;
|
|
36
|
+
written: boolean;
|
|
37
|
+
} | null;
|
|
38
|
+
//#endregion
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { stripJsonc } from "./tsconfig-jsx.js";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
//#region src/agent-compile.ts
|
|
5
|
+
const AGENT_MODULE_FILE = "_agent.gen.ts";
|
|
6
|
+
function list(dir, ext) {
|
|
7
|
+
if (!existsSync(dir)) return [];
|
|
8
|
+
return readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(ext) && !e.name.startsWith("_")).map((e) => e.name).sort();
|
|
9
|
+
}
|
|
10
|
+
function scanAgentDir(dir) {
|
|
11
|
+
if (!existsSync(dir)) return null;
|
|
12
|
+
const instructionsFile = join(dir, "instructions.md");
|
|
13
|
+
const scan = {
|
|
14
|
+
dir,
|
|
15
|
+
name: basename(dir),
|
|
16
|
+
hasConfig: existsSync(join(dir, "agent.ts")),
|
|
17
|
+
instructions: existsSync(instructionsFile) ? readFileSync(instructionsFile, "utf8") : null,
|
|
18
|
+
surfaceVariants: readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name.match(/^instructions\.([a-z0-9_-]+)\.md$/)).filter((m) => m !== null).sort((a, b) => a[1].localeCompare(b[1])).map((m) => ({
|
|
19
|
+
source: m[1],
|
|
20
|
+
raw: readFileSync(join(dir, m[0]), "utf8")
|
|
21
|
+
})),
|
|
22
|
+
tools: list(join(dir, "tools"), ".ts").map((f) => `./tools/${f}`),
|
|
23
|
+
skills: list(join(dir, "skills"), ".md").map((f) => ({
|
|
24
|
+
name: basename(f, ".md"),
|
|
25
|
+
raw: readFileSync(join(dir, "skills", f), "utf8")
|
|
26
|
+
})),
|
|
27
|
+
channels: list(join(dir, "channels"), ".ts").map((f) => `./channels/${f}`),
|
|
28
|
+
channelOverlays: list(join(dir, "channels"), ".md").map((f) => ({
|
|
29
|
+
source: basename(f, ".md"),
|
|
30
|
+
raw: readFileSync(join(dir, "channels", f), "utf8")
|
|
31
|
+
})),
|
|
32
|
+
connections: list(join(dir, "connections"), ".ts").map((f) => `./connections/${f}`)
|
|
33
|
+
};
|
|
34
|
+
return !scan.hasConfig && scan.instructions === null && !scan.tools.length && !scan.skills.length && !scan.channels.length && !scan.surfaceVariants.length && !scan.channelOverlays.length && !scan.connections.length ? null : scan;
|
|
35
|
+
}
|
|
36
|
+
function identFor(prefix, spec, taken) {
|
|
37
|
+
const stem = basename(spec).replace(/\.ts$/, "").replace(/[^A-Za-z0-9]/g, "_");
|
|
38
|
+
let id = `${prefix}_${stem}`;
|
|
39
|
+
for (let i = 2; taken.has(id); i++) id = `${prefix}_${stem}_${i}`;
|
|
40
|
+
taken.add(id);
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
function emitAgentModule(scan, opts) {
|
|
44
|
+
const spec = (s) => JSON.stringify(opts?.tsExtensions ? s : s.replace(/\.ts$/, ""));
|
|
45
|
+
const taken = /* @__PURE__ */ new Set();
|
|
46
|
+
const imports = [];
|
|
47
|
+
const toolIds = scan.tools.map((s) => {
|
|
48
|
+
const id = identFor("tool", s, taken);
|
|
49
|
+
imports.push(`import ${id} from ${spec(s)};`);
|
|
50
|
+
return id;
|
|
51
|
+
});
|
|
52
|
+
const channelIds = scan.channels.map((s) => {
|
|
53
|
+
const id = identFor("channel", s, taken);
|
|
54
|
+
imports.push(`import ${id} from ${spec(s)};`);
|
|
55
|
+
return {
|
|
56
|
+
key: basename(s, ".ts"),
|
|
57
|
+
id
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
const connectionIds = scan.connections.map((s) => {
|
|
61
|
+
const id = identFor("connection", s, taken);
|
|
62
|
+
imports.push(`import ${id} from ${spec(s)};`);
|
|
63
|
+
return id;
|
|
64
|
+
});
|
|
65
|
+
if (scan.hasConfig) imports.push(`import config from ${spec("./agent.ts")};`);
|
|
66
|
+
const lines = [
|
|
67
|
+
"// AUTO-GENERATED by June — do not edit. Compiled from this agent/ directory so",
|
|
68
|
+
"// the definition mounts without filesystem discovery (workerd has no fs).",
|
|
69
|
+
"// Regenerate with `june gen` after adding, removing, or editing agent files.",
|
|
70
|
+
...imports,
|
|
71
|
+
scan.skills.length ? `import { parseSkill, type AgentModule } from "@junejs/core/agent-config";` : `import type { AgentModule } from "@junejs/core/agent-config";`,
|
|
72
|
+
""
|
|
73
|
+
];
|
|
74
|
+
if (!scan.hasConfig) lines.push(`const config = { name: ${JSON.stringify(scan.name)} };`, "");
|
|
75
|
+
lines.push("export const agentModule: AgentModule = {", " config,", ` instructions: ${JSON.stringify(scan.instructions ?? "")},`, scan.surfaceVariants.length ? ` surfaceInstructions: {\n${scan.surfaceVariants.map((v) => ` ${JSON.stringify(v.source)}: ${JSON.stringify(v.raw)},`).join("\n")}\n },` : " surfaceInstructions: {},", ` tools: [${toolIds.join(", ")}],`, scan.skills.length ? ` skills: [\n${scan.skills.map((s) => ` parseSkill(${JSON.stringify(s.name)}, ${JSON.stringify(s.raw)}),`).join("\n")}\n ],` : " skills: [],", channelIds.length ? ` channels: { ${channelIds.map((c) => `${JSON.stringify(c.key)}: ${c.id}`).join(", ")} },` : " channels: {},", scan.channelOverlays.length ? ` channelInstructions: {\n${scan.channelOverlays.map((o) => ` ${JSON.stringify(o.source)}: ${JSON.stringify(o.raw)},`).join("\n")}\n },` : " channelInstructions: {},", ` connections: [${connectionIds.join(", ")}],`, "};", "export default agentModule;", "");
|
|
76
|
+
return lines.join("\n");
|
|
77
|
+
}
|
|
78
|
+
function findAgentDir(root, dirName = "agent") {
|
|
79
|
+
for (const candidate of [join(root, "app", dirName), join(root, dirName)]) if (existsSync(candidate)) return candidate;
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function readTsconfig(path) {
|
|
83
|
+
try {
|
|
84
|
+
return JSON.parse(stripJsonc(readFileSync(path, "utf8")));
|
|
85
|
+
} catch {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function resolveExtends(fromDir, spec) {
|
|
90
|
+
const withJson = (p) => existsSync(p) ? p : !p.endsWith(".json") && existsSync(`${p}.json`) ? `${p}.json` : void 0;
|
|
91
|
+
if (spec.startsWith(".")) return withJson(resolve(fromDir, spec));
|
|
92
|
+
for (let d = fromDir;;) {
|
|
93
|
+
const candidate = withJson(join(d, "node_modules", spec));
|
|
94
|
+
if (candidate) return candidate;
|
|
95
|
+
const parent = dirname(d);
|
|
96
|
+
if (parent === d) return void 0;
|
|
97
|
+
d = parent;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function resolveAllowTsExtensions(path, depth) {
|
|
101
|
+
if (depth > 8) return void 0;
|
|
102
|
+
const tc = readTsconfig(path);
|
|
103
|
+
if (!tc) return void 0;
|
|
104
|
+
const own = tc.compilerOptions?.allowImportingTsExtensions;
|
|
105
|
+
if (own !== void 0) return own;
|
|
106
|
+
const bases = typeof tc.extends === "string" ? [tc.extends] : [...tc.extends ?? []].reverse();
|
|
107
|
+
for (const spec of bases) {
|
|
108
|
+
const base = resolveExtends(dirname(path), spec);
|
|
109
|
+
const inherited = base ? resolveAllowTsExtensions(base, depth + 1) : void 0;
|
|
110
|
+
if (inherited !== void 0) return inherited;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function sniffTsExtensions(dir) {
|
|
114
|
+
for (let d = dir;;) {
|
|
115
|
+
const candidate = join(d, "tsconfig.json");
|
|
116
|
+
if (existsSync(candidate)) return resolveAllowTsExtensions(candidate, 0) ?? false;
|
|
117
|
+
const parent = dirname(d);
|
|
118
|
+
if (parent === d) return false;
|
|
119
|
+
d = parent;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function generateAgentModule(dir, opts) {
|
|
123
|
+
const scan = scanAgentDir(dir);
|
|
124
|
+
if (!scan) return null;
|
|
125
|
+
for (const o of scan.channelOverlays) console.warn(`[june] deprecated: channels/${o.source}.md — move it to instructions.${o.source}.md at the agent root (per-surface behavior is agent-level; see junebuild/june#149).`);
|
|
126
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) if (e.isFile() && /^instructions\..+\.md$/.test(e.name) && !/^instructions\.[a-z0-9_-]+\.md$/.test(e.name)) console.warn(`[june] ${e.name}: unrecognized instructions variant — only single-segment sources (instructions.<source>.md) are parsed today; locale variants are a planned follow-up (junebuild/june#149). This file is ignored.`);
|
|
127
|
+
const code = emitAgentModule(scan, { tsExtensions: opts?.tsExtensions ?? sniffTsExtensions(dir) });
|
|
128
|
+
const file = join(dir, AGENT_MODULE_FILE);
|
|
129
|
+
const stale = (existsSync(file) ? readFileSync(file, "utf8") : null) !== code;
|
|
130
|
+
if (opts?.check) return {
|
|
131
|
+
file,
|
|
132
|
+
code,
|
|
133
|
+
stale,
|
|
134
|
+
written: false
|
|
135
|
+
};
|
|
136
|
+
if (stale) writeFileSync(file, code);
|
|
137
|
+
return {
|
|
138
|
+
file,
|
|
139
|
+
code,
|
|
140
|
+
stale,
|
|
141
|
+
written: stale
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { AGENT_MODULE_FILE, emitAgentModule, findAgentDir, generateAgentModule, scanAgentDir };
|
package/dist/agent-discover.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgentDefinition } from "@junejs/core/agent-config";
|
|
1
|
+
import { AgentDefinition, AgentModule } from "@junejs/core/agent-config";
|
|
2
2
|
//#region src/agent-discover.d.ts
|
|
3
|
-
declare function
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function discoverAgentModule(dir: string): Promise<AgentModule>;
|
|
4
|
+
export declare function discoverAgent(dir: string): Promise<AgentDefinition>;
|
|
5
|
+
//#endregion
|
package/dist/agent-discover.js
CHANGED
|
@@ -2,42 +2,24 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { readFile, readdir } from "node:fs/promises";
|
|
3
3
|
import { basename, extname, join } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
-
import {
|
|
6
|
-
import { connectAll } from "@junejs/core/connections";
|
|
5
|
+
import { assembleAgent, parseSkill } from "@junejs/core/agent-config";
|
|
7
6
|
//#region src/agent-discover.ts
|
|
8
7
|
async function scan(dir, ext) {
|
|
9
8
|
if (!existsSync(dir)) return [];
|
|
10
|
-
return (await readdir(dir, { withFileTypes: true })).filter((e) => e.isFile() && extname(e.name) === ext).map((e) => join(dir, e.name)).sort();
|
|
9
|
+
return (await readdir(dir, { withFileTypes: true })).filter((e) => e.isFile() && extname(e.name) === ext && !e.name.startsWith("_")).map((e) => join(dir, e.name)).sort();
|
|
11
10
|
}
|
|
12
|
-
function
|
|
13
|
-
if (text.startsWith("---")) {
|
|
14
|
-
const end = text.indexOf("\n---", 3);
|
|
15
|
-
if (end !== -1) {
|
|
16
|
-
const front = text.slice(3, end);
|
|
17
|
-
const body = text.slice(end + 4).replace(/^\s*\n/, "");
|
|
18
|
-
const meta = {};
|
|
19
|
-
for (const line of front.split("\n")) {
|
|
20
|
-
const m = line.match(/^\s*(\w+)\s*:\s*(.+?)\s*$/);
|
|
21
|
-
if (m) meta[m[1]] = m[2];
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
name: meta.name ?? name,
|
|
25
|
-
description: meta.description ?? "",
|
|
26
|
-
body
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
name,
|
|
32
|
-
description: (text.split("\n").find((l) => l.trim()) ?? "").replace(/^#\s*/, ""),
|
|
33
|
-
body: text
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async function discoverAgent(dir) {
|
|
11
|
+
async function discoverAgentModule(dir) {
|
|
37
12
|
const configFile = join(dir, "agent.ts");
|
|
38
13
|
const config = existsSync(configFile) ? (await import(pathToFileURL(configFile).href)).default : { name: basename(dir) };
|
|
39
14
|
const instructionsFile = join(dir, "instructions.md");
|
|
40
|
-
const instructions = existsSync(instructionsFile) ? await readFile(instructionsFile, "utf8") :
|
|
15
|
+
const instructions = existsSync(instructionsFile) ? await readFile(instructionsFile, "utf8") : "";
|
|
16
|
+
const surfaceInstructions = {};
|
|
17
|
+
if (existsSync(dir)) for (const e of await readdir(dir, { withFileTypes: true })) {
|
|
18
|
+
if (!e.isFile() || !/^instructions\..+\.md$/.test(e.name)) continue;
|
|
19
|
+
const m = e.name.match(/^instructions\.([a-z0-9_-]+)\.md$/);
|
|
20
|
+
if (m) surfaceInstructions[m[1]] = await readFile(join(dir, e.name), "utf8");
|
|
21
|
+
else console.warn(`[june] ${e.name}: unrecognized instructions variant — only single-segment sources (instructions.<source>.md) are parsed today; locale variants are a planned follow-up (junebuild/june#149). This file is ignored.`);
|
|
22
|
+
}
|
|
41
23
|
const tools = [];
|
|
42
24
|
for (const f of await scan(join(dir, "tools"), ".ts")) {
|
|
43
25
|
const mod = await import(pathToFileURL(f).href);
|
|
@@ -45,31 +27,35 @@ async function discoverAgent(dir) {
|
|
|
45
27
|
}
|
|
46
28
|
const skills = [];
|
|
47
29
|
for (const f of await scan(join(dir, "skills"), ".md")) skills.push(parseSkill(basename(f, ".md"), await readFile(f, "utf8")));
|
|
48
|
-
const channels =
|
|
30
|
+
const channels = {};
|
|
49
31
|
for (const f of await scan(join(dir, "channels"), ".ts")) {
|
|
50
32
|
const mod = await import(pathToFileURL(f).href);
|
|
51
|
-
if (mod.default) channels
|
|
33
|
+
if (mod.default) channels[basename(f, ".ts")] = mod.default;
|
|
52
34
|
}
|
|
53
|
-
const
|
|
35
|
+
const channelInstructions = {};
|
|
36
|
+
for (const f of await scan(join(dir, "channels"), ".md")) {
|
|
37
|
+
const source = basename(f, ".md");
|
|
38
|
+
console.warn(`[june] deprecated: channels/${source}.md — move it to instructions.${source}.md at the agent root (per-surface behavior is agent-level; see junebuild/june#149).`);
|
|
39
|
+
channelInstructions[source] = await readFile(f, "utf8");
|
|
40
|
+
}
|
|
41
|
+
const connections = [];
|
|
54
42
|
for (const f of await scan(join(dir, "connections"), ".ts")) {
|
|
55
43
|
const mod = await import(pathToFileURL(f).href);
|
|
56
|
-
if (mod.default)
|
|
44
|
+
if (mod.default) connections.push(mod.default);
|
|
57
45
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
report: []
|
|
61
|
-
};
|
|
62
|
-
tools.push(...connectionActions);
|
|
63
|
-
return defineAgent({
|
|
64
|
-
name: config.name,
|
|
65
|
-
model: config.model,
|
|
66
|
-
description: config.description,
|
|
46
|
+
return {
|
|
47
|
+
config,
|
|
67
48
|
instructions,
|
|
49
|
+
surfaceInstructions,
|
|
68
50
|
tools,
|
|
69
51
|
skills,
|
|
70
52
|
channels,
|
|
53
|
+
channelInstructions,
|
|
71
54
|
connections
|
|
72
|
-
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function discoverAgent(dir) {
|
|
58
|
+
return assembleAgent(await discoverAgentModule(dir), process.env);
|
|
73
59
|
}
|
|
74
60
|
//#endregion
|
|
75
|
-
export { discoverAgent };
|
|
61
|
+
export { discoverAgent, discoverAgentModule };
|