@junejs/server 1.0.0-dev.28 → 1.0.0-dev.36
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/agent-compile.d.ts +8 -9
- package/dist/agent-discover.d.ts +3 -4
- package/dist/agent-durable.d.ts +20 -19
- package/dist/agent-durable.js +41 -6
- package/dist/agent-native.d.ts +10 -11
- package/dist/agent-native.js +6 -2
- package/dist/app.d.ts +4 -5
- package/dist/app.js +2 -1
- package/dist/blob.d.ts +4 -5
- package/dist/build.d.ts +6 -6
- package/dist/build.js +34 -7
- package/dist/client-bundle.d.ts +8 -9
- package/dist/{config-freeze-DwI-Rmvq.d.ts → config-freeze-ZWC_Qd4h.d.ts} +1 -1
- package/dist/config-freeze.d.ts +1 -1
- package/dist/config-loader.d.ts +3 -4
- package/dist/connection-auth.d.ts +8 -9
- package/dist/content.d.ts +9 -10
- package/dist/core-version.d.ts +3 -4
- 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 +4 -5
- package/dist/favicon.d.ts +16 -17
- package/dist/host.d.ts +5 -5
- package/dist/icon-letter.d.ts +2 -3
- package/dist/index.d.ts +4 -4
- 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 +4 -5
- 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-gcNWqWoI.d.ts → manifest-DSNX4I-G.d.ts} +2 -2
- package/dist/manifest.d.ts +1 -1
- package/dist/negotiate.d.ts +4 -3
- package/dist/negotiate.js +24 -14
- package/dist/{pipeline-cCR6MGNK.d.ts → pipeline-BHUjBO0G.d.ts} +5 -1
- package/dist/pipeline.d.ts +2 -2
- package/dist/pipeline.js +263 -39
- package/dist/resources.d.ts +5 -6
- package/dist/router.d.ts +12 -13
- 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/rsdw-shims.d.ts +2 -1
- package/dist/segment.d.ts +4 -5
- package/dist/sqlite-driver.d.ts +10 -11
- package/dist/static-files.d.ts +4 -5
- package/dist/tsconfig-jsx.d.ts +4 -5
- package/dist/turn-events.d.ts +2 -3
- package/dist/web-manifest.d.ts +3 -4
- package/dist/web-manifest.js +2 -6
- package/dist/{worker-BkFHGtxp.d.ts → worker-Dv4l6Ybs.d.ts} +4 -2
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +35 -18
- package/package.json +5 -5
- package/src/agent-durable.ts +39 -10
- package/src/agent-native.ts +5 -1
- package/src/build.ts +63 -5
- package/src/llms-links.ts +96 -0
- package/src/negotiate.ts +39 -15
- package/src/pipeline.ts +437 -47
- package/src/web-manifest.ts +2 -6
- package/src/worker.ts +55 -17
package/dist/agent-compile.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/agent-compile.d.ts
|
|
2
|
-
declare const AGENT_MODULE_FILE = "_agent.gen.ts";
|
|
3
|
-
type AgentDirScan = {
|
|
2
|
+
export declare const AGENT_MODULE_FILE = "_agent.gen.ts";
|
|
3
|
+
export type AgentDirScan = {
|
|
4
4
|
dir: string;
|
|
5
5
|
name: string;
|
|
6
6
|
hasConfig: boolean;
|
|
@@ -21,13 +21,13 @@ type AgentDirScan = {
|
|
|
21
21
|
}[];
|
|
22
22
|
connections: string[];
|
|
23
23
|
};
|
|
24
|
-
declare function scanAgentDir(dir: string): AgentDirScan | null;
|
|
25
|
-
type EmitOptions = {
|
|
24
|
+
export declare function scanAgentDir(dir: string): AgentDirScan | null;
|
|
25
|
+
export type EmitOptions = {
|
|
26
26
|
tsExtensions?: boolean;
|
|
27
27
|
};
|
|
28
|
-
declare function emitAgentModule(scan: AgentDirScan, opts?: EmitOptions): string;
|
|
29
|
-
declare function findAgentDir(root: string, dirName?: string): string | null;
|
|
30
|
-
declare function generateAgentModule(dir: string, opts?: {
|
|
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
31
|
check?: boolean;
|
|
32
32
|
} & EmitOptions): {
|
|
33
33
|
file: string;
|
|
@@ -35,5 +35,4 @@ declare function generateAgentModule(dir: string, opts?: {
|
|
|
35
35
|
stale: boolean;
|
|
36
36
|
written: boolean;
|
|
37
37
|
} | null;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { AGENT_MODULE_FILE, AgentDirScan, EmitOptions, emitAgentModule, findAgentDir, generateAgentModule, scanAgentDir };
|
|
38
|
+
//#endregion
|
package/dist/agent-discover.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AgentDefinition, AgentModule } from "@junejs/core/agent-config";
|
|
2
2
|
//#region src/agent-discover.d.ts
|
|
3
|
-
declare function discoverAgentModule(dir: string): Promise<AgentModule>;
|
|
4
|
-
declare function discoverAgent(dir: string): Promise<AgentDefinition>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { discoverAgent, discoverAgentModule };
|
|
3
|
+
export declare function discoverAgentModule(dir: string): Promise<AgentModule>;
|
|
4
|
+
export declare function discoverAgent(dir: string): Promise<AgentDefinition>;
|
|
5
|
+
//#endregion
|
package/dist/agent-durable.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { Channel, ChannelFactory } from "@junejs/core/agent-config";
|
|
2
|
-
import { ChannelPolicy, InboundEvent, Model, Msg, ProactiveTrigger, SessionStore, Tool, TurnError, TurnEvent, TurnFailurePhase } from "@junejs/core/agent-runtime";
|
|
2
|
+
import { AuthorizeAnswer, ChannelPolicy, InboundEvent, Model, Msg, ProactiveTrigger, SessionStore, Tool, TurnError, TurnEvent, TurnFailurePhase } from "@junejs/core/agent-runtime";
|
|
3
3
|
import { Connection } from "@junejs/core/connections";
|
|
4
4
|
import { Resources } from "@junejs/core/resources";
|
|
5
5
|
//#region src/agent-durable.d.ts
|
|
6
|
-
type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
7
|
-
interface SqlStorageCursor<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>> {
|
|
6
|
+
export type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
7
|
+
export interface SqlStorageCursor<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>> {
|
|
8
8
|
toArray(): T[];
|
|
9
9
|
one(): T;
|
|
10
10
|
}
|
|
11
|
-
interface SqlStorage {
|
|
11
|
+
export interface SqlStorage {
|
|
12
12
|
exec<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>>(query: string, ...bindings: unknown[]): SqlStorageCursor<T>;
|
|
13
13
|
}
|
|
14
|
-
interface DurableStorage {
|
|
14
|
+
export interface DurableStorage {
|
|
15
15
|
sql: SqlStorage;
|
|
16
16
|
transactionSync<T>(fn: () => T): T;
|
|
17
17
|
}
|
|
18
|
-
interface DurableObjectState {
|
|
18
|
+
export interface DurableObjectState {
|
|
19
19
|
storage: DurableStorage;
|
|
20
20
|
}
|
|
21
|
-
interface DurableObjectStub {
|
|
21
|
+
export interface DurableObjectStub {
|
|
22
22
|
fetch(request: Request): Promise<Response>;
|
|
23
23
|
}
|
|
24
|
-
interface DurableObjectNamespace {
|
|
24
|
+
export interface DurableObjectNamespace {
|
|
25
25
|
idFromName(name: string): unknown;
|
|
26
26
|
get(id: unknown): DurableObjectStub;
|
|
27
27
|
}
|
|
28
|
-
declare class DoSessionStore implements SessionStore {
|
|
28
|
+
export declare class DoSessionStore implements SessionStore {
|
|
29
29
|
private readonly storage;
|
|
30
30
|
constructor(storage: DurableStorage);
|
|
31
31
|
private get sql();
|
|
@@ -43,7 +43,7 @@ declare class DoSessionStore implements SessionStore {
|
|
|
43
43
|
reset(): number;
|
|
44
44
|
unwrap<H = unknown>(): H;
|
|
45
45
|
}
|
|
46
|
-
type DoAgentDef = {
|
|
46
|
+
export type DoAgentDef = {
|
|
47
47
|
name?: string;
|
|
48
48
|
model: Model;
|
|
49
49
|
tools: Tool[];
|
|
@@ -60,8 +60,9 @@ type DoAgentDef = {
|
|
|
60
60
|
phase?: TurnFailurePhase;
|
|
61
61
|
step?: string;
|
|
62
62
|
}) => void | Promise<void>;
|
|
63
|
+
authorizeAnswer?: AuthorizeAnswer;
|
|
63
64
|
};
|
|
64
|
-
declare class AgentDurableObject {
|
|
65
|
+
export declare class AgentDurableObject {
|
|
65
66
|
private session;
|
|
66
67
|
private sessionKey;
|
|
67
68
|
private readonly name;
|
|
@@ -77,6 +78,7 @@ declare class AgentDurableObject {
|
|
|
77
78
|
private connectionsOpened;
|
|
78
79
|
private readonly doEnv;
|
|
79
80
|
private readonly services;
|
|
81
|
+
private readonly authorizeAnswer?;
|
|
80
82
|
private resolveResources;
|
|
81
83
|
private resolveConnections;
|
|
82
84
|
private ready;
|
|
@@ -107,20 +109,19 @@ declare class AgentDurableObject {
|
|
|
107
109
|
transcript(): import("@junejs/core/agent-runtime").Turn[];
|
|
108
110
|
fetch(req: Request): Promise<Response>;
|
|
109
111
|
}
|
|
110
|
-
declare function sseTurnFinalText(res: Response): Promise<string>;
|
|
111
|
-
declare function sseTurnEvents(res: Response): AsyncIterable<TurnEvent>;
|
|
112
|
-
declare const SESSION_HEADER = "x-june-session";
|
|
113
|
-
declare function durableFetch(namespace: DurableObjectNamespace, agent: string, session: string, req: Request): Promise<Response>;
|
|
114
|
-
declare function durableAgentSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
|
|
112
|
+
export declare function sseTurnFinalText(res: Response): Promise<string>;
|
|
113
|
+
export declare function sseTurnEvents(res: Response): AsyncIterable<TurnEvent>;
|
|
114
|
+
export declare const SESSION_HEADER = "x-june-session";
|
|
115
|
+
export declare function durableFetch(namespace: DurableObjectNamespace, agent: string, session: string, req: Request): Promise<Response>;
|
|
116
|
+
export declare function durableAgentSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
|
|
115
117
|
agentName: string;
|
|
116
118
|
chatPath?: string;
|
|
117
119
|
}): (req: Request) => Promise<Response | null>;
|
|
118
|
-
declare function durableChannelSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
|
|
120
|
+
export declare function durableChannelSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
|
|
119
121
|
agentName: string;
|
|
120
122
|
channels: (Channel | ChannelFactory)[];
|
|
121
123
|
env: unknown;
|
|
122
124
|
services?: (env: unknown) => unknown;
|
|
123
125
|
waitUntil?: (p: Promise<unknown>) => void;
|
|
124
126
|
}): (req: Request) => Promise<Response | null>;
|
|
125
|
-
//#endregion
|
|
126
|
-
export { AgentDurableObject, DoAgentDef, DoSessionStore, DurableObjectNamespace, DurableObjectState, DurableObjectStub, DurableStorage, SESSION_HEADER, SqlStorage, SqlStorageCursor, SqlStorageValue, durableAgentSurface, durableChannelSurface, durableFetch, sseTurnEvents, sseTurnFinalText };
|
|
127
|
+
//#endregion
|
package/dist/agent-durable.js
CHANGED
|
@@ -2,7 +2,7 @@ import { observeTurnEvents } from "./turn-events.js";
|
|
|
2
2
|
import { isolateLocal } from "./isolate-local.js";
|
|
3
3
|
import { assertCoreRuntimeVersion } from "./core-version.js";
|
|
4
4
|
import { DeliverUnsupportedError, actionToTool, channelDispatch, resolveChannel } from "@junejs/core/agent-config";
|
|
5
|
-
import { AgentSession, ResumeAuthorizationError, withSystem } from "@junejs/core/agent-runtime";
|
|
5
|
+
import { AgentSession, ResumeAuthorizationError, grantAnswer, withSystem } from "@junejs/core/agent-runtime";
|
|
6
6
|
import { connectAll } from "@junejs/core/connections";
|
|
7
7
|
import { ensureScope, runInScope } from "@junejs/db";
|
|
8
8
|
//#region src/agent-durable.ts
|
|
@@ -107,6 +107,7 @@ var AgentDurableObject = class {
|
|
|
107
107
|
connectionsOpened;
|
|
108
108
|
doEnv;
|
|
109
109
|
services;
|
|
110
|
+
authorizeAnswer;
|
|
110
111
|
resolveResources() {
|
|
111
112
|
return this.resourcesOpened ??= Promise.resolve(typeof this.resourcesInput === "function" ? this.resourcesInput(this.doEnv) : this.resourcesInput ?? {});
|
|
112
113
|
}
|
|
@@ -136,6 +137,7 @@ var AgentDurableObject = class {
|
|
|
136
137
|
this.connectionsInput = def.connections;
|
|
137
138
|
this.doEnv = def.env;
|
|
138
139
|
this.services = def.services;
|
|
140
|
+
this.authorizeAnswer = def.authorizeAnswer;
|
|
139
141
|
const name = def.name ?? "agent";
|
|
140
142
|
const sink = new InProcEventSink();
|
|
141
143
|
sink.subscribe((e) => {
|
|
@@ -277,7 +279,7 @@ var AgentDurableObject = class {
|
|
|
277
279
|
return new Response(sseTurnStream(session, started.turnId), { headers: SSE_HEADERS });
|
|
278
280
|
}
|
|
279
281
|
if (req.method === "POST" && url.pathname.endsWith("/resume")) {
|
|
280
|
-
const { turnId, inputId, input, by, source, target } = await req.json();
|
|
282
|
+
const { turnId, inputId, input, by, principal, source, target } = await req.json();
|
|
281
283
|
await ensureScope();
|
|
282
284
|
const wantsDeliver = url.searchParams.get("deliver") === "1";
|
|
283
285
|
let resumeChannel;
|
|
@@ -290,10 +292,32 @@ var AgentDurableObject = class {
|
|
|
290
292
|
let session;
|
|
291
293
|
try {
|
|
292
294
|
session = this.resolveSession(key);
|
|
295
|
+
} catch (err) {
|
|
296
|
+
return Response.json({ error: err instanceof Error ? err.message : String(err) }, { status: 409 });
|
|
297
|
+
}
|
|
298
|
+
let granted;
|
|
299
|
+
try {
|
|
300
|
+
granted = await runInScope({
|
|
301
|
+
resources,
|
|
302
|
+
services: this.services
|
|
303
|
+
}, () => grantAnswer(session, {
|
|
304
|
+
turnId,
|
|
305
|
+
inputId,
|
|
306
|
+
by,
|
|
307
|
+
principal
|
|
308
|
+
}, this.authorizeAnswer));
|
|
309
|
+
} catch (err) {
|
|
310
|
+
console.error(`[june] agent "${this.name}": authorizeAnswer failed for input "${inputId}" of turn ${turnId}:`, err);
|
|
311
|
+
return Response.json({ error: `authorizeAnswer failed: ${err instanceof Error ? err.message : String(err)} — the answer was NOT applied` }, { status: 500 });
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
293
314
|
runInScope({
|
|
294
315
|
resources,
|
|
295
316
|
services: this.services
|
|
296
|
-
}, () => session.resume(turnId, inputId, input, {
|
|
317
|
+
}, () => session.resume(turnId, inputId, input, {
|
|
318
|
+
by,
|
|
319
|
+
granted
|
|
320
|
+
}));
|
|
297
321
|
} catch (err) {
|
|
298
322
|
const message = err instanceof Error ? err.message : String(err);
|
|
299
323
|
return Response.json({ error: message }, { status: err instanceof ResumeAuthorizationError ? 403 : 409 });
|
|
@@ -466,7 +490,8 @@ function resolveServices(factory, env, agentName) {
|
|
|
466
490
|
return perAgent.get(agentName);
|
|
467
491
|
}
|
|
468
492
|
function durableChannelSurface(getNamespace, opts) {
|
|
469
|
-
|
|
493
|
+
const resolved = opts.channels.map((c) => resolveChannel(c, opts.env));
|
|
494
|
+
const ctx = {
|
|
470
495
|
agent: {
|
|
471
496
|
name: opts.agentName,
|
|
472
497
|
instructions: "",
|
|
@@ -552,7 +577,8 @@ function durableChannelSurface(getNamespace, opts) {
|
|
|
552
577
|
}
|
|
553
578
|
return await res.json();
|
|
554
579
|
}
|
|
555
|
-
}
|
|
580
|
+
};
|
|
581
|
+
return channelDispatch(resolved, ctx);
|
|
556
582
|
}
|
|
557
583
|
function serializeResume(o) {
|
|
558
584
|
try {
|
|
@@ -561,11 +587,20 @@ function serializeResume(o) {
|
|
|
561
587
|
inputId: o.inputId,
|
|
562
588
|
input: o.input,
|
|
563
589
|
by: o.by,
|
|
590
|
+
principal: o.principal,
|
|
564
591
|
source: o.source,
|
|
565
592
|
target: o.target
|
|
566
593
|
});
|
|
567
594
|
} catch (err) {
|
|
568
|
-
|
|
595
|
+
const culprit = ["input", "principal"].find((field) => {
|
|
596
|
+
try {
|
|
597
|
+
JSON.stringify(o[field]);
|
|
598
|
+
return false;
|
|
599
|
+
} catch {
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
602
|
+
}) ?? "payload";
|
|
603
|
+
throw new Error(`resume: ${culprit} is not JSON-serializable (${err.message}) — a resume must round-trip to the DO`);
|
|
569
604
|
}
|
|
570
605
|
}
|
|
571
606
|
function serializeTurn(userText, o) {
|
package/dist/agent-native.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ import { SyncSqlite } from "./sqlite-driver.js";
|
|
|
2
2
|
import { AgentDefinition, ChannelContext } from "@junejs/core/agent-config";
|
|
3
3
|
import { AgentSession, ChannelPolicy, Model, Runtime, Tool } from "@junejs/core/agent-runtime";
|
|
4
4
|
//#region src/agent-native.d.ts
|
|
5
|
-
type AgentDef = {
|
|
5
|
+
export type AgentDef = {
|
|
6
6
|
model: Model;
|
|
7
7
|
tools: Tool[];
|
|
8
8
|
instructions?: string;
|
|
9
9
|
channelInstructions?: Record<string, string | ChannelPolicy>;
|
|
10
10
|
};
|
|
11
|
-
declare function toAgentDef(agent: AgentDefinition, model: Model): AgentDef;
|
|
12
|
-
type NativeRuntimeOptions = {
|
|
11
|
+
export declare function toAgentDef(agent: AgentDefinition, model: Model): AgentDef;
|
|
12
|
+
export type NativeRuntimeOptions = {
|
|
13
13
|
maxSessions?: number;
|
|
14
14
|
};
|
|
15
|
-
declare class NativeRuntime implements Runtime {
|
|
15
|
+
export declare class NativeRuntime implements Runtime {
|
|
16
16
|
private actors;
|
|
17
17
|
private readonly agents;
|
|
18
18
|
private readonly db;
|
|
@@ -23,8 +23,8 @@ declare class NativeRuntime implements Runtime {
|
|
|
23
23
|
get sessionCount(): number;
|
|
24
24
|
private evictIdle;
|
|
25
25
|
}
|
|
26
|
-
declare function createNativeRuntime(agents: Record<string, AgentDef>, path?: string, opts?: NativeRuntimeOptions): Promise<NativeRuntime>;
|
|
27
|
-
declare class MemoryRuntime implements Runtime {
|
|
26
|
+
export declare function createNativeRuntime(agents: Record<string, AgentDef>, path?: string, opts?: NativeRuntimeOptions): Promise<NativeRuntime>;
|
|
27
|
+
export declare class MemoryRuntime implements Runtime {
|
|
28
28
|
private actors;
|
|
29
29
|
private stores;
|
|
30
30
|
private readonly agents;
|
|
@@ -32,13 +32,13 @@ declare class MemoryRuntime implements Runtime {
|
|
|
32
32
|
agentDef(name: string): AgentDef | undefined;
|
|
33
33
|
session(agent: string, id: string): AgentSession;
|
|
34
34
|
}
|
|
35
|
-
type AgentBackend = "native" | "memory" | "durable";
|
|
36
|
-
declare function createAgentRuntime(agents: Record<string, AgentDef>, opts?: {
|
|
35
|
+
export type AgentBackend = "native" | "memory" | "durable";
|
|
36
|
+
export declare function createAgentRuntime(agents: Record<string, AgentDef>, opts?: {
|
|
37
37
|
backend?: AgentBackend;
|
|
38
38
|
path?: string;
|
|
39
39
|
maxSessions?: number;
|
|
40
40
|
}): Promise<Runtime>;
|
|
41
|
-
declare function mountAgent(agent: AgentDefinition, runtime: Runtime, opts?: {
|
|
41
|
+
export declare function mountAgent(agent: AgentDefinition, runtime: Runtime, opts?: {
|
|
42
42
|
chatPath?: string;
|
|
43
43
|
channels?: boolean;
|
|
44
44
|
services?: unknown;
|
|
@@ -48,5 +48,4 @@ declare function mountAgent(agent: AgentDefinition, runtime: Runtime, opts?: {
|
|
|
48
48
|
startAll: () => Promise<void>;
|
|
49
49
|
ctx: ChannelContext;
|
|
50
50
|
};
|
|
51
|
-
//#endregion
|
|
52
|
-
export { AgentBackend, AgentDef, MemoryRuntime, NativeRuntime, NativeRuntimeOptions, createAgentRuntime, createNativeRuntime, mountAgent, toAgentDef };
|
|
51
|
+
//#endregion
|
package/dist/agent-native.js
CHANGED
|
@@ -2,7 +2,7 @@ import { observeTurnEvents } from "./turn-events.js";
|
|
|
2
2
|
import { assertCoreRuntimeVersion } from "./core-version.js";
|
|
3
3
|
import { openLocalSqliteSync } from "./sqlite-driver.js";
|
|
4
4
|
import { buildSystemPrompt, channelFetch } from "@junejs/core/agent-config";
|
|
5
|
-
import { AgentSession, withSystem } from "@junejs/core/agent-runtime";
|
|
5
|
+
import { AgentSession, grantAnswer, withSystem } from "@junejs/core/agent-runtime";
|
|
6
6
|
//#region src/agent-native.ts
|
|
7
7
|
function initSchema(db) {
|
|
8
8
|
db.exec(`CREATE TABLE IF NOT EXISTS agent_sessions (session_id TEXT PRIMARY KEY, status TEXT)`);
|
|
@@ -271,7 +271,11 @@ function mountAgent(agent, runtime, opts = {}) {
|
|
|
271
271
|
},
|
|
272
272
|
resumeStream: async function* (o) {
|
|
273
273
|
const session = runtime.session(agent.name, o.session ?? "default");
|
|
274
|
-
const
|
|
274
|
+
const granted = await grantAnswer(session, o, agent.authorizeAnswer);
|
|
275
|
+
const { turnId } = session.resume(o.turnId, o.inputId, o.input, {
|
|
276
|
+
by: o.by,
|
|
277
|
+
granted
|
|
278
|
+
});
|
|
275
279
|
yield* observeTurnEvents(session, turnId);
|
|
276
280
|
},
|
|
277
281
|
resetSession: (o) => runtime.session(agent.name, o?.session ?? "default").reset()
|
package/dist/app.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { JuneConfig } from "@junejs/core/config";
|
|
2
2
|
//#region src/app.d.ts
|
|
3
|
-
type CreateAppOptions = {
|
|
3
|
+
export type CreateAppOptions = {
|
|
4
4
|
appDir: string;
|
|
5
5
|
config?: JuneConfig;
|
|
6
6
|
};
|
|
7
|
-
type JuneApp = {
|
|
7
|
+
export type JuneApp = {
|
|
8
8
|
fetch(request: Request): Promise<Response>;
|
|
9
9
|
warmup(): Promise<void>;
|
|
10
10
|
routePaths(): Promise<string[]>;
|
|
11
11
|
earlyHints(): string[];
|
|
12
12
|
};
|
|
13
|
-
declare function createApp({ appDir: appDirInput, config }: CreateAppOptions): JuneApp;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { CreateAppOptions, JuneApp, createApp };
|
|
13
|
+
export declare function createApp({ appDir: appDirInput, config }: CreateAppOptions): JuneApp;
|
|
14
|
+
//#endregion
|
package/dist/app.js
CHANGED
|
@@ -137,7 +137,8 @@ function createApp({ appDir: appDirInput, config = {} }) {
|
|
|
137
137
|
const def = await discoverAgent(agentDir);
|
|
138
138
|
const backend = agent.runtime.backend === "durable" ? "native" : agent.runtime.backend;
|
|
139
139
|
const model = anthropic({ model: def.model });
|
|
140
|
-
const
|
|
140
|
+
const rt = await createAgentRuntime({ [def.name]: toAgentDef(def, model) }, { backend });
|
|
141
|
+
const mounted = mountAgent(def, rt, {
|
|
141
142
|
chatPath: agent.runtime.chat.path,
|
|
142
143
|
channels: agent.runtime.channels
|
|
143
144
|
});
|
package/dist/blob.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BlobFactory } from "@junejs/core/resources";
|
|
2
2
|
//#region src/blob.d.ts
|
|
3
|
-
declare function localBlob(opts?: {
|
|
3
|
+
export declare function localBlob(opts?: {
|
|
4
4
|
dir?: string;
|
|
5
5
|
}): BlobFactory;
|
|
6
6
|
interface R2ObjectBody {
|
|
7
7
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
8
8
|
}
|
|
9
|
-
interface R2Bucket {
|
|
9
|
+
export interface R2Bucket {
|
|
10
10
|
get(key: string): Promise<R2ObjectBody | null>;
|
|
11
11
|
put(key: string, data: ArrayBuffer | Uint8Array | string): Promise<unknown>;
|
|
12
12
|
delete(key: string): Promise<void>;
|
|
@@ -18,6 +18,5 @@ interface R2Bucket {
|
|
|
18
18
|
}[];
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
21
|
-
declare function r2(bucket: R2Bucket): BlobFactory;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { R2Bucket, localBlob, r2 };
|
|
21
|
+
export declare function r2(bucket: R2Bucket): BlobFactory;
|
|
22
|
+
//#endregion
|
package/dist/build.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { n as scanAppRoutes, r as scanRoutes, t as RouteEntry } from "./route-scan-DMlwoESy.js";
|
|
2
2
|
import { t as generateContent } from "./content-freeze-CyiW2fRK.js";
|
|
3
|
-
import { i as workerName, n as normalizeBase, r as resolveDeployAdapter, t as freezeConfig } from "./config-freeze-
|
|
4
|
-
import { n as buildManifest } from "./manifest-
|
|
3
|
+
import { i as workerName, n as normalizeBase, r as resolveDeployAdapter, t as freezeConfig } from "./config-freeze-ZWC_Qd4h.js";
|
|
4
|
+
import { n as buildManifest } from "./manifest-DSNX4I-G.js";
|
|
5
5
|
//#region src/build.d.ts
|
|
6
|
-
type BuildResult = {
|
|
6
|
+
export type BuildResult = {
|
|
7
7
|
outFile: string;
|
|
8
8
|
routes: string[];
|
|
9
9
|
dynamicRoutes: string[];
|
|
10
10
|
contentCollections: string[];
|
|
11
11
|
prerendered: string[];
|
|
12
12
|
};
|
|
13
|
-
declare const isBunSpecifier: (id: string) => boolean;
|
|
14
|
-
declare function juneBuild(appRoot: string, options?: {
|
|
13
|
+
export declare const isBunSpecifier: (id: string) => boolean;
|
|
14
|
+
export declare function juneBuild(appRoot: string, options?: {
|
|
15
15
|
outDir?: string;
|
|
16
16
|
external?: string[];
|
|
17
17
|
}): Promise<BuildResult>;
|
|
18
18
|
//#endregion
|
|
19
|
-
export {
|
|
19
|
+
export { type RouteEntry, buildManifest, freezeConfig, generateContent, normalizeBase, resolveDeployAdapter, scanAppRoutes, scanRoutes, workerName };
|
package/dist/build.js
CHANGED
|
@@ -157,7 +157,7 @@ async function juneBuild(appRoot, options = {}) {
|
|
|
157
157
|
const layoutBoundariesField = boundaries.length ? `\n layoutBoundaries: {\n${boundaries.join("\n")}\n },` : "";
|
|
158
158
|
const builtExtraFile = findMiddlewareFile(appDir);
|
|
159
159
|
if (builtExtraFile) imports.push(`import extra from ${JSON.stringify(importPath(genDir, builtExtraFile))};`);
|
|
160
|
-
const linkHeader = buildLinkHeader(frozen.agent);
|
|
160
|
+
const linkHeader = buildLinkHeader(frozen.agent, { catalogs: !frozen.document.basePath });
|
|
161
161
|
const adapterEntry = adapter.entry({ linkHeader });
|
|
162
162
|
const resourceFlags = {
|
|
163
163
|
db: !!resourcesCfg?.db,
|
|
@@ -267,7 +267,14 @@ ${doClass}`;
|
|
|
267
267
|
if (cssAsset) manifest.document.styles = `/${cssAsset}`;
|
|
268
268
|
if (clientAsset) manifest.document.clientScript = `/${clientAsset}`;
|
|
269
269
|
if (moduleCssAsset) manifest.document.moduleStyles = `/${moduleCssAsset}`;
|
|
270
|
-
const
|
|
270
|
+
const isStatic = adapter.capabilities.runtime === "static";
|
|
271
|
+
if (isStatic) manifest.agent = {
|
|
272
|
+
...manifest.agent,
|
|
273
|
+
mcp: false,
|
|
274
|
+
api: false,
|
|
275
|
+
webmcp: false
|
|
276
|
+
};
|
|
277
|
+
const worker = createWorker(manifest, { staticBuild: isStatic });
|
|
271
278
|
let hasAssets = false;
|
|
272
279
|
const publicDir = join(appRoot, "public");
|
|
273
280
|
const publicFiles = [];
|
|
@@ -303,7 +310,6 @@ ${doClass}`;
|
|
|
303
310
|
}
|
|
304
311
|
hasAssets = true;
|
|
305
312
|
}
|
|
306
|
-
const isStatic = adapter.capabilities.runtime === "static";
|
|
307
313
|
const i18n = frozen.i18n;
|
|
308
314
|
const prerenderOne = async (reqPath, def) => {
|
|
309
315
|
const stem = reqPath === "/" ? "index" : reqPath.slice(1);
|
|
@@ -326,6 +332,10 @@ ${doClass}`;
|
|
|
326
332
|
prerendered.push(reqPath);
|
|
327
333
|
hasAssets = true;
|
|
328
334
|
};
|
|
335
|
+
if (isStatic && i18n) {
|
|
336
|
+
const onDomain = Object.keys(i18n.locales).filter((l) => i18n.locales[l].domain);
|
|
337
|
+
if (onDomain.length) throw new Error(`[june build] the static() target serves one host, so i18n locales with their own domain are not supported (${onDomain.join(", ")}). Give them a path prefix instead, e.g. { path: "/${onDomain[0]}" }.`);
|
|
338
|
+
}
|
|
329
339
|
const localeVariants = (path) => isStatic && i18n ? [...new Set(Object.keys(i18n.locales).map((l) => localeHref(i18n, path, l)))] : [path];
|
|
330
340
|
for (const r of routes.filter((x) => !x.dynamic)) {
|
|
331
341
|
const def = manifest.routes[r.path];
|
|
@@ -338,18 +348,34 @@ ${doClass}`;
|
|
|
338
348
|
const sp = dyn.def.staticPaths;
|
|
339
349
|
if (!sp) continue;
|
|
340
350
|
const paths = typeof sp === "function" ? await sp() : sp;
|
|
351
|
+
dyn.def.staticPaths = paths;
|
|
341
352
|
for (const p of paths) await prerenderOne(p, dyn.def);
|
|
342
353
|
}
|
|
343
|
-
|
|
354
|
+
const extra = [
|
|
344
355
|
["/favicon.svg", "favicon.svg"],
|
|
345
356
|
["/manifest.webmanifest", "manifest.webmanifest"],
|
|
346
357
|
["/llms.txt", "llms.txt"],
|
|
347
358
|
["/sitemap.xml", "sitemap.xml"]
|
|
348
|
-
]
|
|
359
|
+
];
|
|
360
|
+
if (manifest.agent.discovery && !manifest.document.site.url && !manifest.document.deployOrigin) console.warn("[june build] no sitemap.xml: set site.url (or deploy.domain) in june.config.ts so its URLs are absolute.");
|
|
361
|
+
const doc = manifest.document;
|
|
362
|
+
if (manifest.agent.discovery && !doc.basePath && (doc.site.url || doc.deployOrigin)) extra.push(["/.well-known/ai-catalog.json", ".well-known/ai-catalog.json"], ["/.well-known/ard.json", ".well-known/ard.json"], ["/.well-known/agent-skills/index.json", ".well-known/agent-skills/index.json"]);
|
|
363
|
+
for (let i = 0; i < extra.length; i++) {
|
|
364
|
+
const [reqPath, file] = extra[i];
|
|
349
365
|
const res = await worker.fetch(new Request(`${PRERENDER_ORIGIN}${reqPath}`));
|
|
350
366
|
if (!res.ok) continue;
|
|
351
|
-
|
|
367
|
+
const bytes = Buffer.from(await res.arrayBuffer());
|
|
368
|
+
await mkdir(dirname(join(assetsDir, file)), { recursive: true });
|
|
369
|
+
await writeFile(join(assetsDir, file), bytes);
|
|
352
370
|
hasAssets = true;
|
|
371
|
+
if (file.endsWith("agent-skills/index.json")) {
|
|
372
|
+
const index = JSON.parse(bytes.toString("utf8"));
|
|
373
|
+
for (const s of index.skills ?? []) {
|
|
374
|
+
if (!s.url) continue;
|
|
375
|
+
const p = new URL(s.url, PRERENDER_ORIGIN).pathname;
|
|
376
|
+
extra.push([p, p.slice(1)]);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
353
379
|
}
|
|
354
380
|
const nf = await worker.fetch(new Request(`${PRERENDER_ORIGIN}/__june_not_found__`));
|
|
355
381
|
await writeFile(join(assetsDir, "404.html"), Buffer.from(await nf.arrayBuffer()));
|
|
@@ -369,7 +395,8 @@ ${doClass}`;
|
|
|
369
395
|
hasAssets = true;
|
|
370
396
|
}
|
|
371
397
|
const pkgPath = join(appRoot, "package.json");
|
|
372
|
-
const
|
|
398
|
+
const pkgName = existsSync(pkgPath) ? JSON.parse(await Bun.file(pkgPath).text()).name : void 0;
|
|
399
|
+
const defaultName = workerName(pkgName ?? basename(appRoot));
|
|
373
400
|
const plan = {
|
|
374
401
|
...resourcesCfg?.db && resourcesCfg.db.kind !== "turso" ? { db: {
|
|
375
402
|
binding: "DB",
|
package/dist/client-bundle.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ModuleMaps } from "./css-modules.js";
|
|
2
2
|
//#region src/client-bundle.d.ts
|
|
3
|
-
declare const CLIENT_SCRIPT_URL = "/_june/client.js";
|
|
4
|
-
declare function findClientEntry(appDir: string): string | undefined;
|
|
3
|
+
export declare const CLIENT_SCRIPT_URL = "/_june/client.js";
|
|
4
|
+
export declare function findClientEntry(appDir: string): string | undefined;
|
|
5
5
|
type BundleMode = "development" | "production";
|
|
6
|
-
declare function isExpectedClientLog(log: {
|
|
6
|
+
export declare function isExpectedClientLog(log: {
|
|
7
7
|
code?: string;
|
|
8
8
|
exporter?: string;
|
|
9
9
|
}): boolean;
|
|
10
|
-
type ClientChunks = Map<string, string>;
|
|
11
|
-
declare function bundleClientSplit(entryFile: string, cwd: string, mode: BundleMode, maps?: ModuleMaps): Promise<ClientChunks>;
|
|
12
|
-
declare function bundleClientToString(entryFile: string, cwd: string, maps?: ModuleMaps): Promise<string>;
|
|
13
|
-
declare function bundleClientToFile(entryFile: string, cwd: string, destDir: string, maps?: ModuleMaps): Promise<string>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { CLIENT_SCRIPT_URL, ClientChunks, bundleClientSplit, bundleClientToFile, bundleClientToString, findClientEntry, isExpectedClientLog };
|
|
10
|
+
export type ClientChunks = Map<string, string>;
|
|
11
|
+
export declare function bundleClientSplit(entryFile: string, cwd: string, mode: BundleMode, maps?: ModuleMaps): Promise<ClientChunks>;
|
|
12
|
+
export declare function bundleClientToString(entryFile: string, cwd: string, maps?: ModuleMaps): Promise<string>;
|
|
13
|
+
export declare function bundleClientToFile(entryFile: string, cwd: string, destDir: string, maps?: ModuleMaps): Promise<string>;
|
|
14
|
+
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as JuneAdapter } from "./adapter-DcZ-W1-7.js";
|
|
2
|
-
import { n as WorkerManifest } from "./worker-
|
|
2
|
+
import { n as WorkerManifest } from "./worker-Dv4l6Ybs.js";
|
|
3
3
|
import { JuneConfig } from "@junejs/core/config";
|
|
4
4
|
import { DocumentConfig } from "@junejs/core/document";
|
|
5
5
|
//#region src/config-freeze.d.ts
|
package/dist/config-freeze.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as workerName, n as normalizeBase, r as resolveDeployAdapter, t as freezeConfig } from "./config-freeze-
|
|
1
|
+
import { i as workerName, n as normalizeBase, r as resolveDeployAdapter, t as freezeConfig } from "./config-freeze-ZWC_Qd4h.js";
|
|
2
2
|
export { freezeConfig, normalizeBase, resolveDeployAdapter, workerName };
|
package/dist/config-loader.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { JuneConfig } from "@junejs/core/config";
|
|
|
3
3
|
/** The config file loadJuneConfig would import, or null. Exported so callers that need a FRESH
|
|
4
4
|
* load (a subprocess probe — see generateContent's bootstrap retry) target the same file the
|
|
5
5
|
* in-process loader would. */
|
|
6
|
-
declare function findJuneConfigPath(appDir: string): string | null;
|
|
7
|
-
declare function loadJuneConfig(appDir: string): Promise<JuneConfig>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { findJuneConfigPath, loadJuneConfig };
|
|
6
|
+
export declare function findJuneConfigPath(appDir: string): string | null;
|
|
7
|
+
export declare function loadJuneConfig(appDir: string): Promise<JuneConfig>;
|
|
8
|
+
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionContext } from "@junejs/core/context";
|
|
2
2
|
//#region src/connection-auth.d.ts
|
|
3
|
-
type AccountTokenStore = (args: {
|
|
3
|
+
export type AccountTokenStore = (args: {
|
|
4
4
|
userId: string;
|
|
5
5
|
providerId: string;
|
|
6
6
|
}) => Promise<{
|
|
@@ -8,15 +8,15 @@ type AccountTokenStore = (args: {
|
|
|
8
8
|
} | null> | {
|
|
9
9
|
accessToken: string;
|
|
10
10
|
} | null;
|
|
11
|
-
type LinkedAccountAuthOptions = {
|
|
11
|
+
export type LinkedAccountAuthOptions = {
|
|
12
12
|
providerId: string;
|
|
13
13
|
store: AccountTokenStore;
|
|
14
14
|
};
|
|
15
|
-
type ConnectionAuth = (ctx?: ActionContext) => Promise<{
|
|
15
|
+
export type ConnectionAuth = (ctx?: ActionContext) => Promise<{
|
|
16
16
|
token: string;
|
|
17
17
|
}>;
|
|
18
|
-
declare function linkedAccountAuth(opts: LinkedAccountAuthOptions): ConnectionAuth;
|
|
19
|
-
type BetterAuthLike = {
|
|
18
|
+
export declare function linkedAccountAuth(opts: LinkedAccountAuthOptions): ConnectionAuth;
|
|
19
|
+
export type BetterAuthLike = {
|
|
20
20
|
api: {
|
|
21
21
|
getAccessToken: (input: {
|
|
22
22
|
body: {
|
|
@@ -31,9 +31,8 @@ type BetterAuthLike = {
|
|
|
31
31
|
} | null | undefined>;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
declare function betterAuthAccountTokenStore(auth: BetterAuthLike): AccountTokenStore;
|
|
35
|
-
declare function betterAuthAccessToken(auth: BetterAuthLike, opts: {
|
|
34
|
+
export declare function betterAuthAccountTokenStore(auth: BetterAuthLike): AccountTokenStore;
|
|
35
|
+
export declare function betterAuthAccessToken(auth: BetterAuthLike, opts: {
|
|
36
36
|
providerId: string;
|
|
37
37
|
}): ConnectionAuth;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { AccountTokenStore, BetterAuthLike, ConnectionAuth, LinkedAccountAuthOptions, betterAuthAccessToken, betterAuthAccountTokenStore, linkedAccountAuth };
|
|
38
|
+
//#endregion
|
package/dist/content.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ContentSource } from "@junejs/core/config";
|
|
2
2
|
//#region src/content.d.ts
|
|
3
|
-
type Heading = {
|
|
3
|
+
export type Heading = {
|
|
4
4
|
depth: number;
|
|
5
5
|
text: string;
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
|
-
declare function headingIds(html: string): {
|
|
8
|
+
export declare function headingIds(html: string): {
|
|
9
9
|
html: string;
|
|
10
10
|
headings: Heading[];
|
|
11
11
|
};
|
|
12
|
-
type ContentEntry = {
|
|
12
|
+
export type ContentEntry = {
|
|
13
13
|
slug: string;
|
|
14
14
|
file: string;
|
|
15
15
|
/** Parsed frontmatter (string values; `tags`-style lists become string[]). */
|
|
@@ -29,25 +29,24 @@ type ContentEntry = {
|
|
|
29
29
|
* subdir, undefined for the flat (default-locale) files. */
|
|
30
30
|
locale?: string;
|
|
31
31
|
};
|
|
32
|
-
type ScannedCollection = {
|
|
32
|
+
export type ScannedCollection = {
|
|
33
33
|
default: ContentEntry[];
|
|
34
34
|
byLocale: Record<string, ContentEntry[]>;
|
|
35
35
|
};
|
|
36
|
-
declare function scanCollection(dir: string, knownLocales?: readonly string[]): ScannedCollection;
|
|
36
|
+
export declare function scanCollection(dir: string, knownLocales?: readonly string[]): ScannedCollection;
|
|
37
37
|
/** All entries in a content directory, newest-first by `date` (then slug). With
|
|
38
38
|
* a `locale`, each entry is its locale variant when present, else the default
|
|
39
39
|
* (so a reader sees the whole collection, localized where available). */
|
|
40
|
-
declare function collection(dir: string, locale?: string): ContentEntry[];
|
|
40
|
+
export declare function collection(dir: string, locale?: string): ContentEntry[];
|
|
41
41
|
/** One entry by slug, or null. With a `locale`, prefer `<dir>/<locale>/<slug>`,
|
|
42
42
|
* falling back to the flat default (a dev-warn flags a partial translation).
|
|
43
43
|
* `fallback: false` is STRICT — a missing variant returns null (so a route can
|
|
44
44
|
* 404 rather than serve default-language content). */
|
|
45
|
-
declare function entry(dir: string, slug: string, locale?: string, opts?: {
|
|
45
|
+
export declare function entry(dir: string, slug: string, locale?: string, opts?: {
|
|
46
46
|
fallback?: boolean;
|
|
47
47
|
}): ContentEntry | null;
|
|
48
|
-
declare function generateContentModule(contentDir: string, knownLocales?: readonly string[], sources?: readonly ContentSource[]): {
|
|
48
|
+
export declare function generateContentModule(contentDir: string, knownLocales?: readonly string[], sources?: readonly ContentSource[]): {
|
|
49
49
|
code: string;
|
|
50
50
|
names: string[];
|
|
51
51
|
};
|
|
52
|
-
//#endregion
|
|
53
|
-
export { ContentEntry, Heading, ScannedCollection, collection, entry, generateContentModule, headingIds, scanCollection };
|
|
52
|
+
//#endregion
|