@apia/ai 5.2.2 → 6.0.2

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 (84) hide show
  1. package/dist/assistant/index.d.d.ts +49 -0
  2. package/dist/assistant/index.d.d.ts.map +1 -0
  3. package/dist/assistant/index.js +154 -0
  4. package/dist/assistant/index.js.map +1 -0
  5. package/dist/assistant/runtime/conversationActivity.js +11 -0
  6. package/dist/assistant/runtime/conversationActivity.js.map +1 -0
  7. package/dist/assistant/runtime/conversationAnnotations.js +28 -0
  8. package/dist/assistant/runtime/conversationAnnotations.js.map +1 -0
  9. package/dist/assistant/runtime/conversationAttachmentPreview.js +33 -0
  10. package/dist/assistant/runtime/conversationAttachmentPreview.js.map +1 -0
  11. package/dist/assistant/runtime/conversationAttachments.js +24 -0
  12. package/dist/assistant/runtime/conversationAttachments.js.map +1 -0
  13. package/dist/assistant/runtime/conversationClient.d.d.ts +26 -0
  14. package/dist/assistant/runtime/conversationClient.d.d.ts.map +1 -0
  15. package/dist/assistant/runtime/conversationClient.js +599 -0
  16. package/dist/assistant/runtime/conversationClient.js.map +1 -0
  17. package/dist/assistant/runtime/conversationPlan.js +12 -0
  18. package/dist/assistant/runtime/conversationPlan.js.map +1 -0
  19. package/dist/assistant/runtime/conversationProjection.d.d.ts +8 -0
  20. package/dist/assistant/runtime/conversationProjection.d.d.ts.map +1 -0
  21. package/dist/assistant/runtime/conversationProjection.js +184 -0
  22. package/dist/assistant/runtime/conversationProjection.js.map +1 -0
  23. package/dist/assistant/runtime/coordinatorProxy.js +302 -0
  24. package/dist/assistant/runtime/coordinatorProxy.js.map +1 -0
  25. package/dist/chat/ChatController/ChatController.d.ts +13 -9
  26. package/dist/chat/ChatController/ChatController.js +103 -94
  27. package/dist/chat/ChatController/ChatController.js.map +1 -1
  28. package/dist/chat/ChatController/annotationStyles.js +1 -78
  29. package/dist/chat/ChatController/annotationStyles.js.map +1 -1
  30. package/dist/chat/ChatController/annotationTargets.d.ts +3 -1
  31. package/dist/chat/ChatController/annotationTargets.js +7 -1
  32. package/dist/chat/ChatController/annotationTargets.js.map +1 -1
  33. package/dist/chat/ChatController/components/AnnotationDraft.js +79 -0
  34. package/dist/chat/ChatController/components/AnnotationDraft.js.map +1 -0
  35. package/dist/chat/ChatController/components/AssistantMessageActions.d.ts +4 -0
  36. package/dist/chat/ChatController/components/AssistantMessageActions.d.ts.map +1 -0
  37. package/dist/chat/ChatController/components/AssistantMessageActions.js +102 -0
  38. package/dist/chat/ChatController/components/AssistantMessageActions.js.map +1 -0
  39. package/dist/chat/ChatController/components/AssistantTurnMessage.d.ts +24 -1
  40. package/dist/chat/ChatController/components/AssistantTurnMessage.js +155 -26
  41. package/dist/chat/ChatController/components/AssistantTurnMessage.js.map +1 -1
  42. package/dist/chat/ChatController/components/ChatMessage.d.ts +8 -5
  43. package/dist/chat/ChatController/components/ChatMessage.js +27 -22
  44. package/dist/chat/ChatController/components/ChatMessage.js.map +1 -1
  45. package/dist/chat/ChatController/components/History.d.ts +5 -1
  46. package/dist/chat/ChatController/components/History.js +19 -8
  47. package/dist/chat/ChatController/components/History.js.map +1 -1
  48. package/dist/chat/ChatController/components/Message.d.ts +7 -2
  49. package/dist/chat/ChatController/components/Message.js +22 -8
  50. package/dist/chat/ChatController/components/Message.js.map +1 -1
  51. package/dist/chat/ChatController/components/MessageBlocks.d.ts +2 -5
  52. package/dist/chat/ChatController/components/MessageBlocks.js +6 -48
  53. package/dist/chat/ChatController/components/MessageBlocks.js.map +1 -1
  54. package/dist/chat/ChatController/components/MessageBody.js +10 -3
  55. package/dist/chat/ChatController/components/MessageBody.js.map +1 -1
  56. package/dist/chat/ChatController/components/PendingMessagesPanel.js +2 -3
  57. package/dist/chat/ChatController/components/PendingMessagesPanel.js.map +1 -1
  58. package/dist/chat/ChatController/components/SentAnnotations.js +6 -3
  59. package/dist/chat/ChatController/components/SentAnnotations.js.map +1 -1
  60. package/dist/chat/ChatController/components/TextArea.d.ts +3 -5
  61. package/dist/chat/ChatController/components/TextArea.js +5 -67
  62. package/dist/chat/ChatController/components/TextArea.js.map +1 -1
  63. package/dist/chat/ChatController/types.d.ts +28 -1
  64. package/dist/index.d.ts +7 -8
  65. package/dist/index.js +5 -6
  66. package/dist/index.js.map +1 -1
  67. package/dist/stream/ResponseStream.d.ts +15 -10
  68. package/dist/stream/ResponseStream.js +58 -61
  69. package/dist/stream/ResponseStream.js.map +1 -1
  70. package/dist/stream/reasoningSummary.js +19 -0
  71. package/dist/stream/reasoningSummary.js.map +1 -0
  72. package/package.json +8 -8
  73. package/dist/assistant/AssistantController.d.ts +0 -53
  74. package/dist/assistant/AssistantController.d.ts.map +0 -1
  75. package/dist/assistant/AssistantController.js +0 -131
  76. package/dist/assistant/AssistantController.js.map +0 -1
  77. package/dist/assistant/HandoffCoordinator.d.ts +0 -18
  78. package/dist/assistant/HandoffCoordinator.d.ts.map +0 -1
  79. package/dist/assistant/HandoffCoordinator.js +0 -35
  80. package/dist/assistant/HandoffCoordinator.js.map +0 -1
  81. package/dist/assistant/PanelAssistantTransport.d.ts +0 -28
  82. package/dist/assistant/PanelAssistantTransport.d.ts.map +0 -1
  83. package/dist/assistant/PanelAssistantTransport.js +0 -48
  84. package/dist/assistant/PanelAssistantTransport.js.map +0 -1
@@ -1,131 +0,0 @@
1
- import { EventEmitter } from '@apia/util';
2
- import { StreamServicePoller } from '../stream/StreamServicePoller.js';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => {
7
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
- return value;
9
- };
10
- class AssistantController extends EventEmitter {
11
- constructor(transport) {
12
- super();
13
- this.transport = transport;
14
- __publicField(this, "poller");
15
- __publicField(this, "active");
16
- __publicField(this, "generation", 0);
17
- __publicField(this, "clearing", false);
18
- }
19
- get isRunning() {
20
- return this.active !== void 0;
21
- }
22
- send(turn) {
23
- if (this.active || this.clearing)
24
- return Promise.reject(new Error("The assistant is busy."));
25
- const generation = ++this.generation;
26
- const active = Promise.resolve().then(() => this.run(turn, generation));
27
- this.active = active;
28
- this.emit("busy", true);
29
- return active.finally(() => {
30
- if (this.active === active) {
31
- this.active = void 0;
32
- this.emit("busy", false);
33
- }
34
- });
35
- }
36
- async cancel() {
37
- ++this.generation;
38
- if (this.poller)
39
- this.poller.closed = true;
40
- await this.transport.cancel();
41
- }
42
- async clearHistory() {
43
- if (this.clearing)
44
- throw new Error("The assistant history is already being cleared.");
45
- this.clearing = true;
46
- try {
47
- if (this.active) {
48
- await this.cancel();
49
- await this.active.catch(() => void 0);
50
- }
51
- await this.transport.clearHistory();
52
- } finally {
53
- this.clearing = false;
54
- }
55
- }
56
- async run(turn, generation) {
57
- const current = () => generation === this.generation;
58
- const unsubscribers = [];
59
- try {
60
- if (!current())
61
- return;
62
- const response = await this.transport.send(turn);
63
- if (!current()) {
64
- await this.transport.cancel();
65
- return;
66
- }
67
- if (response.result.type !== "stream") {
68
- this.emit("result", response.result);
69
- return;
70
- }
71
- if (!response.streamId)
72
- throw new Error("The assistant did not return a stream ID.");
73
- const poller = new StreamServicePoller();
74
- this.poller = poller;
75
- unsubscribers.push(
76
- poller.on("part", (part) => {
77
- if (current())
78
- this.emit("part", part);
79
- }),
80
- poller.on("finalPart", (part) => {
81
- if (current())
82
- this.emit("finalPart", part);
83
- }),
84
- poller.on("intermediateTextStart", (event) => {
85
- if (current())
86
- this.emit("intermediateTextStart", event);
87
- }),
88
- poller.on("blockResponse", (event) => {
89
- if (current())
90
- this.emit("blockResponse", event);
91
- }),
92
- poller.on("response", (event) => {
93
- if (current())
94
- this.emit("response", event);
95
- }),
96
- poller.on("block", (block) => {
97
- if (!current())
98
- return;
99
- if (block.type === "result") {
100
- const result = JSON.parse(block.description);
101
- if (!result || typeof result.type !== "string")
102
- throw new Error("Invalid assistant result.");
103
- poller.stream.disableAnimation();
104
- this.emit("result", result);
105
- } else {
106
- this.emit("block", block);
107
- }
108
- }),
109
- poller.on("error", () => {
110
- poller.closed = true;
111
- if (current()) {
112
- ++this.generation;
113
- this.emit("error", new Error("The assistant stream failed."));
114
- }
115
- })
116
- );
117
- await poller.start(response.streamId);
118
- await poller.stream.waitUntilIdle();
119
- } catch (error) {
120
- if (current())
121
- this.emit("error", error);
122
- throw error;
123
- } finally {
124
- unsubscribers.forEach((unsubscribe) => unsubscribe());
125
- this.poller = void 0;
126
- }
127
- }
128
- }
129
-
130
- export { AssistantController };
131
- //# sourceMappingURL=AssistantController.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AssistantController.js","sources":["../../src/assistant/AssistantController.ts"],"sourcesContent":["import { EventEmitter } from '@apia/util';\r\nimport { StreamServicePoller } from '../stream/StreamServicePoller';\r\nimport type { ResponseStreamEvents } from '../stream/ResponseStream';\nimport type { TChatAnnotation } from '../chat/ChatController/types';\n\r\nexport type AssistantAttachment = {\r\n name: string;\r\n base64: string;\r\n description?: string;\r\n};\r\n\r\nexport type AssistantTurn = {\n message: string;\n files?: AssistantAttachment[];\n annotations?: TChatAnnotation[];\n};\n\r\nexport type AssistantResult = {\r\n type: string;\r\n message?: string;\r\n handoffId?: string;\r\n url?: string;\r\n urlTitle?: string;\r\n [key: string]: unknown;\r\n};\r\n\r\n/** Host adapter. The reusable controller does not know panel IDs or HTTP actions. */\r\nexport interface AssistantTransport {\r\n send(turn: AssistantTurn): Promise<{ result: AssistantResult; streamId?: string }>;\r\n clearHistory(): Promise<void>;\r\n cancel(): Promise<void>;\r\n}\r\n\r\ntype AssistantEvents = ResponseStreamEvents & {\r\n result: AssistantResult;\r\n error: unknown;\r\n busy: boolean;\r\n};\r\n\r\n/** A single conversation, reusable with the existing ChatController or another UI. */\r\nexport class AssistantController extends EventEmitter<AssistantEvents> {\r\n private poller?: StreamServicePoller;\r\n private active?: Promise<void>;\r\n private generation = 0;\r\n private clearing = false;\r\n\r\n constructor(private readonly transport: AssistantTransport) {\r\n super();\r\n }\r\n\r\n get isRunning() { return this.active !== undefined; }\r\n\r\n send(turn: AssistantTurn): Promise<void> {\r\n if (this.active || this.clearing) return Promise.reject(new Error('The assistant is busy.'));\r\n const generation = ++this.generation;\r\n // Schedule after assigning active, including for synchronous transport failures.\r\n const active = Promise.resolve().then(() => this.run(turn, generation));\r\n this.active = active;\r\n this.emit('busy', true);\r\n return active.finally(() => {\r\n if (this.active === active) {\r\n this.active = undefined;\r\n this.emit('busy', false);\r\n }\r\n });\r\n }\r\n\r\n async cancel() {\r\n ++this.generation;\r\n if (this.poller) this.poller.closed = true;\r\n await this.transport.cancel();\r\n }\r\n\r\n async clearHistory() {\r\n if (this.clearing) throw new Error('The assistant history is already being cleared.');\r\n this.clearing = true;\r\n try {\r\n if (this.active) {\r\n await this.cancel();\r\n await this.active.catch(() => undefined);\r\n }\r\n await this.transport.clearHistory();\r\n } finally {\r\n this.clearing = false;\r\n }\r\n }\r\n\r\n private async run(turn: AssistantTurn, generation: number) {\r\n const current = () => generation === this.generation;\r\n const unsubscribers: Array<() => unknown> = [];\r\n try {\r\n if (!current()) return;\r\n const response = await this.transport.send(turn);\r\n if (!current()) {\r\n // Cancellation may have reached the server before the send request started.\r\n await this.transport.cancel();\r\n return;\r\n }\r\n if (response.result.type !== 'stream') {\r\n this.emit('result', response.result);\r\n return;\r\n }\r\n if (!response.streamId) throw new Error('The assistant did not return a stream ID.');\r\n const poller = new StreamServicePoller();\r\n this.poller = poller;\r\n unsubscribers.push(\r\n poller.on('part', part => { if (current()) this.emit('part', part); }),\r\n poller.on('finalPart', part => { if (current()) this.emit('finalPart', part); }),\r\n poller.on('intermediateTextStart', event => { if (current()) this.emit('intermediateTextStart', event); }),\r\n poller.on('blockResponse', event => { if (current()) this.emit('blockResponse', event); }),\r\n poller.on('response', event => { if (current()) this.emit('response', event); }),\r\n poller.on('block', block => {\r\n if (!current()) return;\r\n if (block.type === 'result') {\r\n const result = JSON.parse(block.description) as AssistantResult;\r\n if (!result || typeof result.type !== 'string') throw new Error('Invalid assistant result.');\r\n // Deliver ready tasks while their siblings are still running. Flush current\n // text and render future text directly before navigation can hide this frame.\n poller.stream.disableAnimation();\n this.emit('result', result);\n } else {\r\n this.emit('block', block);\r\n }\r\n }),\r\n poller.on('error', () => {\r\n poller.closed = true;\r\n if (current()) {\r\n ++this.generation;\r\n this.emit('error', new Error('The assistant stream failed.'));\r\n }\r\n }),\r\n );\r\n await poller.start(response.streamId);\r\n // Polling completion does not mean the animated text queue has drained.\r\n await poller.stream.waitUntilIdle();\r\n } catch (error) {\r\n if (current()) this.emit('error', error);\r\n throw error;\r\n } finally {\r\n unsubscribers.forEach(unsubscribe => unsubscribe());\r\n this.poller = undefined;\r\n }\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;AAwCO,MAAM,4BAA4B,YAAA,CAA8B;AAAA,EAMrE,YAA6B,SAAA,EAA+B;AAC1D,IAAA,KAAA,EAAM;AADqB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAL7B,IAAA,aAAA,CAAA,IAAA,EAAQ,QAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAQ,QAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAQ,YAAA,EAAa,CAAA,CAAA;AACrB,IAAA,aAAA,CAAA,IAAA,EAAQ,UAAA,EAAW,KAAA,CAAA;AAAA;AAInB,EAEA,IAAI,SAAA,GAAY;AAAE,IAAA,OAAO,KAAK,MAAA,KAAW,MAAA;AAAA;AAAW,EAEpD,KAAK,IAAA,EAAoC;AACvC,IAAA,IAAI,IAAA,CAAK,UAAU,IAAA,CAAK,QAAA;AAAU,MAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,KAAA,CAAM,wBAAwB,CAAC,CAAA;AAC3F,IAAA,MAAM,UAAA,GAAa,EAAE,IAAA,CAAK,UAAA;AAE1B,IAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,OAAA,EA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IAAA,CAAK,IAAA,CAAK,SAAS,KAAK,CAAA;AACvC,MAAA,MAAM,KAAA;AAAA,KACR,SAAE;AACA,MAAA,aAAA,CAAc,OAAA,CAAQ,CAAA,WAAA,KAAe,WAAA,EAAa,CAAA;AAClD,MAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA;AAChB;AAEJ;;;;"}
@@ -1,18 +0,0 @@
1
- import { AssistantResult } from './AssistantController.js';
2
-
3
- interface ClientHandoffHandler {
4
- /** Dispatch only. Returning does NOT mean the destination opened successfully. */
5
- dispatch(result: AssistantResult): void | Promise<void>;
6
- }
7
- /** Duplicate dispatch protection per conversation; actual readiness is acknowledged by the receiver. */
8
- declare class HandoffCoordinator {
9
- private readonly handlers;
10
- private readonly onDispatchFailure?;
11
- private readonly dispatched;
12
- constructor(handlers: Readonly<Record<string, ClientHandoffHandler>>, onDispatchFailure?: ((handoffId: string) => Promise<void>) | undefined);
13
- dispatch(result: AssistantResult): Promise<void>;
14
- clear(): void;
15
- }
16
-
17
- export { type ClientHandoffHandler, HandoffCoordinator };
18
- //# sourceMappingURL=HandoffCoordinator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HandoffCoordinator.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, key + "" , value);
5
- return value;
6
- };
7
- class HandoffCoordinator {
8
- constructor(handlers, onDispatchFailure) {
9
- this.handlers = handlers;
10
- this.onDispatchFailure = onDispatchFailure;
11
- __publicField(this, "dispatched", /* @__PURE__ */ new Set());
12
- }
13
- async dispatch(result) {
14
- if (!result.handoffId)
15
- throw new Error("A tracked handoff requires an identifier.");
16
- if (this.dispatched.has(result.handoffId))
17
- return;
18
- this.dispatched.add(result.handoffId);
19
- try {
20
- const handler = this.handlers[result.type];
21
- if (!handler)
22
- throw new Error(`Unsupported handoff result: ${result.type}`);
23
- await handler.dispatch(result);
24
- } catch (error) {
25
- await this.onDispatchFailure?.(result.handoffId);
26
- throw error;
27
- }
28
- }
29
- clear() {
30
- this.dispatched.clear();
31
- }
32
- }
33
-
34
- export { HandoffCoordinator };
35
- //# sourceMappingURL=HandoffCoordinator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HandoffCoordinator.js","sources":["../../src/assistant/HandoffCoordinator.ts"],"sourcesContent":["import type { AssistantResult } from './AssistantController';\r\n\r\nexport interface ClientHandoffHandler {\r\n /** Dispatch only. Returning does NOT mean the destination opened successfully. */\r\n dispatch(result: AssistantResult): void | Promise<void>;\r\n}\r\n\r\n/** Duplicate dispatch protection per conversation; actual readiness is acknowledged by the receiver. */\r\nexport class HandoffCoordinator {\r\n private readonly dispatched = new Set<string>();\r\n\r\n constructor(private readonly handlers: Readonly<Record<string, ClientHandoffHandler>>,\r\n private readonly onDispatchFailure?: (handoffId: string) => Promise<void>) { }\r\n\r\n async dispatch(result: AssistantResult) {\r\n if (!result.handoffId) throw new Error('A tracked handoff requires an identifier.');\r\n if (this.dispatched.has(result.handoffId)) return;\r\n // Retain the ID even on an uncertain dispatch failure: retrying could duplicate a process.\r\n this.dispatched.add(result.handoffId);\r\n try {\r\n const handler = this.handlers[result.type];\r\n if (!handler) throw new Error(`Unsupported handoff result: ${result.type}`);\r\n await handler.dispatch(result);\r\n } catch (error) {\r\n await this.onDispatchFailure?.(result.handoffId);\r\n throw error;\r\n }\r\n }\r\n\r\n clear() { this.dispatched.clear(); }\r\n}\r\n"],"names":[],"mappings":";;;;;;AAQO,MAAM,kBAAA,CAAmB;AAAA,EAG9B,WAAA,CAA6B,UACR,iBAAA,EAA0D;AADlD,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AACR,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAHrB,IAAA,aAAA,CAAA,IAAA,EAAiB,YAAA,sBAAiB,GAAA,EAAY,CAAA;AAAA;AAGmC,EAEjF,MAAM,SAAS,MAAA,EAAyB;AACtC,IAAA,IAAI,CAAC,MAAA,CAAO,SAAA;AAAW,MAAA,MAAM,IAAI,MAAM,2CAA2C,CAAA;AAClF,IAAA,IAAI,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,MAAA,CAAO,SAAS,CAAA;AAAG,MAAA;AAE3C,IAAA,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,MAAA,CAAO,SAAS,CAAA;AACpC,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,QAAA,CAAS,MAAA,CAAO,IAAI,CAAA;AACzC,MAAA,IAAI,CAAC,OAAA;AAAS,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,MAAA,CAAO,IAAI,CAAA,CAAE,CAAA;AAC1E,MAAA,MAAM,OAAA,CAAQ,SAAS,MAAM,CAAA;AAAA,aACtB,KAAA,EAAO;AACd,MAAA,MAAM,IAAA,CAAK,iBAAA,GAAoB,MAAA,CAAO,SAAS,CAAA;AAC/C,MAAA,MAAM,KAAA;AAAA;AACR;AACF,EAEA,KAAA,GAAQ;AAAE,IAAA,IAAA,CAAK,WAAW,KAAA,EAAM;AAAA;AAClC;;;;"}
@@ -1,28 +0,0 @@
1
- import { AssistantTransport, AssistantTurn, AssistantResult } from './AssistantController.js';
2
-
3
- /** Minimal structural contract; no dependency on dashboard-controller. */
4
- type PanelDispatcher = (request: {
5
- action: string;
6
- } & Record<string, unknown>) => Promise<{
7
- hasError?: boolean;
8
- data?: {
9
- executionResult?: string;
10
- streamId?: string;
11
- } | null;
12
- } | null>;
13
- declare class PanelAssistantTransport implements AssistantTransport {
14
- private readonly dispatch;
15
- constructor(dispatch: PanelDispatcher);
16
- send(turn: AssistantTurn): Promise<{
17
- result: AssistantResult;
18
- streamId: string | undefined;
19
- }>;
20
- clearHistory(): Promise<void>;
21
- cancel(): Promise<void>;
22
- reportDispatchFailure(handoffId: string): Promise<void>;
23
- openPresentedTask(presentationId: string, position: number): Promise<AssistantResult>;
24
- private action;
25
- }
26
-
27
- export { PanelAssistantTransport };
28
- //# sourceMappingURL=PanelAssistantTransport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PanelAssistantTransport.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,48 +0,0 @@
1
- class PanelAssistantTransport {
2
- constructor(dispatch) {
3
- this.dispatch = dispatch;
4
- }
5
- async send(turn) {
6
- const response = await this.dispatch({
7
- action: "userMessage",
8
- message: turn.message,
9
- fileMessages: JSON.stringify(turn.files ?? []),
10
- annotations: JSON.stringify(turn.annotations ?? [])
11
- });
12
- if (response?.hasError || !response?.data?.executionResult) {
13
- throw new Error("The panel could not start the assistant turn.");
14
- }
15
- const result = JSON.parse(response.data.executionResult);
16
- if (!result || typeof result.type !== "string")
17
- throw new Error("Invalid assistant result.");
18
- return { result, streamId: response.data.streamId };
19
- }
20
- async clearHistory() {
21
- await this.action("clearHistory");
22
- }
23
- async cancel() {
24
- await this.action("cancel");
25
- }
26
- async reportDispatchFailure(handoffId) {
27
- const response = await this.dispatch({ action: "handoffFailed", handoffId });
28
- if (!response || response.hasError)
29
- throw new Error("Could not report the handoff failure.");
30
- }
31
- async openPresentedTask(presentationId, position) {
32
- const response = await this.dispatch({ action: "openPresentedTask", presentationId, position });
33
- if (response?.hasError || !response?.data?.executionResult)
34
- throw new Error("La tarea de la tabla ya no est\xE1 disponible. Consult\xE1 la lista nuevamente.");
35
- const result = JSON.parse(response.data.executionResult);
36
- if (result?.type !== "openUrl" || !result.url)
37
- throw new Error("No se pudo preparar la apertura de la tarea.");
38
- return result;
39
- }
40
- async action(action) {
41
- const response = await this.dispatch({ action });
42
- if (!response || response.hasError)
43
- throw new Error(`Assistant ${action} failed.`);
44
- }
45
- }
46
-
47
- export { PanelAssistantTransport };
48
- //# sourceMappingURL=PanelAssistantTransport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PanelAssistantTransport.js","sources":["../../src/assistant/PanelAssistantTransport.ts"],"sourcesContent":["import type { AssistantTransport, AssistantTurn, AssistantResult } from './AssistantController';\r\n\r\n/** Minimal structural contract; no dependency on dashboard-controller. */\r\ntype PanelDispatcher = (request: { action: string } & Record<string, unknown>) => Promise<{\r\n hasError?: boolean;\r\n data?: { executionResult?: string; streamId?: string } | null;\r\n} | null>;\r\n\r\nexport class PanelAssistantTransport implements AssistantTransport {\r\n constructor(private readonly dispatch: PanelDispatcher) { }\r\n\r\n async send(turn: AssistantTurn) {\r\n const response = await this.dispatch({\r\n action: 'userMessage',\r\n message: turn.message,\r\n fileMessages: JSON.stringify(turn.files ?? []),\n annotations: JSON.stringify(turn.annotations ?? []),\n });\r\n if (response?.hasError || !response?.data?.executionResult) {\r\n throw new Error('The panel could not start the assistant turn.');\r\n }\r\n const result = JSON.parse(response.data.executionResult) as AssistantResult;\r\n if (!result || typeof result.type !== 'string') throw new Error('Invalid assistant result.');\r\n return { result, streamId: response.data.streamId };\r\n }\r\n\r\n async clearHistory() { await this.action('clearHistory'); }\r\n async cancel() { await this.action('cancel'); }\r\n\r\n async reportDispatchFailure(handoffId: string) {\n const response = await this.dispatch({ action: 'handoffFailed', handoffId });\r\n if (!response || response.hasError) throw new Error('Could not report the handoff failure.');\r\n }\n\n\tasync openPresentedTask(presentationId: string, position: number): Promise<AssistantResult> {\n\t\tconst response = await this.dispatch({ action: 'openPresentedTask', presentationId, position });\n\t\tif (response?.hasError || !response?.data?.executionResult)\n\t\t\tthrow new Error('La tarea de la tabla ya no está disponible. Consultá la lista nuevamente.');\n\t\tconst result = JSON.parse(response.data.executionResult) as AssistantResult;\n\t\tif (result?.type !== 'openUrl' || !result.url) throw new Error('No se pudo preparar la apertura de la tarea.');\n\t\treturn result;\n\t}\n\r\n private async action(action: string) {\r\n const response = await this.dispatch({ action });\r\n if (!response || response.hasError) throw new Error(`Assistant ${action} failed.`);\r\n }\r\n}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