@isdk/ai-tool 0.0.6 → 0.0.8

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 (85) hide show
  1. package/dist/chunk-B7IE5ATQ.mjs +1 -0
  2. package/dist/chunk-U5DDQYSF.mjs +1 -22
  3. package/dist/funcs.d.mts +2 -2
  4. package/dist/funcs.d.ts +2 -2
  5. package/dist/funcs.js +1 -5020
  6. package/dist/funcs.mjs +1 -37
  7. package/dist/{index-D4KjfAKl.d.mts → index-Dgo3ZXPQ.d.mts} +29 -14
  8. package/dist/{index-D4KjfAKl.d.ts → index-Dgo3ZXPQ.d.ts} +29 -14
  9. package/dist/index.d.mts +372 -56
  10. package/dist/index.d.ts +372 -56
  11. package/dist/index.js +1 -5245
  12. package/dist/index.mjs +1 -402
  13. package/dist/test/util.js +1 -97
  14. package/dist/test/util.mjs +1 -60
  15. package/docs/classes/AbortError.md +8 -8
  16. package/docs/classes/AlreadyExistsError.md +8 -8
  17. package/docs/classes/BaseError.md +8 -8
  18. package/docs/classes/CancelableAbility.md +431 -0
  19. package/docs/classes/ClientTools.md +101 -51
  20. package/docs/classes/CommonError.md +8 -8
  21. package/docs/classes/EventClient.md +123 -73
  22. package/docs/classes/EventServer.md +121 -71
  23. package/docs/classes/EventToolFunc.md +91 -41
  24. package/docs/classes/FStringPromptTemplate.md +18 -18
  25. package/docs/classes/FewShotPromptTemplate.md +22 -22
  26. package/docs/classes/GolangPromptTemplate.md +18 -18
  27. package/docs/classes/HFEnvironment.md +9 -9
  28. package/docs/classes/HFInterpreter.md +17 -17
  29. package/docs/classes/HFTemplate.md +4 -4
  30. package/docs/classes/HfPromptTemplate.md +18 -18
  31. package/docs/classes/IntSet.md +249 -0
  32. package/docs/classes/NotFoundError.md +8 -8
  33. package/docs/classes/NotImplementationError.md +8 -8
  34. package/docs/classes/PromptExampleSelector.md +8 -8
  35. package/docs/classes/PromptTemplate.md +17 -17
  36. package/docs/classes/ReadableStreamError.md +8 -8
  37. package/docs/classes/ResClientTools.md +107 -57
  38. package/docs/classes/ResServerTools.md +105 -55
  39. package/docs/classes/SSEChannel.md +15 -15
  40. package/docs/classes/Semaphore.md +273 -0
  41. package/docs/classes/ServerTools.md +98 -48
  42. package/docs/classes/TaskAbortController.md +157 -0
  43. package/docs/classes/ToolFunc.md +80 -38
  44. package/docs/enums/AsyncFeatureBits.md +41 -0
  45. package/docs/enums/AsyncFeatures.md +41 -0
  46. package/docs/enums/ErrorCode.md +41 -19
  47. package/docs/enums/XXHashAlgorithm.md +2 -2
  48. package/docs/interfaces/AIChatAssistantMessageParam.md +6 -6
  49. package/docs/interfaces/AIChatContentPartImage.md +2 -2
  50. package/docs/interfaces/AIChatContentPartText.md +2 -2
  51. package/docs/interfaces/AIChatMessageParamBase.md +1 -1
  52. package/docs/interfaces/AIChatMessageToolCall.md +3 -3
  53. package/docs/interfaces/AIChatSystemMessageParam.md +3 -3
  54. package/docs/interfaces/AIChatToolMessageParam.md +4 -4
  55. package/docs/interfaces/AIChatUserMessageParam.md +7 -7
  56. package/docs/interfaces/AIResult.md +16 -5
  57. package/docs/interfaces/AIStreamParser.md +1 -1
  58. package/docs/interfaces/AIStreamParserOptions.md +1 -1
  59. package/docs/interfaces/BaseFunc.md +7 -7
  60. package/docs/interfaces/BaseFuncItem.md +6 -6
  61. package/docs/interfaces/CancelableAbilityOptions.md +126 -0
  62. package/docs/interfaces/ClientFuncItem.md +10 -10
  63. package/docs/interfaces/DotenvExpandOptions.md +3 -3
  64. package/docs/interfaces/DotenvExpandOutput.md +2 -2
  65. package/docs/interfaces/EventClientFuncParams.md +4 -4
  66. package/docs/interfaces/EventServerFuncParams.md +5 -5
  67. package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
  68. package/docs/interfaces/FuncItem.md +7 -7
  69. package/docs/interfaces/FuncParam.md +16 -5
  70. package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
  71. package/docs/interfaces/PromptTemplateOptions.md +6 -6
  72. package/docs/interfaces/RemoteFuncItem.md +10 -10
  73. package/docs/interfaces/ResClientFuncParams.md +2 -2
  74. package/docs/interfaces/ResServerFuncParams.md +5 -5
  75. package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
  76. package/docs/interfaces/ServerFuncItem.md +11 -11
  77. package/docs/interfaces/ServerFuncParams.md +2 -2
  78. package/docs/interfaces/StreamCallbacksAndOptions.md +124 -0
  79. package/docs/interfaces/TaskAbortControllers.md +7 -0
  80. package/docs/interfaces/TaskPromise.md +151 -0
  81. package/docs/interfaces/ToolFuncPackage.md +63 -0
  82. package/docs/modules.md +1156 -225
  83. package/package.json +5 -6
  84. package/dist/chunk-6AXCY6TJ.mjs +0 -5090
  85. package/docs/interfaces/AIStreamCallbacksAndOptions.md +0 -158
package/dist/funcs.mjs CHANGED
@@ -1,37 +1 @@
1
- import {
2
- EventClient,
3
- EventServer,
4
- EventToolFunc,
5
- _lrucache,
6
- createLRUCache,
7
- event,
8
- eventClient,
9
- eventServer,
10
- getDefaultSimilarPassingScore,
11
- isSimilar,
12
- lrucache,
13
- mergeSegments,
14
- registerCoreTools,
15
- segments,
16
- similarity,
17
- splitSegments
18
- } from "./chunk-6AXCY6TJ.mjs";
19
- import "./chunk-U5DDQYSF.mjs";
20
- export {
21
- EventClient,
22
- EventServer,
23
- EventToolFunc,
24
- _lrucache,
25
- createLRUCache,
26
- event,
27
- eventClient,
28
- eventServer,
29
- getDefaultSimilarPassingScore,
30
- isSimilar,
31
- lrucache,
32
- mergeSegments,
33
- registerCoreTools,
34
- segments,
35
- similarity,
36
- splitSegments
37
- };
1
+ import{EventClient as m,EventServer as o,EventToolFunc as r,_lrucache as p,createLRUCache as t,event as c,eventClient as h,eventServer as i,lrucache as j,registerCoreTools as k}from"./chunk-B7IE5ATQ.mjs";import"./chunk-U5DDQYSF.mjs";export{m as EventClient,o as EventServer,r as EventToolFunc,p as _lrucache,t as createLRUCache,c as event,h as eventClient,i as eventServer,j as lrucache,k as registerCoreTools};
@@ -1,15 +1,29 @@
1
1
  import { EventEmitter, Event } from 'events-ex';
2
2
  import { AdvancePropertyManager } from 'property-manager';
3
3
  import { ICacheOptions, Cache } from 'secondary-cache';
4
- import { IncomingMessage, ServerResponse } from 'http';
5
4
  import { AbstractError } from 'abstract-error';
5
+ import { IncomingMessage, ServerResponse } from 'http';
6
6
 
7
+ declare const ToolAsyncMultiTaskBit = 0;
8
+ declare const ToolAsyncCancelableBit = 1;
9
+ declare const ToolAsyncPriorityBit = 2;
10
+ declare enum AsyncFeatureBits {
11
+ MultiTask = 0,
12
+ Cancelable = 1,
13
+ Priority = 2
14
+ }
15
+ declare enum AsyncFeatures {
16
+ MultiTask = 1,// B0001
17
+ Cancelable = 2,// B010
18
+ Priority = 4
19
+ }
7
20
  type FuncParamType = string;
8
21
  interface FuncParam {
9
22
  name?: string;
10
23
  type?: FuncParamType;
11
24
  required?: boolean;
12
25
  description?: string;
26
+ asyncFeatures?: number;
13
27
  depends?: {
14
28
  [name: string]: ToolFunc;
15
29
  };
@@ -35,6 +49,11 @@ interface BaseFunc extends BaseFuncItem {
35
49
  interface Funcs {
36
50
  [name: string]: ToolFunc;
37
51
  }
52
+ interface ToolFuncPackage {
53
+ name: string;
54
+ register: (data?: any) => void;
55
+ unregister?: () => void;
56
+ }
38
57
  declare interface ToolFunc extends BaseFunc {
39
58
  [name: string]: any;
40
59
  }
@@ -45,6 +64,7 @@ declare class ToolFunc extends AdvancePropertyManager {
45
64
  static list(): Funcs;
46
65
  static getByTag(tagName: string): ToolFunc | undefined;
47
66
  static getAllByTag(tagName: string): ToolFunc[];
67
+ static hasAsyncFeature(feature: AsyncFeatureBits): boolean;
48
68
  static run(name: string, params?: any): Promise<any>;
49
69
  static runSync(name: string, params?: any): any;
50
70
  static getFunc(name: string): any;
@@ -70,6 +90,7 @@ declare class ToolFunc extends AdvancePropertyManager {
70
90
  runWithPos(...params: any[]): Promise<any>;
71
91
  runWithPosAs(name: string, ...params: any[]): Promise<any>;
72
92
  getFuncWithPos(name?: string): any;
93
+ hasAsyncFeature(feature: AsyncFeatureBits): boolean;
73
94
  }
74
95
  declare const ToolFuncSchema: {
75
96
  name: {
@@ -98,6 +119,9 @@ declare const ToolFuncSchema: {
98
119
  tags: {
99
120
  type: string[];
100
121
  };
122
+ asyncFeatures: {
123
+ type: string;
124
+ };
101
125
  };
102
126
 
103
127
  declare const PASSING_SCORE = 0.618;
@@ -136,6 +160,7 @@ interface RemoteFuncItem extends BaseFuncItem {
136
160
  type ErrorCodeType = number | string;
137
161
  declare enum ErrorCode {
138
162
  OK = 200,
163
+ Accepted = 202,
139
164
  BadRequest = 400,
140
165
  InvalidArgument = 400,
141
166
  Unauthorized = 401,
@@ -147,12 +172,13 @@ declare enum ErrorCode {
147
172
  RequestTimeout = 408,
148
173
  Conflict = 409,
149
174
  Corruption = 409,
175
+ TooManyRequests = 429,
150
176
  Aborted = 499,
151
177
  InternalError = 500,
152
178
  NotImplemented = 501,
153
179
  NotSupported = 501,
154
180
  BadGateway = 502,
155
- ServiceUnavailable = 503,
181
+ ServiceUnavailable = 503,// task is processing and Retry-After
156
182
  GatewayTimeout = 504
157
183
  }
158
184
  declare const InternalErrorCode = ErrorCode.InternalError;
@@ -446,17 +472,6 @@ declare function _lrucache(this: ToolFunc, { key, value, options }?: {
446
472
  declare function createLRUCache(name: string, options?: ICacheOptions | number): ToolFunc;
447
473
  declare const lrucache: ToolFunc;
448
474
 
449
- declare const similarity: ServerTools;
450
-
451
- declare function getDefaultSimilarPassingScore(modelId: string): number;
452
- declare const isSimilar: ServerTools;
453
-
454
- declare const splitSegments: ServerTools;
455
-
456
- declare const mergeSegments: ServerTools;
457
-
458
- declare const segments: ServerTools;
459
-
460
475
  interface ResClientFuncParams {
461
476
  id?: string | number;
462
477
  act?: string;
@@ -603,4 +618,4 @@ declare const eventServer: EventServer;
603
618
 
604
619
  declare function registerCoreTools(): void;
605
620
 
606
- export { segments as $, type AIModelNameRules as A, BaseError as B, CommonError as C, ClientToolFuncSchema as D, type ErrorCodeType as E, type FuncParamType as F, type ServerFuncParams as G, type ServerFuncItem as H, InternalErrorCode as I, ServerTools as J, ServerToolFuncSchema as K, registerCoreTools as L, EventToolFunc as M, NotImplementedErrorCode as N, event as O, PASSING_SCORE as P, createLRUCache as Q, RemoteToolFuncSchema as R, SSEChannelAlreadyClosedErrCode as S, type TFunc as T, lrucache as U, similarity as V, getDefaultSimilarPassingScore as W, isSimilar as X, splitSegments as Y, mergeSegments as Z, _lrucache as _, ActionNames as a, type EventClientFuncParams as a0, EventClient as a1, eventClient as a2, type EventServerFuncParams as a3, EventServer as a4, eventServer as a5, type ResClientFuncParams as a6, ResClientTools as a7, ResClientToolsSchema as a8, type ResServerFuncParams as a9, ResServerTools as aa, ResServerToolsSchema as ab, type ActionName as b, type AIModelNameRuleFn as c, type AIModelNameRule as d, type RemoteFuncItem as e, ErrorCode as f, NotFoundErrorCode as g, AlreadyExistsErrorCode as h, AbortErrorCode as i, NotImplementationError as j, NotFoundError as k, AlreadyExistsError as l, AbortError as m, createError as n, SSEChannel as o, type FuncParam as p, type FuncParams as q, type BaseFuncItem as r, type FuncItem as s, throwError as t, type BaseFunc as u, type Funcs as v, ToolFunc as w, ToolFuncSchema as x, type ClientFuncItem as y, ClientTools as z };
621
+ export { lrucache as $, AsyncFeatures as A, BaseError as B, CommonError as C, type BaseFunc as D, type ErrorCodeType as E, type FuncParamType as F, type Funcs as G, type ToolFuncPackage as H, InternalErrorCode as I, ToolFuncSchema as J, type ClientFuncItem as K, ClientTools as L, ClientToolFuncSchema as M, NotImplementedErrorCode as N, type ServerFuncParams as O, PASSING_SCORE as P, type ServerFuncItem as Q, RemoteToolFuncSchema as R, SSEChannelAlreadyClosedErrCode as S, ToolFunc as T, ServerTools as U, ServerToolFuncSchema as V, registerCoreTools as W, EventToolFunc as X, event as Y, createLRUCache as Z, _lrucache as _, type AIModelNameRules as a, type EventClientFuncParams as a0, EventClient as a1, eventClient as a2, type EventServerFuncParams as a3, EventServer as a4, eventServer as a5, type ResClientFuncParams as a6, ResClientTools as a7, ResClientToolsSchema as a8, type ResServerFuncParams as a9, ResServerTools as aa, ResServerToolsSchema as ab, ActionNames as b, type ActionName as c, type AIModelNameRuleFn as d, type AIModelNameRule as e, type RemoteFuncItem as f, ErrorCode as g, NotFoundErrorCode as h, AlreadyExistsErrorCode as i, AbortErrorCode as j, NotImplementationError as k, NotFoundError as l, AlreadyExistsError as m, AbortError as n, createError as o, SSEChannel as p, ToolAsyncMultiTaskBit as q, ToolAsyncCancelableBit as r, ToolAsyncPriorityBit as s, throwError as t, AsyncFeatureBits as u, type FuncParam as v, type FuncParams as w, type TFunc as x, type BaseFuncItem as y, type FuncItem as z };
@@ -1,15 +1,29 @@
1
1
  import { EventEmitter, Event } from 'events-ex';
2
2
  import { AdvancePropertyManager } from 'property-manager';
3
3
  import { ICacheOptions, Cache } from 'secondary-cache';
4
- import { IncomingMessage, ServerResponse } from 'http';
5
4
  import { AbstractError } from 'abstract-error';
5
+ import { IncomingMessage, ServerResponse } from 'http';
6
6
 
7
+ declare const ToolAsyncMultiTaskBit = 0;
8
+ declare const ToolAsyncCancelableBit = 1;
9
+ declare const ToolAsyncPriorityBit = 2;
10
+ declare enum AsyncFeatureBits {
11
+ MultiTask = 0,
12
+ Cancelable = 1,
13
+ Priority = 2
14
+ }
15
+ declare enum AsyncFeatures {
16
+ MultiTask = 1,// B0001
17
+ Cancelable = 2,// B010
18
+ Priority = 4
19
+ }
7
20
  type FuncParamType = string;
8
21
  interface FuncParam {
9
22
  name?: string;
10
23
  type?: FuncParamType;
11
24
  required?: boolean;
12
25
  description?: string;
26
+ asyncFeatures?: number;
13
27
  depends?: {
14
28
  [name: string]: ToolFunc;
15
29
  };
@@ -35,6 +49,11 @@ interface BaseFunc extends BaseFuncItem {
35
49
  interface Funcs {
36
50
  [name: string]: ToolFunc;
37
51
  }
52
+ interface ToolFuncPackage {
53
+ name: string;
54
+ register: (data?: any) => void;
55
+ unregister?: () => void;
56
+ }
38
57
  declare interface ToolFunc extends BaseFunc {
39
58
  [name: string]: any;
40
59
  }
@@ -45,6 +64,7 @@ declare class ToolFunc extends AdvancePropertyManager {
45
64
  static list(): Funcs;
46
65
  static getByTag(tagName: string): ToolFunc | undefined;
47
66
  static getAllByTag(tagName: string): ToolFunc[];
67
+ static hasAsyncFeature(feature: AsyncFeatureBits): boolean;
48
68
  static run(name: string, params?: any): Promise<any>;
49
69
  static runSync(name: string, params?: any): any;
50
70
  static getFunc(name: string): any;
@@ -70,6 +90,7 @@ declare class ToolFunc extends AdvancePropertyManager {
70
90
  runWithPos(...params: any[]): Promise<any>;
71
91
  runWithPosAs(name: string, ...params: any[]): Promise<any>;
72
92
  getFuncWithPos(name?: string): any;
93
+ hasAsyncFeature(feature: AsyncFeatureBits): boolean;
73
94
  }
74
95
  declare const ToolFuncSchema: {
75
96
  name: {
@@ -98,6 +119,9 @@ declare const ToolFuncSchema: {
98
119
  tags: {
99
120
  type: string[];
100
121
  };
122
+ asyncFeatures: {
123
+ type: string;
124
+ };
101
125
  };
102
126
 
103
127
  declare const PASSING_SCORE = 0.618;
@@ -136,6 +160,7 @@ interface RemoteFuncItem extends BaseFuncItem {
136
160
  type ErrorCodeType = number | string;
137
161
  declare enum ErrorCode {
138
162
  OK = 200,
163
+ Accepted = 202,
139
164
  BadRequest = 400,
140
165
  InvalidArgument = 400,
141
166
  Unauthorized = 401,
@@ -147,12 +172,13 @@ declare enum ErrorCode {
147
172
  RequestTimeout = 408,
148
173
  Conflict = 409,
149
174
  Corruption = 409,
175
+ TooManyRequests = 429,
150
176
  Aborted = 499,
151
177
  InternalError = 500,
152
178
  NotImplemented = 501,
153
179
  NotSupported = 501,
154
180
  BadGateway = 502,
155
- ServiceUnavailable = 503,
181
+ ServiceUnavailable = 503,// task is processing and Retry-After
156
182
  GatewayTimeout = 504
157
183
  }
158
184
  declare const InternalErrorCode = ErrorCode.InternalError;
@@ -446,17 +472,6 @@ declare function _lrucache(this: ToolFunc, { key, value, options }?: {
446
472
  declare function createLRUCache(name: string, options?: ICacheOptions | number): ToolFunc;
447
473
  declare const lrucache: ToolFunc;
448
474
 
449
- declare const similarity: ServerTools;
450
-
451
- declare function getDefaultSimilarPassingScore(modelId: string): number;
452
- declare const isSimilar: ServerTools;
453
-
454
- declare const splitSegments: ServerTools;
455
-
456
- declare const mergeSegments: ServerTools;
457
-
458
- declare const segments: ServerTools;
459
-
460
475
  interface ResClientFuncParams {
461
476
  id?: string | number;
462
477
  act?: string;
@@ -603,4 +618,4 @@ declare const eventServer: EventServer;
603
618
 
604
619
  declare function registerCoreTools(): void;
605
620
 
606
- export { segments as $, type AIModelNameRules as A, BaseError as B, CommonError as C, ClientToolFuncSchema as D, type ErrorCodeType as E, type FuncParamType as F, type ServerFuncParams as G, type ServerFuncItem as H, InternalErrorCode as I, ServerTools as J, ServerToolFuncSchema as K, registerCoreTools as L, EventToolFunc as M, NotImplementedErrorCode as N, event as O, PASSING_SCORE as P, createLRUCache as Q, RemoteToolFuncSchema as R, SSEChannelAlreadyClosedErrCode as S, type TFunc as T, lrucache as U, similarity as V, getDefaultSimilarPassingScore as W, isSimilar as X, splitSegments as Y, mergeSegments as Z, _lrucache as _, ActionNames as a, type EventClientFuncParams as a0, EventClient as a1, eventClient as a2, type EventServerFuncParams as a3, EventServer as a4, eventServer as a5, type ResClientFuncParams as a6, ResClientTools as a7, ResClientToolsSchema as a8, type ResServerFuncParams as a9, ResServerTools as aa, ResServerToolsSchema as ab, type ActionName as b, type AIModelNameRuleFn as c, type AIModelNameRule as d, type RemoteFuncItem as e, ErrorCode as f, NotFoundErrorCode as g, AlreadyExistsErrorCode as h, AbortErrorCode as i, NotImplementationError as j, NotFoundError as k, AlreadyExistsError as l, AbortError as m, createError as n, SSEChannel as o, type FuncParam as p, type FuncParams as q, type BaseFuncItem as r, type FuncItem as s, throwError as t, type BaseFunc as u, type Funcs as v, ToolFunc as w, ToolFuncSchema as x, type ClientFuncItem as y, ClientTools as z };
621
+ export { lrucache as $, AsyncFeatures as A, BaseError as B, CommonError as C, type BaseFunc as D, type ErrorCodeType as E, type FuncParamType as F, type Funcs as G, type ToolFuncPackage as H, InternalErrorCode as I, ToolFuncSchema as J, type ClientFuncItem as K, ClientTools as L, ClientToolFuncSchema as M, NotImplementedErrorCode as N, type ServerFuncParams as O, PASSING_SCORE as P, type ServerFuncItem as Q, RemoteToolFuncSchema as R, SSEChannelAlreadyClosedErrCode as S, ToolFunc as T, ServerTools as U, ServerToolFuncSchema as V, registerCoreTools as W, EventToolFunc as X, event as Y, createLRUCache as Z, _lrucache as _, type AIModelNameRules as a, type EventClientFuncParams as a0, EventClient as a1, eventClient as a2, type EventServerFuncParams as a3, EventServer as a4, eventServer as a5, type ResClientFuncParams as a6, ResClientTools as a7, ResClientToolsSchema as a8, type ResServerFuncParams as a9, ResServerTools as aa, ResServerToolsSchema as ab, ActionNames as b, type ActionName as c, type AIModelNameRuleFn as d, type AIModelNameRule as e, type RemoteFuncItem as f, ErrorCode as g, NotFoundErrorCode as h, AlreadyExistsErrorCode as i, AbortErrorCode as j, NotImplementationError as k, NotFoundError as l, AlreadyExistsError as m, AbortError as n, createError as o, SSEChannel as p, ToolAsyncMultiTaskBit as q, ToolAsyncCancelableBit as r, ToolAsyncPriorityBit as s, throwError as t, AsyncFeatureBits as u, type FuncParam as v, type FuncParams as w, type TFunc as x, type BaseFuncItem as y, type FuncItem as z };