@campfire-interactive/cfi-ai-hub-client 2.0.1 → 2.0.3

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 (51) hide show
  1. package/dist/ai.d.ts +16 -1
  2. package/dist/ai.d.ts.map +1 -1
  3. package/dist/ai.js +27 -0
  4. package/dist/ai.js.map +1 -1
  5. package/dist/client.d.ts +14 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +22 -0
  8. package/dist/client.js.map +1 -1
  9. package/dist/conversations.d.ts +28 -0
  10. package/dist/conversations.d.ts.map +1 -0
  11. package/dist/conversations.js +74 -0
  12. package/dist/conversations.js.map +1 -0
  13. package/dist/documents.d.ts +18 -0
  14. package/dist/documents.d.ts.map +1 -0
  15. package/dist/documents.js +28 -0
  16. package/dist/documents.js.map +1 -0
  17. package/dist/forecast.d.ts +61 -0
  18. package/dist/forecast.d.ts.map +1 -0
  19. package/dist/forecast.js +164 -0
  20. package/dist/forecast.js.map +1 -0
  21. package/dist/http.d.ts +12 -0
  22. package/dist/http.d.ts.map +1 -1
  23. package/dist/http.js +73 -0
  24. package/dist/http.js.map +1 -1
  25. package/dist/index.d.ts +8 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +16 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/jobs.d.ts +33 -0
  30. package/dist/jobs.d.ts.map +1 -0
  31. package/dist/jobs.js +79 -0
  32. package/dist/jobs.js.map +1 -0
  33. package/dist/macro.d.ts +35 -0
  34. package/dist/macro.d.ts.map +1 -0
  35. package/dist/macro.js +64 -0
  36. package/dist/macro.js.map +1 -0
  37. package/dist/mock.d.ts +31 -1
  38. package/dist/mock.d.ts.map +1 -1
  39. package/dist/mock.js +249 -0
  40. package/dist/mock.js.map +1 -1
  41. package/dist/prompts.d.ts +24 -0
  42. package/dist/prompts.d.ts.map +1 -0
  43. package/dist/prompts.js +71 -0
  44. package/dist/prompts.js.map +1 -0
  45. package/dist/rag.d.ts +18 -0
  46. package/dist/rag.d.ts.map +1 -0
  47. package/dist/rag.js +39 -0
  48. package/dist/rag.js.map +1 -0
  49. package/dist/types.d.ts +415 -0
  50. package/dist/types.d.ts.map +1 -1
  51. package/package.json +35 -35
package/dist/ai.d.ts CHANGED
@@ -1,9 +1,24 @@
1
1
  import type { HttpTransport } from './http';
2
- import type { ChatRequest, ChatResponse, EmbeddingRequest, EmbeddingResponse, SentimentRequest, SentimentResponse, SummarizeRequest, SummarizeResponse } from './types';
2
+ import type { ChatChunk, ChatRequest, ChatResponse, EmbeddingRequest, EmbeddingResponse, SentimentRequest, SentimentResponse, StreamingChatRequest, StructuredRequest, StructuredResponse, SummarizeRequest, SummarizeResponse } from './types';
3
3
  export declare class AiResource {
4
4
  private readonly http;
5
5
  constructor(http: HttpTransport);
6
6
  chat(input: ChatRequest): Promise<ChatResponse>;
7
+ /**
8
+ * Stream a multi-turn chat completion. Yields ChatChunk events
9
+ * (`chunk` / `tool_call` / `done` / `error`).
10
+ *
11
+ * Errors emitted by the hub mid-stream surface as a final
12
+ * `{type: 'error', error: {...}}` chunk and end the iterator —
13
+ * callers don't need try/catch around `for await`.
14
+ */
15
+ chatStream(input: StreamingChatRequest): AsyncIterable<ChatChunk>;
16
+ /**
17
+ * Force a JSON-schema-validated structured response. The hub retries
18
+ * up to `max_repair_retries` times on validation failure before
19
+ * surfacing 422 InvalidOutputError.
20
+ */
21
+ structured(input: StructuredRequest): Promise<StructuredResponse>;
7
22
  embeddings(input: EmbeddingRequest): Promise<EmbeddingResponse>;
8
23
  sentiment(input: SentimentRequest): Promise<SentimentResponse>;
9
24
  summarize(input: SummarizeRequest): Promise<SummarizeResponse>;
package/dist/ai.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,E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AAC;IAQ/D,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAQ9D,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAOrE"}
package/dist/ai.js CHANGED
@@ -13,6 +13,33 @@ class AiResource {
13
13
  body: input,
14
14
  });
15
15
  }
16
+ /**
17
+ * Stream a multi-turn chat completion. Yields ChatChunk events
18
+ * (`chunk` / `tool_call` / `done` / `error`).
19
+ *
20
+ * Errors emitted by the hub mid-stream surface as a final
21
+ * `{type: 'error', error: {...}}` chunk and end the iterator —
22
+ * callers don't need try/catch around `for await`.
23
+ */
24
+ chatStream(input) {
25
+ return this.http.streamSse({
26
+ method: 'POST',
27
+ path: '/ai/chat/stream',
28
+ body: input,
29
+ });
30
+ }
31
+ /**
32
+ * Force a JSON-schema-validated structured response. The hub retries
33
+ * up to `max_repair_retries` times on validation failure before
34
+ * surfacing 422 InvalidOutputError.
35
+ */
36
+ async structured(input) {
37
+ return this.http.request({
38
+ method: 'POST',
39
+ path: '/ai/structured',
40
+ body: input,
41
+ });
42
+ }
16
43
  async embeddings(input) {
17
44
  return this.http.request({
18
45
  method: 'POST',
package/dist/ai.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":";;;AAYA,MAAa,UAAU;IACQ;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,IAAI,CAAC,KAAkB;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAe;YACrC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAuB;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB;YAC1C,MAAM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,KAAK,CAAC,UAAU,CAAC,KAAuB;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAuB;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAuB;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AA/DD,gCA+DC"}
package/dist/client.d.ts CHANGED
@@ -4,6 +4,13 @@ import { OmsfResource } from './omsf';
4
4
  import { VendorResource } from './vendor';
5
5
  import { TrackerResource } from './tracker';
6
6
  import { CacheResource } from './cache';
7
+ import { ForecastResource } from './forecast';
8
+ import { MacroResource } from './macro';
9
+ import { JobsResource } from './jobs';
10
+ import { PromptsResource } from './prompts';
11
+ import { RagResource } from './rag';
12
+ import { ConversationsResource } from './conversations';
13
+ import { DocumentsResource } from './documents';
7
14
  import type { CfiAiHubClientConfig } from './types';
8
15
  export declare class CfiAiHubClient {
9
16
  readonly ai: AiResource;
@@ -12,6 +19,13 @@ export declare class CfiAiHubClient {
12
19
  readonly vendor: VendorResource;
13
20
  readonly tracker: TrackerResource;
14
21
  readonly cache: CacheResource;
22
+ readonly forecast: ForecastResource;
23
+ readonly macro: MacroResource;
24
+ readonly jobs: JobsResource;
25
+ readonly prompts: PromptsResource;
26
+ readonly rag: RagResource;
27
+ readonly conversations: ConversationsResource;
28
+ readonly documents: DocumentsResource;
15
29
  constructor(config: CfiAiHubClientConfig);
16
30
  }
17
31
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,qBAAa,cAAc;IACzB,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;gBAElB,MAAM,EAAE,oBAAoB;CASzC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,qBAAa,cAAc;IACzB,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;gBAE1B,MAAM,EAAE,oBAAoB;CAgBzC"}
package/dist/client.js CHANGED
@@ -8,6 +8,13 @@ const omsf_1 = require("./omsf");
8
8
  const vendor_1 = require("./vendor");
9
9
  const tracker_1 = require("./tracker");
10
10
  const cache_1 = require("./cache");
11
+ const forecast_1 = require("./forecast");
12
+ const macro_1 = require("./macro");
13
+ const jobs_1 = require("./jobs");
14
+ const prompts_1 = require("./prompts");
15
+ const rag_1 = require("./rag");
16
+ const conversations_1 = require("./conversations");
17
+ const documents_1 = require("./documents");
11
18
  class CfiAiHubClient {
12
19
  ai;
13
20
  bom;
@@ -15,6 +22,14 @@ class CfiAiHubClient {
15
22
  vendor;
16
23
  tracker;
17
24
  cache;
25
+ forecast;
26
+ macro;
27
+ // Phase 1 additions (1.1.0)
28
+ jobs;
29
+ prompts;
30
+ rag;
31
+ conversations;
32
+ documents;
18
33
  constructor(config) {
19
34
  const http = new http_1.HttpTransport(config);
20
35
  this.ai = new ai_1.AiResource(http);
@@ -23,6 +38,13 @@ class CfiAiHubClient {
23
38
  this.vendor = new vendor_1.VendorResource(http);
24
39
  this.tracker = new tracker_1.TrackerResource(http);
25
40
  this.cache = new cache_1.CacheResource(http);
41
+ this.forecast = new forecast_1.ForecastResource(http);
42
+ this.macro = new macro_1.MacroResource(http);
43
+ this.jobs = new jobs_1.JobsResource(http);
44
+ this.prompts = new prompts_1.PromptsResource(http);
45
+ this.rag = new rag_1.RagResource(http);
46
+ this.conversations = new conversations_1.ConversationsResource(http);
47
+ this.documents = new documents_1.DocumentsResource(http);
26
48
  }
27
49
  }
28
50
  exports.CfiAiHubClient = CfiAiHubClient;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;AACvC,6BAAkC;AAClC,+BAAoC;AACpC,iCAAsC;AACtC,qCAA0C;AAC1C,uCAA4C;AAC5C,mCAAwC;AAGxC,MAAa,cAAc;IAChB,EAAE,CAAa;IACf,GAAG,CAAc;IACjB,IAAI,CAAe;IACnB,MAAM,CAAiB;IACvB,OAAO,CAAkB;IACzB,KAAK,CAAgB;IAE9B,YAAY,MAA4B;QACtC,MAAM,IAAI,GAAG,IAAI,oBAAa,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,GAAG,IAAI,eAAU,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,IAAI,iBAAW,CAAC,IAAI,CAAC,CAAC;QACjC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IAAI,yBAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAY,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,GAAG,IAAI,iBAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,IAAI,qCAAqB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF;AAhCD,wCAgCC"}
@@ -0,0 +1,28 @@
1
+ import type { HttpTransport } from './http';
2
+ import type { AppendMessageRequest, ChatChunk, ConversationListOptions, ConversationListResponse, ConversationMessageResponse, ConversationResponse, CreateConversationRequest } from './types';
3
+ /**
4
+ * Multi-turn chat thread persistence (capability C15).
5
+ *
6
+ * Conversations are tenant-scoped; cross-tenant reads return 404. Use
7
+ * {@link list} with metadata filters (`rfq_id`, `bom_id`, `program_id`,
8
+ * `feature`) to find threads scoped to a business entity.
9
+ */
10
+ export declare class ConversationsResource {
11
+ private readonly http;
12
+ constructor(http: HttpTransport);
13
+ create(input?: CreateConversationRequest): Promise<ConversationResponse>;
14
+ list(options?: ConversationListOptions): Promise<ConversationListResponse>;
15
+ get(conversationId: string): Promise<ConversationResponse>;
16
+ delete(conversationId: string): Promise<void>;
17
+ /** Plain append — useful when caller already has the assistant reply. */
18
+ appendMessage(conversationId: string, input: AppendMessageRequest): Promise<ConversationMessageResponse>;
19
+ /**
20
+ * Append a user message and stream the assistant reply (SSE).
21
+ * Persists the user message immediately + the assistant message on
22
+ * stream completion (with usage metadata).
23
+ *
24
+ * Same chunk shape as {@link AiResource.chatStream}.
25
+ */
26
+ appendMessageStream(conversationId: string, input: AppendMessageRequest): AsyncIterable<ChatChunk>;
27
+ }
28
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../src/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,MAAM,CACV,KAAK,GAAE,yBAA8B,GACpC,OAAO,CAAC,oBAAoB,CAAC;IAQ1B,IAAI,CACR,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,wBAAwB,CAAC;IAgB9B,GAAG,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAO1D,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD,yEAAyE;IACnE,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,2BAA2B,CAAC;IAQvC;;;;;;OAMG;IACH,mBAAmB,CACjB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,oBAAoB,GAC1B,aAAa,CAAC,SAAS,CAAC;CAO5B"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConversationsResource = void 0;
4
+ /**
5
+ * Multi-turn chat thread persistence (capability C15).
6
+ *
7
+ * Conversations are tenant-scoped; cross-tenant reads return 404. Use
8
+ * {@link list} with metadata filters (`rfq_id`, `bom_id`, `program_id`,
9
+ * `feature`) to find threads scoped to a business entity.
10
+ */
11
+ class ConversationsResource {
12
+ http;
13
+ constructor(http) {
14
+ this.http = http;
15
+ }
16
+ async create(input = {}) {
17
+ return this.http.request({
18
+ method: 'POST',
19
+ path: '/ai/conversations',
20
+ body: input,
21
+ });
22
+ }
23
+ async list(options = {}) {
24
+ return this.http.request({
25
+ method: 'GET',
26
+ path: '/ai/conversations',
27
+ query: {
28
+ user_only: options.user_only,
29
+ include_deleted: options.include_deleted,
30
+ limit: options.limit,
31
+ rfq_id: options.rfq_id,
32
+ bom_id: options.bom_id,
33
+ program_id: options.program_id,
34
+ feature: options.feature,
35
+ },
36
+ });
37
+ }
38
+ async get(conversationId) {
39
+ return this.http.request({
40
+ method: 'GET',
41
+ path: `/ai/conversations/${encodeURIComponent(conversationId)}`,
42
+ });
43
+ }
44
+ async delete(conversationId) {
45
+ await this.http.request({
46
+ method: 'DELETE',
47
+ path: `/ai/conversations/${encodeURIComponent(conversationId)}`,
48
+ });
49
+ }
50
+ /** Plain append — useful when caller already has the assistant reply. */
51
+ async appendMessage(conversationId, input) {
52
+ return this.http.request({
53
+ method: 'POST',
54
+ path: `/ai/conversations/${encodeURIComponent(conversationId)}/messages`,
55
+ body: input,
56
+ });
57
+ }
58
+ /**
59
+ * Append a user message and stream the assistant reply (SSE).
60
+ * Persists the user message immediately + the assistant message on
61
+ * stream completion (with usage metadata).
62
+ *
63
+ * Same chunk shape as {@link AiResource.chatStream}.
64
+ */
65
+ appendMessageStream(conversationId, input) {
66
+ return this.http.streamSse({
67
+ method: 'POST',
68
+ path: `/ai/conversations/${encodeURIComponent(conversationId)}/messages/stream`,
69
+ body: input,
70
+ });
71
+ }
72
+ }
73
+ exports.ConversationsResource = ConversationsResource;
74
+ //# sourceMappingURL=conversations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AK,CAAC,aAAa,CACjB,cAAsB,EACtB,KAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA8B;YACpD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB,kBAAkB,CAAC,cAAc,CAAC,WAAW;YACxE,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,mBAAmB,CACjB,cAAsB,EACtB,KAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAY;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB,kBAAkB,CAAC,cAAc,CAAC,kBAAkB;YAC/E,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AA1ED,sDA0EC"}
@@ -0,0 +1,18 @@
1
+ import type { HttpTransport } from './http';
2
+ import type { GenerateDocumentRequest, GenerateDocumentResponse } from './types';
3
+ /**
4
+ * AI-driven document generation (capability C12).
5
+ *
6
+ * Always async — `generate` submits a job and returns its id. Poll via
7
+ * {@link JobsResource.result} (or {@link JobsResource.pollUntilDone})
8
+ * to get the final {@link DocumentJobResult}.
9
+ *
10
+ * Today only `format: 'docx'` is supported by the hub; other formats
11
+ * return 422 with a clear message.
12
+ */
13
+ export declare class DocumentsResource {
14
+ private readonly http;
15
+ constructor(http: HttpTransport);
16
+ generate(input: GenerateDocumentRequest): Promise<GenerateDocumentResponse>;
17
+ }
18
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,QAAQ,CACZ,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;CAOrC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentsResource = void 0;
4
+ /**
5
+ * AI-driven document generation (capability C12).
6
+ *
7
+ * Always async — `generate` submits a job and returns its id. Poll via
8
+ * {@link JobsResource.result} (or {@link JobsResource.pollUntilDone})
9
+ * to get the final {@link DocumentJobResult}.
10
+ *
11
+ * Today only `format: 'docx'` is supported by the hub; other formats
12
+ * return 422 with a clear message.
13
+ */
14
+ class DocumentsResource {
15
+ http;
16
+ constructor(http) {
17
+ this.http = http;
18
+ }
19
+ async generate(input) {
20
+ return this.http.request({
21
+ method: 'POST',
22
+ path: '/ai/documents',
23
+ body: input,
24
+ });
25
+ }
26
+ }
27
+ exports.DocumentsResource = DocumentsResource;
28
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,QAAQ,CACZ,KAA8B;QAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA2B;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AAZD,8CAYC"}
@@ -0,0 +1,61 @@
1
+ import type { HttpTransport } from './http';
2
+ import type { BatchForecastJobResponse, BatchForecastRequest, BatchForecastResult, ForecastHealthResponse, ForecastJobResponse, ForecastRequest, ForecastResponse, PollProgressOptions, ProgressResponse } from './types';
3
+ export declare class ForecastResource {
4
+ private readonly http;
5
+ constructor(http: HttpTransport);
6
+ /**
7
+ * Synchronous single-series forecast. Runs all requested models (or auto-selects
8
+ * the best model when `models` is omitted) and returns immediately.
9
+ *
10
+ * For large series or long horizons use `predictAsync` to avoid HTTP timeouts.
11
+ */
12
+ predict(request: ForecastRequest): Promise<ForecastResponse>;
13
+ /**
14
+ * Submit a single-series forecast as a background job.
15
+ * Returns a `progress_id` immediately — poll with `getJob` or `pollJob`.
16
+ */
17
+ predictAsync(request: ForecastRequest): Promise<ForecastJobResponse>;
18
+ /**
19
+ * Submit a batch of up to 500 series for concurrent background forecasting.
20
+ * Returns a `progress_id` immediately — poll with `getJob` or `pollBatchJob`.
21
+ */
22
+ predictBatch(request: BatchForecastRequest): Promise<BatchForecastJobResponse>;
23
+ /**
24
+ * Get the current status of a single-series background forecast job.
25
+ * When `status === 'completed'`, `data` contains the `ForecastResponse`.
26
+ */
27
+ getJob(progressId: string): Promise<ProgressResponse<ForecastResponse>>;
28
+ /**
29
+ * Get the current status of a batch background forecast job.
30
+ * When `status === 'completed'`, `data` contains the `BatchForecastResult`.
31
+ */
32
+ getBatchJob(progressId: string): Promise<ProgressResponse<BatchForecastResult>>;
33
+ /**
34
+ * Poll a single-series job until it reaches a terminal status.
35
+ * Throws `CfiAiHubError` on timeout or if the abort signal fires.
36
+ */
37
+ pollJob(progressId: string, options?: PollProgressOptions): Promise<ProgressResponse<ForecastResponse>>;
38
+ /**
39
+ * Poll a batch job until it reaches a terminal status.
40
+ * Throws `CfiAiHubError` on timeout or if the abort signal fires.
41
+ */
42
+ pollBatchJob(progressId: string, options?: PollProgressOptions): Promise<ProgressResponse<BatchForecastResult>>;
43
+ /**
44
+ * Convenience: submit a single-series async forecast and wait for the result.
45
+ * Equivalent to `predictAsync` followed by `pollJob`.
46
+ *
47
+ * @throws `CfiAiHubError` when the job fails, times out, or is aborted.
48
+ */
49
+ predictAsyncAndWait(request: ForecastRequest, options?: PollProgressOptions): Promise<ForecastResponse>;
50
+ /**
51
+ * Convenience: submit a batch and wait for the full result.
52
+ * Equivalent to `predictBatch` followed by `pollBatchJob`.
53
+ *
54
+ * @throws `CfiAiHubError` when the job fails, times out, or is aborted.
55
+ */
56
+ predictBatchAndWait(request: BatchForecastRequest, options?: PollProgressOptions): Promise<BatchForecastResult>;
57
+ /** Model load status, enabled models, and inference device configuration. */
58
+ health(): Promise<ForecastHealthResponse>;
59
+ private _poll;
60
+ }
61
+ //# sourceMappingURL=forecast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forecast.d.ts","sourceRoot":"","sources":["../src/forecast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAUjB,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQlE;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ1E;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAQpF;;;OAGG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAO7E;;;OAGG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;IAOrF;;;OAGG;IACG,OAAO,CACX,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAI9C;;;OAGG;IACG,YAAY,CAChB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;IAIjD;;;;;OAKG;IACG,mBAAmB,CACvB,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,gBAAgB,CAAC;IAiB5B;;;;;OAKG;IACG,mBAAmB,CACvB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAiB/B,6EAA6E;IACvE,MAAM,IAAI,OAAO,CAAC,sBAAsB,CAAC;YAOjC,KAAK;CAmCpB"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForecastResource = void 0;
4
+ const errors_1 = require("./errors");
5
+ const types_1 = require("./types");
6
+ const TERMINAL_STATUSES = new Set([
7
+ types_1.ProgressStatus.DONE,
8
+ types_1.ProgressStatus.ERROR,
9
+ types_1.ProgressStatus.ABORT,
10
+ types_1.ProgressStatus.ABORT_WITH_MESSAGE,
11
+ ]);
12
+ class ForecastResource {
13
+ http;
14
+ constructor(http) {
15
+ this.http = http;
16
+ }
17
+ /**
18
+ * Synchronous single-series forecast. Runs all requested models (or auto-selects
19
+ * the best model when `models` is omitted) and returns immediately.
20
+ *
21
+ * For large series or long horizons use `predictAsync` to avoid HTTP timeouts.
22
+ */
23
+ async predict(request) {
24
+ return this.http.request({
25
+ method: 'POST',
26
+ path: '/forecast/predict',
27
+ body: request,
28
+ });
29
+ }
30
+ /**
31
+ * Submit a single-series forecast as a background job.
32
+ * Returns a `progress_id` immediately — poll with `getJob` or `pollJob`.
33
+ */
34
+ async predictAsync(request) {
35
+ return this.http.request({
36
+ method: 'POST',
37
+ path: '/forecast/predict-async',
38
+ body: request,
39
+ });
40
+ }
41
+ /**
42
+ * Submit a batch of up to 500 series for concurrent background forecasting.
43
+ * Returns a `progress_id` immediately — poll with `getJob` or `pollBatchJob`.
44
+ */
45
+ async predictBatch(request) {
46
+ return this.http.request({
47
+ method: 'POST',
48
+ path: '/forecast/predict-batch',
49
+ body: request,
50
+ });
51
+ }
52
+ /**
53
+ * Get the current status of a single-series background forecast job.
54
+ * When `status === 'completed'`, `data` contains the `ForecastResponse`.
55
+ */
56
+ async getJob(progressId) {
57
+ return this.http.request({
58
+ method: 'GET',
59
+ path: `/forecast/jobs/${encodeURIComponent(progressId)}`,
60
+ });
61
+ }
62
+ /**
63
+ * Get the current status of a batch background forecast job.
64
+ * When `status === 'completed'`, `data` contains the `BatchForecastResult`.
65
+ */
66
+ async getBatchJob(progressId) {
67
+ return this.http.request({
68
+ method: 'GET',
69
+ path: `/forecast/jobs/${encodeURIComponent(progressId)}`,
70
+ });
71
+ }
72
+ /**
73
+ * Poll a single-series job until it reaches a terminal status.
74
+ * Throws `CfiAiHubError` on timeout or if the abort signal fires.
75
+ */
76
+ async pollJob(progressId, options = {}) {
77
+ return this._poll(progressId, options);
78
+ }
79
+ /**
80
+ * Poll a batch job until it reaches a terminal status.
81
+ * Throws `CfiAiHubError` on timeout or if the abort signal fires.
82
+ */
83
+ async pollBatchJob(progressId, options = {}) {
84
+ return this._poll(progressId, options);
85
+ }
86
+ /**
87
+ * Convenience: submit a single-series async forecast and wait for the result.
88
+ * Equivalent to `predictAsync` followed by `pollJob`.
89
+ *
90
+ * @throws `CfiAiHubError` when the job fails, times out, or is aborted.
91
+ */
92
+ async predictAsyncAndWait(request, options = {}) {
93
+ const job = await this.predictAsync(request);
94
+ const result = await this.pollJob(job.progress_id, options);
95
+ if (result.status === types_1.ProgressStatus.ERROR) {
96
+ throw new errors_1.CfiAiHubError(result.error ?? 'Forecast job failed', 0, 'FORECAST_JOB_FAILED');
97
+ }
98
+ if (!result.data) {
99
+ throw new errors_1.CfiAiHubError('Forecast job completed but returned no data', 0, 'NO_DATA');
100
+ }
101
+ return result.data;
102
+ }
103
+ /**
104
+ * Convenience: submit a batch and wait for the full result.
105
+ * Equivalent to `predictBatch` followed by `pollBatchJob`.
106
+ *
107
+ * @throws `CfiAiHubError` when the job fails, times out, or is aborted.
108
+ */
109
+ async predictBatchAndWait(request, options = {}) {
110
+ const job = await this.predictBatch(request);
111
+ const result = await this.pollBatchJob(job.progress_id, options);
112
+ if (result.status === types_1.ProgressStatus.ERROR) {
113
+ throw new errors_1.CfiAiHubError(result.error ?? 'Batch forecast job failed', 0, 'BATCH_JOB_FAILED');
114
+ }
115
+ if (!result.data) {
116
+ throw new errors_1.CfiAiHubError('Batch job completed but returned no data', 0, 'NO_DATA');
117
+ }
118
+ return result.data;
119
+ }
120
+ /** Model load status, enabled models, and inference device configuration. */
121
+ async health() {
122
+ return this.http.request({
123
+ method: 'GET',
124
+ path: '/forecast/health',
125
+ });
126
+ }
127
+ async _poll(progressId, options) {
128
+ const intervalMs = options.intervalMs ?? 2000;
129
+ const timeoutMs = options.timeoutMs ?? 30 * 60 * 1000;
130
+ const deadline = Date.now() + timeoutMs;
131
+ while (true) {
132
+ if (options.signal?.aborted) {
133
+ throw new errors_1.CfiAiHubError('Polling aborted', 0, 'ABORTED');
134
+ }
135
+ const progress = await this.http.request({
136
+ method: 'GET',
137
+ path: `/forecast/jobs/${encodeURIComponent(progressId)}`,
138
+ });
139
+ options.onProgress?.(progress);
140
+ if (TERMINAL_STATUSES.has(progress.status)) {
141
+ return progress;
142
+ }
143
+ if (Date.now() >= deadline) {
144
+ throw new errors_1.CfiAiHubError(`Forecast job polling timed out after ${timeoutMs}ms for job ${progressId}`, 0, 'POLL_TIMEOUT');
145
+ }
146
+ await sleep(intervalMs, options.signal);
147
+ }
148
+ }
149
+ }
150
+ exports.ForecastResource = ForecastResource;
151
+ function sleep(ms, signal) {
152
+ return new Promise((resolve, reject) => {
153
+ const timer = setTimeout(() => {
154
+ signal?.removeEventListener('abort', onAbort);
155
+ resolve();
156
+ }, ms);
157
+ const onAbort = () => {
158
+ clearTimeout(timer);
159
+ reject(new errors_1.CfiAiHubError('Polling aborted', 0, 'ABORTED'));
160
+ };
161
+ signal?.addEventListener('abort', onAbort, { once: true });
162
+ });
163
+ }
164
+ //# sourceMappingURL=forecast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forecast.js","sourceRoot":"","sources":["../src/forecast.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AAazC,mCAAyC;AAEzC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS;IACxC,sBAAc,CAAC,IAAI;IACnB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,kBAAkB;CAClC,CAAC,CAAC;AAEH,MAAa,gBAAgB;IACE;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,OAAwB;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAmB;YACzC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,CAAC,OAAwB;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsB;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,CAAC,OAA6B;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA2B;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CA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 -22,6 +22,18 @@ export declare class HttpTransport {
22
22
  private readonly etagCache;
23
23
  constructor(config: CfiAiHubClientConfig);
24
24
  request<T>(options: HttpRequestOptions): Promise<T>;
25
+ /**
26
+ * Stream Server-Sent Events from a POST endpoint.
27
+ *
28
+ * Yields parsed objects one per SSE frame (`data: {json}\n\n`). The hub
29
+ * emits errors as a final `{type: 'error', error: {...}}` chunk and ends
30
+ * the stream — callers iterate safely without try/catch around `for await`.
31
+ *
32
+ * Network / transport errors before the stream starts (timeout, 4xx/5xx
33
+ * on the initial response) DO throw — they're not part of the stream
34
+ * protocol.
35
+ */
36
+ streamSse<T>(options: HttpRequestOptions): AsyncIterable<T>;
25
37
  requestMultipart<T>(options: HttpMultipartOptions): Promise<T>;
26
38
  private buildUrl;
27
39
  private execute;
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,C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