@agentica/core 0.10.0 → 0.10.1-dev.20250302
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/LICENSE +21 -21
- package/README.md +419 -419
- package/package.json +1 -1
- package/prompts/cancel.md +4 -4
- package/prompts/common.md +2 -2
- package/prompts/describe.md +6 -6
- package/prompts/execute.md +6 -6
- package/prompts/initialize.md +2 -2
- package/prompts/select.md +6 -6
- package/src/Agentica.ts +323 -323
- package/src/chatgpt/ChatGptAgent.ts +75 -75
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +464 -464
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +287 -287
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +52 -52
- package/src/chatgpt/ChatGptHistoryDecoder.ts +88 -88
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +88 -88
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +319 -319
- package/src/functional/createHttpLlmApplication.ts +63 -63
- package/src/index.ts +19 -19
- package/src/internal/AgenticaConstant.ts +4 -4
- package/src/internal/AgenticaDefaultPrompt.ts +43 -43
- package/src/internal/AgenticaOperationComposer.ts +87 -87
- package/src/internal/AgenticaPromptFactory.ts +32 -32
- package/src/internal/AgenticaPromptTransformer.ts +86 -86
- package/src/internal/AgenticaTokenUsageAggregator.ts +115 -115
- package/src/internal/MathUtil.ts +3 -3
- package/src/internal/Singleton.ts +22 -22
- package/src/internal/__map_take.ts +15 -15
- package/src/structures/IAgenticaConfig.ts +123 -123
- package/src/structures/IAgenticaContext.ts +129 -129
- package/src/structures/IAgenticaController.ts +133 -133
- package/src/structures/IAgenticaEvent.ts +229 -229
- package/src/structures/IAgenticaExecutor.ts +156 -156
- package/src/structures/IAgenticaOperation.ts +63 -63
- package/src/structures/IAgenticaOperationCollection.ts +52 -52
- package/src/structures/IAgenticaOperationSelection.ts +68 -68
- package/src/structures/IAgenticaPrompt.ts +182 -182
- package/src/structures/IAgenticaProps.ts +70 -70
- package/src/structures/IAgenticaSystemPrompt.ts +124 -124
- package/src/structures/IAgenticaTokenUsage.ts +107 -107
- package/src/structures/IAgenticaVendor.ts +39 -39
- package/src/structures/internal/__IChatCancelFunctionsApplication.ts +23 -23
- package/src/structures/internal/__IChatFunctionReference.ts +21 -21
- package/src/structures/internal/__IChatInitialApplication.ts +15 -15
- package/src/structures/internal/__IChatSelectFunctionsApplication.ts +24 -24
- package/src/typings/AgenticaSource.ts +6 -6
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import { Primitive } from "typia";
|
|
3
|
-
|
|
4
|
-
import { IAgenticaOperation } from "../structures/IAgenticaOperation";
|
|
5
|
-
import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
|
|
6
|
-
import { AgenticaPromptFactory } from "./AgenticaPromptFactory";
|
|
7
|
-
|
|
8
|
-
export namespace AgenticaPromptTransformer {
|
|
9
|
-
export const transform = <Model extends ILlmSchema.Model>(props: {
|
|
10
|
-
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
11
|
-
input: Primitive<IAgenticaPrompt<Model>>;
|
|
12
|
-
}): IAgenticaPrompt<Model> => {
|
|
13
|
-
// TEXT
|
|
14
|
-
if (props.input.type === "text") return props.input;
|
|
15
|
-
// SELECT & CANCEL
|
|
16
|
-
else if (props.input.type === "select" || props.input.type === "cancel")
|
|
17
|
-
return {
|
|
18
|
-
...props.input,
|
|
19
|
-
operations: props.input.operations.map((func) =>
|
|
20
|
-
AgenticaPromptFactory.selection({
|
|
21
|
-
...findOperation({
|
|
22
|
-
operations: props.operations,
|
|
23
|
-
input: func,
|
|
24
|
-
}),
|
|
25
|
-
reason: func.reason,
|
|
26
|
-
}),
|
|
27
|
-
),
|
|
28
|
-
} satisfies
|
|
29
|
-
| IAgenticaPrompt.ISelect<Model>
|
|
30
|
-
| IAgenticaPrompt.ICancel<Model>;
|
|
31
|
-
// EXECUTE
|
|
32
|
-
else if (props.input.type === "execute")
|
|
33
|
-
return transformExecute({
|
|
34
|
-
operations: props.operations,
|
|
35
|
-
input: props.input,
|
|
36
|
-
}) satisfies IAgenticaPrompt.IExecute<Model>;
|
|
37
|
-
// DESCRIBE
|
|
38
|
-
return {
|
|
39
|
-
type: "describe",
|
|
40
|
-
text: props.input.text,
|
|
41
|
-
executions: props.input.executions.map((next) =>
|
|
42
|
-
transformExecute({
|
|
43
|
-
operations: props.operations,
|
|
44
|
-
input: next,
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
47
|
-
} satisfies IAgenticaPrompt.IDescribe<Model>;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const transformExecute = <Model extends ILlmSchema.Model>(props: {
|
|
51
|
-
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
52
|
-
input: Primitive<IAgenticaPrompt.IExecute<Model>>;
|
|
53
|
-
}): IAgenticaPrompt.IExecute<Model> => {
|
|
54
|
-
const operation = findOperation({
|
|
55
|
-
operations: props.operations,
|
|
56
|
-
input: props.input,
|
|
57
|
-
});
|
|
58
|
-
return AgenticaPromptFactory.execute({
|
|
59
|
-
type: "execute",
|
|
60
|
-
protocol: operation.protocol as "http",
|
|
61
|
-
controller: operation.controller,
|
|
62
|
-
function: operation.function,
|
|
63
|
-
id: props.input.id,
|
|
64
|
-
name: props.input.name,
|
|
65
|
-
arguments: props.input.arguments,
|
|
66
|
-
value: props.input.value,
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const findOperation = <Model extends ILlmSchema.Model>(props: {
|
|
71
|
-
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
72
|
-
input: {
|
|
73
|
-
controller: string;
|
|
74
|
-
function: string;
|
|
75
|
-
};
|
|
76
|
-
}): IAgenticaOperation.IHttp<Model> => {
|
|
77
|
-
const found: IAgenticaOperation<Model> | undefined = props.operations
|
|
78
|
-
.get(props.input.controller)
|
|
79
|
-
?.get(props.input.function);
|
|
80
|
-
if (found === undefined)
|
|
81
|
-
throw new Error(
|
|
82
|
-
`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`,
|
|
83
|
-
);
|
|
84
|
-
return found as IAgenticaOperation.IHttp<Model>;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import { Primitive } from "typia";
|
|
3
|
+
|
|
4
|
+
import { IAgenticaOperation } from "../structures/IAgenticaOperation";
|
|
5
|
+
import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
|
|
6
|
+
import { AgenticaPromptFactory } from "./AgenticaPromptFactory";
|
|
7
|
+
|
|
8
|
+
export namespace AgenticaPromptTransformer {
|
|
9
|
+
export const transform = <Model extends ILlmSchema.Model>(props: {
|
|
10
|
+
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
11
|
+
input: Primitive<IAgenticaPrompt<Model>>;
|
|
12
|
+
}): IAgenticaPrompt<Model> => {
|
|
13
|
+
// TEXT
|
|
14
|
+
if (props.input.type === "text") return props.input;
|
|
15
|
+
// SELECT & CANCEL
|
|
16
|
+
else if (props.input.type === "select" || props.input.type === "cancel")
|
|
17
|
+
return {
|
|
18
|
+
...props.input,
|
|
19
|
+
operations: props.input.operations.map((func) =>
|
|
20
|
+
AgenticaPromptFactory.selection({
|
|
21
|
+
...findOperation({
|
|
22
|
+
operations: props.operations,
|
|
23
|
+
input: func,
|
|
24
|
+
}),
|
|
25
|
+
reason: func.reason,
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
} satisfies
|
|
29
|
+
| IAgenticaPrompt.ISelect<Model>
|
|
30
|
+
| IAgenticaPrompt.ICancel<Model>;
|
|
31
|
+
// EXECUTE
|
|
32
|
+
else if (props.input.type === "execute")
|
|
33
|
+
return transformExecute({
|
|
34
|
+
operations: props.operations,
|
|
35
|
+
input: props.input,
|
|
36
|
+
}) satisfies IAgenticaPrompt.IExecute<Model>;
|
|
37
|
+
// DESCRIBE
|
|
38
|
+
return {
|
|
39
|
+
type: "describe",
|
|
40
|
+
text: props.input.text,
|
|
41
|
+
executions: props.input.executions.map((next) =>
|
|
42
|
+
transformExecute({
|
|
43
|
+
operations: props.operations,
|
|
44
|
+
input: next,
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
} satisfies IAgenticaPrompt.IDescribe<Model>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const transformExecute = <Model extends ILlmSchema.Model>(props: {
|
|
51
|
+
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
52
|
+
input: Primitive<IAgenticaPrompt.IExecute<Model>>;
|
|
53
|
+
}): IAgenticaPrompt.IExecute<Model> => {
|
|
54
|
+
const operation = findOperation({
|
|
55
|
+
operations: props.operations,
|
|
56
|
+
input: props.input,
|
|
57
|
+
});
|
|
58
|
+
return AgenticaPromptFactory.execute({
|
|
59
|
+
type: "execute",
|
|
60
|
+
protocol: operation.protocol as "http",
|
|
61
|
+
controller: operation.controller,
|
|
62
|
+
function: operation.function,
|
|
63
|
+
id: props.input.id,
|
|
64
|
+
name: props.input.name,
|
|
65
|
+
arguments: props.input.arguments,
|
|
66
|
+
value: props.input.value,
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const findOperation = <Model extends ILlmSchema.Model>(props: {
|
|
71
|
+
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
72
|
+
input: {
|
|
73
|
+
controller: string;
|
|
74
|
+
function: string;
|
|
75
|
+
};
|
|
76
|
+
}): IAgenticaOperation.IHttp<Model> => {
|
|
77
|
+
const found: IAgenticaOperation<Model> | undefined = props.operations
|
|
78
|
+
.get(props.input.controller)
|
|
79
|
+
?.get(props.input.function);
|
|
80
|
+
if (found === undefined)
|
|
81
|
+
throw new Error(
|
|
82
|
+
`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`,
|
|
83
|
+
);
|
|
84
|
+
return found as IAgenticaOperation.IHttp<Model>;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
|
|
3
|
-
import { IAgenticaTokenUsage } from "../structures/IAgenticaTokenUsage";
|
|
4
|
-
|
|
5
|
-
export namespace AgenticaTokenUsageAggregator {
|
|
6
|
-
export const aggregate = (props: {
|
|
7
|
-
kind: Exclude<keyof IAgenticaTokenUsage, "aggregate">;
|
|
8
|
-
completion: OpenAI.ChatCompletion;
|
|
9
|
-
usage: IAgenticaTokenUsage;
|
|
10
|
-
}): void => {
|
|
11
|
-
if (!props.completion.usage) return;
|
|
12
|
-
|
|
13
|
-
//----
|
|
14
|
-
// COMPONENT
|
|
15
|
-
//----
|
|
16
|
-
const component: IAgenticaTokenUsage.IComponent = props.usage[props.kind];
|
|
17
|
-
|
|
18
|
-
// TOTAL
|
|
19
|
-
component.total += props.completion.usage.total_tokens;
|
|
20
|
-
|
|
21
|
-
// PROMPT
|
|
22
|
-
component.input.total += props.completion.usage.prompt_tokens;
|
|
23
|
-
props.completion.usage.prompt_tokens_details?.audio_tokens ?? 0;
|
|
24
|
-
component.input.cached +=
|
|
25
|
-
props.completion.usage.prompt_tokens_details?.cached_tokens ?? 0;
|
|
26
|
-
|
|
27
|
-
// COMPLETION
|
|
28
|
-
component.output.total += props.completion.usage.total_tokens;
|
|
29
|
-
component.output.accepted_prediction +=
|
|
30
|
-
props.completion.usage.completion_tokens_details
|
|
31
|
-
?.accepted_prediction_tokens ?? 0;
|
|
32
|
-
component.output.reasoning +=
|
|
33
|
-
props.completion.usage.completion_tokens_details?.reasoning_tokens ?? 0;
|
|
34
|
-
component.output.rejected_prediction +=
|
|
35
|
-
props.completion.usage.completion_tokens_details
|
|
36
|
-
?.rejected_prediction_tokens ?? 0;
|
|
37
|
-
|
|
38
|
-
//----
|
|
39
|
-
// RE-AGGREGATE
|
|
40
|
-
//----
|
|
41
|
-
const sum = (getter: (comp: IAgenticaTokenUsage.IComponent) => number) =>
|
|
42
|
-
Object.entries(props.usage)
|
|
43
|
-
.filter(([key]) => key !== "aggregate")
|
|
44
|
-
.map(([_, comp]) => getter(comp))
|
|
45
|
-
.reduce((a, b) => a + b, 0);
|
|
46
|
-
const aggregate: IAgenticaTokenUsage.IComponent = props.usage.aggregate;
|
|
47
|
-
aggregate.total = sum((comp) => comp.total);
|
|
48
|
-
aggregate.input.total = sum((comp) => comp.input.total);
|
|
49
|
-
aggregate.input.cached = sum((comp) => comp.input.cached);
|
|
50
|
-
aggregate.output.total = sum((comp) => comp.output.total);
|
|
51
|
-
aggregate.output.reasoning = sum((comp) => comp.output.reasoning);
|
|
52
|
-
aggregate.output.accepted_prediction = sum(
|
|
53
|
-
(comp) => comp.output.accepted_prediction,
|
|
54
|
-
);
|
|
55
|
-
aggregate.output.rejected_prediction = sum(
|
|
56
|
-
(comp) => comp.output.rejected_prediction,
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const plus = (
|
|
61
|
-
x: IAgenticaTokenUsage,
|
|
62
|
-
y: IAgenticaTokenUsage,
|
|
63
|
-
): IAgenticaTokenUsage => {
|
|
64
|
-
const component = (
|
|
65
|
-
a: IAgenticaTokenUsage.IComponent,
|
|
66
|
-
b: IAgenticaTokenUsage.IComponent,
|
|
67
|
-
): IAgenticaTokenUsage.IComponent => ({
|
|
68
|
-
total: a.total + b.total,
|
|
69
|
-
input: {
|
|
70
|
-
total: a.input.total + b.input.total,
|
|
71
|
-
cached: a.input.cached + b.input.cached,
|
|
72
|
-
},
|
|
73
|
-
output: {
|
|
74
|
-
total: a.output.total + b.output.total,
|
|
75
|
-
reasoning: a.output.reasoning + b.output.reasoning,
|
|
76
|
-
accepted_prediction:
|
|
77
|
-
a.output.accepted_prediction + b.output.accepted_prediction,
|
|
78
|
-
rejected_prediction:
|
|
79
|
-
a.output.rejected_prediction + b.output.rejected_prediction,
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
aggregate: component(x.aggregate, y.aggregate),
|
|
84
|
-
initialize: component(x.initialize, y.initialize),
|
|
85
|
-
select: component(x.select, y.select),
|
|
86
|
-
cancel: component(x.cancel, y.cancel),
|
|
87
|
-
call: component(x.call, y.call),
|
|
88
|
-
describe: component(x.describe, y.describe),
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const zero = (): IAgenticaTokenUsage => {
|
|
93
|
-
const component = (): IAgenticaTokenUsage.IComponent => ({
|
|
94
|
-
total: 0,
|
|
95
|
-
input: {
|
|
96
|
-
total: 0,
|
|
97
|
-
cached: 0,
|
|
98
|
-
},
|
|
99
|
-
output: {
|
|
100
|
-
total: 0,
|
|
101
|
-
reasoning: 0,
|
|
102
|
-
accepted_prediction: 0,
|
|
103
|
-
rejected_prediction: 0,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
return {
|
|
107
|
-
aggregate: component(),
|
|
108
|
-
initialize: component(),
|
|
109
|
-
select: component(),
|
|
110
|
-
cancel: component(),
|
|
111
|
-
call: component(),
|
|
112
|
-
describe: component(),
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
}
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
|
|
3
|
+
import { IAgenticaTokenUsage } from "../structures/IAgenticaTokenUsage";
|
|
4
|
+
|
|
5
|
+
export namespace AgenticaTokenUsageAggregator {
|
|
6
|
+
export const aggregate = (props: {
|
|
7
|
+
kind: Exclude<keyof IAgenticaTokenUsage, "aggregate">;
|
|
8
|
+
completion: OpenAI.ChatCompletion;
|
|
9
|
+
usage: IAgenticaTokenUsage;
|
|
10
|
+
}): void => {
|
|
11
|
+
if (!props.completion.usage) return;
|
|
12
|
+
|
|
13
|
+
//----
|
|
14
|
+
// COMPONENT
|
|
15
|
+
//----
|
|
16
|
+
const component: IAgenticaTokenUsage.IComponent = props.usage[props.kind];
|
|
17
|
+
|
|
18
|
+
// TOTAL
|
|
19
|
+
component.total += props.completion.usage.total_tokens;
|
|
20
|
+
|
|
21
|
+
// PROMPT
|
|
22
|
+
component.input.total += props.completion.usage.prompt_tokens;
|
|
23
|
+
props.completion.usage.prompt_tokens_details?.audio_tokens ?? 0;
|
|
24
|
+
component.input.cached +=
|
|
25
|
+
props.completion.usage.prompt_tokens_details?.cached_tokens ?? 0;
|
|
26
|
+
|
|
27
|
+
// COMPLETION
|
|
28
|
+
component.output.total += props.completion.usage.total_tokens;
|
|
29
|
+
component.output.accepted_prediction +=
|
|
30
|
+
props.completion.usage.completion_tokens_details
|
|
31
|
+
?.accepted_prediction_tokens ?? 0;
|
|
32
|
+
component.output.reasoning +=
|
|
33
|
+
props.completion.usage.completion_tokens_details?.reasoning_tokens ?? 0;
|
|
34
|
+
component.output.rejected_prediction +=
|
|
35
|
+
props.completion.usage.completion_tokens_details
|
|
36
|
+
?.rejected_prediction_tokens ?? 0;
|
|
37
|
+
|
|
38
|
+
//----
|
|
39
|
+
// RE-AGGREGATE
|
|
40
|
+
//----
|
|
41
|
+
const sum = (getter: (comp: IAgenticaTokenUsage.IComponent) => number) =>
|
|
42
|
+
Object.entries(props.usage)
|
|
43
|
+
.filter(([key]) => key !== "aggregate")
|
|
44
|
+
.map(([_, comp]) => getter(comp))
|
|
45
|
+
.reduce((a, b) => a + b, 0);
|
|
46
|
+
const aggregate: IAgenticaTokenUsage.IComponent = props.usage.aggregate;
|
|
47
|
+
aggregate.total = sum((comp) => comp.total);
|
|
48
|
+
aggregate.input.total = sum((comp) => comp.input.total);
|
|
49
|
+
aggregate.input.cached = sum((comp) => comp.input.cached);
|
|
50
|
+
aggregate.output.total = sum((comp) => comp.output.total);
|
|
51
|
+
aggregate.output.reasoning = sum((comp) => comp.output.reasoning);
|
|
52
|
+
aggregate.output.accepted_prediction = sum(
|
|
53
|
+
(comp) => comp.output.accepted_prediction,
|
|
54
|
+
);
|
|
55
|
+
aggregate.output.rejected_prediction = sum(
|
|
56
|
+
(comp) => comp.output.rejected_prediction,
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const plus = (
|
|
61
|
+
x: IAgenticaTokenUsage,
|
|
62
|
+
y: IAgenticaTokenUsage,
|
|
63
|
+
): IAgenticaTokenUsage => {
|
|
64
|
+
const component = (
|
|
65
|
+
a: IAgenticaTokenUsage.IComponent,
|
|
66
|
+
b: IAgenticaTokenUsage.IComponent,
|
|
67
|
+
): IAgenticaTokenUsage.IComponent => ({
|
|
68
|
+
total: a.total + b.total,
|
|
69
|
+
input: {
|
|
70
|
+
total: a.input.total + b.input.total,
|
|
71
|
+
cached: a.input.cached + b.input.cached,
|
|
72
|
+
},
|
|
73
|
+
output: {
|
|
74
|
+
total: a.output.total + b.output.total,
|
|
75
|
+
reasoning: a.output.reasoning + b.output.reasoning,
|
|
76
|
+
accepted_prediction:
|
|
77
|
+
a.output.accepted_prediction + b.output.accepted_prediction,
|
|
78
|
+
rejected_prediction:
|
|
79
|
+
a.output.rejected_prediction + b.output.rejected_prediction,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
aggregate: component(x.aggregate, y.aggregate),
|
|
84
|
+
initialize: component(x.initialize, y.initialize),
|
|
85
|
+
select: component(x.select, y.select),
|
|
86
|
+
cancel: component(x.cancel, y.cancel),
|
|
87
|
+
call: component(x.call, y.call),
|
|
88
|
+
describe: component(x.describe, y.describe),
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const zero = (): IAgenticaTokenUsage => {
|
|
93
|
+
const component = (): IAgenticaTokenUsage.IComponent => ({
|
|
94
|
+
total: 0,
|
|
95
|
+
input: {
|
|
96
|
+
total: 0,
|
|
97
|
+
cached: 0,
|
|
98
|
+
},
|
|
99
|
+
output: {
|
|
100
|
+
total: 0,
|
|
101
|
+
reasoning: 0,
|
|
102
|
+
accepted_prediction: 0,
|
|
103
|
+
rejected_prediction: 0,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
aggregate: component(),
|
|
108
|
+
initialize: component(),
|
|
109
|
+
select: component(),
|
|
110
|
+
cancel: component(),
|
|
111
|
+
call: component(),
|
|
112
|
+
describe: component(),
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}
|
package/src/internal/MathUtil.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export namespace MathUtil {
|
|
2
|
-
export const round = (value: number): number => Math.floor(value * 100) / 100;
|
|
3
|
-
}
|
|
1
|
+
export namespace MathUtil {
|
|
2
|
+
export const round = (value: number): number => Math.floor(value * 100) / 100;
|
|
3
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export class Singleton<T, Args extends any[] = []> {
|
|
5
|
-
private readonly closure_: (...args: Args) => T;
|
|
6
|
-
private value_: T | object;
|
|
7
|
-
|
|
8
|
-
public constructor(closure: (...args: Args) => T) {
|
|
9
|
-
this.closure_ = closure;
|
|
10
|
-
this.value_ = NOT_MOUNTED_YET;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public get(...args: Args): T {
|
|
14
|
-
if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_(...args);
|
|
15
|
-
return this.value_ as T;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
const NOT_MOUNTED_YET = {};
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export class Singleton<T, Args extends any[] = []> {
|
|
5
|
+
private readonly closure_: (...args: Args) => T;
|
|
6
|
+
private value_: T | object;
|
|
7
|
+
|
|
8
|
+
public constructor(closure: (...args: Args) => T) {
|
|
9
|
+
this.closure_ = closure;
|
|
10
|
+
this.value_ = NOT_MOUNTED_YET;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public get(...args: Args): T {
|
|
14
|
+
if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_(...args);
|
|
15
|
+
return this.value_ as T;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
const NOT_MOUNTED_YET = {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export const __map_take = <Key, T>(
|
|
5
|
-
dict: Map<Key, T>,
|
|
6
|
-
key: Key,
|
|
7
|
-
generator: () => T,
|
|
8
|
-
): T => {
|
|
9
|
-
const oldbie: T | undefined = dict.get(key);
|
|
10
|
-
if (oldbie) return oldbie;
|
|
11
|
-
|
|
12
|
-
const value: T = generator();
|
|
13
|
-
dict.set(key, value);
|
|
14
|
-
return value;
|
|
15
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export const __map_take = <Key, T>(
|
|
5
|
+
dict: Map<Key, T>,
|
|
6
|
+
key: Key,
|
|
7
|
+
generator: () => T,
|
|
8
|
+
): T => {
|
|
9
|
+
const oldbie: T | undefined = dict.get(key);
|
|
10
|
+
if (oldbie) return oldbie;
|
|
11
|
+
|
|
12
|
+
const value: T = generator();
|
|
13
|
+
dict.set(key, value);
|
|
14
|
+
return value;
|
|
15
|
+
};
|