@artinet/ask 0.1.5 → 0.1.6

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.
@@ -1,2 +1,2 @@
1
- import * as sdk from "@artinet/sdk";
1
+ import * as sdk from '@artinet/sdk';
2
2
  export declare function chat(agentCard: sdk.A2A.AgentCard, client: sdk.AgentMessenger, taskId?: string, verbose?: boolean, message?: string | undefined): Promise<void>;
package/dist/src/chat.js CHANGED
@@ -1,7 +1,7 @@
1
- import * as sdk from "@artinet/sdk";
2
- import chalk from "chalk";
3
- import prompts from "prompts";
4
- import { v4 as uuidv4 } from "uuid";
1
+ import * as sdk from '@artinet/sdk';
2
+ import chalk from 'chalk';
3
+ import prompts from 'prompts';
4
+ import { v4 as uuidv4 } from 'uuid';
5
5
  // sdk.applyDefaults();
6
6
  function getTaskState(update) {
7
7
  const state = update?.status?.state ??
@@ -10,10 +10,10 @@ function getTaskState(update) {
10
10
  return state;
11
11
  }
12
12
  function createBanner(kind, state, verbose = false) {
13
- let banner = "";
13
+ let banner = '';
14
14
  if (verbose) {
15
15
  banner =
16
- chalk.bgWhite(chalk.grey(`📥 Type: ${chalk.bgWhiteBright(chalk.black(kind.toUpperCase().replace("-", " ")))}`)) + " ";
16
+ chalk.bgWhite(chalk.grey(`📥 Type: ${chalk.bgWhiteBright(chalk.black(kind.toUpperCase().replace('-', ' ')))}`)) + ' ';
17
17
  }
18
18
  if (state) {
19
19
  switch (state) {
@@ -26,7 +26,7 @@ function createBanner(kind, state, verbose = false) {
26
26
  case sdk.A2A.TaskState.rejected:
27
27
  banner = chalk.bgRed(`${state.toUpperCase()}`);
28
28
  break;
29
- case sdk.A2A.TaskState["auth-required"]:
29
+ case sdk.A2A.TaskState['auth-required']:
30
30
  banner = chalk.bgMagenta(`${state.toUpperCase()}`);
31
31
  break;
32
32
  case sdk.A2A.TaskState.unknown:
@@ -35,7 +35,7 @@ function createBanner(kind, state, verbose = false) {
35
35
  case sdk.A2A.TaskState.submitted:
36
36
  banner = chalk.bgYellow(chalk.black(`${state.toUpperCase()}`));
37
37
  break;
38
- case sdk.A2A.TaskState["input-required"]:
38
+ case sdk.A2A.TaskState['input-required']:
39
39
  banner = chalk.bgMagenta(chalk.black(`${state.toUpperCase()}`));
40
40
  break;
41
41
  case sdk.A2A.TaskState.working:
@@ -46,8 +46,8 @@ function createBanner(kind, state, verbose = false) {
46
46
  break;
47
47
  }
48
48
  }
49
- if (banner.length > 0 && banner[banner.length - 1] !== " ") {
50
- return banner + " ";
49
+ if (banner.length > 0 && banner[banner.length - 1] !== ' ') {
50
+ return banner + ' ';
51
51
  }
52
52
  return banner;
53
53
  }
@@ -56,8 +56,8 @@ async function sendMessage(client, message, taskId, verbose = false) {
56
56
  messageId: uuidv4(),
57
57
  taskId: taskId,
58
58
  kind: sdk.A2A.Kind.message,
59
- role: "user",
60
- parts: [{ text: message, kind: "text" }],
59
+ role: 'user',
60
+ parts: [{ text: message, kind: 'text' }],
61
61
  };
62
62
  if (verbose) {
63
63
  console.log(chalk.bgWhite(chalk.black(`📤 Sending message: ${msg.messageId}`)));
@@ -66,17 +66,17 @@ async function sendMessage(client, message, taskId, verbose = false) {
66
66
  message: msg,
67
67
  });
68
68
  if (!agentResponseSource) {
69
- console.error(chalk.red("No response from agent"));
69
+ console.error(chalk.red('No response from agent'));
70
70
  return;
71
71
  }
72
72
  const banner = createBanner(agentResponseSource.kind, getTaskState(agentResponseSource), verbose);
73
- console.log(banner + chalk.gray("Agent: ") + sdk.extractTextContent(agentResponseSource));
73
+ console.log(banner + chalk.gray('Agent: ') + sdk.extractTextContent(agentResponseSource));
74
74
  console.log();
75
75
  }
76
76
  export async function chat(agentCard, client, taskId = uuidv4(), verbose = false, message = undefined) {
77
77
  if (!client) {
78
- console.error(chalk.red("No client provided"));
79
- throw new Error("chat: no client provided");
78
+ console.error(chalk.red('No client provided'));
79
+ throw new Error('chat: no client provided');
80
80
  }
81
81
  const name = agentCard.name;
82
82
  const version = agentCard.version;
@@ -95,19 +95,19 @@ export async function chat(agentCard, client, taskId = uuidv4(), verbose = false
95
95
  console.log(chalk.bgGray("Chat started: Type 'exit' to quit.\n"));
96
96
  while (true) {
97
97
  const response = await prompts({
98
- type: "text",
99
- name: "message",
100
- message: "User:",
98
+ type: 'text',
99
+ name: 'message',
100
+ message: 'User:',
101
101
  });
102
- if (!response.message || response.message.trim().toLowerCase() === "exit") {
102
+ if (!response.message || response.message.trim().toLowerCase() === 'exit') {
103
103
  break;
104
104
  }
105
105
  const msg = {
106
106
  messageId: uuidv4(),
107
107
  taskId: taskId,
108
108
  kind: sdk.A2A.Kind.message,
109
- role: "user",
110
- parts: [{ text: response.message, kind: "text" }],
109
+ role: 'user',
110
+ parts: [{ text: response.message, kind: 'text' }],
111
111
  };
112
112
  console.log();
113
113
  if (verbose) {
@@ -119,20 +119,20 @@ export async function chat(agentCard, client, taskId = uuidv4(), verbose = false
119
119
  });
120
120
  for await (const update of agentResponseSource) {
121
121
  const banner = createBanner(update.kind, getTaskState(update), verbose);
122
- if ((update.kind === "message" || update.kind === "task") && !verbose) {
122
+ if ((update.kind === 'message' || update.kind === 'task') && !verbose) {
123
123
  continue;
124
124
  }
125
- const response = sdk.extractTextContent(update) ?? "No response";
125
+ const response = sdk.extractTextContent(update) ?? 'No response';
126
126
  if (response) {
127
- console.log(banner + chalk.gray("Agent: ") + response);
127
+ console.log(banner + chalk.gray('Agent: ') + response);
128
128
  }
129
129
  else if (verbose && banner.length > 0) {
130
- console.log(banner + chalk.gray("Status Update: ☑️"));
130
+ console.log(banner + chalk.gray('Status Update: ☑️'));
131
131
  }
132
132
  }
133
133
  }
134
134
  catch (error) {
135
- console.error(chalk.red("Error sending message: ") + error);
135
+ console.error(chalk.red('Error sending message: ') + error);
136
136
  }
137
137
  console.log();
138
138
  }
package/dist/src/cli.js CHANGED
@@ -4,38 +4,38 @@
4
4
  * Copyright 2025 The Artinet Project
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
- import * as sdk from "@artinet/sdk";
8
- import { Command } from "commander";
9
- import { chat } from "./chat.js";
10
- import chalk from "chalk";
7
+ import * as sdk from '@artinet/sdk';
8
+ import { Command } from 'commander';
9
+ import { chat } from './chat.js';
10
+ import chalk from 'chalk';
11
11
  const program = new Command();
12
12
  program
13
- .name("ask")
14
- .description("A lightweight chat client for connecting to A2A Servers")
15
- .version("0.0.8")
16
- .option("-v, --verbose", "Enable verbose output")
17
- .option("-t, --task <taskId>", "Set the task ID")
18
- .option("-e, --endpoint <endpoint>", "Set the A2A endpoint (default: http://localhost:3000/a2a)")
19
- .option("-c, --card", "Show the agent card")
20
- .option("-m, --message <message>", "Send a single message and exit")
13
+ .name('ask')
14
+ .description('A lightweight chat client for connecting to A2A Servers')
15
+ .version('0.1.6')
16
+ .option('-v, --verbose', 'Enable verbose output')
17
+ .option('-t, --task <taskId>', 'Set the task ID')
18
+ .option('-e, --endpoint <endpoint>', 'Set the A2A endpoint (default: http://localhost:3000/a2a)')
19
+ .option('-c, --card', 'Show the agent card')
20
+ .option('-m, --message <message>', 'Send a single message and exit')
21
21
  .action(async (options) => {
22
22
  let client;
23
23
  try {
24
24
  client = await sdk.createMessenger({
25
- baseUrl: options?.endpoint ?? "http://localhost:3000/a2a",
25
+ baseUrl: options?.endpoint ?? 'http://localhost:3000/a2a',
26
26
  });
27
27
  }
28
28
  catch (error) {
29
- console.error(chalk.red("Error creating client:"));
29
+ console.error(chalk.red('Error creating client:'));
30
30
  console.error(error instanceof Error ? error.message : String(error));
31
31
  process.exit(1);
32
32
  }
33
33
  if (!client) {
34
- console.error(chalk.red("Failed to create client"));
34
+ console.error(chalk.red('Failed to create client'));
35
35
  process.exit(1);
36
36
  }
37
37
  let agentCard = await client.getAgentCard().catch((error) => {
38
- console.error(chalk.red("Error getting agent card:"));
38
+ console.error(chalk.red('Error getting agent card:'));
39
39
  console.error(error instanceof Error ? error.message : String(error));
40
40
  process.exit(1);
41
41
  });
@@ -51,12 +51,12 @@ program.configureHelp({
51
51
  sortSubcommands: true,
52
52
  showGlobalOptions: false,
53
53
  });
54
- program.on("command:*", () => {
55
- console.error(chalk.red(`Unknown command: ${program.args.join(" ")}`));
56
- console.log(chalk.yellow("See --help for available commands."));
54
+ program.on('command:*', () => {
55
+ console.error(chalk.red(`Unknown command: ${program.args.join(' ')}`));
56
+ console.log(chalk.yellow('See --help for available commands.'));
57
57
  process.exit(1);
58
58
  });
59
- program.on("exit", () => {
59
+ program.on('exit', () => {
60
60
  console.error(chalk.red(`Exiting...`));
61
61
  process.exit(0);
62
62
  });
@@ -1,2 +1,2 @@
1
- export * from "./chat.js";
2
- export * from "./cli.js";
1
+ export * from './chat.js';
2
+ export * from './cli.js';
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./chat.js";
2
- export * from "./cli.js";
1
+ export * from './chat.js';
2
+ export * from './cli.js';
package/package.json CHANGED
@@ -1,65 +1,66 @@
1
1
  {
2
- "name": "@artinet/ask",
3
- "version": "0.1.5",
4
- "description": "A lightweight command-line chat client for connecting to A2A Servers.",
5
- "author": "artinet",
6
- "license": "Apache-2.0",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/the-artinet-project/artinet"
10
- },
11
- "issues": {
12
- "url": "https://github.com/the-artinet-project/artinetissues"
13
- },
14
- "files": [
15
- "dist",
16
- "package.json",
17
- "README.md",
18
- "LICENSE"
19
- ],
20
- "bin": {
21
- "ask": "./dist/src/cli.js"
22
- },
23
- "keywords": [
24
- "ask",
25
- "artinet",
26
- "chat",
27
- "a2a",
28
- "agent2agent",
29
- "agent",
30
- "ai",
31
- "artificial intelligence"
32
- ],
33
- "engines": {
34
- "node": ">=20.0.0"
35
- },
36
- "type": "module",
37
- "main": "./dist/src/index.js",
38
- "module": "./dist/src/index.js",
39
- "types": "./dist/src/index.d.ts",
40
- "rootDir": ".",
41
- "scripts": {
42
- "prepublishOnly": "npm run clean:all && npm i && npm run build",
43
- "build": "tsc --project tsconfig.json",
44
- "clean": "rimraf dist",
45
- "clean:all": "rimraf dist node_modules package-lock.json",
46
- "dev": "tsx src/cli.ts",
47
- "dev:server": "tsx src/test-server.ts",
48
- "ask": "node dist/src/cli.js"
49
- },
50
- "dependencies": {
51
- "@artinet/sdk": "^0.6.4",
52
- "chalk": "^5.6.2",
53
- "commander": "^14.0.1",
54
- "prompts": "^2.4.2",
55
- "uuid": "^13.0.0"
56
- },
57
- "devDependencies": {
58
- "@types/node": "^25.0.9",
59
- "@types/prompts": "^2.4.9",
60
- "rimraf": "^6.1.2",
61
- "ts-node": "^10.9.2",
62
- "tsx": "^4.21.0",
63
- "typescript": "^5.9.3"
64
- }
2
+ "name": "@artinet/ask",
3
+ "version": "0.1.6",
4
+ "description": "A lightweight command-line chat client for connecting to A2A Servers.",
5
+ "author": "artinet",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/the-artinet-project/artinet"
10
+ },
11
+ "issues": {
12
+ "url": "https://github.com/the-artinet-project/artinetissues"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "package.json",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "bin": {
21
+ "ask": "./dist/src/cli.js"
22
+ },
23
+ "keywords": [
24
+ "ask",
25
+ "artinet",
26
+ "chat",
27
+ "a2a",
28
+ "agent2agent",
29
+ "agent",
30
+ "ai",
31
+ "artificial intelligence"
32
+ ],
33
+ "engines": {
34
+ "node": ">=20.0.0"
35
+ },
36
+ "type": "module",
37
+ "main": "./dist/src/index.js",
38
+ "module": "./dist/src/index.js",
39
+ "types": "./dist/src/index.d.ts",
40
+ "rootDir": ".",
41
+ "scripts": {
42
+ "prepublishOnly": "npm run clean:all && npm i && npm run build",
43
+ "build": "tsc --project tsconfig.json",
44
+ "postbuild": "chmod +x dist/src/cli.js",
45
+ "clean": "rimraf dist",
46
+ "clean:all": "rimraf dist node_modules package-lock.json",
47
+ "dev": "tsx src/cli.ts",
48
+ "dev:server": "tsx src/test-server.ts",
49
+ "ask": "node dist/src/cli.js"
50
+ },
51
+ "dependencies": {
52
+ "@artinet/sdk": "^0.6.4",
53
+ "chalk": "^5.6.2",
54
+ "commander": "^14.0.1",
55
+ "prompts": "^2.4.2",
56
+ "uuid": "^13.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^25.0.9",
60
+ "@types/prompts": "^2.4.9",
61
+ "rimraf": "^6.1.2",
62
+ "ts-node": "^10.9.2",
63
+ "tsx": "^4.21.0",
64
+ "typescript": "^5.9.3"
65
+ }
65
66
  }