@agentuity/core 0.0.5 → 0.0.7

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/AGENTS.md CHANGED
@@ -19,7 +19,7 @@ Core utilities and shared types for the Agentuity framework. This package provid
19
19
 
20
20
  ## Structure
21
21
 
22
- ```
22
+ ```text
23
23
  src/
24
24
  ├── index.ts # Main entry point, exports all modules
25
25
  ├── json.ts # JSON utilities
package/README.md CHANGED
@@ -10,7 +10,7 @@ bun add @agentuity/core
10
10
 
11
11
  ## Overview
12
12
 
13
- `@agentuity/core` provides foundational utilities, type helpers, and standard schema interfaces used across the Agentuity ecosystem. This package is a dependency for both `@agentuity/server` and `@agentuity/react`.
13
+ `@agentuity/core` provides foundational utilities, type helpers, and standard schema interfaces used across the Agentuity ecosystem. This package is a dependency for both `@agentuity/runtime` and `@agentuity/react`.
14
14
 
15
15
  ## Features
16
16
 
@@ -32,7 +32,7 @@ Provides a standard interface for schema validation that works with libraries li
32
32
  ### Type Helpers
33
33
 
34
34
  ```typescript
35
- import { /* type utilities */ } from '@agentuity/core';
35
+ import {} from /* type utilities */ '@agentuity/core';
36
36
  ```
37
37
 
38
38
  TypeScript utility types for enhanced type safety.
@@ -40,12 +40,7 @@ TypeScript utility types for enhanced type safety.
40
40
  ### Storage Services
41
41
 
42
42
  ```typescript
43
- import type {
44
- KeyValueStorage,
45
- ObjectStorage,
46
- StreamStorage,
47
- VectorStorage
48
- } from '@agentuity/core';
43
+ import type { KeyValueStorage, ObjectStorage, StreamStorage, VectorStorage } from '@agentuity/core';
49
44
  ```
50
45
 
51
46
  Interfaces for various storage backends used in Agentuity applications.
@@ -53,14 +48,14 @@ Interfaces for various storage backends used in Agentuity applications.
53
48
  ### JSON Utilities
54
49
 
55
50
  ```typescript
56
- import { /* JSON utilities */ } from '@agentuity/core';
51
+ import {} from /* JSON utilities */ '@agentuity/core';
57
52
  ```
58
53
 
59
54
  Helpers for working with JSON data.
60
55
 
61
56
  ## Usage
62
57
 
63
- This package is typically used as a peer dependency and not directly imported in user code. The `@agentuity/server` and `@agentuity/react` packages expose the necessary types and utilities.
58
+ This package is typically used as a peer dependency and not directly imported in user code. The `@agentuity/runtime` and `@agentuity/react` packages expose the necessary types and utilities.
64
59
 
65
60
  ## License
66
61
 
package/dist/index.js CHANGED
@@ -127,7 +127,7 @@ async function toPayload(data) {
127
127
  }
128
128
  async function fromResponse(response) {
129
129
  const contentType = response.headers.get("content-type");
130
- if (contentType?.includes("/json")) {
130
+ if (!contentType || contentType?.includes("/json")) {
131
131
  return await response.json();
132
132
  }
133
133
  if (contentType?.includes("text/")) {
@@ -430,101 +430,6 @@ class ObjectStorageService {
430
430
  }
431
431
  }
432
432
  }
433
- // src/services/server.ts
434
- class ServerFetchAdapter {
435
- #config;
436
- constructor(config) {
437
- this.#config = config;
438
- }
439
- async _invoke(url, options) {
440
- const headers = {
441
- ...options.headers,
442
- ...this.#config.headers
443
- };
444
- if (options.contentType) {
445
- headers["Content-Type"] = options.contentType;
446
- } else if (typeof options.body === "string" || options.body instanceof Uint8Array || options.body instanceof ArrayBuffer) {
447
- headers["Content-Type"] = "application/octet-stream";
448
- }
449
- const res = await fetch(url, {
450
- method: options.method ?? "POST",
451
- body: options.body,
452
- headers,
453
- signal: options.signal,
454
- ...options.duplex ? { duplex: options.duplex } : {}
455
- });
456
- if (res.ok) {
457
- switch (res.status) {
458
- case 100:
459
- case 101:
460
- case 102:
461
- case 204:
462
- case 304:
463
- return {
464
- ok: true,
465
- data: undefined,
466
- response: res
467
- };
468
- default:
469
- break;
470
- }
471
- if (options?.binary) {
472
- return {
473
- ok: true,
474
- data: undefined,
475
- response: res
476
- };
477
- }
478
- const data = await fromResponse(res);
479
- return {
480
- ok: true,
481
- data,
482
- response: res
483
- };
484
- }
485
- if (res.status === 404) {
486
- return {
487
- ok: false,
488
- response: res
489
- };
490
- }
491
- const err = await toServiceException(res);
492
- throw err;
493
- }
494
- async invoke(url, options = { method: "POST" }) {
495
- if (this.#config.onBefore) {
496
- let result = undefined;
497
- let err = undefined;
498
- await this.#config.onBefore(url, options, async () => {
499
- try {
500
- result = await this._invoke(url, options);
501
- if (this.#config.onAfter) {
502
- await this.#config.onAfter(url, options, result);
503
- }
504
- } catch (ex) {
505
- err = ex;
506
- if (this.#config.onAfter) {
507
- await this.#config.onAfter(url, options, {
508
- ok: false,
509
- response: new Response(err.message ?? String(err), {
510
- status: err.statusCode ?? 500
511
- })
512
- }, err);
513
- }
514
- }
515
- });
516
- if (err) {
517
- throw err;
518
- }
519
- return result;
520
- } else {
521
- return await this._invoke(url, options);
522
- }
523
- }
524
- }
525
- function createServerFetchAdapter(config) {
526
- return new ServerFetchAdapter(config);
527
- }
528
433
  // src/services/stream.ts
529
434
  var encoder = new TextEncoder;
530
435
 
@@ -1096,8 +1001,11 @@ class VectorStorageService {
1096
1001
  }
1097
1002
  }
1098
1003
  export {
1004
+ toServiceException,
1005
+ toPayload,
1099
1006
  safeStringify,
1100
- createServerFetchAdapter,
1007
+ fromResponse,
1008
+ buildUrl,
1101
1009
  VectorStorageService,
1102
1010
  StreamStorageService,
1103
1011
  ServiceException,
@@ -1,4 +1,4 @@
1
- import { Body } from './adapter';
1
+ import type { Body } from './adapter';
2
2
  import { ServiceException } from './exception';
3
3
  export declare const buildUrl: (base: string, path: string, subpath?: string, query?: URLSearchParams) => string;
4
4
  export declare function toServiceException(response: Response): Promise<ServiceException>;
@@ -1 +1 @@
1
- {"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,KACrB,MAWF,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgCtF;AAMD,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CA0CtE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAYpE"}
1
+ {"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,KACrB,MAWF,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgCtF;AAMD,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CA0CtE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAYpE"}
@@ -2,7 +2,7 @@ export * from './adapter';
2
2
  export * from './exception';
3
3
  export * from './keyvalue';
4
4
  export * from './objectstore';
5
- export * from './server';
6
5
  export * from './stream';
7
6
  export * from './vector';
7
+ export { buildUrl, toServiceException, toPayload, fromResponse } from './_util';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/core",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,22 +0,0 @@
1
- import type { FetchRequest, FetchResponse, FetchAdapter } from './adapter';
2
- import { ServiceException } from './exception';
3
- interface ServiceAdapterConfig {
4
- headers: Record<string, string>;
5
- onBefore?: (url: string, options: FetchRequest, invoke: () => Promise<void>) => Promise<void>;
6
- onAfter?: <T>(url: string, options: FetchRequest, response: FetchResponse<T>, err?: ServiceException) => Promise<void>;
7
- }
8
- declare class ServerFetchAdapter implements FetchAdapter {
9
- #private;
10
- constructor(config: ServiceAdapterConfig);
11
- private _invoke;
12
- invoke<T>(url: string, options?: FetchRequest): Promise<FetchResponse<T>>;
13
- }
14
- /**
15
- * Create a Server Side Fetch Adapter to allow the server to add headers and track outgoing requests
16
- *
17
- * @param config the service config
18
- * @returns
19
- */
20
- export declare function createServerFetchAdapter(config: ServiceAdapterConfig): ServerFetchAdapter;
21
- export {};
22
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/services/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,UAAU,oBAAoB;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,OAAO,CAAC,EAAE,CAAC,CAAC,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,CAAC,EAAE,gBAAgB,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,cAAM,kBAAmB,YAAW,YAAY;;gBAGnC,MAAM,EAAE,oBAAoB;YAG1B,OAAO;IA4Df,MAAM,CAAC,CAAC,EACb,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,YAAiC,GACxC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAmC5B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,sBAEpE"}