sideagent 0.3.0 → 0.4.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/dist/keys.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ type KeyEnvironment = "test" | "live";
2
+ interface PublishableKeyParts {
3
+ environment: KeyEnvironment;
4
+ /** host[:port], no scheme. */
5
+ host: string;
6
+ agentId: string;
7
+ }
8
+ /** Request header that carries the publishable key. Authorization stays free for the user's token. */
9
+ declare const PUBLISHABLE_KEY_HEADER = "x-sideagent-key";
10
+ declare function publishableKey(environment: KeyEnvironment, host: string, agentId: string): string;
11
+ /** The key's parts, or null when it is not a well-formed publishable key. */
12
+ declare function parsePublishableKey(key: string): PublishableKeyParts | null;
13
+ /** The agent's data-plane URL. https, except http for localhost and 127.0.0.1 (local development). */
14
+ declare function publishableEndpoint({ host, agentId }: PublishableKeyParts): string;
15
+
16
+ export { type KeyEnvironment, PUBLISHABLE_KEY_HEADER, type PublishableKeyParts, parsePublishableKey, publishableEndpoint, publishableKey };
package/dist/keys.js ADDED
@@ -0,0 +1,12 @@
1
+ import {
2
+ PUBLISHABLE_KEY_HEADER,
3
+ parsePublishableKey,
4
+ publishableEndpoint,
5
+ publishableKey
6
+ } from "./chunk-73FXXOAR.js";
7
+ export {
8
+ PUBLISHABLE_KEY_HEADER,
9
+ parsePublishableKey,
10
+ publishableEndpoint,
11
+ publishableKey
12
+ };
@@ -1,8 +1,8 @@
1
1
  import { ThreadMeta } from '../protocol.js';
2
2
  export { AgentEvent, ChatRequest } from '../protocol.js';
3
3
  import { z } from 'zod';
4
- import { BaseCheckpointSaver } from '@langchain/langgraph';
5
4
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
5
+ import { BaseCheckpointSaver } from '@langchain/langgraph';
6
6
 
7
7
  declare const configSchema: z.ZodObject<{
8
8
  spec: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
@@ -65,24 +65,6 @@ interface UrlGuardOptions {
65
65
  /** Throws unless `url` is safe to call under the pinned config. */
66
66
  declare function assertAllowedUrl(url: string, opts: UrlGuardOptions): URL;
67
67
 
68
- interface KnowledgeSourceInput {
69
- id: string;
70
- title: string;
71
- content: string;
72
- }
73
- interface KnowledgeUrlInput {
74
- url: string;
75
- title?: string;
76
- }
77
- interface KnowledgeOptions {
78
- sources: KnowledgeSourceInput[];
79
- urls: (string | KnowledgeUrlInput)[];
80
- topK: number;
81
- ttlMs: number;
82
- maxSourceBytes: number;
83
- maxChunks: number;
84
- chunkSize: number;
85
- }
86
68
  interface ChunkMeta {
87
69
  sourceId: string;
88
70
  title: string;
@@ -109,13 +91,34 @@ declare class MemoryVectorStore implements VectorStore {
109
91
  replace(sourceId: string, chunks: StoredChunk[]): Promise<void>;
110
92
  search(vector: number[], k: number): Promise<Hit[]>;
111
93
  }
94
+
112
95
  /** Splits markdown/plain text into chunks of roughly `size` chars, keeping the nearest heading as context. */
113
96
  declare function chunkText(content: string, size: number): string[];
97
+
114
98
  /** Dependency-free HTML to text/markdown-ish conversion. Plain text out; never HTML. */
115
99
  declare function htmlToText(html: string): {
116
100
  title?: string;
117
101
  text: string;
118
102
  };
103
+
104
+ interface KnowledgeSourceInput {
105
+ id: string;
106
+ title: string;
107
+ content: string;
108
+ }
109
+ interface KnowledgeUrlInput {
110
+ url: string;
111
+ title?: string;
112
+ }
113
+ interface KnowledgeOptions {
114
+ sources: KnowledgeSourceInput[];
115
+ urls: (string | KnowledgeUrlInput)[];
116
+ topK: number;
117
+ ttlMs: number;
118
+ maxSourceBytes: number;
119
+ maxChunks: number;
120
+ chunkSize: number;
121
+ }
119
122
  interface SourceStatus {
120
123
  id: string;
121
124
  title: string;
@@ -147,12 +150,33 @@ declare class KnowledgeBase {
147
150
  load(): Promise<void>;
148
151
  private loadUrls;
149
152
  private ingest;
150
- private fetchPage;
151
153
  /** Re-fetches URL sources. Keeps the old data for any source that fails. Concurrent calls share one run. */
152
154
  refresh(): Promise<void>;
153
155
  search(query: string): Promise<Hit[]>;
154
156
  }
155
157
 
158
+ interface DoctorReport {
159
+ ok: boolean;
160
+ checks: {
161
+ name: string;
162
+ ok: boolean;
163
+ detail: string;
164
+ }[];
165
+ tools: {
166
+ operationId: string;
167
+ method: string;
168
+ path: string;
169
+ approval: "required" | "auto";
170
+ }[];
171
+ knowledge?: {
172
+ id: string;
173
+ title: string;
174
+ url?: string;
175
+ chunks: number;
176
+ error?: string;
177
+ }[];
178
+ }
179
+
156
180
  interface AuditEvent {
157
181
  at: number;
158
182
  userId: string;
@@ -191,11 +215,13 @@ interface AuthResult {
191
215
  /** Headers forwarded to your API (e.g. Authorization, Cookie). Never shown to the LLM. */
192
216
  headers?: Record<string, string>;
193
217
  }
218
+
194
219
  /** Same shape as LangChain's Embeddings, minimal so any adapter fits. */
195
220
  interface EmbeddingsLike {
196
221
  embedDocuments(texts: string[]): Promise<number[][]>;
197
222
  embedQuery(text: string): Promise<number[]>;
198
223
  }
224
+
199
225
  interface CreateAgentOptions extends AgentConfigInput {
200
226
  /** Your own chat model (e.g. workersAiChatModel from sideagent/workers-ai). Use instead of `llm`, never with it. It must support bindTools(). */
201
227
  model?: BaseChatModel;
@@ -214,27 +240,6 @@ interface CreateAgentOptions extends AgentConfigInput {
214
240
  /** Where knowledge embeddings live. Defaults to in-memory (re-embedded on every start). */
215
241
  vectorStore?: VectorStore;
216
242
  }
217
- interface DoctorReport {
218
- ok: boolean;
219
- checks: {
220
- name: string;
221
- ok: boolean;
222
- detail: string;
223
- }[];
224
- tools: {
225
- operationId: string;
226
- method: string;
227
- path: string;
228
- approval: "required" | "auto";
229
- }[];
230
- knowledge?: {
231
- id: string;
232
- title: string;
233
- url?: string;
234
- chunks: number;
235
- error?: string;
236
- }[];
237
- }
238
243
  declare function createAgent(options: CreateAgentOptions): Promise<{
239
244
  handler: (request: Request) => Promise<Response>;
240
245
  doctor: () => Promise<DoctorReport>;