digital-workers 2.1.3 → 2.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/README.md +2 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +33 -21
- package/dist/actions.js.map +1 -1
- package/dist/agent-comms.d.ts.map +1 -1
- package/dist/agent-comms.js +36 -25
- package/dist/agent-comms.js.map +1 -1
- package/dist/approve.d.ts +40 -8
- package/dist/approve.d.ts.map +1 -1
- package/dist/approve.js +86 -20
- package/dist/approve.js.map +1 -1
- package/dist/ask.d.ts +38 -7
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +85 -25
- package/dist/ask.js.map +1 -1
- package/dist/browse.d.ts +223 -0
- package/dist/browse.d.ts.map +1 -0
- package/dist/browse.js +392 -0
- package/dist/browse.js.map +1 -0
- package/dist/capability-tiers.js +3 -3
- package/dist/capability-tiers.js.map +1 -1
- package/dist/cascade-context.d.ts +28 -28
- package/dist/client.d.ts +162 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +64 -0
- package/dist/client.js.map +1 -0
- package/dist/decide.d.ts +42 -6
- package/dist/decide.d.ts.map +1 -1
- package/dist/decide.js +54 -11
- package/dist/decide.js.map +1 -1
- package/dist/do.d.ts +36 -7
- package/dist/do.d.ts.map +1 -1
- package/dist/do.js +82 -39
- package/dist/do.js.map +1 -1
- package/dist/error-escalation.d.ts.map +1 -1
- package/dist/error-escalation.js +38 -38
- package/dist/error-escalation.js.map +1 -1
- package/dist/generate.d.ts +48 -7
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +49 -8
- package/dist/generate.js.map +1 -1
- package/dist/goals.d.ts +10 -9
- package/dist/goals.d.ts.map +1 -1
- package/dist/goals.js +30 -24
- package/dist/goals.js.map +1 -1
- package/dist/image.d.ts +189 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +528 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +49 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -2
- package/dist/index.js.map +1 -1
- package/dist/is.d.ts +45 -10
- package/dist/is.d.ts.map +1 -1
- package/dist/is.js +56 -21
- package/dist/is.js.map +1 -1
- package/dist/kpis.d.ts +24 -15
- package/dist/kpis.d.ts.map +1 -1
- package/dist/kpis.js +16 -14
- package/dist/kpis.js.map +1 -1
- package/dist/load-balancing.d.ts.map +1 -1
- package/dist/load-balancing.js +124 -38
- package/dist/load-balancing.js.map +1 -1
- package/dist/logger.d.ts +76 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +39 -0
- package/dist/logger.js.map +1 -0
- package/dist/notify.d.ts +38 -9
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +72 -17
- package/dist/notify.js.map +1 -1
- package/dist/role.d.ts +5 -4
- package/dist/role.d.ts.map +1 -1
- package/dist/role.js +13 -10
- package/dist/role.js.map +1 -1
- package/dist/runtime.d.ts +310 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +510 -0
- package/dist/runtime.js.map +1 -0
- package/dist/team.d.ts +11 -6
- package/dist/team.d.ts.map +1 -1
- package/dist/team.js +22 -15
- package/dist/team.js.map +1 -1
- package/dist/transports/email.d.ts +318 -0
- package/dist/transports/email.d.ts.map +1 -0
- package/dist/transports/email.js +779 -0
- package/dist/transports/email.js.map +1 -0
- package/dist/transports/slack.d.ts +515 -0
- package/dist/transports/slack.d.ts.map +1 -0
- package/dist/transports/slack.js +844 -0
- package/dist/transports/slack.js.map +1 -0
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +44 -25
- package/dist/transports.js.map +1 -1
- package/dist/types.d.ts +141 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/id.d.ts +19 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +21 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/video.d.ts +203 -0
- package/dist/video.d.ts.map +1 -0
- package/dist/video.js +528 -0
- package/dist/video.js.map +1 -0
- package/dist/worker.d.ts +343 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +698 -0
- package/dist/worker.js.map +1 -0
- package/package.json +32 -14
- package/src/actions.ts +39 -30
- package/src/agent-comms.ts +54 -92
- package/src/approve.ts +91 -20
- package/src/ask.ts +99 -25
- package/src/browse.ts +627 -0
- package/src/capability-tiers.ts +5 -5
- package/src/client.ts +221 -0
- package/src/decide.ts +81 -35
- package/src/do.ts +98 -52
- package/src/error-escalation.ts +55 -67
- package/src/generate.ts +52 -18
- package/src/goals.ts +36 -27
- package/src/image.ts +816 -0
- package/src/index.ts +187 -2
- package/src/is.ts +59 -25
- package/src/kpis.ts +41 -36
- package/src/load-balancing.ts +132 -46
- package/src/logger.ts +93 -0
- package/src/notify.ts +78 -17
- package/src/role.ts +30 -20
- package/src/runtime.ts +796 -0
- package/src/team.ts +24 -19
- package/src/transports/email.ts +1160 -0
- package/src/transports/slack.ts +1320 -0
- package/src/transports.ts +58 -43
- package/src/types.ts +174 -46
- package/src/utils/id.ts +21 -0
- package/src/video.ts +906 -0
- package/src/worker.ts +1007 -0
- package/test/approve.test.ts +305 -0
- package/test/ask.test.ts +274 -0
- package/test/browse.test.ts +361 -0
- package/test/decide.test.ts +252 -0
- package/test/do.test.ts +144 -0
- package/test/error-logging.test.ts +357 -0
- package/test/generate.test.ts +319 -0
- package/test/image.test.ts +398 -0
- package/test/is.test.ts +287 -0
- package/test/load-balancing-safety.test.ts +404 -0
- package/test/notify.test.ts +434 -0
- package/test/primitives.test.ts +320 -0
- package/test/runtime-integration.test.ts +892 -0
- package/test/transports/crypto.test.ts +230 -0
- package/test/transports/email.test.ts +866 -0
- package/test/transports/id-generation.test.ts +91 -0
- package/test/transports/slack.test.ts +760 -0
- package/test/type-safety.test.ts +834 -0
- package/test/types.test.ts +60 -2
- package/test/video.test.ts +530 -0
- package/test/worker.test.ts +1433 -0
- package/tsconfig.json +4 -1
- package/vitest.config.ts +42 -0
- package/wrangler.jsonc +36 -0
- package/LICENSE +0 -21
- package/src/actions.js +0 -436
- package/src/approve.js +0 -234
- package/src/ask.js +0 -226
- package/src/decide.js +0 -244
- package/src/do.js +0 -227
- package/src/generate.js +0 -298
- package/src/goals.js +0 -205
- package/src/index.js +0 -68
- package/src/is.js +0 -317
- package/src/kpis.js +0 -270
- package/src/notify.js +0 -219
- package/src/role.js +0 -110
- package/src/team.js +0 -130
- package/src/transports.js +0 -357
- package/src/types.js +0 -71
package/dist/generate.d.ts
CHANGED
|
@@ -1,25 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content generation functionality for digital workers
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: Worker-Context Generation vs Direct LLM Generation
|
|
5
|
+
* --------------------------------------------------------------
|
|
6
|
+
* This module provides content generation within a worker context,
|
|
7
|
+
* with rich metadata about the generation process.
|
|
8
|
+
*
|
|
9
|
+
* - `digital-workers.generate()` - Generates content with full metadata
|
|
10
|
+
* (tokens used, duration, model info) and supports multiple content types
|
|
11
|
+
* including text, code, structured, image, video, and audio.
|
|
12
|
+
*
|
|
13
|
+
* - `ai-functions.generate()` - Core generation primitive that powers all
|
|
14
|
+
* ai-functions; lower-level function with type-based dispatch.
|
|
15
|
+
*
|
|
16
|
+
* The key difference is context and metadata:
|
|
17
|
+
* - digital-workers returns `GenerateResult<T>` with content + metadata
|
|
18
|
+
* - ai-functions returns just the generated content
|
|
19
|
+
*
|
|
20
|
+
* Use digital-workers when you need:
|
|
21
|
+
* - Rich metadata about generation (tokens, duration, model)
|
|
22
|
+
* - Content type variants (text, code, structured, media)
|
|
23
|
+
* - Tone, audience, and length modifiers
|
|
24
|
+
* - Iterative refinement workflows
|
|
25
|
+
*
|
|
26
|
+
* Use ai-functions when you need:
|
|
27
|
+
* - Direct LLM generation without metadata
|
|
28
|
+
* - Template literal syntax (`ai\`prompt\``)
|
|
29
|
+
* - Promise pipelining and schema inference
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
3
32
|
*/
|
|
4
33
|
import type { GenerateResult, GenerateOptions } from './types.js';
|
|
5
34
|
/**
|
|
6
|
-
* Generate content
|
|
35
|
+
* Generate content with rich metadata and multiple content type support.
|
|
7
36
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
37
|
+
* **Key Difference from ai-functions.generate():**
|
|
38
|
+
* Unlike `ai-functions.generate()` which is a lower-level type-dispatch
|
|
39
|
+
* function, this function returns a `GenerateResult` wrapper with:
|
|
40
|
+
* - The generated content
|
|
41
|
+
* - Generation metadata (model, tokens, duration)
|
|
42
|
+
* - Content type information
|
|
43
|
+
*
|
|
44
|
+
* This provides better observability for worker-based content generation.
|
|
10
45
|
*
|
|
11
46
|
* @param prompt - What to generate
|
|
12
|
-
* @param options - Generation options
|
|
13
|
-
* @returns Promise resolving to
|
|
47
|
+
* @param options - Generation options (type, schema, instructions, model)
|
|
48
|
+
* @returns Promise resolving to GenerateResult with content and metadata
|
|
14
49
|
*
|
|
15
50
|
* @example
|
|
16
51
|
* ```ts
|
|
17
|
-
* // Generate text content
|
|
52
|
+
* // Generate text content with metadata
|
|
18
53
|
* const result = await generate('Write a product description for wireless earbuds', {
|
|
19
54
|
* type: 'text',
|
|
20
55
|
* instructions: 'Focus on sound quality and battery life. Keep it under 100 words.',
|
|
21
56
|
* })
|
|
22
|
-
* console.log(result.content)
|
|
57
|
+
* console.log(result.content) // The generated text
|
|
58
|
+
* console.log(result.metadata.tokens) // Tokens used
|
|
59
|
+
* console.log(result.metadata.duration) // Generation time in ms
|
|
23
60
|
* ```
|
|
24
61
|
*
|
|
25
62
|
* @example
|
|
@@ -48,7 +85,11 @@ import type { GenerateResult, GenerateOptions } from './types.js';
|
|
|
48
85
|
* instructions: 'Use TypeScript and hooks. Include prop types.',
|
|
49
86
|
* })
|
|
50
87
|
* console.log(result.content) // TypeScript React component code
|
|
88
|
+
* console.log(result.metadata.language) // 'typescript'
|
|
51
89
|
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see {@link ai-functions#generate} for lower-level type-dispatch generation
|
|
92
|
+
* @see {@link ai-functions#ai} for template literal generation syntax
|
|
52
93
|
*/
|
|
53
94
|
export declare function generate<T = string>(prompt: string, options?: GenerateOptions): Promise<GenerateResult<T>>;
|
|
54
95
|
export declare namespace generate {
|
package/dist/generate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,MAAM,EACvC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CA6G5B;yBAhHqB,QAAQ;qBAuID,CAAC,mBACpB,MAAM,SACP,MAAM,YACJ,eAAe,KACvB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;mBA2BT,CAAC,mBAClB,MAAM,QACR,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,YAC1E,eAAe,KACvB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;sBAuCC,CAAC,mBACrB,MAAM,YACJ,MAAM,YACP,eAAe,KACvB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;qBA8BA,CAAC,mBACpB,MAAM,UACN,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,YACjD,eAAe,KACvB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;iBAoCJ,CAAC,mBAChB,MAAM,eACD,MAAM,EAAE,YACZ,eAAe,KACvB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/generate.js
CHANGED
|
@@ -1,25 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content generation functionality for digital workers
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: Worker-Context Generation vs Direct LLM Generation
|
|
5
|
+
* --------------------------------------------------------------
|
|
6
|
+
* This module provides content generation within a worker context,
|
|
7
|
+
* with rich metadata about the generation process.
|
|
8
|
+
*
|
|
9
|
+
* - `digital-workers.generate()` - Generates content with full metadata
|
|
10
|
+
* (tokens used, duration, model info) and supports multiple content types
|
|
11
|
+
* including text, code, structured, image, video, and audio.
|
|
12
|
+
*
|
|
13
|
+
* - `ai-functions.generate()` - Core generation primitive that powers all
|
|
14
|
+
* ai-functions; lower-level function with type-based dispatch.
|
|
15
|
+
*
|
|
16
|
+
* The key difference is context and metadata:
|
|
17
|
+
* - digital-workers returns `GenerateResult<T>` with content + metadata
|
|
18
|
+
* - ai-functions returns just the generated content
|
|
19
|
+
*
|
|
20
|
+
* Use digital-workers when you need:
|
|
21
|
+
* - Rich metadata about generation (tokens, duration, model)
|
|
22
|
+
* - Content type variants (text, code, structured, media)
|
|
23
|
+
* - Tone, audience, and length modifiers
|
|
24
|
+
* - Iterative refinement workflows
|
|
25
|
+
*
|
|
26
|
+
* Use ai-functions when you need:
|
|
27
|
+
* - Direct LLM generation without metadata
|
|
28
|
+
* - Template literal syntax (`ai\`prompt\``)
|
|
29
|
+
* - Promise pipelining and schema inference
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
3
32
|
*/
|
|
4
33
|
import { generateObject, generateText } from 'ai-functions';
|
|
5
34
|
/**
|
|
6
|
-
* Generate content
|
|
35
|
+
* Generate content with rich metadata and multiple content type support.
|
|
36
|
+
*
|
|
37
|
+
* **Key Difference from ai-functions.generate():**
|
|
38
|
+
* Unlike `ai-functions.generate()` which is a lower-level type-dispatch
|
|
39
|
+
* function, this function returns a `GenerateResult` wrapper with:
|
|
40
|
+
* - The generated content
|
|
41
|
+
* - Generation metadata (model, tokens, duration)
|
|
42
|
+
* - Content type information
|
|
7
43
|
*
|
|
8
|
-
*
|
|
9
|
-
* code, structured data, images, video, and audio.
|
|
44
|
+
* This provides better observability for worker-based content generation.
|
|
10
45
|
*
|
|
11
46
|
* @param prompt - What to generate
|
|
12
|
-
* @param options - Generation options
|
|
13
|
-
* @returns Promise resolving to
|
|
47
|
+
* @param options - Generation options (type, schema, instructions, model)
|
|
48
|
+
* @returns Promise resolving to GenerateResult with content and metadata
|
|
14
49
|
*
|
|
15
50
|
* @example
|
|
16
51
|
* ```ts
|
|
17
|
-
* // Generate text content
|
|
52
|
+
* // Generate text content with metadata
|
|
18
53
|
* const result = await generate('Write a product description for wireless earbuds', {
|
|
19
54
|
* type: 'text',
|
|
20
55
|
* instructions: 'Focus on sound quality and battery life. Keep it under 100 words.',
|
|
21
56
|
* })
|
|
22
|
-
* console.log(result.content)
|
|
57
|
+
* console.log(result.content) // The generated text
|
|
58
|
+
* console.log(result.metadata.tokens) // Tokens used
|
|
59
|
+
* console.log(result.metadata.duration) // Generation time in ms
|
|
23
60
|
* ```
|
|
24
61
|
*
|
|
25
62
|
* @example
|
|
@@ -48,10 +85,14 @@ import { generateObject, generateText } from 'ai-functions';
|
|
|
48
85
|
* instructions: 'Use TypeScript and hooks. Include prop types.',
|
|
49
86
|
* })
|
|
50
87
|
* console.log(result.content) // TypeScript React component code
|
|
88
|
+
* console.log(result.metadata.language) // 'typescript'
|
|
51
89
|
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see {@link ai-functions#generate} for lower-level type-dispatch generation
|
|
92
|
+
* @see {@link ai-functions#ai} for template literal generation syntax
|
|
52
93
|
*/
|
|
53
94
|
export async function generate(prompt, options = {}) {
|
|
54
|
-
const { type = 'text', schema, instructions, model = 'sonnet'
|
|
95
|
+
const { type = 'text', schema, instructions, model = 'sonnet' } = options;
|
|
55
96
|
const startTime = Date.now();
|
|
56
97
|
switch (type) {
|
|
57
98
|
case 'text': {
|
package/dist/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAc,EACd,UAA2B,EAAE;IAE7B,MAAM,EAAE,IAAI,GAAG,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAA;IAEzE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAE5B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,YAAY,GAAG,YAAY;gBAC/B,CAAC,CAAC,wCAAwC,YAAY,EAAE;gBACxD,CAAC,CAAC,sCAAsC,CAAA;YAE1C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC;gBAChC,KAAK;gBACL,MAAM;gBACN,MAAM,EAAE,YAAY;aACrB,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,IAAS;gBACzB,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE;oBACR,KAAK;oBACL,MAAM,EAAE,MAAM,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CAAA;IAE/C,gCAAgC;IAChC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,GAAG,MAAM,QAAQ,CACrB,iCAAiC,MAAM,CAAC,OAAO,mBAAmB,UAAU,EAAE,EAC9E,OAAO,CACR,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/dist/goals.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Goals definition for digital workers
|
|
3
3
|
*/
|
|
4
|
-
import type { WorkerGoals,
|
|
4
|
+
import type { WorkerGoals, WorkerKPI } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Define worker goals
|
|
7
7
|
*
|
|
@@ -13,7 +13,7 @@ import type { WorkerGoals, KPI } from './types.js';
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
|
-
* const engineeringGoals =
|
|
16
|
+
* const engineeringGoals = defineGoals({
|
|
17
17
|
* shortTerm: [
|
|
18
18
|
* 'Complete Q1 roadmap features',
|
|
19
19
|
* 'Reduce bug backlog by 30%',
|
|
@@ -53,7 +53,7 @@ import type { WorkerGoals, KPI } from './types.js';
|
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```ts
|
|
56
|
-
* const supportGoals =
|
|
56
|
+
* const supportGoals = defineGoals({
|
|
57
57
|
* shortTerm: [
|
|
58
58
|
* 'Achieve 95% customer satisfaction',
|
|
59
59
|
* 'Reduce average response time to < 5 min',
|
|
@@ -76,14 +76,15 @@ import type { WorkerGoals, KPI } from './types.js';
|
|
|
76
76
|
* })
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export declare function
|
|
80
|
-
export declare namespace
|
|
79
|
+
export declare function defineGoals(definition: WorkerGoals): WorkerGoals;
|
|
80
|
+
export declare namespace defineGoals {
|
|
81
81
|
var addShortTerm: (goals: WorkerGoals, goal: string) => WorkerGoals;
|
|
82
82
|
var addLongTerm: (goals: WorkerGoals, goal: string) => WorkerGoals;
|
|
83
83
|
var addStrategic: (goals: WorkerGoals, goal: string) => WorkerGoals;
|
|
84
|
-
var addMetric: (goals: WorkerGoals, kpi:
|
|
85
|
-
var updateMetric: (goals: WorkerGoals, name: string, updates: Partial<Omit<
|
|
86
|
-
var progress: (kpi: Pick<
|
|
87
|
-
var onTrack: (kpi: Pick<
|
|
84
|
+
var addMetric: (goals: WorkerGoals, kpi: WorkerKPI) => WorkerGoals;
|
|
85
|
+
var updateMetric: (goals: WorkerGoals, name: string, updates: Partial<Omit<WorkerKPI, "name">>) => WorkerGoals;
|
|
86
|
+
var progress: (kpi: Pick<WorkerKPI, "current" | "target">) => number;
|
|
87
|
+
var onTrack: (kpi: Pick<WorkerKPI, "current" | "target">, threshold?: number) => boolean;
|
|
88
88
|
}
|
|
89
|
+
export { defineGoals as Goals };
|
|
89
90
|
//# sourceMappingURL=goals.d.ts.map
|
package/dist/goals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goals.d.ts","sourceRoot":"","sources":["../src/goals.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"goals.d.ts","sourceRoot":"","sources":["../src/goals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAEhE;yBAFe,WAAW;8BAgBQ,WAAW,QAAQ,MAAM,KAAG,WAAW;6BAiBxC,WAAW,QAAQ,MAAM,KAAG,WAAW;8BAiBtC,WAAW,QAAQ,MAAM,KAAG,WAAW;2BAyB1C,WAAW,OAAO,SAAS,KAAG,WAAW;8BAsBhE,WAAW,QACZ,MAAM,WACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,KACxC,WAAW;wBAuBe,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,CAAC,KAAG,MAAM;uBAiB/C,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,CAAC,yBAAoB,OAAO;;AAK5F,OAAO,EAAE,WAAW,IAAI,KAAK,EAAE,CAAA"}
|
package/dist/goals.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Goals definition for digital workers
|
|
3
3
|
*/
|
|
4
|
+
import { calculateProgress, isOnTrack } from 'org.ai';
|
|
5
|
+
// Note: Goal, Goals types are re-exported from types.ts which imports from org.ai
|
|
4
6
|
/**
|
|
5
7
|
* Define worker goals
|
|
6
8
|
*
|
|
@@ -12,7 +14,7 @@
|
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
14
16
|
* ```ts
|
|
15
|
-
* const engineeringGoals =
|
|
17
|
+
* const engineeringGoals = defineGoals({
|
|
16
18
|
* shortTerm: [
|
|
17
19
|
* 'Complete Q1 roadmap features',
|
|
18
20
|
* 'Reduce bug backlog by 30%',
|
|
@@ -52,7 +54,7 @@
|
|
|
52
54
|
*
|
|
53
55
|
* @example
|
|
54
56
|
* ```ts
|
|
55
|
-
* const supportGoals =
|
|
57
|
+
* const supportGoals = defineGoals({
|
|
56
58
|
* shortTerm: [
|
|
57
59
|
* 'Achieve 95% customer satisfaction',
|
|
58
60
|
* 'Reduce average response time to < 5 min',
|
|
@@ -75,7 +77,7 @@
|
|
|
75
77
|
* })
|
|
76
78
|
* ```
|
|
77
79
|
*/
|
|
78
|
-
export function
|
|
80
|
+
export function defineGoals(definition) {
|
|
79
81
|
return definition;
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
@@ -87,10 +89,10 @@ export function Goals(definition) {
|
|
|
87
89
|
*
|
|
88
90
|
* @example
|
|
89
91
|
* ```ts
|
|
90
|
-
* const updated =
|
|
92
|
+
* const updated = defineGoals.addShortTerm(engineeringGoals, 'Complete security audit')
|
|
91
93
|
* ```
|
|
92
94
|
*/
|
|
93
|
-
|
|
95
|
+
defineGoals.addShortTerm = (goals, goal) => ({
|
|
94
96
|
...goals,
|
|
95
97
|
shortTerm: [...goals.shortTerm, goal],
|
|
96
98
|
});
|
|
@@ -103,10 +105,10 @@ Goals.addShortTerm = (goals, goal) => ({
|
|
|
103
105
|
*
|
|
104
106
|
* @example
|
|
105
107
|
* ```ts
|
|
106
|
-
* const updated =
|
|
108
|
+
* const updated = defineGoals.addLongTerm(engineeringGoals, 'Build ML platform')
|
|
107
109
|
* ```
|
|
108
110
|
*/
|
|
109
|
-
|
|
111
|
+
defineGoals.addLongTerm = (goals, goal) => ({
|
|
110
112
|
...goals,
|
|
111
113
|
longTerm: [...goals.longTerm, goal],
|
|
112
114
|
});
|
|
@@ -119,10 +121,10 @@ Goals.addLongTerm = (goals, goal) => ({
|
|
|
119
121
|
*
|
|
120
122
|
* @example
|
|
121
123
|
* ```ts
|
|
122
|
-
* const updated =
|
|
124
|
+
* const updated = defineGoals.addStrategic(engineeringGoals, 'Become carbon neutral')
|
|
123
125
|
* ```
|
|
124
126
|
*/
|
|
125
|
-
|
|
127
|
+
defineGoals.addStrategic = (goals, goal) => ({
|
|
126
128
|
...goals,
|
|
127
129
|
strategic: [...(goals.strategic || []), goal],
|
|
128
130
|
});
|
|
@@ -135,7 +137,7 @@ Goals.addStrategic = (goals, goal) => ({
|
|
|
135
137
|
*
|
|
136
138
|
* @example
|
|
137
139
|
* ```ts
|
|
138
|
-
* const updated =
|
|
140
|
+
* const updated = defineGoals.addMetric(engineeringGoals, {
|
|
139
141
|
* name: 'Code Quality',
|
|
140
142
|
* description: 'Code quality score from SonarQube',
|
|
141
143
|
* current: 85,
|
|
@@ -146,7 +148,7 @@ Goals.addStrategic = (goals, goal) => ({
|
|
|
146
148
|
* })
|
|
147
149
|
* ```
|
|
148
150
|
*/
|
|
149
|
-
|
|
151
|
+
defineGoals.addMetric = (goals, kpi) => ({
|
|
150
152
|
...goals,
|
|
151
153
|
metrics: [...(goals.metrics || []), kpi],
|
|
152
154
|
});
|
|
@@ -160,16 +162,20 @@ Goals.addMetric = (goals, kpi) => ({
|
|
|
160
162
|
*
|
|
161
163
|
* @example
|
|
162
164
|
* ```ts
|
|
163
|
-
* const updated =
|
|
165
|
+
* const updated = defineGoals.updateMetric(engineeringGoals, 'Deployment Frequency', {
|
|
164
166
|
* current: 8,
|
|
165
167
|
* trend: 'up',
|
|
166
168
|
* })
|
|
167
169
|
* ```
|
|
168
170
|
*/
|
|
169
|
-
|
|
170
|
-
...
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
defineGoals.updateMetric = (goals, name, updates) => {
|
|
172
|
+
const updatedMetrics = goals.metrics?.map((kpi) => kpi.name === name ? { ...kpi, ...updates } : kpi);
|
|
173
|
+
const result = { ...goals };
|
|
174
|
+
if (updatedMetrics) {
|
|
175
|
+
result.metrics = updatedMetrics;
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
};
|
|
173
179
|
/**
|
|
174
180
|
* Get progress for a KPI (0-1)
|
|
175
181
|
*
|
|
@@ -179,13 +185,11 @@ Goals.updateMetric = (goals, name, updates) => ({
|
|
|
179
185
|
* @example
|
|
180
186
|
* ```ts
|
|
181
187
|
* const kpi = { current: 75, target: 100 }
|
|
182
|
-
* const progress =
|
|
188
|
+
* const progress = defineGoals.progress(kpi) // 0.75
|
|
183
189
|
* ```
|
|
184
190
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return 0;
|
|
188
|
-
return Math.min(1, Math.max(0, kpi.current / kpi.target));
|
|
191
|
+
defineGoals.progress = (kpi) => {
|
|
192
|
+
return calculateProgress(kpi);
|
|
189
193
|
};
|
|
190
194
|
/**
|
|
191
195
|
* Check if a KPI is on track
|
|
@@ -197,10 +201,12 @@ Goals.progress = (kpi) => {
|
|
|
197
201
|
* @example
|
|
198
202
|
* ```ts
|
|
199
203
|
* const kpi = { current: 85, target: 100 }
|
|
200
|
-
* const onTrack =
|
|
204
|
+
* const onTrack = defineGoals.onTrack(kpi) // true (85% >= 80% threshold)
|
|
201
205
|
* ```
|
|
202
206
|
*/
|
|
203
|
-
|
|
204
|
-
return
|
|
207
|
+
defineGoals.onTrack = (kpi, threshold = 0.8) => {
|
|
208
|
+
return isOnTrack(kpi, threshold);
|
|
205
209
|
};
|
|
210
|
+
// Legacy alias for backward compatibility
|
|
211
|
+
export { defineGoals as Goals };
|
|
206
212
|
//# sourceMappingURL=goals.js.map
|
package/dist/goals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goals.js","sourceRoot":"","sources":["../src/goals.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"goals.js","sourceRoot":"","sources":["../src/goals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGrD,kFAAkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,UAAU,WAAW,CAAC,UAAuB;IACjD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,WAAW,CAAC,YAAY,GAAG,CAAC,KAAkB,EAAE,IAAY,EAAe,EAAE,CAAC,CAAC;IAC7E,GAAG,KAAK;IACR,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC;CACtC,CAAC,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,WAAW,CAAC,WAAW,GAAG,CAAC,KAAkB,EAAE,IAAY,EAAe,EAAE,CAAC,CAAC;IAC5E,GAAG,KAAK;IACR,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,CA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,EAAE;IAC7F,OAAO,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,KAAK,EAAE,CAAA"}
|
package/dist/image.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image generation functionality for digital workers
|
|
3
|
+
*
|
|
4
|
+
* This module provides image generation primitives within a worker context,
|
|
5
|
+
* with rich metadata about the generation process.
|
|
6
|
+
*
|
|
7
|
+
* - `image()` - Generates images with full metadata (model, size, style)
|
|
8
|
+
* - `image.variations()` - Creates variations of an existing image
|
|
9
|
+
* - `image.edit()` - Edits an image with a text prompt and optional mask
|
|
10
|
+
* - `image.upscale()` - Upscales an image to higher resolution
|
|
11
|
+
* - `image.style()` - Creates a curried function for a specific style
|
|
12
|
+
*
|
|
13
|
+
* The key difference from direct API calls is context and metadata:
|
|
14
|
+
* - digital-workers returns `ImageResult` with content + metadata
|
|
15
|
+
* - Direct API calls return just the generated image
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Available image style presets
|
|
21
|
+
*/
|
|
22
|
+
export type ImageStyle = 'realistic' | 'artistic' | 'cartoon' | 'abstract' | 'photographic' | 'digital-art' | 'cinematic';
|
|
23
|
+
/**
|
|
24
|
+
* Available image sizes
|
|
25
|
+
*/
|
|
26
|
+
export type ImageSize = '256x256' | '512x512' | '1024x1024' | '1024x1792' | '1792x1024';
|
|
27
|
+
/**
|
|
28
|
+
* Available image formats
|
|
29
|
+
*/
|
|
30
|
+
export type ImageFormat = 'png' | 'jpeg' | 'webp' | 'b64_json' | 'url';
|
|
31
|
+
/**
|
|
32
|
+
* Options for image generation
|
|
33
|
+
*/
|
|
34
|
+
export interface ImageOptions {
|
|
35
|
+
/** The prompt describing the image to generate */
|
|
36
|
+
prompt: string;
|
|
37
|
+
/** The style preset to apply */
|
|
38
|
+
style?: ImageStyle;
|
|
39
|
+
/** The size of the generated image */
|
|
40
|
+
size?: ImageSize;
|
|
41
|
+
/** The model to use for generation */
|
|
42
|
+
model?: string;
|
|
43
|
+
/** Number of images to generate (1-10) */
|
|
44
|
+
n?: number;
|
|
45
|
+
/** Output format */
|
|
46
|
+
format?: ImageFormat;
|
|
47
|
+
/** Quality setting */
|
|
48
|
+
quality?: 'standard' | 'hd';
|
|
49
|
+
/** Negative prompt - what to avoid in the image */
|
|
50
|
+
negativePrompt?: string;
|
|
51
|
+
/** Seed for reproducible generation */
|
|
52
|
+
seed?: number;
|
|
53
|
+
/** Additional model-specific parameters */
|
|
54
|
+
parameters?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Result of image generation
|
|
58
|
+
*/
|
|
59
|
+
export interface ImageResult {
|
|
60
|
+
/** URL or base64 data of the generated image */
|
|
61
|
+
url: string;
|
|
62
|
+
/** The original prompt */
|
|
63
|
+
prompt: string;
|
|
64
|
+
/** The revised/enhanced prompt if the model modified it */
|
|
65
|
+
revisedPrompt?: string;
|
|
66
|
+
/** Generation metadata */
|
|
67
|
+
metadata: {
|
|
68
|
+
/** Model used for generation */
|
|
69
|
+
model: string;
|
|
70
|
+
/** Size of the generated image */
|
|
71
|
+
size: string;
|
|
72
|
+
/** Style applied */
|
|
73
|
+
style?: string;
|
|
74
|
+
/** Generation duration in milliseconds */
|
|
75
|
+
duration?: number;
|
|
76
|
+
/** Seed used for generation */
|
|
77
|
+
seed?: number;
|
|
78
|
+
/** Format of the output */
|
|
79
|
+
format?: ImageFormat;
|
|
80
|
+
/** Quality setting used */
|
|
81
|
+
quality?: string;
|
|
82
|
+
/** Provider-specific metadata */
|
|
83
|
+
provider?: Record<string, unknown>;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for image variations
|
|
88
|
+
*/
|
|
89
|
+
export interface VariationOptions {
|
|
90
|
+
/** Number of variations to generate */
|
|
91
|
+
count?: number;
|
|
92
|
+
/** Size of the generated variations */
|
|
93
|
+
size?: ImageSize;
|
|
94
|
+
/** Model to use for generation */
|
|
95
|
+
model?: string;
|
|
96
|
+
/** Output format */
|
|
97
|
+
format?: ImageFormat;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Options for image editing
|
|
101
|
+
*/
|
|
102
|
+
export interface EditOptions {
|
|
103
|
+
/** The prompt describing the edit */
|
|
104
|
+
prompt: string;
|
|
105
|
+
/** URL or base64 of the mask image (transparent areas will be edited) */
|
|
106
|
+
mask?: string;
|
|
107
|
+
/** Size of the output image */
|
|
108
|
+
size?: ImageSize;
|
|
109
|
+
/** Model to use for editing */
|
|
110
|
+
model?: string;
|
|
111
|
+
/** Number of edits to generate */
|
|
112
|
+
n?: number;
|
|
113
|
+
/** Output format */
|
|
114
|
+
format?: ImageFormat;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Options for image upscaling
|
|
118
|
+
*/
|
|
119
|
+
export interface UpscaleOptions {
|
|
120
|
+
/** Scale factor (2, 4, etc.) */
|
|
121
|
+
scale?: number;
|
|
122
|
+
/** Model to use for upscaling */
|
|
123
|
+
model?: string;
|
|
124
|
+
/** Output format */
|
|
125
|
+
format?: ImageFormat;
|
|
126
|
+
/** Denoise level (0-1) */
|
|
127
|
+
denoise?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Result of image upscaling
|
|
131
|
+
*/
|
|
132
|
+
export interface UpscaleResult extends ImageResult {
|
|
133
|
+
/** Original image dimensions */
|
|
134
|
+
originalSize: {
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
};
|
|
138
|
+
/** Upscaled image dimensions */
|
|
139
|
+
upscaledSize: {
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
};
|
|
143
|
+
/** Scale factor used */
|
|
144
|
+
scaleFactor: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Generate an image from a text prompt
|
|
148
|
+
*
|
|
149
|
+
* @param prompt - The text prompt describing the image to generate
|
|
150
|
+
* @param options - Generation options (style, size, model, etc.)
|
|
151
|
+
* @returns Promise resolving to ImageResult with URL and metadata
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* // Generate a simple image
|
|
156
|
+
* const result = await image('A sunset over mountains')
|
|
157
|
+
* console.log(result.url) // URL to the generated image
|
|
158
|
+
* console.log(result.metadata.model) // Model used
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* // Generate with options
|
|
164
|
+
* const result = await image('A portrait of a robot', {
|
|
165
|
+
* style: 'cinematic',
|
|
166
|
+
* size: '1024x1024',
|
|
167
|
+
* quality: 'hd',
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* // Generate multiple images
|
|
174
|
+
* const result = await image('Abstract patterns', {
|
|
175
|
+
* style: 'abstract',
|
|
176
|
+
* n: 4,
|
|
177
|
+
* })
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare function image(prompt: string, options?: Partial<ImageOptions>): Promise<ImageResult>;
|
|
181
|
+
export declare namespace image {
|
|
182
|
+
var variations: (imageUrl: string, options?: VariationOptions) => Promise<ImageResult[]>;
|
|
183
|
+
var edit: (imageUrl: string, options: EditOptions) => Promise<ImageResult>;
|
|
184
|
+
var upscale: (imageUrl: string, options?: UpscaleOptions) => Promise<UpscaleResult>;
|
|
185
|
+
var style: (stylePreset: ImageStyle) => (prompt: string, options?: Partial<Omit<ImageOptions, "style">>) => Promise<ImageResult>;
|
|
186
|
+
var batch: (prompts: string[], options?: Partial<ImageOptions>) => Promise<ImageResult[]>;
|
|
187
|
+
var aspectRatio: (prompt: string, ratio: "portrait" | "landscape" | "square", options?: Partial<Omit<ImageOptions, "size">>) => Promise<ImageResult>;
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,UAAU,GACV,SAAS,GACT,UAAU,GACV,cAAc,GACd,aAAa,GACb,WAAW,CAAA;AAEf;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAA;AAEvF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAA;IACd,gCAAgC;IAChC,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,sCAAsC;IACtC,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,oBAAoB;IACpB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,sBAAsB;IACtB,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC3B,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAA;IACX,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,2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