taskforceai-sdk 1.2.1 → 1.3.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/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ MIT License with Attribution Requirement for Large-Scale Commercial Use
2
+
3
+ Copyright (c) 2025 Clay Warren
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ ADDITIONAL COMMERCIAL ATTRIBUTION REQUIREMENT:
16
+ If you use this Software, in whole or in part, in any product, service, or
17
+ application that serves more than 100,000 users, you must:
18
+
19
+ 1. Provide clear attribution to Clay Warren as the original creator
20
+ 2. Include a statement that your product uses the "TaskForceAI" framework
21
+ 3. This attribution must be visible in one of the following locations:
22
+ - Product documentation
23
+ - About page/section
24
+ - Credits section
25
+ - Help/support documentation
26
+ - Or equivalent user-accessible location
27
+
28
+ Example attribution: "Powered by TaskForceAI by Clay Warren"
29
+ or "Uses TaskForceAI multi-agent system created by Clay Warren"
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
package/README.md CHANGED
@@ -38,6 +38,22 @@ for await (const status of stream) {
38
38
  }
39
39
  ```
40
40
 
41
+ ## Mock Mode
42
+
43
+ Build and test your integration without an API key using mock mode:
44
+
45
+ ```typescript
46
+ import { TaskForceAI } from 'taskforceai-sdk';
47
+
48
+ // No API key required in mock mode
49
+ const client = new TaskForceAI({ mockMode: true });
50
+
51
+ const result = await client.runTask('Test your integration');
52
+ console.log(result.result); // "This is a mock response. Configure your API key to get real results."
53
+ ```
54
+
55
+ Mock mode simulates the full task lifecycle locally—no network requests are made. Tasks go through "processing" then "completed" states, making it easy to build UIs and test error handling before launch.
56
+
41
57
  ## API Reference
42
58
 
43
59
  ### TaskForceAI
@@ -52,10 +68,11 @@ constructor(options: TaskForceAIOptions)
52
68
 
53
69
  **Options:**
54
70
 
55
- - `apiKey` (required): Your API key
71
+ - `apiKey` (required unless `mockMode` is true): Your API key
56
72
  - `baseUrl` (optional): API base URL (default: https://taskforceai.chat/api/developer)
57
73
  - `timeout` (optional): Request timeout in milliseconds (default: 30000)
58
74
  - `responseHook` (optional): Callback invoked with every raw `fetch` response
75
+ - `mockMode` (optional): Enable mock mode for development without an API key (default: false)
59
76
 
60
77
  #### Methods
61
78
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { TaskForceAIError, transportDefaults as def } from './transport';
2
3
  import type { TaskForceAIOptions, TaskResult, TaskStatus, TaskStatusCallback, TaskStatusStream, TaskSubmissionOptions } from './types';
3
4
  import { VERSION } from './types';
@@ -6,7 +7,10 @@ export declare class TaskForceAI {
6
7
  private url;
7
8
  private t;
8
9
  private rh?;
10
+ private mm;
11
+ private mcc;
9
12
  constructor(o: TaskForceAIOptions);
13
+ private mockResponse;
10
14
  private req;
11
15
  submitTask(p: string, o?: TaskSubmissionOptions): Promise<string>;
12
16
  getTaskStatus(id: any): Promise<TaskStatus>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","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qBAA0B,EAC7B,EAAE,OAAqB,EACvB,GAAG,MAAsB,EACzB,EAAE,CAAC,EAAE,kBAAkB;IAKzB,gBAAgB,CACd,EAAE,EAAE,GAAG,EACP,EAAE,OAAqB,EACvB,GAAG,MAAsB,EACzB,EAAE,CAAC,EAAE,kBAAkB,EACvB,GAAG,CAAC,EAAE,WAAW,GAChB,gBAAgB;IAgBb,aAAa,CACjB,CAAC,EAAE,MAAM,EACT,CAAC,GAAE,qBAA0B,EAC7B,EAAE,OAAqB,EACvB,GAAG,MAAsB,EACzB,EAAE,CAAC,EAAE,kBAAkB,EACvB,GAAG,CAAC,EAAE,WAAW;CAIpB;AAED,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,OAAO,EACP,GAAG,IAAI,iBAAiB,GACzB,CAAC"}
package/dist/index.js CHANGED
@@ -9,14 +9,46 @@ Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () {
9
9
  const sleep = (ms) => new Promise((resolve) => {
10
10
  setTimeout(() => resolve(), ms);
11
11
  });
12
+ const MOCK_RESULT = 'This is a mock response. Configure your API key to get real results.';
12
13
  class TaskForceAI {
13
14
  constructor(o) {
14
- this.req = (e, i = {}, r = false) => (0, transport_1.makeRequest)(e, i, { apiKey: this.ak, baseUrl: this.url, timeout: this.t, responseHook: this.rh }, r, transport_1.transportDefaults.maxRetries);
15
- this.ak = o.apiKey;
15
+ this.mcc = new Map();
16
+ this.req = (e, i = {}, r = false) => {
17
+ if (this.mm) {
18
+ return Promise.resolve(this.mockResponse(e, i.method || 'GET'));
19
+ }
20
+ return (0, transport_1.makeRequest)(e, i, { apiKey: this.ak, baseUrl: this.url, timeout: this.t, responseHook: this.rh }, r, transport_1.transportDefaults.maxRetries);
21
+ };
22
+ this.mm = o.mockMode ?? false;
23
+ if (!this.mm && !o.apiKey) {
24
+ throw new transport_1.TaskForceAIError('API key is required when not in mock mode');
25
+ }
26
+ this.ak = o.apiKey || '';
16
27
  this.url = o.baseUrl || 'https://taskforceai.chat/api/developer';
17
28
  this.t = o.timeout || transport_1.transportDefaults.timeout;
18
29
  this.rh = o.responseHook;
19
30
  }
31
+ mockResponse(e, method) {
32
+ if (method === 'POST' && e === '/run') {
33
+ const taskId = `mock-${Math.random().toString(36).slice(2, 10)}`;
34
+ this.mcc.set(taskId, 0);
35
+ return { taskId, status: 'processing' };
36
+ }
37
+ if (e.startsWith('/status/')) {
38
+ const taskId = e.split('/').pop();
39
+ const count = this.mcc.get(taskId) || 0;
40
+ this.mcc.set(taskId, count + 1);
41
+ if (count < 1) {
42
+ return { taskId, status: 'processing', message: 'Mock task processing...' };
43
+ }
44
+ return { taskId, status: 'completed', result: MOCK_RESULT };
45
+ }
46
+ if (e.startsWith('/results/')) {
47
+ const taskId = e.split('/').pop();
48
+ return { taskId, status: 'completed', result: MOCK_RESULT };
49
+ }
50
+ return { status: 'ok' };
51
+ }
20
52
  async submitTask(p, o = {}) {
21
53
  if (typeof p !== 'string' || !p.trim())
22
54
  throw new transport_1.TaskForceAIError('Prompt must be a non-empty string');
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  export declare class TaskForceAIError extends Error {
2
3
  statusCode?: number | undefined;
3
4
  constructor(message: string, statusCode?: number | undefined);
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAsCA,qBAAa,gBAAiB,SAAQ,KAAK;IAGhC,UAAU,CAAC,EAAE,MAAM;gBAD1B,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA;CAK7B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,WAAW,GAAU,CAAC,EACjC,UAAU,MAAM,EAChB,SAAS,WAAW,EACpB,4CAA4C,eAAe,EAC3D,mBAAiB,EACjB,mBAAgC,KAC/B,OAAO,CAAC,CAAC,CAyDX,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":";AAsCA,qBAAa,gBAAiB,SAAQ,KAAK;IAGhC,UAAU,CAAC;gBADlB,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,oBAAQ;CAK7B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,WAAW,gBACZ,MAAM,WACP,WAAW,8CACwB,eAAe,yDA4D5D,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ /// <reference types="node" />
1
2
  export declare const VERSION = "1.2.1";
2
3
  export interface TaskForceAIOptions {
3
- apiKey: string;
4
+ apiKey?: string;
4
5
  baseUrl?: string;
5
6
  timeout?: number;
6
7
  responseHook?: TaskResponseHook;
8
+ mockMode?: boolean;
7
9
  }
8
10
  export type TaskSubmissionOptions = {
9
11
  [key: string]: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,g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qBAAqB,GAAG;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAC9D,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAE5D,MAAM,WAAW,gBAAiB,SAAQ,aAAa,CAAC,UAAU,CAAC;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,IAAI,IAAI,CAAC;CAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskforceai-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "TypeScript SDK for TaskForceAI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,10 +27,10 @@
27
27
  "license": "MIT",
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "git+https://github.com/ClayWarren/grok4fastheavy.git"
30
+ "url": "git+https://github.com/ClayWarren/taskforceai-sdk-typescript.git"
31
31
  },
32
32
  "bugs": {
33
- "url": "https://github.com/ClayWarren/grok4fastheavy/issues"
33
+ "url": "https://github.com/ClayWarren/taskforceai-sdk-typescript/issues"
34
34
  },
35
35
  "homepage": "https://taskforceai.chat",
36
36
  "engines": {