@artil-ai/server 0.1.1 → 0.1.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.
package/README.md CHANGED
@@ -34,8 +34,7 @@ reaching the server from outside needs Tailscale. Both can wait for
34
34
  **2. Sign a client in**
35
35
 
36
36
  ```bash
37
- export ARTIL_BASE_URL=http://localhost:4747
38
- artil auth login --account claude
37
+ artil auth login --base-url http://localhost:4747
39
38
  ```
40
39
 
41
40
  The CLI remembers the server from here on.
package/bin/main.js CHANGED
@@ -22187,11 +22187,15 @@ class TelegramChannel extends Channel {
22187
22187
  name = "Telegram";
22188
22188
  recipients = "the id of someone who wrote to the agent's bot first, or a bot's @username";
22189
22189
  senders = "a person's @username or Telegram user id, or a bot's @username";
22190
- credentials = "The bot's token, from @BotFather";
22190
+ credentials = "Bot token";
22191
22191
  credentialsGuide = [
22192
- "In Telegram, send /mybots to @BotFather, choose the bot and tap API Token to copy its token; /newbot makes a new bot.",
22193
- "Messages to the bot then reach the agent instead of anything the bot was connected to before, and a bot belongs to one agent at a time.",
22194
- "A bot cannot start a chat, so the agent writes only to people who wrote to its bot first, and it reads private chats only."
22192
+ "Open @BotFather in Telegram.",
22193
+ "Send /newbot to make a bot, or /mybots to pick one you have.",
22194
+ "Tap API Token and copy it.",
22195
+ "",
22196
+ "Messages to the bot reach this account from now on.",
22197
+ "People write to the bot first, in private chats.",
22198
+ "Then the agent can answer."
22195
22199
  ].join(`
22196
22200
  `);
22197
22201
  #provider;
@@ -22322,7 +22326,7 @@ var channel = {
22322
22326
  create: ({ webhookUrl, secret, fetch: fetch2 }) => new TelegramChannel(createBotApi({ webhook: webhookUrl ? { url: webhookUrl, secret } : undefined, fetch: fetch2 }))
22323
22327
  };
22324
22328
  // package.json
22325
- var version2 = "0.1.1";
22329
+ var version2 = "0.1.3";
22326
22330
 
22327
22331
  // src/app/cli.ts
22328
22332
  import { parseArgs } from "util";
@@ -24087,11 +24091,28 @@ function createAddressCommands({ agents, addresses, out }) {
24087
24091
  ]);
24088
24092
  }
24089
24093
 
24094
+ // src/platform/artil-cli.ts
24095
+ var {$ } = globalThis.Bun;
24096
+ function loginCommand(baseUrl) {
24097
+ return `artil auth login --base-url ${baseUrl}`;
24098
+ }
24099
+ function findArtilCli() {
24100
+ return {
24101
+ installed: Bun.which("artil") !== null,
24102
+ async install() {
24103
+ const installed = await $`bun install --global artil-ai`.nothrow().quiet();
24104
+ if (installed.exitCode !== 0) {
24105
+ throw new Error(installed.stderr.toString().trim() || `bun install exited with ${installed.exitCode}`);
24106
+ }
24107
+ }
24108
+ };
24109
+ }
24110
+
24090
24111
  // src/domains/agents/commands.ts
24091
24112
  function signInGuide({ baseUrl, names }) {
24092
24113
  return [
24093
24114
  `Sign ${names.length === 1 ? "the agent" : "each agent"} in from its client:`,
24094
- ...names.map((name) => ` ARTIL_BASE_URL=${baseUrl} artil auth login --account ${shellQuoted(name)}`),
24115
+ ...names.map((name) => ` ${loginCommand(baseUrl)} --account ${shellQuoted(name)}`),
24095
24116
  `MCP clients connect to ${baseUrl}/mcp and sign in on the page it opens.`,
24096
24117
  "On a computer without a browser, make a token with: artil-server account token <name>"
24097
24118
  ].join(`
@@ -24138,7 +24159,7 @@ function createAgentCommands({
24138
24159
  const token = tokens.issue({ agentId: agent.id, name: "artil-server account token" });
24139
24160
  out([
24140
24161
  `A token for ${agent.name}. Keep it secret; it signs in as the agent until you revoke it.`,
24141
- ` ARTIL_BASE_URL=${await baseUrl()} artil auth login --token ${token}`
24162
+ ` ${loginCommand(await baseUrl())} --token ${token}`
24142
24163
  ].join(`
24143
24164
  `));
24144
24165
  }
@@ -52003,7 +52024,7 @@ function createApp({ services, hosts, password: password2, workspace, log: log2
52003
52024
  }).get("/accounts/*", (c3) => c3.text(`This server has no web app. Manage its agents with artil-server; see artil-server --help.
52004
52025
  `)).get("/", (c3) => c3.text(`Artil Server is running. Sign an agent in with:
52005
52026
 
52006
- ARTIL_BASE_URL=${hosts.requestOrigin(c3.req.raw)} artil auth login
52027
+ ${loginCommand(hosts.requestOrigin(c3.req.raw))}
52007
52028
  `)).all("*", (c3) => notFound(c3.req.method, c3.req.path));
52008
52029
  }
52009
52030
 
@@ -52135,12 +52156,14 @@ async function createAgents(context) {
52135
52156
  }
52136
52157
  }
52137
52158
  async function setUpChannel({ context, channel: channel2 }) {
52138
- const agents2 = context.agents.list();
52139
- if (agents2.length === 0)
52140
- return;
52141
- for (;; ) {
52159
+ function accountsWithout() {
52160
+ return context.agents.list().filter(({ id: id2 }) => !context.addresses.findByAgent({ agentId: id2, channel: channel2.kind }));
52161
+ }
52162
+ let connected = false;
52163
+ let agents2 = accountsWithout();
52164
+ while (agents2.length > 0) {
52142
52165
  const connectNow = requireAnswer(await confirm({
52143
- message: `Connect a ${channel2.name} address to an account?`,
52166
+ message: `Connect a ${channel2.name} address to ${connected ? "another" : "an"} account?`,
52144
52167
  initialValue: false
52145
52168
  }));
52146
52169
  if (!connectNow)
@@ -52164,10 +52187,12 @@ async function setUpChannel({ context, channel: channel2 }) {
52164
52187
  credentials: credentials.trim()
52165
52188
  });
52166
52189
  progressSpinner.stop(`${address.value} now reaches ${agent.name} on ${channel2.name}`);
52190
+ connected = true;
52167
52191
  } catch (cause) {
52168
52192
  progressSpinner.error(messageOf(cause, `Could not connect the ${channel2.name} address`));
52169
52193
  continue;
52170
52194
  }
52195
+ agents2 = accountsWithout();
52171
52196
  const sender = requireAnswer(await text({
52172
52197
  message: `Who may wake ${agent.name} on ${channel2.name}? Give ${channel2.senders}, or leave it empty for only the server's agents`,
52173
52198
  defaultValue: ""
@@ -52387,7 +52412,7 @@ async function serve({ paths, config: config2, environment }) {
52387
52412
  log: out
52388
52413
  });
52389
52414
  out(`Artil Server is at ${server.baseUrl}${config2.public ? " (public, through Tailscale Funnel)" : ""}.`);
52390
- out(`Sign an agent in with: ARTIL_BASE_URL=${server.baseUrl} artil auth login`);
52415
+ out(`Sign an agent in with: ${loginCommand(server.baseUrl)}`);
52391
52416
  out(`MCP clients connect to ${server.baseUrl}/mcp`);
52392
52417
  const { promise: promise3, resolve } = Promise.withResolvers();
52393
52418
  process.once("SIGINT", resolve);
@@ -52490,20 +52515,6 @@ async function runCli(environment) {
52490
52515
  }
52491
52516
  }
52492
52517
 
52493
- // src/platform/artil-cli.ts
52494
- var {$ } = globalThis.Bun;
52495
- function findArtilCli() {
52496
- return {
52497
- installed: Bun.which("artil") !== null,
52498
- async install() {
52499
- const installed = await $`bun install --global artil-ai`.nothrow().quiet();
52500
- if (installed.exitCode !== 0) {
52501
- throw new Error(installed.stderr.toString().trim() || `bun install exited with ${installed.exitCode}`);
52502
- }
52503
- }
52504
- };
52505
- }
52506
-
52507
52518
  // src/platform/tailscale.ts
52508
52519
  import { existsSync } from "fs";
52509
52520
  var statusSchema = exports_external2.object({
@@ -52602,5 +52613,5 @@ try {
52602
52613
  process.exitCode = 1;
52603
52614
  }
52604
52615
 
52605
- //# debugId=F29E635AF65D464664756E2164756E21
52616
+ //# debugId=AEA9957F245E4E5164756E2164756E21
52606
52617
  //# sourceMappingURL=main.js.map