@exellix/ai-tasks 9.0.6 → 9.1.1

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 (177) hide show
  1. package/CHANGELOG.md +22 -4
  2. package/README.md +5 -5
  3. package/RUNTASK_REQUEST.md +17 -15
  4. package/dist/compile/compileTaskConfiguration.d.ts.map +1 -1
  5. package/dist/compile/compileTaskConfiguration.js +3 -0
  6. package/dist/compile/compileTaskConfiguration.js.map +1 -1
  7. package/dist/core/task-sdk.d.ts.map +1 -1
  8. package/dist/core/task-sdk.js +112 -166
  9. package/dist/core/task-sdk.js.map +1 -1
  10. package/dist/invocation/types.d.ts +1 -1
  11. package/dist/narrix/narrixUnitExecution.js +2 -2
  12. package/dist/narrix/narrixUnitExecution.js.map +1 -1
  13. package/dist/node-execution/buildRequestFromNodePlan.d.ts +4 -0
  14. package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
  15. package/dist/node-execution/buildRequestFromNodePlan.js +4 -13
  16. package/dist/node-execution/buildRequestFromNodePlan.js.map +1 -1
  17. package/dist/node-execution/compileProfessionalAnswerRequest.d.ts +2 -0
  18. package/dist/node-execution/compileProfessionalAnswerRequest.d.ts.map +1 -0
  19. package/dist/node-execution/compileProfessionalAnswerRequest.js +4 -0
  20. package/dist/node-execution/compileProfessionalAnswerRequest.js.map +1 -0
  21. package/dist/node-execution/rejectForbiddenWireFields.d.ts +2 -0
  22. package/dist/node-execution/rejectForbiddenWireFields.d.ts.map +1 -1
  23. package/dist/node-execution/rejectForbiddenWireFields.js +42 -7
  24. package/dist/node-execution/rejectForbiddenWireFields.js.map +1 -1
  25. package/dist/node-execution/resolveUnitModelSelection.d.ts.map +1 -1
  26. package/dist/node-execution/resolveUnitModelSelection.js +10 -1
  27. package/dist/node-execution/resolveUnitModelSelection.js.map +1 -1
  28. package/dist/observability/graphExecutionRunLogContract.d.ts +1 -1
  29. package/dist/observability/graphExecutionRunLogContract.js +1 -1
  30. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts +19 -3
  31. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts.map +1 -1
  32. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js +7 -1
  33. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js.map +1 -1
  34. package/dist/post-steps/audit/loadAuditTemplates.d.ts +2 -55
  35. package/dist/post-steps/audit/loadAuditTemplates.d.ts.map +1 -1
  36. package/dist/post-steps/audit/loadAuditTemplates.js +3 -38
  37. package/dist/post-steps/audit/loadAuditTemplates.js.map +1 -1
  38. package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts +8 -0
  39. package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts.map +1 -0
  40. package/dist/post-steps/audit/parseAuditFuncxOutput.js +62 -0
  41. package/dist/post-steps/audit/parseAuditFuncxOutput.js.map +1 -0
  42. package/dist/post-steps/audit/parseAuditOutput.d.ts +2 -0
  43. package/dist/post-steps/audit/parseAuditOutput.d.ts.map +1 -1
  44. package/dist/post-steps/audit/parseAuditOutput.js +56 -0
  45. package/dist/post-steps/audit/parseAuditOutput.js.map +1 -1
  46. package/dist/post-steps/audit/runAudit.d.ts.map +1 -1
  47. package/dist/post-steps/audit/runAudit.js +53 -113
  48. package/dist/post-steps/audit/runAudit.js.map +1 -1
  49. package/dist/post-steps/audit/runAuditFuncxCall.d.ts +18 -0
  50. package/dist/post-steps/audit/runAuditFuncxCall.d.ts.map +1 -0
  51. package/dist/post-steps/audit/runAuditFuncxCall.js +59 -0
  52. package/dist/post-steps/audit/runAuditFuncxCall.js.map +1 -0
  53. package/dist/synthesis/resolveSourceMaterial.d.ts.map +1 -1
  54. package/dist/synthesis/resolveSourceMaterial.js +14 -0
  55. package/dist/synthesis/resolveSourceMaterial.js.map +1 -1
  56. package/dist/types/task-types.d.ts +4 -3
  57. package/dist/types/task-types.d.ts.map +1 -1
  58. package/dist/utils/bridgeRunSkillGatewayMemory.d.ts.map +1 -1
  59. package/dist/utils/bridgeRunSkillGatewayMemory.js +1 -0
  60. package/dist/utils/bridgeRunSkillGatewayMemory.js.map +1 -1
  61. package/dist/utils/executionMemoryInputRecord.d.ts +12 -0
  62. package/dist/utils/executionMemoryInputRecord.d.ts.map +1 -0
  63. package/dist/utils/executionMemoryInputRecord.js +28 -0
  64. package/dist/utils/executionMemoryInputRecord.js.map +1 -0
  65. package/dist/utils/resolveAiProfileModel.d.ts +1 -1
  66. package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
  67. package/dist/utils/skillTemplateVariables.d.ts +3 -2
  68. package/dist/utils/skillTemplateVariables.d.ts.map +1 -1
  69. package/dist/utils/skillTemplateVariables.js +3 -2
  70. package/dist/utils/skillTemplateVariables.js.map +1 -1
  71. package/dist/validation/validateProfessionalAnswerContract.d.ts +8 -0
  72. package/dist/validation/validateProfessionalAnswerContract.d.ts.map +1 -0
  73. package/dist/validation/validateProfessionalAnswerContract.js +45 -0
  74. package/dist/validation/validateProfessionalAnswerContract.js.map +1 -0
  75. package/dist/validation/validateRunTaskConfig.d.ts.map +1 -1
  76. package/dist/validation/validateRunTaskConfig.js +2 -0
  77. package/dist/validation/validateRunTaskConfig.js.map +1 -1
  78. package/documenations/record-and-template-variables.md +21 -13
  79. package/documenations/run-task-execution-flow.md +1 -1
  80. package/documenations/schemas/v1/run-task-request.json +1 -1
  81. package/documenations/upstream-feature-requests/README.md +9 -5
  82. package/documenations/upstream-feature-requests/ai-skills-orchestrator-invoke-contract-5.9.md +1 -1
  83. package/documenations/upstream-feature-requests/funcx-4.9.13-open-items.md +62 -0
  84. package/documenations/upstream-feature-requests/funcx-gap-analysis-cr-fr.md +401 -0
  85. package/documenations/upstream-feature-requests/funcx-pre-post-sidekick-actions.md +1 -0
  86. package/documenations/upstream-feature-requests/graph-engine-runtask-contract-alignment-investigation.md +370 -0
  87. package/documenations/upstream-feature-requests/xynthesis-ai-profiles-2.1-import-break.md +2 -2
  88. package/documenations/upstream-feature-requests/xynthesis-openrouter-wire-model-double-prefix-bug.md +1 -1
  89. package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +1 -1
  90. package/package.json +14 -17
  91. package/.docs/DOWNSTREAM_ENV.md +0 -42
  92. package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +0 -64
  93. package/.docs/INTERMEDIATE_STEPS.md +0 -82
  94. package/.docs/activity-structure.md +0 -31
  95. package/.docs/ai-task-ai-scoping-spec.md +0 -338
  96. package/.docs/ai-tasks-model-profile-aliases-7x.md +0 -96
  97. package/.docs/blockers-and-issues.md +0 -346
  98. package/.docs/building-runTask-sdk.md +0 -659
  99. package/.docs/building-skill-execution-orchestrator.md +0 -968
  100. package/.docs/code-used-before/run-task.txt +0 -39
  101. package/.docs/code-used-before/task-executor.ts.old +0 -57
  102. package/.docs/code-used-before/test-run-task.ts.old +0 -42
  103. package/.docs/code-used-before/types.txt +0 -23
  104. package/.docs/env-ready-policy.md +0 -40
  105. package/.docs/flow-io/flow-README.md +0 -76
  106. package/.docs/flow-io/narrix.md +0 -124
  107. package/.docs/flow-io/web-scoping.md +0 -135
  108. package/.docs/flow-io/xynthesis-post.md +0 -154
  109. package/.docs/flow-io/xynthesis-pre.md +0 -181
  110. package/.docs/gap-analysis.md +0 -201
  111. package/.docs/integration-facts-ai-tasks.md +0 -109
  112. package/.docs/investigation/ai-skills.md +0 -170
  113. package/.docs/investigation/external-packages-assignments.md +0 -66
  114. package/.docs/investigation/integration-summary.md +0 -20
  115. package/.docs/investigation/narrix-catalox.md +0 -29
  116. package/.docs/investigation/workplan-close-graph-engine-gaps.md +0 -101
  117. package/.docs/logging-stack.md +0 -30
  118. package/.docs/memory-narrix-adapter-developer-guide.md +0 -402
  119. package/.docs/memory-narrix-adapter-requirements.md +0 -112
  120. package/.docs/narrix-context-consumption-gap.md +0 -184
  121. package/.docs/narrix-context-downstream-report.md +0 -30
  122. package/.docs/narrix-ingest-and-packs-library-spec.md +0 -240
  123. package/.docs/narrix-record-input-current-design.md +0 -48
  124. package/.docs/pacakge.md +0 -48
  125. package/.docs/possible-components/README.md +0 -11
  126. package/.docs/possible-components/integration/README.md +0 -10
  127. package/.docs/possible-components/integration/gaps-when-merging.md +0 -16
  128. package/.docs/possible-components/integration/platform.md +0 -54
  129. package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +0 -26
  130. package/.docs/possible-components/integration/roadmap-and-checklists.md +0 -54
  131. package/.docs/possible-components/post-component/README.md +0 -18
  132. package/.docs/possible-components/post-component/builder-guide.md +0 -175
  133. package/.docs/possible-components/post-component/gaps-and-artifacts.md +0 -52
  134. package/.docs/possible-components/post-component/handler-audit.md +0 -47
  135. package/.docs/possible-components/post-component/handler-polish.md +0 -41
  136. package/.docs/possible-components/post-component/unified-protocol.md +0 -59
  137. package/.docs/possible-components/pre-component/README.md +0 -22
  138. package/.docs/possible-components/pre-component/builder-guide.md +0 -127
  139. package/.docs/possible-components/pre-component/gaps-and-artifacts.md +0 -35
  140. package/.docs/possible-components/pre-component/handler-ai-scoping.md +0 -45
  141. package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +0 -49
  142. package/.docs/possible-components/pre-component/handler-narrix-system2.md +0 -35
  143. package/.docs/possible-components/pre-component/handler-synthesized-context.md +0 -65
  144. package/.docs/possible-components/pre-component/handler-web-scope.md +0 -29
  145. package/.docs/possible-components/pre-component/unified-protocol.md +0 -89
  146. package/.docs/prefer-openrouter-routing-policy.md +0 -114
  147. package/.docs/questions-for-ai-skills.md +0 -123
  148. package/.docs/realtime-narrixing-gap-analysis.md +0 -40
  149. package/.docs/realtime-narrixing.md +0 -433
  150. package/.docs/run-context-object.md +0 -32
  151. package/.docs/session-id-usage.md +0 -26
  152. package/.docs/skill-library-spec.md +0 -249
  153. package/.docs/synthesized-context-strategy-spec.md +0 -906
  154. package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +0 -46
  155. package/.docs/web-scopper-embed.md +0 -93
  156. package/.docs/xynthesis-wiring-and-io.md +0 -12
  157. package/documenations/activix-feature-request-identity.md +0 -123
  158. package/documenations/bug-report-xynthesis-and-synthesis-call.md +0 -217
  159. package/documenations/feature-request-ai-skills-raw-template-access.md +0 -82
  160. package/documenations/feature-request-athenix-core-directive.md +0 -145
  161. package/documenations/feature-request-athenix-token-extraction.md +0 -124
  162. package/documenations/funcx-upstream-github-issues-draft.md +0 -153
  163. package/documenations/identity-metadata-contract.md +0 -165
  164. package/documenations/run-task-single-run-checklist.md +0 -109
  165. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-1-no-concrete-wire-in-graph-plans.md +0 -93
  166. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-2-skillModel-profile-only-at-storage.md +0 -88
  167. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-3-reject-concrete-models-in-catalog-rows.md +0 -76
  168. package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-1-suggested-profile-in-catalogs.md +0 -96
  169. package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-2-graph-engine-failure-phase-attribution.md +0 -92
  170. package/documenations/sessions/2026-06-08-subnets-model-resolution/INVESTIGATION-original-bug.md +0 -182
  171. package/documenations/sessions/2026-06-08-subnets-model-resolution/PROBLEM.md +0 -236
  172. package/documenations/sessions/2026-06-08-subnets-model-resolution/README.md +0 -11
  173. package/documenations/sessions/2026-06-08-subnets-model-resolution/funcx-test-resolveModel.cheapDefaultWireSlug.test.ts +0 -117
  174. package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +0 -129
  175. package/documenations/upstream-feedback-request-shape-clarification.md +0 -101
  176. package/documenations/web-context-precedence.md +0 -33
  177. package/documenations/xynthesis-activix-telemetry.md +0 -28
@@ -1,659 +0,0 @@
1
- # Building a Minimal SDK with Only `runTask` Functionality
2
-
3
- This guide provides step-by-step instructions for creating a new SDK that uses `@woroces/ai-skills` and implements **only** the `runTask` functionality. This is useful when you want a lightweight wrapper that focuses exclusively on task execution without the full feature set of the main SDK.
4
-
5
- ## Table of Contents
6
-
7
- 1. [Overview](#overview)
8
- 2. [Prerequisites](#prerequisites)
9
- 3. [Project Setup](#project-setup)
10
- 4. [Understanding `runTask`](#understanding-runtask)
11
- 5. [Implementation Guide](#implementation-guide)
12
- 6. [Complete Example](#complete-example)
13
- 7. [Testing](#testing)
14
- 8. [Advanced Configuration](#advanced-configuration)
15
- 9. [Troubleshooting](#troubleshooting)
16
-
17
- ---
18
-
19
- ## Overview
20
-
21
- The `runTask` method is a specialized execution method that:
22
- - Executes tasks with a specific execution strategy (currently only `DIRECT`)
23
- - Enriches memories with scoping data (if Context Manager is available)
24
- - Generates context markdown from enriched memories
25
- - Delegates to the underlying skill executor
26
- - Returns structured FlexMD responses
27
-
28
- **Key Difference from `runSkill`**: `runTask` includes additional context enrichment steps and supports execution types, making it suitable for more complex orchestration scenarios.
29
-
30
- ---
31
-
32
- ## Prerequisites
33
-
34
- Before starting, ensure you have:
35
-
36
- - **Node.js** >= 18.0.0
37
- - **npm** or **yarn** package manager
38
- - **TypeScript** knowledge
39
- - Access to GitHub Package Registry (for installing `@woroces/ai-skills`)
40
- - A GitHub token with package read permissions (if using remote content registry)
41
-
42
- ---
43
-
44
- ## Project Setup
45
-
46
- ### Step 1: Initialize Your Project
47
-
48
- ```bash
49
- mkdir my-task-sdk
50
- cd my-task-sdk
51
- npm init -y
52
- ```
53
-
54
- ### Step 2: Install TypeScript and Build Tools
55
-
56
- ```bash
57
- npm install --save-dev typescript @types/node ts-node
58
- ```
59
-
60
- ### Step 3: Configure TypeScript
61
-
62
- Create `tsconfig.json`:
63
-
64
- ```json
65
- {
66
- "compilerOptions": {
67
- "target": "ES2020",
68
- "module": "commonjs",
69
- "lib": ["ES2020"],
70
- "outDir": "./dist",
71
- "rootDir": "./src",
72
- "strict": true,
73
- "esModuleInterop": true,
74
- "skipLibCheck": true,
75
- "forceConsistentCasingInFileNames": true,
76
- "declaration": true,
77
- "declarationMap": true,
78
- "sourceMap": true,
79
- "resolveJsonModule": true
80
- },
81
- "include": ["src/**/*"],
82
- "exclude": ["node_modules", "dist", "**/*.test.ts"]
83
- }
84
- ```
85
-
86
- ### Step 4: Configure npm Registry for GitHub Packages
87
-
88
- Create `.npmrc` file:
89
-
90
- ```
91
- @woroces:registry=https://npm.pkg.github.com
92
- @athenices:registry=https://npm.pkg.github.com
93
- //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN_HERE
94
- ```
95
-
96
- Replace `YOUR_GITHUB_TOKEN_HERE` with your GitHub personal access token that has `read:packages` permission.
97
-
98
- ### Step 5: Install Core Dependencies
99
-
100
- ```bash
101
- npm install @woroces/ai-skills @athenices/ai-gateway
102
- ```
103
-
104
- **Note**: The `@woroces/ai-skills` package will automatically pull in its dependencies:
105
- - `@athenices/ai-gateway` (already listed)
106
- - `@athenices/execution-memory-manager`
107
- - `@athenices/xontext` (optional, for context enrichment)
108
- - `logs-gateway`
109
- - `nx-config2`
110
- - `nx-helpers`
111
-
112
- ### Step 6: Update package.json Scripts
113
-
114
- Add build and development scripts:
115
-
116
- ```json
117
- {
118
- "scripts": {
119
- "build": "tsc",
120
- "dev": "ts-node src/index.ts",
121
- "prepublishOnly": "npm run build"
122
- }
123
- }
124
- ```
125
-
126
- ---
127
-
128
- ## Understanding `runTask`
129
-
130
- ### API Signature
131
-
132
- ```typescript
133
- async runTask<TParsed = any>(
134
- input: RunTaskRequest
135
- ): Promise<RunSkillResponse<TParsed>>
136
- ```
137
-
138
- ### Input Interface: `RunTaskRequest`
139
-
140
- ```typescript
141
- interface RunTaskRequest {
142
- skillKey: string; // "skills/professional-answer" or "tasks/..."
143
- input: Record<string, any> | string; // Task input data
144
- executionType: ExecutionType; // Currently only ExecutionType.DIRECT
145
-
146
- // Optional fields
147
- variables?: Record<string, any>; // Contextual variables (e.g., orgName, tone)
148
- context?: Record<string, any> | string; // Additional context
149
- knowledge?: Record<string, any>; // Knowledge base data
150
-
151
- // Memory management
152
- jobMemory?: JobHistory; // History of all previous task results
153
- taskMemory?: TaskHistory; // History of skills executed up to this task
154
-
155
- // Identifiers
156
- jobId?: string;
157
- agentId?: string;
158
- skillId?: string;
159
- masterSkillId?: string;
160
- masterSkillActivityId?: string;
161
-
162
- // Configuration
163
- timeoutMs?: number; // Request timeout in milliseconds
164
- }
165
- ```
166
-
167
- ### Output Interface: `RunSkillResponse<TParsed>`
168
-
169
- ```typescript
170
- interface RunSkillResponse<TParsed = any> {
171
- skillKey: string; // The skill key that was executed
172
- rawText: string; // Raw response from the gateway
173
- flexMd: {
174
- frame: string; // FlexMD frame name (e.g., "professional-answer")
175
- payloads: Record<string, string>; // Parsed payloads from FlexMD
176
- };
177
- parsed: TParsed; // Typed parsed data (same as payloads by default)
178
- metadata: {
179
- instructionVersion?: string; // Version of the instruction used
180
- activityId?: string; // Unique activity identifier
181
- };
182
- }
183
- ```
184
-
185
- ### ExecutionType Enum
186
-
187
- ```typescript
188
- enum ExecutionType {
189
- DIRECT = "direct" // Currently the only supported type
190
- }
191
- ```
192
-
193
- ### How `runTask` Works Internally
194
-
195
- 1. **Extract Task ID**: Removes `"tasks/"` prefix from `skillKey` if present
196
- 2. **Build Memory Bundle**: Combines `jobMemory` and `taskMemory`
197
- 3. **Enrich Memories** (if Context Manager available):
198
- - Retrieves scoping definitions for the task
199
- - Executes scoping queries
200
- - Integrates results into memory bundle
201
- 4. **Generate Context Markdown** (if Context Manager available):
202
- - Uses context maps to generate markdown from enriched memories
203
- 5. **Execute Task**: Delegates to `TaskExecutor` which:
204
- - For `DIRECT` type: Passes through to `SkillExecutor`
205
- - `SkillExecutor` invokes the AI Gateway
206
- - Parses FlexMD response
207
- - Returns structured result
208
-
209
- ---
210
-
211
- ## Implementation Guide
212
-
213
- ### Step 1: Create the Main SDK Class
214
-
215
- Create `src/task-sdk.ts`:
216
-
217
- ```typescript
218
- import {
219
- XeonoxSkillsClient,
220
- RunTaskRequest,
221
- RunSkillResponse,
222
- ExecutionType
223
- } from "@woroces/ai-skills";
224
- import type { XeonoxSkillsClientOptions } from "@woroces/ai-skills";
225
-
226
- /**
227
- * Minimal Task SDK
228
- *
229
- * A lightweight wrapper around @woroces/ai-skills that provides
230
- * only the runTask functionality.
231
- */
232
- export class TaskSDK {
233
- private client: XeonoxSkillsClient;
234
-
235
- constructor(options?: XeonoxSkillsClientOptions) {
236
- // Initialize the underlying client
237
- // The client handles all the complexity: gateway setup, registry management, etc.
238
- this.client = new XeonoxSkillsClient(options);
239
- }
240
-
241
- /**
242
- * Execute a task with the specified execution type.
243
- *
244
- * @param request The task execution request
245
- * @returns Promise resolving to the task response
246
- */
247
- async runTask<TParsed = any>(
248
- request: RunTaskRequest
249
- ): Promise<RunSkillResponse<TParsed>> {
250
- // Ensure executionType is set (default to DIRECT if not provided)
251
- const taskRequest: RunTaskRequest = {
252
- ...request,
253
- executionType: request.executionType || ExecutionType.DIRECT
254
- };
255
-
256
- // Delegate to the underlying client
257
- return this.client.runTask<TParsed>(taskRequest);
258
- }
259
-
260
- /**
261
- * Convenience method for direct task execution.
262
- *
263
- * @param skillKey The skill key to execute
264
- * @param input The input data
265
- * @param options Optional additional parameters
266
- */
267
- async executeDirect<TParsed = any>(
268
- skillKey: string,
269
- input: Record<string, any> | string,
270
- options?: {
271
- variables?: Record<string, any>;
272
- context?: Record<string, any> | string;
273
- knowledge?: Record<string, any>;
274
- jobMemory?: any;
275
- taskMemory?: any;
276
- jobId?: string;
277
- agentId?: string;
278
- timeoutMs?: number;
279
- }
280
- ): Promise<RunSkillResponse<TParsed>> {
281
- return this.runTask<TParsed>({
282
- skillKey,
283
- input,
284
- executionType: ExecutionType.DIRECT,
285
- ...options
286
- });
287
- }
288
- }
289
-
290
- // Re-export types for convenience
291
- export type { RunTaskRequest, RunSkillResponse } from "@woroces/ai-skills";
292
- export { ExecutionType } from "@woroces/ai-skills";
293
- ```
294
-
295
- ### Step 2: Create the Main Entry Point
296
-
297
- Create `src/index.ts`:
298
-
299
- ```typescript
300
- export { TaskSDK } from "./task-sdk";
301
- export type { RunTaskRequest, RunSkillResponse } from "@woroces/ai-skills";
302
- export { ExecutionType } from "@woroces/ai-skills";
303
- ```
304
-
305
- ### Step 3: Update package.json
306
-
307
- Add proper metadata:
308
-
309
- ```json
310
- {
311
- "name": "my-task-sdk",
312
- "version": "1.0.0",
313
- "description": "Minimal SDK for task execution using @woroces/ai-skills",
314
- "main": "dist/index.js",
315
- "types": "dist/index.d.ts",
316
- "files": ["dist"],
317
- "keywords": ["ai", "tasks", "llm", "skills"],
318
- "author": "Your Name",
319
- "license": "ISC"
320
- }
321
- ```
322
-
323
- ---
324
-
325
- ## Complete Example
326
-
327
- ### Example 1: Basic Usage
328
-
329
- Create `examples/basic-usage.ts`:
330
-
331
- ```typescript
332
- import { TaskSDK, ExecutionType } from "../src";
333
- import * as dotenv from "dotenv";
334
-
335
- dotenv.config();
336
-
337
- async function basicExample() {
338
- // Initialize the SDK
339
- const sdk = new TaskSDK({
340
- packageName: "MY-TASK-SDK",
341
- enableContentRegistry: true,
342
- contentRegistryLocalPath: "./.metadata" // or use remote registry
343
- });
344
-
345
- // Execute a task
346
- const result = await sdk.runTask({
347
- skillKey: "skills/professional-answer",
348
- executionType: ExecutionType.DIRECT,
349
- input: {
350
- question: "What is the capital of France?"
351
- },
352
- variables: {
353
- orgName: "MyOrganization",
354
- tone: "professional"
355
- }
356
- });
357
-
358
- console.log("Task executed successfully!");
359
- console.log("Frame:", result.flexMd.frame);
360
- console.log("Payloads:", result.flexMd.payloads);
361
- console.log("Parsed:", result.parsed);
362
- }
363
-
364
- basicExample().catch(console.error);
365
- ```
366
-
367
- ### Example 2: Using Convenience Method
368
-
369
- ```typescript
370
- import { TaskSDK } from "../src";
371
-
372
- async function convenienceExample() {
373
- const sdk = new TaskSDK({
374
- enableContentRegistry: true
375
- });
376
-
377
- const result = await sdk.executeDirect(
378
- "skills/professional-answer",
379
- { question: "Explain quantum computing" },
380
- {
381
- variables: { orgName: "TechCorp" },
382
- jobId: "job-123",
383
- agentId: "agent-abc"
384
- }
385
- );
386
-
387
- // Access the structured response
388
- const shortAnswer = result.flexMd.payloads.shortAnswer;
389
- const fullAnswer = result.flexMd.payloads.fullAnswer;
390
-
391
- console.log("Short Answer:", shortAnswer);
392
- console.log("Full Answer:", fullAnswer);
393
- }
394
-
395
- convenienceExample().catch(console.error);
396
- ```
397
-
398
- ### Example 3: With Memory Management
399
-
400
- ```typescript
401
- import { TaskSDK, ExecutionType } from "../src";
402
- import type { JobHistory, TaskHistory } from "@athenices/execution-memory-manager";
403
-
404
- async function withMemoryExample() {
405
- const sdk = new TaskSDK();
406
-
407
- // Build up memory from previous tasks
408
- const jobMemory: JobHistory = {
409
- // Previous task results
410
- };
411
-
412
- const taskMemory: TaskHistory = {
413
- // Previous skill executions
414
- };
415
-
416
- const result = await sdk.runTask({
417
- skillKey: "skills/professional-decision",
418
- executionType: ExecutionType.DIRECT,
419
- input: {
420
- scenario: "Should we migrate to cloud?"
421
- },
422
- variables: {
423
- orgName: "EnterpriseCorp"
424
- },
425
- jobMemory,
426
- taskMemory,
427
- jobId: "job-456"
428
- });
429
-
430
- console.log("Decision:", result.parsed);
431
- }
432
-
433
- withMemoryExample().catch(console.error);
434
- ```
435
-
436
- ---
437
-
438
- ## Testing
439
-
440
- ### Step 1: Create Test File
441
-
442
- Create `src/task-sdk.test.ts`:
443
-
444
- ```typescript
445
- import { TaskSDK, ExecutionType } from "./task-sdk";
446
- import * as dotenv from "dotenv";
447
-
448
- dotenv.config();
449
-
450
- describe("TaskSDK", () => {
451
- let sdk: TaskSDK;
452
-
453
- beforeAll(() => {
454
- sdk = new TaskSDK({
455
- packageName: "TEST-SDK",
456
- enableContentRegistry: true,
457
- contentRegistryLocalPath: "./.metadata"
458
- });
459
- });
460
-
461
- test("should execute a direct task", async () => {
462
- const result = await sdk.runTask({
463
- skillKey: "skills/professional-answer",
464
- executionType: ExecutionType.DIRECT,
465
- input: {
466
- question: "What is 2+2?"
467
- },
468
- variables: {
469
- orgName: "TestOrg"
470
- }
471
- });
472
-
473
- expect(result).toBeDefined();
474
- expect(result.skillKey).toBe("skills/professional-answer");
475
- expect(result.flexMd).toBeDefined();
476
- expect(result.flexMd.frame).toBeDefined();
477
- expect(result.flexMd.payloads).toBeDefined();
478
- });
479
-
480
- test("should use convenience method", async () => {
481
- const result = await sdk.executeDirect(
482
- "skills/professional-answer",
483
- { question: "Test question" }
484
- );
485
-
486
- expect(result).toBeDefined();
487
- expect(result.skillKey).toBe("skills/professional-answer");
488
- });
489
- });
490
- ```
491
-
492
- ### Step 2: Install Testing Dependencies
493
-
494
- ```bash
495
- npm install --save-dev jest @types/jest ts-jest
496
- ```
497
-
498
- ### Step 3: Configure Jest
499
-
500
- Create `jest.config.js`:
501
-
502
- ```javascript
503
- module.exports = {
504
- preset: 'ts-jest',
505
- testEnvironment: 'node',
506
- roots: ['<rootDir>/src'],
507
- testMatch: ['**/*.test.ts'],
508
- collectCoverageFrom: ['src/**/*.ts', '!src/**/*.test.ts']
509
- };
510
- ```
511
-
512
- ---
513
-
514
- ## Advanced Configuration
515
-
516
- ### Environment Variables
517
-
518
- The SDK uses environment variables for automatic configuration (ERC mode):
519
-
520
- ```bash
521
- # Required for GitHub-based content registry
522
- export GITHUB_TOKEN=your_github_token
523
- export GITHUB_REPO_URL=https://github.com/your-org/content-registry
524
-
525
- # AI Provider Keys (at least one required)
526
- export OPENAI_API_KEY=your_openai_key
527
- # OR
528
- export GROK_API_KEY=your_grok_key
529
-
530
- # Optional: MongoDB for context enrichment
531
- export MONGODB_URI=mongodb://localhost:27017/your-db
532
- ```
533
-
534
- ### Custom Gateway Configuration
535
-
536
- You can provide a pre-configured gateway:
537
-
538
- ```typescript
539
- import { AIGateway } from "@athenices/ai-gateway";
540
- import { TaskSDK } from "./src";
541
-
542
- // Create custom gateway
543
- const gateway = new AIGateway({
544
- packageName: "CUSTOM-GATEWAY",
545
- enableActivityTracking: true,
546
- enableContentRegistry: true,
547
- // ... other gateway options
548
- });
549
-
550
- // Use it in the SDK
551
- const sdk = new TaskSDK({
552
- gateway: gateway
553
- });
554
- ```
555
-
556
- ### Local Development Mode
557
-
558
- For offline development:
559
-
560
- ```typescript
561
- const sdk = new TaskSDK({
562
- enableContentRegistry: true,
563
- contentRegistryLocalPath: "./local-metadata",
564
- forceLocal: true, // Bypass remote registry
565
- forceCreateRootDirectory: true // Auto-create directories
566
- });
567
- ```
568
-
569
- ---
570
-
571
- ## Troubleshooting
572
-
573
- ### Issue: "Content not found" Error
574
-
575
- **Problem**: The skill key cannot be resolved.
576
-
577
- **Solutions**:
578
- 1. Verify the skill key format: `"skills/professional-answer"` (not `"professional-answer"`)
579
- 2. Ensure content registry contains the skill at the expected path
580
- 3. Check `contentRegistryLocalPath` if using local registry
581
- 4. Verify `GITHUB_TOKEN` and `GITHUB_REPO_URL` if using remote registry
582
-
583
- ### Issue: "Repository not accessible"
584
-
585
- **Problem**: Cannot connect to GitHub content registry.
586
-
587
- **Solutions**:
588
- 1. Verify `GITHUB_TOKEN` has correct permissions (`repo` scope for private repos)
589
- 2. Check `GITHUB_REPO_URL` points to an existing repository
590
- 3. Ensure repository is accessible (not private without proper token)
591
-
592
- ### Issue: "Unsupported execution type"
593
-
594
- **Problem**: Using an execution type other than `DIRECT`.
595
-
596
- **Solution**: Currently only `ExecutionType.DIRECT` is supported. Ensure you're using:
597
- ```typescript
598
- executionType: ExecutionType.DIRECT
599
- ```
600
-
601
- ### Issue: "Environment validation failed"
602
-
603
- **Problem**: Missing required environment variables.
604
-
605
- **Solutions**:
606
- 1. Ensure at least one AI provider key is set (`OPENAI_API_KEY` or `GROK_API_KEY`)
607
- 2. If using remote registry, set `GITHUB_TOKEN` and `GITHUB_REPO_URL`
608
- 3. Check `.env` file is loaded (if using `dotenv`)
609
-
610
- ### Issue: TypeScript compilation errors
611
-
612
- **Problem**: Type definitions not found.
613
-
614
- **Solutions**:
615
- 1. Ensure `@woroces/ai-skills` is installed: `npm install @woroces/ai-skills`
616
- 2. Check `tsconfig.json` includes proper module resolution
617
- 3. Verify `skipLibCheck: true` in `tsconfig.json` if needed
618
-
619
- ---
620
-
621
- ## Summary
622
-
623
- You've now created a minimal SDK that:
624
-
625
- 1. ✅ Wraps `@woroces/ai-skills` with a focused API
626
- 2. ✅ Provides only `runTask` functionality
627
- 3. ✅ Includes convenience methods for common use cases
628
- 4. ✅ Handles all underlying complexity (gateway, registry, parsing)
629
- 5. ✅ Supports both local and remote content registries
630
- 6. ✅ Includes proper TypeScript types
631
-
632
- ### Key Takeaways
633
-
634
- - **Minimal Surface Area**: Your SDK only exposes `runTask`, keeping the API simple
635
- - **Full Power Underneath**: You still get all the benefits of the full SDK (context enrichment, memory management, FlexMD parsing)
636
- - **Easy to Extend**: You can add more methods later if needed
637
- - **Type Safe**: Full TypeScript support with proper type inference
638
-
639
- ### Next Steps
640
-
641
- 1. Add error handling wrappers
642
- 2. Implement retry logic
643
- 3. Add request/response logging
644
- 4. Create additional convenience methods
645
- 5. Add validation for inputs
646
- 6. Implement caching if needed
647
-
648
- ---
649
-
650
- ## Additional Resources
651
-
652
- - [@woroces/ai-skills README](../README.md) - Full SDK documentation
653
- - [FlexMD Format Documentation](../docs/metadata.md) - Understanding FlexMD responses
654
- - [Content Registry Guide](../README.md#content-registry) - Setting up content registry
655
- - [AI Gateway Documentation](https://github.com/athenices/ai-gateway) - Understanding the underlying gateway
656
-
657
- ---
658
-
659
- **Questions?** Check the main SDK documentation or open an issue in the repository.