@junejs/server 0.1.2-dev.1 → 0.1.2-dev.2

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.
@@ -71,6 +71,7 @@ declare function durableChannelSurface(getNamespace: () => DurableObjectNamespac
71
71
  agentName: string;
72
72
  channels: (Channel | ChannelFactory)[];
73
73
  env: unknown;
74
+ services?: (env: unknown) => unknown;
74
75
  waitUntil?: (p: Promise<unknown>) => void;
75
76
  }): (req: Request) => Promise<Response | null>;
76
77
  //#endregion
@@ -131,6 +131,7 @@ function durableChannelSurface(getNamespace, opts) {
131
131
  channels: [],
132
132
  connections: []
133
133
  },
134
+ services: opts.services?.(opts.env),
134
135
  waitUntil: opts.waitUntil,
135
136
  run: async (message, o) => {
136
137
  const namespace = getNamespace();
@@ -31,6 +31,7 @@ declare function createAgentRuntime(agents: Record<string, AgentDef>, opts?: {
31
31
  declare function mountAgent(agent: AgentDefinition, runtime: Runtime, opts?: {
32
32
  chatPath?: string;
33
33
  channels?: boolean;
34
+ services?: unknown;
34
35
  }): {
35
36
  surface: (req: Request) => Promise<Response | null>;
36
37
  fetch: (req: Request) => Promise<Response | null>;
@@ -152,6 +152,7 @@ function mountAgent(agent, runtime, opts = {}) {
152
152
  const channelsOn = opts.channels ?? true;
153
153
  const ctx = {
154
154
  agent,
155
+ services: opts.services,
155
156
  run: (message, o) => runtime.session(agent.name, o?.session ?? "default").turn({
156
157
  turnId: o?.turnId,
157
158
  userText: message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junejs/server",
3
- "version": "0.1.2-dev.1",
3
+ "version": "0.1.2-dev.2",
4
4
  "description": "June host adapters + dev server. Host-coupled; depends on the pure @junejs/core contract layer.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -125,7 +125,7 @@
125
125
  "build": "tsdown"
126
126
  },
127
127
  "dependencies": {
128
- "@junejs/core": ">=0.1.1-dev.3",
128
+ "@junejs/core": ">=0.1.1-dev.4",
129
129
  "@junejs/db": ">=0.0.34-dev.0",
130
130
  "@momiji-rs/sparkdown": "^0.0.4",
131
131
  "lightningcss": "^1.27.0",
@@ -299,6 +299,11 @@ export function durableChannelSurface(
299
299
  agentName: string;
300
300
  channels: (Channel | ChannelFactory)[];
301
301
  env: unknown;
302
+ // The app's services factory — the SAME one AgentDurableObject uses — resolved HERE
303
+ // (worker isolate) and exposed to channel hooks as ctx.services. Channel hooks run at
304
+ // the edge, outside the DO, so they can't read the DO's ambient currentServices(); this
305
+ // gives them the same DI bag. Resolved once per surface construction.
306
+ services?: (env: unknown) => unknown;
302
307
  waitUntil?: (p: Promise<unknown>) => void;
303
308
  },
304
309
  ): (req: Request) => Promise<Response | null> {
@@ -307,6 +312,7 @@ export function durableChannelSurface(
307
312
  // A minimal but complete AgentDefinition — channels only read ctx.agent.name; the
308
313
  // full def isn't present in the worker (tools/model live in the DO).
309
314
  agent: { name: opts.agentName, instructions: "", tools: [], skills: [], channels: [], connections: [] } satisfies AgentDefinition,
315
+ services: opts.services?.(opts.env),
310
316
  waitUntil: opts.waitUntil,
311
317
  run: async (message, o) => {
312
318
  const namespace = getNamespace();
@@ -195,7 +195,7 @@ export async function createAgentRuntime(
195
195
  export function mountAgent(
196
196
  agent: AgentDefinition,
197
197
  runtime: Runtime,
198
- opts: { chatPath?: string; channels?: boolean } = {},
198
+ opts: { chatPath?: string; channels?: boolean; services?: unknown } = {},
199
199
  ): {
200
200
  surface: (req: Request) => Promise<Response | null>;
201
201
  fetch: (req: Request) => Promise<Response | null>;
@@ -206,6 +206,7 @@ export function mountAgent(
206
206
  const channelsOn = opts.channels ?? true;
207
207
  const ctx: ChannelContext = {
208
208
  agent,
209
+ services: opts.services, // same DI bag reachable from channel hooks (parity with durableChannelSurface)
209
210
  run: (message, o) =>
210
211
  runtime.session(agent.name, o?.session ?? "default").turn({ turnId: o?.turnId, userText: message, event: o?.event }),
211
212
  };