@copado/agentia-cli 0.118.0-alpha.0 → 0.120.0-alpha.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/README.md +224 -293
- package/dist/commands/cicd/notification/configure.d.ts +1 -1
- package/dist/commands/cicd/work/deployment-step/create.d.ts +1 -1
- package/dist/commands/testing/build/run.d.ts +2 -2
- package/dist/commands/testing/data-table/create.d.ts +1 -1
- package/dist/commands/testing/data-table/update.d.ts +1 -1
- package/dist/commands/testing/job/create.d.ts +1 -1
- package/dist/commands/testing/job/schedule/set.d.ts +1 -1
- package/dist/commands/testing/job/update.d.ts +1 -1
- package/dist/commands/testing/robot/update.d.ts +1 -1
- package/dist/commands/testing/run.d.ts +2 -2
- package/dist/commands/testing/test/run.d.ts +2 -2
- package/dist/lib/ai-chat-session.d.ts +0 -3
- package/dist/lib/ai-chat-session.js +66 -182
- package/dist/lib/ai-chat-session.js.map +1 -1
- package/dist/lib/ai-gateway.d.ts +1 -8
- package/dist/lib/ai-gateway.js +2 -34
- package/dist/lib/ai-gateway.js.map +1 -1
- package/dist/lib/ai-types.d.ts +0 -18
- package/dist/lib/ai-types.js +1 -45
- package/dist/lib/ai-types.js.map +1 -1
- package/dist/lib/format.d.ts +0 -2
- package/dist/lib/format.js +2 -5
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/loopback-callback-server.d.ts +1 -0
- package/dist/lib/loopback-callback-server.js +13 -6
- package/dist/lib/loopback-callback-server.js.map +1 -1
- package/dist/lib/mcp/tools.d.ts +2 -2
- package/dist/lib/testing-data-command.d.ts +1 -1
- package/dist/lib/testing-flags.d.ts +2 -2
- package/oclif.manifest.json +691 -842
- package/package.json +13 -12
- package/templates/skills/agentia-ai/SKILL.md +5 -5
- package/templates/skills/agentia-ai/references/ai-agents.md +3 -18
- package/dist/commands/ai/session/list.d.ts +0 -14
- package/dist/commands/ai/session/list.js +0 -46
- package/dist/commands/ai/session/list.js.map +0 -1
- package/dist/commands/ai/session/start.d.ts +0 -17
- package/dist/commands/ai/session/start.js +0 -60
- package/dist/commands/ai/session/start.js.map +0 -1
- package/dist/lib/ai-session-banner.d.ts +0 -5
- package/dist/lib/ai-session-banner.js +0 -20
- package/dist/lib/ai-session-banner.js.map +0 -1
- package/dist/lib/ai-session-tui-blocks.d.ts +0 -9
- package/dist/lib/ai-session-tui-blocks.js +0 -36
- package/dist/lib/ai-session-tui-blocks.js.map +0 -1
- package/dist/lib/ai-session-tui-clipboard.d.ts +0 -22
- package/dist/lib/ai-session-tui-clipboard.js +0 -78
- package/dist/lib/ai-session-tui-clipboard.js.map +0 -1
- package/dist/lib/ai-session-tui-composer.d.ts +0 -35
- package/dist/lib/ai-session-tui-composer.js +0 -96
- package/dist/lib/ai-session-tui-composer.js.map +0 -1
- package/dist/lib/ai-session-tui-highlight.d.ts +0 -11
- package/dist/lib/ai-session-tui-highlight.js +0 -310
- package/dist/lib/ai-session-tui-highlight.js.map +0 -1
- package/dist/lib/ai-session-tui-keys.d.ts +0 -42
- package/dist/lib/ai-session-tui-keys.js +0 -159
- package/dist/lib/ai-session-tui-keys.js.map +0 -1
- package/dist/lib/ai-session-tui-mermaid-image.d.ts +0 -43
- package/dist/lib/ai-session-tui-mermaid-image.js +0 -444
- package/dist/lib/ai-session-tui-mermaid-image.js.map +0 -1
- package/dist/lib/ai-session-tui-mermaid-paint.d.ts +0 -3
- package/dist/lib/ai-session-tui-mermaid-paint.js +0 -182
- package/dist/lib/ai-session-tui-mermaid-paint.js.map +0 -1
- package/dist/lib/ai-session-tui-mermaid.d.ts +0 -19
- package/dist/lib/ai-session-tui-mermaid.js +0 -158
- package/dist/lib/ai-session-tui-mermaid.js.map +0 -1
- package/dist/lib/ai-session-tui-message.d.ts +0 -9
- package/dist/lib/ai-session-tui-message.js +0 -24
- package/dist/lib/ai-session-tui-message.js.map +0 -1
- package/dist/lib/ai-session-tui-scroll.d.ts +0 -32
- package/dist/lib/ai-session-tui-scroll.js +0 -148
- package/dist/lib/ai-session-tui-scroll.js.map +0 -1
- package/dist/lib/ai-session-tui-slash.d.ts +0 -14
- package/dist/lib/ai-session-tui-slash.js +0 -53
- package/dist/lib/ai-session-tui-slash.js.map +0 -1
- package/dist/lib/ai-session-tui-welcome.d.ts +0 -12
- package/dist/lib/ai-session-tui-welcome.js +0 -33
- package/dist/lib/ai-session-tui-welcome.js.map +0 -1
- package/dist/lib/ai-session-tui-wrap.d.ts +0 -2
- package/dist/lib/ai-session-tui-wrap.js +0 -24
- package/dist/lib/ai-session-tui-wrap.js.map +0 -1
- package/dist/lib/ai-session-tui.d.ts +0 -7
- package/dist/lib/ai-session-tui.js +0 -859
- package/dist/lib/ai-session-tui.js.map +0 -1
- package/dist/lib/ai-sessions.d.ts +0 -17
- package/dist/lib/ai-sessions.js +0 -142
- package/dist/lib/ai-sessions.js.map +0 -1
|
@@ -8,7 +8,7 @@ export default class NotificationConfigure extends AgentiaCommand {
|
|
|
8
8
|
'destination-type': import("@oclif/core/interfaces").OptionFlag<"user" | "channel", import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
event: import("@oclif/core/interfaces").OptionFlag<"Promotion_Success" | "Promotion_Failed" | "Promotion_Conflict" | "Failed_Promotion_Creation" | "Deploy_Success" | "Deploy_Failed" | "Commit_Failed" | "Successful_Snapshot" | "Failed_Snapshot" | "ManualTask_Assigned" | "Test_Success" | "Test_Failed" | "Test_Cancelled" | "Test_Not Started" | "Quality_Gate_Success" | "Quality_Gate_Failed" | "Quality_Gate_Cancelled" | "Quality_Gate_Not Started" | "Create_Package_Success" | "Create_Package_Failure" | "Generate_Package_Version_Success" | "Generate_Package_Version_Failure" | "Import_Package_Success" | "Import_Package_Failure" | "Publish_Package_Success" | "Publish_Package_Failure", import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'pipeline-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
subscription: import("@oclif/core/interfaces").OptionFlag<"
|
|
11
|
+
subscription: import("@oclif/core/interfaces").OptionFlag<"user" | "all", import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
};
|
|
13
13
|
run(): Promise<ConfigureNotificationResult>;
|
|
14
14
|
}
|
|
@@ -15,7 +15,7 @@ export default class WorkDeploymentStepCreate extends AgentiaCommand {
|
|
|
15
15
|
'custom-step-api-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
'data-set-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
17
|
'data-template-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
-
environment: import("@oclif/core/interfaces").OptionFlag<"
|
|
18
|
+
environment: import("@oclif/core/interfaces").OptionFlag<"source" | "both" | "destination" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
19
|
'flow-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
20
|
'function-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
21
|
instructions: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -10,7 +10,7 @@ export default class TestingBuildRun extends TestingRunCommand {
|
|
|
10
10
|
static examples: string[];
|
|
11
11
|
static flags: {
|
|
12
12
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
'console-colors': import("@oclif/core/interfaces").OptionFlag<"
|
|
13
|
+
'console-colors': import("@oclif/core/interfaces").OptionFlag<"on" | "auto" | "ansi" | "off" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
'console-width': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
datatable: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
doc: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -23,7 +23,7 @@ export default class TestingBuildRun extends TestingRunCommand {
|
|
|
23
23
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
24
|
'no-exit-code': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
25
|
param: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
-
record: import("@oclif/core/interfaces").OptionFlag<"none" | "
|
|
26
|
+
record: import("@oclif/core/interfaces").OptionFlag<"none" | "failed" | "all" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
27
|
'rerun-failed': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
28
|
'rerun-failed-from-latest': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
29
|
'run-empty-suite': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -9,7 +9,7 @@ export default class TestingDataTableCreate extends AgentiaCommand {
|
|
|
9
9
|
topics: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
header: import("@oclif/core/interfaces").OptionFlag<"
|
|
12
|
+
header: import("@oclif/core/interfaces").OptionFlag<"row" | "column", import("@oclif/core/interfaces").CustomOptions>;
|
|
13
13
|
'json-data': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
15
|
job: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -14,7 +14,7 @@ export default class TestingDataTableUpdate extends AgentiaCommand {
|
|
|
14
14
|
topics: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
16
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
header: import("@oclif/core/interfaces").OptionFlag<"
|
|
17
|
+
header: import("@oclif/core/interfaces").OptionFlag<"row" | "column", import("@oclif/core/interfaces").CustomOptions>;
|
|
18
18
|
'json-data': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
19
|
stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
20
|
job: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -20,7 +20,7 @@ export default class TestingJobCreate extends AgentiaCommand {
|
|
|
20
20
|
'screen-height': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
21
|
'screen-width': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
22
|
'show-video-params': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
-
'suite-type': import("@oclif/core/interfaces").OptionFlag<"default" | "
|
|
23
|
+
'suite-type': import("@oclif/core/interfaces").OptionFlag<"default" | "bitbar" | "browserstack" | "browserstackdesktop" | "lambdatest" | "lambdatestdesktop" | "mobile" | "paceconnectmobile" | "privatemobile" | "rpa" | "selenese" | "zap" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
24
|
timeout: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
25
|
validation: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
26
26
|
'git-branch': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -10,7 +10,7 @@ export default class TestingJobScheduleSet extends AgentiaCommand {
|
|
|
10
10
|
static examples: string[];
|
|
11
11
|
static flags: {
|
|
12
12
|
cron: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
record: import("@oclif/core/interfaces").OptionFlag<"none" | "
|
|
13
|
+
record: import("@oclif/core/interfaces").OptionFlag<"none" | "failed" | "all" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
timezone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
project: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
};
|
|
@@ -21,7 +21,7 @@ export default class TestingJobUpdate extends AgentiaCommand {
|
|
|
21
21
|
'screen-height': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
22
|
'screen-width': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
23
|
'show-video-params': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
-
'suite-type': import("@oclif/core/interfaces").OptionFlag<"default" | "
|
|
24
|
+
'suite-type': import("@oclif/core/interfaces").OptionFlag<"default" | "bitbar" | "browserstack" | "browserstackdesktop" | "lambdatest" | "lambdatestdesktop" | "mobile" | "paceconnectmobile" | "privatemobile" | "rpa" | "selenese" | "zap" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
25
|
timeout: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
26
|
'git-branch': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
27
|
'git-domain-credential': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -12,7 +12,7 @@ export default class TestingRobotUpdate extends AgentiaCommand {
|
|
|
12
12
|
label: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
13
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
reporting: import("@oclif/core/interfaces").OptionFlag<"all" | "nothing" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
-
'robot-type': import("@oclif/core/interfaces").OptionFlag<"default" | "
|
|
15
|
+
'robot-type': import("@oclif/core/interfaces").OptionFlag<"default" | "bitbar" | "browserstack" | "browserstackdesktop" | "lambdatest" | "lambdatestdesktop" | "mobile" | "paceconnectmobile" | "privatemobile" | "pabot" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
project: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
17
|
};
|
|
18
18
|
run(): Promise<TestingRobot>;
|
|
@@ -10,7 +10,7 @@ export default class TestingRun extends TestingRunCommand {
|
|
|
10
10
|
static examples: string[];
|
|
11
11
|
static flags: {
|
|
12
12
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
'console-colors': import("@oclif/core/interfaces").OptionFlag<"
|
|
13
|
+
'console-colors': import("@oclif/core/interfaces").OptionFlag<"on" | "auto" | "ansi" | "off" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
'console-width': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
datatable: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
doc: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -23,7 +23,7 @@ export default class TestingRun extends TestingRunCommand {
|
|
|
23
23
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
24
|
'no-exit-code': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
25
|
param: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
-
record: import("@oclif/core/interfaces").OptionFlag<"none" | "
|
|
26
|
+
record: import("@oclif/core/interfaces").OptionFlag<"none" | "failed" | "all" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
27
|
'rerun-failed': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
28
|
'rerun-failed-from-latest': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
29
|
'run-empty-suite': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -10,7 +10,7 @@ export default class TestingTestRun extends TestingRunCommand {
|
|
|
10
10
|
static examples: string[];
|
|
11
11
|
static flags: {
|
|
12
12
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
'console-colors': import("@oclif/core/interfaces").OptionFlag<"
|
|
13
|
+
'console-colors': import("@oclif/core/interfaces").OptionFlag<"on" | "auto" | "ansi" | "off" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
'console-width': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
datatable: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
doc: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -23,7 +23,7 @@ export default class TestingTestRun extends TestingRunCommand {
|
|
|
23
23
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
24
|
'no-exit-code': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
25
|
param: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
-
record: import("@oclif/core/interfaces").OptionFlag<"none" | "
|
|
26
|
+
record: import("@oclif/core/interfaces").OptionFlag<"none" | "failed" | "all" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
27
|
'rerun-failed': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
28
|
'rerun-failed-from-latest': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
29
|
'run-empty-suite': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -4,9 +4,6 @@ import { type CredentialSyncOptions } from './credential-sync.js';
|
|
|
4
4
|
export type AiChatSessionOptions = AiConnectionOverrides & AiContextOptions & CredentialSyncOptions & {
|
|
5
5
|
agent: AiAgent;
|
|
6
6
|
dialogue?: string;
|
|
7
|
-
loadHistory?: boolean;
|
|
8
|
-
sameSessionAgentSwitch?: boolean;
|
|
9
|
-
sessionCommands?: boolean;
|
|
10
7
|
timeoutMs?: number;
|
|
11
8
|
};
|
|
12
9
|
export type AiChatSessionResult = {
|
|
@@ -3,9 +3,8 @@ import { createInterface } from 'node:readline';
|
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
import { AiGateway } from './ai-gateway.js';
|
|
5
5
|
import { bootstrapAiDialogue } from './ai-operations.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { agentForAssistantId, AI_CHAT_AGENTS, AI_SESSION_LIST_DEFAULT_PAGE_SIZE, assistantIdForAgent, dialogueAssistantId, dialogueMessageText, enrichAiPrompt, } from './ai-types.js';
|
|
6
|
+
import { formatAiTerminalMessage, StreamingMarkdownRenderer, streamSupportsColor } from './ai-terminal-renderer.js';
|
|
7
|
+
import { AI_CHAT_AGENTS, assistantIdForAgent, enrichAiPrompt } from './ai-types.js';
|
|
9
8
|
function writeLine(stream, value = '') {
|
|
10
9
|
stream.write(`${value}\n`);
|
|
11
10
|
}
|
|
@@ -39,11 +38,7 @@ function isGracefulReadlineClose(error) {
|
|
|
39
38
|
function errorMessage(error) {
|
|
40
39
|
return error instanceof Error ? error.message : String(error);
|
|
41
40
|
}
|
|
42
|
-
function renderHelp(output
|
|
43
|
-
if (sessionCommands) {
|
|
44
|
-
writeLine(output, `Commands: /help, /session, /${AI_CHAT_AGENTS.join(', /')}, /clear, /exit`);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
41
|
+
function renderHelp(output) {
|
|
47
42
|
writeLine(output, `Commands: /help, /clear, /agent <${AI_CHAT_AGENTS.join('|')}>, /exit`);
|
|
48
43
|
}
|
|
49
44
|
function normalizeAgent(value) {
|
|
@@ -52,34 +47,10 @@ function normalizeAgent(value) {
|
|
|
52
47
|
}
|
|
53
48
|
return undefined;
|
|
54
49
|
}
|
|
55
|
-
function slashAgent(line) {
|
|
56
|
-
if (!line.startsWith('/'))
|
|
57
|
-
return undefined;
|
|
58
|
-
return normalizeAgent(line.slice(1));
|
|
59
|
-
}
|
|
60
|
-
function renderHistory(output, dialogue, colors) {
|
|
61
|
-
const messages = dialogue.messages ?? [];
|
|
62
|
-
if (messages.length === 0)
|
|
63
|
-
return;
|
|
64
|
-
writeLine(output, 'Previous messages:');
|
|
65
|
-
for (const message of messages) {
|
|
66
|
-
const role = message.role === 'human' ? 'You' : 'Agent';
|
|
67
|
-
const text = dialogueMessageText(message);
|
|
68
|
-
writeLine(output, `${role}:`);
|
|
69
|
-
if (text.length > 0)
|
|
70
|
-
writeLine(output, renderMarkdown(text, { colors }));
|
|
71
|
-
writeLine(output);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
50
|
export async function runAiChatSession(options, io = defaultChatIo()) {
|
|
75
51
|
let { agent } = options;
|
|
76
52
|
let bootstrap = await bootstrapAiDialogue({ ...options, agent, kind: 'chat' });
|
|
77
53
|
let turns = 0;
|
|
78
|
-
let listedSessions = [];
|
|
79
|
-
let pendingSessionPick = false;
|
|
80
|
-
const sessionCommands = options.sessionCommands === true;
|
|
81
|
-
const sameSessionAgentSwitch = options.sameSessionAgentSwitch === true;
|
|
82
|
-
const loadHistory = options.loadHistory === true;
|
|
83
54
|
const stderrColors = streamSupportsColor(io.error);
|
|
84
55
|
const stdoutColors = streamSupportsColor(io.output);
|
|
85
56
|
const reportCredentialSyncWarning = () => {
|
|
@@ -96,164 +67,77 @@ export async function runAiChatSession(options, io = defaultChatIo()) {
|
|
|
96
67
|
const close = () => {
|
|
97
68
|
rl.close();
|
|
98
69
|
};
|
|
99
|
-
const switchAgent = async (nextAgent) => {
|
|
100
|
-
agent = nextAgent;
|
|
101
|
-
if (sameSessionAgentSwitch) {
|
|
102
|
-
writeLine(io.output, `Using ${agent} agent on session ${bootstrap.dialogue.id}`);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
bootstrap = await bootstrapAiDialogue({ ...options, agent, dialogue: undefined, kind: 'chat' });
|
|
106
|
-
reportCredentialSyncWarning();
|
|
107
|
-
writeLine(io.output, `Switched to ${agent} agent. Dialogue: ${bootstrap.dialogue.id}`);
|
|
108
|
-
};
|
|
109
|
-
const openSession = async (dialogue) => {
|
|
110
|
-
const nextAgent = agentForAssistantId(dialogueAssistantId(dialogue));
|
|
111
|
-
if (nextAgent !== undefined)
|
|
112
|
-
agent = nextAgent;
|
|
113
|
-
bootstrap = { assistantId: assistantIdForAgent(agent), dialogue };
|
|
114
|
-
writeLine(io.output, `${agent} Agent chat`);
|
|
115
|
-
writeLine(io.output, `Dialogue: ${bootstrap.dialogue.id}`);
|
|
116
|
-
if (loadHistory)
|
|
117
|
-
renderHistory(io.output, dialogue, stdoutColors);
|
|
118
|
-
};
|
|
119
|
-
const listAndPromptSessions = async () => {
|
|
120
|
-
const page = await listAiSessions({ ...options, pageSize: AI_SESSION_LIST_DEFAULT_PAGE_SIZE });
|
|
121
|
-
listedSessions = page.data;
|
|
122
|
-
if (listedSessions.length === 0) {
|
|
123
|
-
writeLine(io.output, 'No AI sessions found.');
|
|
124
|
-
pendingSessionPick = false;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
writeLine(io.output, formatAiSessionTable(listedSessions));
|
|
128
|
-
writeLine(io.output, 'Enter a number or session id to switch, or /cancel.');
|
|
129
|
-
pendingSessionPick = true;
|
|
130
|
-
};
|
|
131
|
-
const selectSession = async (selection) => {
|
|
132
|
-
const picked = pickSessionFromList(selection, listedSessions);
|
|
133
|
-
if (picked === undefined) {
|
|
134
|
-
writeLine(io.error, 'Unknown session. Use a list number or a dialogue UUID.');
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const dialogue = await AiGateway.getDialogue(picked.id, options);
|
|
138
|
-
pendingSessionPick = false;
|
|
139
|
-
await openSession(dialogue);
|
|
140
|
-
};
|
|
141
|
-
const handleSessionCommand = async (line) => {
|
|
142
|
-
if (!sessionCommands)
|
|
143
|
-
return false;
|
|
144
|
-
if ((line === '/cancel' || line === 'cancel') && pendingSessionPick) {
|
|
145
|
-
pendingSessionPick = false;
|
|
146
|
-
writeLine(io.output, 'Session switch cancelled.');
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
if (pendingSessionPick && !line.startsWith('/')) {
|
|
150
|
-
await selectSession(line);
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
if (line === '/session') {
|
|
154
|
-
await listAndPromptSessions();
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
if (line.startsWith('/session ')) {
|
|
158
|
-
const selection = line.slice('/session '.length).trim();
|
|
159
|
-
if (listedSessions.length === 0) {
|
|
160
|
-
const page = await listAiSessions({ ...options, pageSize: AI_SESSION_LIST_DEFAULT_PAGE_SIZE });
|
|
161
|
-
listedSessions = page.data;
|
|
162
|
-
}
|
|
163
|
-
await selectSession(selection);
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
return false;
|
|
167
|
-
};
|
|
168
|
-
const handleCommand = async (line) => {
|
|
169
|
-
if (line.length === 0)
|
|
170
|
-
return 'continue';
|
|
171
|
-
if (line === '/exit' || line === 'exit' || line === 'quit')
|
|
172
|
-
return 'exit';
|
|
173
|
-
if (line === '/help') {
|
|
174
|
-
renderHelp(io.output, sessionCommands);
|
|
175
|
-
return 'continue';
|
|
176
|
-
}
|
|
177
|
-
if (await handleSessionCommand(line))
|
|
178
|
-
return 'continue';
|
|
179
|
-
if (line === '/clear') {
|
|
180
|
-
bootstrap = await bootstrapAiDialogue({ ...options, agent, dialogue: undefined, kind: 'chat' });
|
|
181
|
-
reportCredentialSyncWarning();
|
|
182
|
-
pendingSessionPick = false;
|
|
183
|
-
writeLine(io.output, `Started new dialogue: ${bootstrap.dialogue.id}`);
|
|
184
|
-
return 'continue';
|
|
185
|
-
}
|
|
186
|
-
const shortcutAgent = sessionCommands ? slashAgent(line) : undefined;
|
|
187
|
-
if (shortcutAgent !== undefined) {
|
|
188
|
-
await switchAgent(shortcutAgent);
|
|
189
|
-
return 'continue';
|
|
190
|
-
}
|
|
191
|
-
if (line.startsWith('/agent ')) {
|
|
192
|
-
const nextAgent = normalizeAgent(line.slice('/agent '.length).trim());
|
|
193
|
-
if (nextAgent === undefined) {
|
|
194
|
-
writeLine(io.error, `Unknown agent. Use ${AI_CHAT_AGENTS.join(', ')}.`);
|
|
195
|
-
return 'continue';
|
|
196
|
-
}
|
|
197
|
-
await switchAgent(nextAgent);
|
|
198
|
-
return 'continue';
|
|
199
|
-
}
|
|
200
|
-
return 'prompt';
|
|
201
|
-
};
|
|
202
|
-
const sendTurn = async (line) => {
|
|
203
|
-
const requestId = uuidv4();
|
|
204
|
-
let completed = false;
|
|
205
|
-
const renderer = new StreamingMarkdownRenderer({ colors: stdoutColors });
|
|
206
|
-
const prompt = enrichAiPrompt(line, {
|
|
207
|
-
component: options.component,
|
|
208
|
-
sfOrg: options.sfOrg,
|
|
209
|
-
userStory: options.userStory,
|
|
210
|
-
workItem: options.workItem,
|
|
211
|
-
});
|
|
212
|
-
try {
|
|
213
|
-
await AiGateway.sendMessage(bootstrap.dialogue.id, {
|
|
214
|
-
assistantId: assistantIdForAgent(agent),
|
|
215
|
-
'dev_context': null,
|
|
216
|
-
integrations: null,
|
|
217
|
-
prompt,
|
|
218
|
-
'request_id': requestId,
|
|
219
|
-
'system_prompt': null,
|
|
220
|
-
}, options, (chunk) => {
|
|
221
|
-
if (chunk.type === 'token' && typeof chunk.content === 'string')
|
|
222
|
-
renderer.write(io.output, chunk.content);
|
|
223
|
-
if ((chunk.type === 'status' || chunk.type === 'warning') && typeof chunk.content === 'string') {
|
|
224
|
-
const kind = chunk.type === 'warning' ? 'warning' : 'status';
|
|
225
|
-
writeLine(io.error, formatAiTerminalMessage(chunk.content, kind, { colors: stderrColors }));
|
|
226
|
-
}
|
|
227
|
-
if (chunk.type === 'error' && typeof chunk.content === 'string') {
|
|
228
|
-
throw new Error(chunk.content);
|
|
229
|
-
}
|
|
230
|
-
if (chunk.type === 'done' || chunk.type === 'performance' || chunk.type === 'stream_complete')
|
|
231
|
-
completed = true;
|
|
232
|
-
});
|
|
233
|
-
renderer.finish(io.output);
|
|
234
|
-
if (!completed)
|
|
235
|
-
throw new Error('AI stream ended before stream_complete. Response may be incomplete.');
|
|
236
|
-
turns += 1;
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
writeLine(io.error, `AI turn failed: ${errorMessage(error)}`);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
70
|
process.once('SIGINT', close);
|
|
243
71
|
try {
|
|
244
72
|
writeLine(io.output, `${agent} Agent chat`);
|
|
245
73
|
writeLine(io.output, `Dialogue: ${bootstrap.dialogue.id}`);
|
|
246
|
-
renderHelp(io.output
|
|
247
|
-
if (loadHistory)
|
|
248
|
-
renderHistory(io.output, bootstrap.dialogue, stdoutColors);
|
|
74
|
+
renderHelp(io.output);
|
|
249
75
|
while (true) {
|
|
250
76
|
const line = (await question(rl, '> ')).trim();
|
|
251
|
-
|
|
252
|
-
|
|
77
|
+
if (line.length === 0)
|
|
78
|
+
continue;
|
|
79
|
+
if (line === '/exit' || line === 'exit' || line === 'quit')
|
|
253
80
|
break;
|
|
254
|
-
if (
|
|
81
|
+
if (line === '/help') {
|
|
82
|
+
renderHelp(io.output);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (line === '/clear') {
|
|
86
|
+
bootstrap = await bootstrapAiDialogue({ ...options, agent, dialogue: undefined, kind: 'chat' });
|
|
87
|
+
reportCredentialSyncWarning();
|
|
88
|
+
writeLine(io.output, `Started new dialogue: ${bootstrap.dialogue.id}`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (line.startsWith('/agent ')) {
|
|
92
|
+
const nextAgent = normalizeAgent(line.slice('/agent '.length).trim());
|
|
93
|
+
if (nextAgent === undefined) {
|
|
94
|
+
writeLine(io.error, `Unknown agent. Use ${AI_CHAT_AGENTS.join(', ')}.`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
agent = nextAgent;
|
|
98
|
+
bootstrap = await bootstrapAiDialogue({ ...options, agent, dialogue: undefined, kind: 'chat' });
|
|
99
|
+
reportCredentialSyncWarning();
|
|
100
|
+
writeLine(io.output, `Switched to ${agent} agent. Dialogue: ${bootstrap.dialogue.id}`);
|
|
255
101
|
continue;
|
|
256
|
-
|
|
102
|
+
}
|
|
103
|
+
const requestId = uuidv4();
|
|
104
|
+
let completed = false;
|
|
105
|
+
const renderer = new StreamingMarkdownRenderer({ colors: stdoutColors });
|
|
106
|
+
const prompt = enrichAiPrompt(line, {
|
|
107
|
+
component: options.component,
|
|
108
|
+
sfOrg: options.sfOrg,
|
|
109
|
+
userStory: options.userStory,
|
|
110
|
+
workItem: options.workItem,
|
|
111
|
+
});
|
|
112
|
+
try {
|
|
113
|
+
await AiGateway.sendMessage(bootstrap.dialogue.id, {
|
|
114
|
+
assistantId: assistantIdForAgent(agent),
|
|
115
|
+
'dev_context': null,
|
|
116
|
+
integrations: null,
|
|
117
|
+
prompt,
|
|
118
|
+
'request_id': requestId,
|
|
119
|
+
'system_prompt': null,
|
|
120
|
+
}, options, (chunk) => {
|
|
121
|
+
if (chunk.type === 'token' && typeof chunk.content === 'string')
|
|
122
|
+
renderer.write(io.output, chunk.content);
|
|
123
|
+
if ((chunk.type === 'status' || chunk.type === 'warning') && typeof chunk.content === 'string') {
|
|
124
|
+
const kind = chunk.type === 'warning' ? 'warning' : 'status';
|
|
125
|
+
writeLine(io.error, formatAiTerminalMessage(chunk.content, kind, { colors: stderrColors }));
|
|
126
|
+
}
|
|
127
|
+
if (chunk.type === 'error' && typeof chunk.content === 'string') {
|
|
128
|
+
throw new Error(chunk.content);
|
|
129
|
+
}
|
|
130
|
+
if (chunk.type === 'done' || chunk.type === 'performance' || chunk.type === 'stream_complete')
|
|
131
|
+
completed = true;
|
|
132
|
+
});
|
|
133
|
+
renderer.finish(io.output);
|
|
134
|
+
if (!completed)
|
|
135
|
+
throw new Error('AI stream ended before stream_complete. Response may be incomplete.');
|
|
136
|
+
turns += 1;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
writeLine(io.error, `AI turn failed: ${errorMessage(error)}`);
|
|
140
|
+
}
|
|
257
141
|
}
|
|
258
142
|
}
|
|
259
143
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-chat-session.js","sourceRoot":"","sources":["../../src/lib/ai-chat-session.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,EAAC,eAAe,EAAiB,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAC,EAAE,IAAI,MAAM,EAAC,MAAM,MAAM,CAAA;AAGjC,OAAO,EAAC,SAAS,EAAC,MAAM,i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d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { URL } from 'node:url';
|
|
2
2
|
import { type AiConnectionOverrides } from './ai-config.js';
|
|
3
|
-
import { type AiDialogue, type
|
|
3
|
+
import { type AiDialogue, type AiIntegration, type AiIntegrationCreate, type AiMessageCreate, type AiOrganizationQuota, type AiStreamChunk, type AiWorkspace, type AiWorkspaceCreate, type AiWorkspaceMember, type AiWorkspaceMemberCreate, type AiWorkspaceSummary, type AiWorkspaceUpdate } from './ai-types.js';
|
|
4
4
|
export type AiRequest = {
|
|
5
5
|
body?: unknown;
|
|
6
6
|
endpoint: string;
|
|
@@ -8,7 +8,6 @@ export type AiRequest = {
|
|
|
8
8
|
responseType?: 'json' | 'ndjson';
|
|
9
9
|
};
|
|
10
10
|
export type AiGatewayCallOptions = AiConnectionOverrides & {
|
|
11
|
-
signal?: AbortSignal;
|
|
12
11
|
timeoutMs?: number;
|
|
13
12
|
};
|
|
14
13
|
export type AiHttpRequestOptions = {
|
|
@@ -17,15 +16,10 @@ export type AiHttpRequestOptions = {
|
|
|
17
16
|
method: string;
|
|
18
17
|
onData?: (chunk: Buffer) => void;
|
|
19
18
|
onStatus?: (status: number) => void;
|
|
20
|
-
signal?: AbortSignal;
|
|
21
19
|
timeoutMs: number;
|
|
22
20
|
url: URL;
|
|
23
21
|
};
|
|
24
22
|
export type AiHttpRequestFn = (options: AiHttpRequestOptions) => Promise<string>;
|
|
25
|
-
export declare class AiRequestAbortedError extends Error {
|
|
26
|
-
constructor(message?: string);
|
|
27
|
-
}
|
|
28
|
-
export declare function isAiRequestAborted(error: unknown): boolean;
|
|
29
23
|
export declare class AiGatewayError extends Error {
|
|
30
24
|
readonly requestMethod?: string;
|
|
31
25
|
readonly requestUrl?: string;
|
|
@@ -53,7 +47,6 @@ export declare class AiGateway {
|
|
|
53
47
|
static getDialogue(dialogueId: string, options?: AiGatewayCallOptions): Promise<AiDialogue>;
|
|
54
48
|
static getOrganizationQuota(options?: AiGatewayCallOptions): Promise<AiOrganizationQuota>;
|
|
55
49
|
static getWorkspace(workspaceId: string, options?: AiGatewayCallOptions): Promise<AiWorkspace>;
|
|
56
|
-
static listDialogues(options?: AiGatewayCallOptions): Promise<AiDialogueSummary[]>;
|
|
57
50
|
static listIntegrations(options?: AiGatewayCallOptions): Promise<AiIntegration[]>;
|
|
58
51
|
static listWorkspaces(options?: AiGatewayCallOptions): Promise<AiWorkspaceSummary[]>;
|
|
59
52
|
static sendMessage(dialogueId: string, message: AiMessageCreate, options: AiGatewayCallOptions, onChunk: (chunk: AiStreamChunk) => void): Promise<void>;
|
package/dist/lib/ai-gateway.js
CHANGED
|
@@ -3,18 +3,9 @@ import * as https from 'node:https';
|
|
|
3
3
|
import { URL } from 'node:url';
|
|
4
4
|
import { AI_DEFAULT_TIMEOUT_MS, AI_DEFAULT_WORKSPACE_NAME, resolveAiCredentials } from './ai-config.js';
|
|
5
5
|
import { AiStreamParser } from './ai-stream-parser.js';
|
|
6
|
-
import { dialogueEndpoint, dialogueMessagesEndpoint, dialoguesEndpoint, integrationEndpoint, integrationsEndpoint, normalizeAiDialogue,
|
|
6
|
+
import { dialogueEndpoint, dialogueMessagesEndpoint, dialoguesEndpoint, integrationEndpoint, integrationsEndpoint, normalizeAiDialogue, normalizeAiIntegration, normalizeAiIntegrationList, normalizeAiOrganizationQuota, normalizeAiWorkspace, normalizeAiWorkspaceList, normalizeAiWorkspaceMember, quotaEndpoint, workspaceEndpoint, workspaceMembersEndpoint, workspacesEndpoint, } from './ai-types.js';
|
|
7
7
|
import { AI_GATEWAY_EVENT_SERVICE, createTransactionId, gatewayRefererHeaders, gatewayUserAgent, getGatewayTransactionId, scheduleGatewayEventLog, } from './cicd-gateway.js';
|
|
8
8
|
import { formatDebugBody, logVerboseDebug } from './debug.js';
|
|
9
|
-
export class AiRequestAbortedError extends Error {
|
|
10
|
-
constructor(message = 'AI request cancelled.') {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = 'AbortError';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function isAiRequestAborted(error) {
|
|
16
|
-
return error instanceof AiRequestAbortedError || (error instanceof Error && error.name === 'AbortError');
|
|
17
|
-
}
|
|
18
9
|
export class AiGatewayError extends Error {
|
|
19
10
|
requestMethod;
|
|
20
11
|
requestUrl;
|
|
@@ -108,10 +99,7 @@ function withRequestSuffix(message, request) {
|
|
|
108
99
|
return message;
|
|
109
100
|
return message.endsWith('.') ? `${message} ${suffix}` : `${message}. ${suffix}`;
|
|
110
101
|
}
|
|
111
|
-
function
|
|
112
|
-
// Replaced after the request exists so destroy can run.
|
|
113
|
-
}
|
|
114
|
-
function defaultHttpsRequest({ body, headers, method, onData, onStatus, signal, timeoutMs, url, }) {
|
|
102
|
+
function defaultHttpsRequest({ body, headers, method, onData, onStatus, timeoutMs, url, }) {
|
|
115
103
|
const hasBody = body !== undefined;
|
|
116
104
|
const payload = hasBody ? JSON.stringify(body) : '';
|
|
117
105
|
const requestHeaders = {
|
|
@@ -126,12 +114,10 @@ function defaultHttpsRequest({ body, headers, method, onData, onStatus, signal,
|
|
|
126
114
|
return new Promise((resolve, reject) => {
|
|
127
115
|
const chunks = [];
|
|
128
116
|
let settled = false;
|
|
129
|
-
let onAbort = noopAbort;
|
|
130
117
|
const rejectOnce = (error) => {
|
|
131
118
|
if (settled)
|
|
132
119
|
return;
|
|
133
120
|
settled = true;
|
|
134
|
-
signal?.removeEventListener('abort', onAbort);
|
|
135
121
|
reject(error);
|
|
136
122
|
};
|
|
137
123
|
const req = transport.request({
|
|
@@ -161,7 +147,6 @@ function defaultHttpsRequest({ body, headers, method, onData, onStatus, signal,
|
|
|
161
147
|
if (settled)
|
|
162
148
|
return;
|
|
163
149
|
settled = true;
|
|
164
|
-
signal?.removeEventListener('abort', onAbort);
|
|
165
150
|
const raw = Buffer.concat(chunks).toString('utf8');
|
|
166
151
|
onStatus?.(status);
|
|
167
152
|
if (status >= 400) {
|
|
@@ -183,15 +168,6 @@ function defaultHttpsRequest({ body, headers, method, onData, onStatus, signal,
|
|
|
183
168
|
req.on('timeout', () => {
|
|
184
169
|
req.destroy(new Error(`AI Gateway request timed out after ${Math.ceil(timeoutMs / 1000)} seconds.`));
|
|
185
170
|
});
|
|
186
|
-
onAbort = () => {
|
|
187
|
-
req.destroy();
|
|
188
|
-
rejectOnce(new AiRequestAbortedError());
|
|
189
|
-
};
|
|
190
|
-
if (signal?.aborted) {
|
|
191
|
-
onAbort();
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
signal?.addEventListener('abort', onAbort);
|
|
195
171
|
if (hasBody)
|
|
196
172
|
req.write(payload);
|
|
197
173
|
req.end();
|
|
@@ -240,7 +216,6 @@ async function executeJsonRequest(request, options = {}) {
|
|
|
240
216
|
body: request.body,
|
|
241
217
|
headers,
|
|
242
218
|
method: request.method,
|
|
243
|
-
signal: options.signal,
|
|
244
219
|
timeoutMs: options.timeoutMs ?? AI_DEFAULT_TIMEOUT_MS,
|
|
245
220
|
url,
|
|
246
221
|
});
|
|
@@ -295,7 +270,6 @@ async function executeStreamRequest(request, options, onChunk) {
|
|
|
295
270
|
for (const parsed of parser.push(chunk))
|
|
296
271
|
onChunk(parsed);
|
|
297
272
|
},
|
|
298
|
-
signal: options.signal,
|
|
299
273
|
timeoutMs: options.timeoutMs ?? AI_DEFAULT_TIMEOUT_MS,
|
|
300
274
|
url,
|
|
301
275
|
});
|
|
@@ -371,12 +345,6 @@ export class AiGateway {
|
|
|
371
345
|
method: 'GET',
|
|
372
346
|
}, options));
|
|
373
347
|
}
|
|
374
|
-
static async listDialogues(options = {}) {
|
|
375
|
-
return normalizeAiDialogueList(await executeJsonRequest({
|
|
376
|
-
endpoint: dialoguesEndpoint(),
|
|
377
|
-
method: 'GET',
|
|
378
|
-
}, options));
|
|
379
|
-
}
|
|
380
348
|
static async listIntegrations(options = {}) {
|
|
381
349
|
return normalizeAiIntegrationList(await executeJsonRequest({
|
|
382
350
|
endpoint: integrationsEndpoint('MEMBER'),
|