@junejs/server 0.1.3 → 0.2.1

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 (131) hide show
  1. package/assets/icon-latin.LICENSE.txt +92 -0
  2. package/assets/icon-latin.ttf +0 -0
  3. package/dist/adapter-D0UnYBuN.d.ts +64 -0
  4. package/dist/adapter.d.ts +2 -56
  5. package/dist/adapter.js +107 -6
  6. package/dist/agent-compile.d.ts +38 -0
  7. package/dist/agent-compile.js +145 -0
  8. package/dist/agent-discover.d.ts +4 -4
  9. package/dist/agent-discover.js +30 -44
  10. package/dist/agent-durable.d.ts +94 -19
  11. package/dist/agent-durable.js +647 -32
  12. package/dist/agent-native.d.ts +44 -13
  13. package/dist/agent-native.js +264 -27
  14. package/dist/app.d.ts +5 -5
  15. package/dist/app.js +42 -10
  16. package/dist/assets.d.ts +23 -0
  17. package/dist/assets.js +123 -0
  18. package/dist/blob.d.ts +4 -5
  19. package/dist/build.d.ts +8 -30
  20. package/dist/build.js +143 -298
  21. package/dist/client-bundle.d.ts +8 -9
  22. package/dist/client-bundle.js +1 -1
  23. package/dist/config-freeze-r5p-vTWv.d.ts +17 -0
  24. package/dist/config-freeze.d.ts +2 -0
  25. package/dist/config-freeze.js +54 -0
  26. package/dist/config-loader.d.ts +3 -4
  27. package/dist/connection-auth.d.ts +38 -0
  28. package/dist/connection-auth.js +31 -0
  29. package/dist/content-freeze-CyiW2fRK.d.ts +4 -0
  30. package/dist/content-freeze.d.ts +2 -0
  31. package/dist/content-freeze.js +83 -0
  32. package/dist/content.d.ts +22 -9
  33. package/dist/content.js +43 -3
  34. package/dist/core-version.d.ts +4 -0
  35. package/dist/core-version.js +12 -0
  36. package/dist/css-modules-ambient.d.ts +2 -1
  37. package/dist/css-modules.d.ts +10 -11
  38. package/dist/css.d.ts +9 -10
  39. package/dist/d1-migrate.d.ts +6 -7
  40. package/dist/d1-migrate.js +3 -2
  41. package/dist/db.d.ts +2 -2
  42. package/dist/deploy.d.ts +3 -4
  43. package/dist/deploy.js +3 -2
  44. package/dist/dev-reload.d.ts +3 -4
  45. package/dist/dev.d.ts +8 -5
  46. package/dist/dev.js +40 -9
  47. package/dist/favicon.d.ts +37 -0
  48. package/dist/favicon.js +248 -0
  49. package/dist/host.d.ts +6 -5
  50. package/dist/host.js +2 -1
  51. package/dist/icon-letter.d.ts +3 -0
  52. package/dist/icon-letter.js +8 -0
  53. package/dist/index.d.ts +11 -5
  54. package/dist/index.js +9 -3
  55. package/dist/instrumentation.d.ts +2 -3
  56. package/dist/instrumentation.js +2 -1
  57. package/dist/island-registry.d.ts +6 -7
  58. package/dist/isolate-local.d.ts +5 -0
  59. package/dist/isolate-local.js +12 -0
  60. package/dist/kv.d.ts +3 -4
  61. package/dist/llms-links.d.ts +9 -0
  62. package/dist/llms-links.js +65 -0
  63. package/dist/manifest-CwTT1zVs.d.ts +11 -0
  64. package/dist/manifest.d.ts +2 -0
  65. package/dist/manifest.js +113 -0
  66. package/dist/negotiate.d.ts +4 -3
  67. package/dist/negotiate.js +24 -14
  68. package/dist/{pipeline-CCp9idQ4.d.ts → pipeline-BHUjBO0G.d.ts} +13 -1
  69. package/dist/pipeline.d.ts +2 -2
  70. package/dist/pipeline.js +286 -35
  71. package/dist/resources.d.ts +5 -6
  72. package/dist/route-rank.d.ts +6 -7
  73. package/dist/route-scan-BMbBzPIB.d.ts +20 -0
  74. package/dist/route-scan.d.ts +2 -0
  75. package/dist/route-scan.js +100 -0
  76. package/dist/router.d.ts +12 -13
  77. package/dist/router.js +51 -38
  78. package/dist/rsc-build.d.ts +6 -7
  79. package/dist/rsc-bundle.d.ts +6 -7
  80. package/dist/rsc-manifest.d.ts +5 -6
  81. package/dist/rsc-runtime/flight-render-routes.d.ts +3 -4
  82. package/dist/rsc-runtime/flight-render.d.ts +2 -3
  83. package/dist/rsc-runtime/flight-to-html.d.ts +2 -3
  84. package/dist/rsc-runtime/flight-to-html.js +3 -2
  85. package/dist/rsc-runtime/rsc-worker.js +11 -8
  86. package/dist/rsc-runtime/rsdw-shims.d.ts +2 -1
  87. package/dist/segment.d.ts +4 -5
  88. package/dist/sqlite-driver.d.ts +11 -11
  89. package/dist/sqlite-driver.js +17 -4
  90. package/dist/static-files.d.ts +4 -5
  91. package/dist/tsconfig-jsx.d.ts +4 -4
  92. package/dist/tsconfig-jsx.js +1 -1
  93. package/dist/turn-events.d.ts +4 -0
  94. package/dist/turn-events.js +46 -0
  95. package/dist/web-manifest.d.ts +5 -0
  96. package/dist/web-manifest.js +42 -0
  97. package/dist/worker-2qbQjj2c.d.ts +64 -0
  98. package/dist/worker.d.ts +2 -57
  99. package/dist/worker.js +69 -27
  100. package/package.json +28 -9
  101. package/src/adapter.ts +149 -4
  102. package/src/agent-compile.ts +271 -0
  103. package/src/agent-discover.ts +77 -63
  104. package/src/agent-durable.ts +998 -30
  105. package/src/agent-native.ts +370 -35
  106. package/src/app.ts +75 -6
  107. package/src/assets.ts +200 -0
  108. package/src/build.ts +241 -449
  109. package/src/config-freeze.ts +109 -0
  110. package/src/connection-auth.ts +101 -0
  111. package/src/content-freeze.ts +151 -0
  112. package/src/content.ts +55 -4
  113. package/src/core-version.ts +34 -0
  114. package/src/dev.ts +41 -8
  115. package/src/favicon.ts +325 -0
  116. package/src/host.ts +4 -3
  117. package/src/icon-letter.ts +14 -0
  118. package/src/index.ts +22 -0
  119. package/src/isolate-local.ts +33 -0
  120. package/src/llms-links.ts +96 -0
  121. package/src/manifest.ts +130 -0
  122. package/src/negotiate.ts +39 -15
  123. package/src/pipeline.ts +494 -44
  124. package/src/route-scan.ts +161 -0
  125. package/src/router.ts +66 -54
  126. package/src/rsc-runtime/rsc-worker.tsx +5 -4
  127. package/src/sqlite-driver.ts +36 -6
  128. package/src/tsconfig-jsx.ts +2 -2
  129. package/src/turn-events.ts +43 -0
  130. package/src/web-manifest.ts +38 -0
  131. package/src/worker.ts +131 -35
@@ -1,73 +1,148 @@
1
1
  import { Channel, ChannelFactory } from "@junejs/core/agent-config";
2
- import { Model, Msg, SessionStore, Tool } from "@junejs/core/agent-runtime";
2
+ import { AuthorizeAnswer, ChannelPolicy, InboundEvent, InputAnnouncement, Model, Msg, NoteKind, ProactiveTrigger, SessionStore, Tool, TurnError, TurnEvent, TurnFailurePhase } from "@junejs/core/agent-runtime";
3
+ import { FileStore } from "@junejs/core/agent-files";
4
+ import { Connection } from "@junejs/core/connections";
3
5
  import { Resources } from "@junejs/core/resources";
4
6
  //#region src/agent-durable.d.ts
5
- type SqlStorageValue = ArrayBuffer | string | number | null;
6
- interface SqlStorageCursor<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>> {
7
+ export type SqlStorageValue = ArrayBuffer | string | number | null;
8
+ export interface SqlStorageCursor<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>> {
7
9
  toArray(): T[];
8
10
  one(): T;
9
11
  }
10
- interface SqlStorage {
12
+ export interface SqlStorage {
11
13
  exec<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>>(query: string, ...bindings: unknown[]): SqlStorageCursor<T>;
12
14
  }
13
- interface DurableStorage {
15
+ export interface DurableStorage {
14
16
  sql: SqlStorage;
15
17
  transactionSync<T>(fn: () => T): T;
18
+ setAlarm?(scheduledTime: number): unknown;
16
19
  }
17
- interface DurableObjectState {
20
+ export interface DurableObjectState {
18
21
  storage: DurableStorage;
19
22
  }
20
- interface DurableObjectStub {
23
+ export interface DurableObjectStub {
21
24
  fetch(request: Request): Promise<Response>;
22
25
  }
23
- interface DurableObjectNamespace {
26
+ export interface DurableObjectNamespace {
24
27
  idFromName(name: string): unknown;
25
28
  get(id: unknown): DurableObjectStub;
26
29
  }
27
- declare class DoSessionStore implements SessionStore {
30
+ export declare class DoSessionStore implements SessionStore {
28
31
  private readonly storage;
29
32
  constructor(storage: DurableStorage);
30
33
  private get sql();
31
34
  appendMessage(m: Msg): void;
32
35
  messages(): Msg[];
33
- hasUserTurn(turnId: string): boolean;
36
+ hasOpeningMessage(turnId: string): boolean;
34
37
  getStep(id: string): unknown | undefined;
35
38
  putStep(id: string, output: unknown): void;
39
+ delStep(id: string): void;
36
40
  getStatus(): string;
37
41
  setStatus(s: string): void;
42
+ getSessionKey(): string | undefined;
43
+ setSessionKey(key: string): void;
38
44
  tx<T>(fn: () => T): T;
45
+ reset(inTx?: () => void): number;
39
46
  unwrap<H = unknown>(): H;
40
47
  }
41
- type DoAgentDef = {
48
+ export type DoAgentDef = {
42
49
  name?: string;
43
50
  model: Model;
44
51
  tools: Tool[];
45
52
  instructions?: string;
46
- resources?: Resources;
53
+ channelInstructions?: Record<string, string | ChannelPolicy>;
54
+ channels?: (Channel | ChannelFactory)[];
55
+ env?: unknown;
56
+ resources?: Resources | ((env: unknown) => Promise<Resources> | Resources);
57
+ connections?: Connection[];
47
58
  services?: unknown;
59
+ onTurnError?: (failure: {
60
+ turnId: string;
61
+ error: TurnError;
62
+ phase?: TurnFailurePhase;
63
+ step?: string;
64
+ }) => void | Promise<void>;
65
+ authorizeAnswer?: AuthorizeAnswer;
66
+ onInputAnnouncement?: (a: InputAnnouncement) => void | Promise<void>;
67
+ files?: FileStore;
48
68
  };
49
- declare class AgentDurableObject {
69
+ export declare class AgentDurableObject {
50
70
  private session;
51
- private readonly resources;
71
+ private sessionKey;
72
+ private readonly name;
73
+ private readonly store;
74
+ private readonly sink;
75
+ private readonly model;
76
+ private readonly tools;
77
+ private readonly channels;
78
+ private readonly channelInstructions?;
79
+ private readonly resourcesInput;
80
+ private resourcesOpened;
81
+ private readonly connectionsInput;
82
+ private connectionsOpened;
83
+ private readonly doEnv;
52
84
  private readonly services;
85
+ private readonly authorizeAnswer?;
86
+ private readonly onInputAnnouncement?;
87
+ private readonly storage;
88
+ private readonly files;
89
+ private announceFailures;
90
+ private resolveResources;
91
+ private resolveConnections;
92
+ private ready;
53
93
  constructor(state: DurableObjectState, def: DoAgentDef);
94
+ private resolveSession;
95
+ alarm(): Promise<void>;
96
+ private armWatchdog;
97
+ private scheduleAlarm;
98
+ private deliverHeld;
54
99
  turn(input: {
55
100
  turnId?: string;
56
101
  userText: string;
102
+ event?: InboundEvent;
103
+ trigger?: ProactiveTrigger;
104
+ session?: string;
57
105
  }): Promise<string>;
106
+ start(input: {
107
+ turnId?: string;
108
+ userText: string;
109
+ event?: InboundEvent;
110
+ trigger?: ProactiveTrigger;
111
+ session?: string;
112
+ }): Promise<{
113
+ turnId: string;
114
+ }>;
115
+ note(input: {
116
+ by: string;
117
+ kind: NoteKind;
118
+ text: string;
119
+ session?: string;
120
+ }): Promise<{
121
+ noteId: string;
122
+ }>;
123
+ reset(opts?: {
124
+ session?: string;
125
+ }): Promise<{
126
+ previousSession: string;
127
+ generation: number;
128
+ }>;
58
129
  transcript(): import("@junejs/core/agent-runtime").Turn[];
59
130
  fetch(req: Request): Promise<Response>;
60
131
  }
61
- declare function durableFetch(namespace: DurableObjectNamespace, agent: string, session: string, req: Request): Promise<Response>;
62
- declare function durableAgentSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
132
+ export declare function sseTurnFinalText(res: Response): Promise<string>;
133
+ export declare function sseTurnEvents(res: Response): AsyncIterable<TurnEvent>;
134
+ export declare const SESSION_HEADER = "x-june-session";
135
+ export declare function durableFetch(namespace: DurableObjectNamespace, agent: string, session: string, req: Request): Promise<Response>;
136
+ export declare function durableAgentSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
63
137
  agentName: string;
64
138
  chatPath?: string;
65
139
  }): (req: Request) => Promise<Response | null>;
66
- declare function durableChannelSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
140
+ export declare function durableChannelSurface(getNamespace: () => DurableObjectNamespace | undefined, opts: {
67
141
  agentName: string;
68
142
  channels: (Channel | ChannelFactory)[];
69
143
  env: unknown;
144
+ services?: (env: unknown) => unknown;
70
145
  waitUntil?: (p: Promise<unknown>) => void;
146
+ files?: FileStore;
71
147
  }): (req: Request) => Promise<Response | null>;
72
- //#endregion
73
- export { AgentDurableObject, DoAgentDef, DoSessionStore, DurableObjectNamespace, DurableObjectState, DurableObjectStub, DurableStorage, SqlStorage, SqlStorageCursor, SqlStorageValue, durableAgentSurface, durableChannelSurface, durableFetch };
148
+ //#endregion