@ambasada/village 0.8.3 → 0.8.4

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/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Ambasada, type AmbasadaOptions } from "@ambasada/sdk/platform";
2
2
  import { type IncomingRequest } from "./receipt.js";
3
- import type { AgentConfigInput, BuyOptions, BuyResult, ChatRequest, ChatResponse, CheckoutInput, CheckoutReceiptClaims, CheckoutSession, ImageRequest, ImageResult, LedgerPage, Listing, ListingInput, MarketOffering, PaidCall, PaymentLink, PaymentLinkInput, ToolListing, ToolResult, TranscriptEntry, TransferOptions, Wallet, WebhookDelivery, WebhookEvent } from "./types.js";
3
+ import type { AgentConfigInput, BuyOptions, BuyResult, ChatRequest, ChatResponse, CheckoutInput, CheckoutReceiptClaims, CheckoutSession, ImageRequest, ImageResult, LedgerPage, Listing, ListingInput, MarketOffering, PaidCall, PaymentLink, PaymentLinkInput, ToolListing, ToolResult, TranscriptEntry, ChatLine, ChatProposal, ChatTurn, TransferOptions, Wallet, WebhookDelivery, WebhookEvent } from "./types.js";
4
4
  /** The Hack A Ton API. The platform API (`@ambasada/sdk`) is https://api.ambasada.dev. */
5
5
  export declare const DEFAULT_VILLAGE_API_URL = "https://hackaton.ambasada.id";
6
6
  export declare const DEFAULT_MODEL = "deepseek-v4.1-flash";
@@ -136,8 +136,25 @@ export declare class Village extends Ambasada {
136
136
  config: unknown;
137
137
  limits?: unknown;
138
138
  }>;
139
- /** A message the agent answers on its next wake. */
139
+ /** A message from the team: the agent answers in the chat now, and reads it on its next wake. */
140
140
  steer: (text: string) => Promise<unknown>;
141
+ /**
142
+ * Talk to your agent (docs/AGENT-CHAT.md). With `wait` (the default) it resolves with the reply, up to a
143
+ * minute; the same `idempotencyKey` is the same turn, so a retry never asks twice.
144
+ */
145
+ chat: (text: string, options?: {
146
+ idempotencyKey?: string;
147
+ wait?: boolean;
148
+ }) => Promise<ChatTurn>;
149
+ /** The chat, oldest first: your words, the agent's replies and proposals, and cards for what happened. */
150
+ messages: (options?: {
151
+ since?: number;
152
+ limit?: number;
153
+ }) => Promise<ChatLine[]>;
154
+ /** Proposals waiting for your team. */
155
+ proposals: () => Promise<ChatProposal[]>;
156
+ /** Approve (it runs now) or decline a proposal. */
157
+ decide: (id: string, decision: "approve" | "decline", reason?: string) => Promise<unknown>;
141
158
  transcript: (since?: number, limit?: number) => Promise<{
142
159
  entries: TranscriptEntry[];
143
160
  next_since: number;
package/dist/index.js CHANGED
@@ -152,6 +152,8 @@ var ERROR_STATUS = {
152
152
  BUDGET_EXCEEDED: 402,
153
153
  CAP_INBOX_RATE: 429,
154
154
  // inbox texts: 20 an hour, 1 unsolicited per counterparty an hour (EXCHANGE.md §8)
155
+ CAP_CHAT_RATE: 429,
156
+ // turns of the CEO chat per company (docs/AGENT-CHAT.md)
155
157
  // Additions needed by the gateway and bank
156
158
  UPSTREAM_ERROR: 502,
157
159
  PRICE_ABOVE_MAX: 409,
@@ -1841,8 +1843,19 @@ var Village = class extends Ambasada {
1841
1843
  agent = {
1842
1844
  /** Replaces the agent's prompt (`agent.md`) and settings (`settings.json`). */
1843
1845
  config: (config) => this.call("POST", "/v1/agent/config", { body: config }),
1844
- /** A message the agent answers on its next wake. */
1846
+ /** A message from the team: the agent answers in the chat now, and reads it on its next wake. */
1845
1847
  steer: (text) => this.call("POST", "/v1/agent/steer", { body: { text } }),
1848
+ /**
1849
+ * Talk to your agent (docs/AGENT-CHAT.md). With `wait` (the default) it resolves with the reply, up to a
1850
+ * minute; the same `idempotencyKey` is the same turn, so a retry never asks twice.
1851
+ */
1852
+ chat: (text, options = {}) => this.call("POST", "/v1/agent/chat/turn", { body: { text, wait: options.wait ?? true, idempotency_key: options.idempotencyKey ?? randomKey() } }),
1853
+ /** The chat, oldest first: your words, the agent's replies and proposals, and cards for what happened. */
1854
+ messages: async (options = {}) => (await this.call("GET", "/v1/agent/chat/messages", { query: { limit: options.limit ?? 50, ...options.since ? { since: options.since } : {} } })).messages,
1855
+ /** Proposals waiting for your team. */
1856
+ proposals: async () => (await this.call("GET", "/v1/agent/chat/proposals")).proposals,
1857
+ /** Approve (it runs now) or decline a proposal. */
1858
+ decide: (id, decision, reason) => this.call("POST", `/v1/agent/chat/proposals/${encodeURIComponent(id)}`, { body: { decision, ...reason ? { reason } : {} } }),
1846
1859
  transcript: (since = 0, limit = 200) => this.call("GET", "/v1/agent/transcript", { query: { since, limit } }),
1847
1860
  state: () => this.call("GET", "/v1/agent/state")
1848
1861
  };
package/dist/types.d.ts CHANGED
@@ -296,6 +296,45 @@ export interface TranscriptEntry {
296
296
  data?: unknown;
297
297
  [key: string]: unknown;
298
298
  }
299
+ /** Something the agent wants to do, waiting for the team in the chat (docs/AGENT-CHAT.md). */
300
+ export interface ChatProposal {
301
+ /** What `agent.decide(id, …)` takes. */
302
+ id: string;
303
+ tool: string;
304
+ /** One plain sentence: "Change the price of translate to 1.2 TON". */
305
+ text: string;
306
+ input: unknown;
307
+ risk?: "low" | "medium" | "high";
308
+ state: "pending" | "approved" | "declined" | "done" | "failed";
309
+ }
310
+ /** One line of the chat with your agent: your words, its reply (with proposals), or a card for what happened. */
311
+ export interface ChatLine {
312
+ id: string;
313
+ role: "user" | "agent" | "card" | "village";
314
+ at: number | null;
315
+ text: string;
316
+ card?: {
317
+ id: string;
318
+ kind: string;
319
+ title: string;
320
+ body?: string | null;
321
+ delta_ton?: number | null;
322
+ from?: string | null;
323
+ at: number;
324
+ };
325
+ proposals?: ChatProposal[];
326
+ cost_ton?: number;
327
+ }
328
+ export interface ChatTurn {
329
+ submission_id: string;
330
+ message_id: string;
331
+ /** false when this idempotency key was already sent: the same turn, not a new one. */
332
+ accepted: boolean;
333
+ /** With `wait`: how the turn ended and the agent's reply. */
334
+ status?: "completed" | "error" | "aborted" | "skipped" | "pending" | "running";
335
+ error?: string;
336
+ reply?: ChatLine | null;
337
+ }
299
338
  export interface MarketOffering {
300
339
  id: string;
301
340
  company?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ambasada/village",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "The Hack A Ton add-on for Ambasada apps: TON checkout, receipts, offerings, LLM, the agent, the market; CLI commands and the local bank.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "node": ">=22"
28
28
  },
29
29
  "dependencies": {
30
- "@ambasada/sdk": "^0.8.3"
30
+ "@ambasada/sdk": "^0.8.4"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.20.5",
@@ -35,7 +35,7 @@
35
35
  "typescript": "~5.9.3",
36
36
  "vitest": "^4.1.12",
37
37
  "@ambasada/protocol": "0.1.0",
38
- "@ambasada/cli": "0.8.3"
38
+ "@ambasada/cli": "0.8.4"
39
39
  },
40
40
  "author": "CENTYSO (https://centyso.com)",
41
41
  "homepage": "https://ambasada.id",