@agentuity/stream 3.0.10 → 3.1.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/src/index.ts CHANGED
@@ -1,21 +1,4 @@
1
- export {
2
- StreamStorageService,
3
- StreamStorage,
4
- Stream,
5
- type CreateStreamProps,
6
- type ListStreamsParams,
7
- type ListStreamsResponse,
8
- type StreamInfo,
9
- type StreamSortField,
10
- STREAM_MIN_TTL_SECONDS,
11
- STREAM_MAX_TTL_SECONDS,
12
- STREAM_DEFAULT_TTL_SECONDS,
13
- CreateStreamPropsSchema,
14
- ListStreamsParamsSchema,
15
- ListStreamsResponseSchema,
16
- StreamInfoSchema,
17
- StreamSortFieldSchema,
18
- } from '@agentuity/core/stream';
1
+ export * from './service.ts';
19
2
 
20
3
  import {
21
4
  StreamStorageService,
@@ -24,20 +7,18 @@ import {
24
7
  type ListStreamsResponse,
25
8
  type StreamInfo,
26
9
  type Stream,
27
- } from '@agentuity/core/stream';
28
- import { createServerFetchAdapter, buildClientHeaders, type Logger } from '@agentuity/adapter';
29
- import { createMinimalLogger } from '@agentuity/core';
30
- import { getEnv } from '@agentuity/core';
31
- import { getServiceUrls } from '@agentuity/core/config';
10
+ } from './service.ts';
11
+ import { getServiceUrls } from '@agentuity/config';
12
+ import {
13
+ createServiceAdapter,
14
+ isLogger,
15
+ resolveApiKey,
16
+ resolveRegion,
17
+ resolveServiceUrl,
18
+ type Logger,
19
+ } from '@agentuity/client';
32
20
  import { z } from 'zod';
33
21
 
34
- const isLogger = (val: unknown): val is Logger =>
35
- typeof val === 'object' &&
36
- val !== null &&
37
- ['info', 'warn', 'error', 'debug', 'trace'].every(
38
- (m) => typeof (val as Record<string, unknown>)[m] === 'function'
39
- );
40
-
41
22
  export const StreamClientOptionsSchema = z.object({
42
23
  apiKey: z.string().optional().describe('API key for authentication'),
43
24
  url: z.string().optional().describe('Base URL for the Stream API'),
@@ -51,21 +32,17 @@ export class StreamClient {
51
32
 
52
33
  constructor(options: StreamClientOptions = {}) {
53
34
  const validatedOptions = StreamClientOptionsSchema.parse(options);
54
- const apiKey =
55
- validatedOptions.apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
56
- const region = getEnv('AGENTUITY_REGION') ?? 'usc';
57
- const serviceUrls = getServiceUrls(region);
58
-
59
- const url = validatedOptions.url || getEnv('AGENTUITY_STREAM_URL') || serviceUrls.stream;
60
-
61
- const logger = validatedOptions.logger ?? createMinimalLogger();
62
-
63
- const headers = buildClientHeaders({
64
- apiKey,
35
+ const serviceUrls = getServiceUrls(resolveRegion());
36
+ const url = resolveServiceUrl({
37
+ url: validatedOptions.url,
38
+ envKey: 'AGENTUITY_STREAM_URL',
39
+ fallback: serviceUrls.stream,
40
+ });
41
+ const { adapter } = createServiceAdapter({
42
+ apiKey: resolveApiKey(validatedOptions.apiKey),
65
43
  orgId: validatedOptions.orgId,
44
+ logger: validatedOptions.logger,
66
45
  });
67
-
68
- const adapter = createServerFetchAdapter({ headers }, logger);
69
46
  this.#service = new StreamStorageService(url, adapter);
70
47
  }
71
48