@alfe.ai/mcp-server 0.2.5 → 0.2.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.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
2
3
  import { ChangelogEntry, EncryptedEnvelopeV1, FieldEnvelope, FieldFormat, FieldSensitivity, GeneratedDataKey, IntegrationConfigResult, IntegrationInstall, RegistryEntry, ScopeInfo, SecretAggregate, SecretCategory, SecretMetadata, SecretScope } from "@alfe/types";
3
4
 
4
5
  //#region ../agent-api-client/dist/index.d.ts
@@ -29,26 +30,32 @@ declare class AgentApiTransport {
29
30
  * `Content-Type: application/json` and parses a `{ data: T }` envelope,
30
31
  * neither of which fits a raw-audio flow (voice TTS/STT), so those go
31
32
  * through this instead. Auth (Bearer), the request budget, and the single
32
- * retry on transient 5xx / network errors are kept in sync with
33
- * `request()`. Retries fire only on statuses produced BEFORE the route
34
- * handler runs (authorizer-timeout 500 + LB 502/503/504), so re-issuing a
35
- * POST does not risk a duplicate side effect.
33
+ * retry policy on transient 5xx / network errors is kept in sync with
34
+ * `request()`. Safe read methods retry once by default; mutation methods do
35
+ * not, because a response can be lost after a handler or provider call has
36
+ * already succeeded.
36
37
  */
37
38
  rawRequest(path: string, init: {
38
39
  method: string;
39
40
  headers: Headers;
40
41
  body?: BodyInit | Uint8Array;
42
+ }, extra?: {
43
+ retry?: boolean;
41
44
  }): Promise<Response>;
42
45
  /**
43
46
  * @param extra.timeoutMs Per-request abort timeout (default REQUEST_TIMEOUT_MS).
44
47
  * Long endpoints (image generation) pass a larger value so the gateway's
45
48
  * own timeout wins with a readable status instead of a client-side abort.
46
- * @param extra.retry Whether to retry once on transient failures (default
47
- * true). Expensive/non-idempotent endpoints pass false.
49
+ * @param extra.retry Whether to retry once on transient failures. Safe reads
50
+ * (GET/HEAD/OPTIONS) default to true; mutations default to false. Set true
51
+ * only when the endpoint's server-side contract is explicitly idempotent.
52
+ * @param extra.signal Optional caller cancellation combined with the client's
53
+ * own timeout budget. Aborting either signal cancels the request.
48
54
  */
49
55
  request<T>(path: string, options?: RequestInit, extra?: {
50
56
  timeoutMs?: number;
51
57
  retry?: boolean;
58
+ signal?: AbortSignal;
52
59
  }): Promise<T>;
53
60
  }
54
61
  /**
@@ -64,7 +71,7 @@ declare class ApiBase {
64
71
  //# sourceMappingURL=transport.d.ts.map
65
72
  //#endregion
66
73
  //#region src/domains/workspace.d.ts
67
- /** Response of GET /agents/me/workspace (services/agents). */
74
+ /** Response of GET /agent/workspace (services/agents). */
68
75
  interface AgentWorkspaceInfo {
69
76
  templateKey?: string;
70
77
  defaultModel?: string;
@@ -92,7 +99,7 @@ interface AgentWorkspaceInfo {
92
99
  }
93
100
  declare class WorkspaceApi extends ApiBase {
94
101
  /**
95
- * GET /agents/me/workspace — workspace config for the authenticated agent
102
+ * GET /agent/workspace — workspace config for the authenticated agent
96
103
  * (template assignment, default model, org roster).
97
104
  */
98
105
  getWorkspace(): Promise<AgentWorkspaceInfo>;
@@ -235,6 +242,8 @@ declare class SyncApi extends ApiBase {
235
242
  sharedListFiles(args: {
236
243
  scope: "org" | "team" | "project";
237
244
  scopeId: string;
245
+ limit?: number;
246
+ cursor?: string;
238
247
  }): Promise<{
239
248
  files: SharedFileEntry[];
240
249
  nextCursor: string | null;
@@ -394,7 +403,9 @@ declare class KnowledgeApi extends ApiBase {
394
403
  * from `services/org`, then fetches the bytes directly from S3 (the one
395
404
  * legitimate raw fetch in a plugin — same pattern as sync).
396
405
  */
397
- readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string): Promise<{
406
+ readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, opts?: {
407
+ maxBytes?: number;
408
+ }): Promise<{
398
409
  filePath: string;
399
410
  text: string;
400
411
  }>;
@@ -433,15 +444,11 @@ interface MobileAvailableNumber {
433
444
  }
434
445
  /** Approved WhatsApp content template from GET /mobile/whatsapp/templates. */
435
446
  interface WhatsAppTemplate {
436
- sid: string;
437
- friendlyName: string;
447
+ contentSid: string;
448
+ name: string;
438
449
  language: string;
439
450
  body: string;
440
451
  variables: Record<string, string>;
441
- dateCreated: string;
442
- dateUpdated: string;
443
- approvalStatus?: string;
444
- rejectionReason?: string;
445
452
  category?: string;
446
453
  }
447
454
  declare class MobileApi extends ApiBase {
@@ -689,15 +696,22 @@ declare class SearchApi extends ApiBase {
689
696
  offset?: number;
690
697
  country?: string;
691
698
  freshness?: string;
699
+ }, options?: {
700
+ signal?: AbortSignal;
692
701
  }): Promise<unknown>;
693
702
  searchImages(params: {
694
703
  query: string;
695
704
  count?: number;
705
+ }, options?: {
706
+ signal?: AbortSignal;
696
707
  }): Promise<unknown>;
697
708
  searchNews(params: {
698
709
  query: string;
699
710
  count?: number;
711
+ offset?: number;
700
712
  freshness?: string;
713
+ }, options?: {
714
+ signal?: AbortSignal;
701
715
  }): Promise<unknown>;
702
716
  /** Search news across the selected provider's corpus. → POST /agent/news/search */
703
717
  newsSearch(params: {
@@ -721,6 +735,48 @@ declare class SearchApi extends ApiBase {
721
735
  }
722
736
  //# sourceMappingURL=search.d.ts.map
723
737
  //#endregion
738
+ //#region src/domains/webhooks.d.ts
739
+ interface AgentWebhook {
740
+ webhookId: string;
741
+ tenantId: string;
742
+ agentId: string;
743
+ name: string;
744
+ provider: string;
745
+ active: boolean;
746
+ createdBy: string;
747
+ createdAt: string;
748
+ updatedAt: string;
749
+ }
750
+ interface CreatedAgentWebhook extends AgentWebhook {
751
+ url: string;
752
+ signingSecret: string;
753
+ }
754
+ interface AgentWebhookDelivery {
755
+ deliveryId: string;
756
+ webhookId: string;
757
+ status: string;
758
+ attempts: number;
759
+ createdAt: string;
760
+ deliveredAt?: string;
761
+ }
762
+ declare class WebhooksApi extends ApiBase {
763
+ createWebhook(args: {
764
+ name: string;
765
+ provider?: "generic" | "github" | "stripe" | "slack";
766
+ }): Promise<CreatedAgentWebhook>;
767
+ listWebhooks(): Promise<AgentWebhook[]>;
768
+ deleteWebhook(webhookId: string): Promise<{
769
+ webhookId: string;
770
+ active: false;
771
+ }>;
772
+ rotateWebhookSecret(webhookId: string): Promise<{
773
+ webhookId: string;
774
+ signingSecret: string;
775
+ }>;
776
+ listWebhookDeliveries(webhookId: string): Promise<AgentWebhookDelivery[]>;
777
+ }
778
+ //# sourceMappingURL=webhooks.d.ts.map
779
+ //#endregion
724
780
  //#region src/domains/chat.d.ts
725
781
  declare class ChatApi extends ApiBase {
726
782
  presignAttachments(files: {
@@ -857,8 +913,9 @@ declare class ConnectCredentialsApi extends ApiBase {
857
913
  * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
858
914
  * and look up the matching account by that selector at dispatch time.
859
915
  *
860
- * Returned `accounts[i].accountIdentifier` is the Xero tenantId the
861
- * stable cross-session identifier the LLM should pass.
916
+ * `xeroTenantId` is the model-facing organisation selector. The separate
917
+ * `accountIdentifier` is the Connect persistence key used for refresh and
918
+ * may be an email; never substitute one for the other.
862
919
  */
863
920
  getXeroAccounts(): Promise<{
864
921
  accounts: {
@@ -876,12 +933,12 @@ declare class ConnectCredentialsApi extends ApiBase {
876
933
  expiresAt: string;
877
934
  }>;
878
935
  /**
879
- * Pattern A: refresh a specific Xero connection by its `accountIdentifier`
880
- * (the Xero `tenantId`). The legacy `refreshXeroToken()` only refreshes
881
- * the *primary* connection, which is wrong for multi-tenant Xero where
882
- * each tenant has its own non-interchangeable access token.
936
+ * Refresh a specific Xero Connection by its exact `accountIdentifier` from
937
+ * `getXeroAccounts()`. Do not substitute `xeroTenantId`: current Xero OAuth
938
+ * rows may use the account email as their persistence key even when a sole
939
+ * organisation tenant ID is available in provider metadata.
883
940
  */
884
- refreshXeroAccountToken(xeroTenantId: string): Promise<{
941
+ refreshXeroAccountToken(accountIdentifier: string): Promise<{
885
942
  accessToken: string;
886
943
  accessTokenExpiresAt: string;
887
944
  expiresAt: string;
@@ -1036,6 +1093,21 @@ declare class ConnectCredentialsApi extends ApiBase {
1036
1093
  accessToken: string;
1037
1094
  expiresAt: string;
1038
1095
  }>;
1096
+ /**
1097
+ * Pattern A: refresh one MYOB Connection by its stable
1098
+ * `accountIdentifier` (the MYOB business id returned by
1099
+ * `getMYOBAccounts()`).
1100
+ *
1101
+ * MYOB refresh tokens belong to individual Connection rows. A
1102
+ * multi-business client must use this method instead of refreshing the
1103
+ * primary Connection and copying that access token into every cached
1104
+ * business client.
1105
+ */
1106
+ refreshMYOBAccountToken(accountIdentifier: string): Promise<{
1107
+ accessToken: string;
1108
+ accessTokenExpiresAt: string;
1109
+ expiresAt: string;
1110
+ }>;
1039
1111
  /**
1040
1112
  * @deprecated Returns a single primary credential blob. Use
1041
1113
  * `getSalesforceAccounts()` for the multi-account shape required by
@@ -1098,9 +1170,6 @@ declare class ConnectCredentialsApi extends ApiBase {
1098
1170
  connectedAt: string;
1099
1171
  accessToken: string;
1100
1172
  accessTokenExpiresAt: string;
1101
- refreshToken: string;
1102
- clientId: string;
1103
- clientSecret: string;
1104
1173
  email: string;
1105
1174
  microsoftTenantId: string;
1106
1175
  workspaceDomain: string;
@@ -1374,59 +1443,35 @@ declare class IdentityApi extends ApiBase {
1374
1443
  }>;
1375
1444
  mergeIdentities(survivorId: string, args: {
1376
1445
  mergedId: string;
1377
- changedBy: {
1378
- type: string;
1379
- id: string;
1380
- name?: string;
1381
- };
1382
1446
  }): Promise<{
1383
1447
  ok: boolean;
1384
1448
  error?: string;
1385
1449
  }>;
1386
- unmergeIdentity(identityId: string, args: {
1387
- changedBy: {
1388
- type: string;
1389
- id: string;
1390
- name?: string;
1391
- };
1392
- }): Promise<{
1450
+ unmergeIdentity(identityId: string): Promise<{
1393
1451
  ok: boolean;
1394
1452
  error?: string;
1395
1453
  }>;
1396
1454
  addIdentityNote(identityId: string, args: {
1397
1455
  content: string;
1398
1456
  category?: string;
1399
- changedBy: {
1400
- type: string;
1401
- id: string;
1402
- name?: string;
1403
- };
1404
1457
  }): Promise<{
1405
1458
  noteId: string | null;
1406
1459
  }>;
1407
1460
  tagIdentity(identityId: string, args: {
1408
1461
  tag: string;
1409
1462
  action: "add" | "remove";
1410
- changedBy: {
1411
- type: string;
1412
- id: string;
1413
- name?: string;
1414
- };
1415
1463
  }): Promise<{
1416
1464
  ok: boolean;
1417
1465
  }>;
1418
1466
  getIdentityChangelog(identityId: string, args?: {
1419
1467
  limit?: number;
1468
+ cursor?: string;
1420
1469
  }): Promise<{
1421
1470
  entries: unknown[];
1471
+ cursor: string | null;
1422
1472
  }>;
1423
1473
  rollbackIdentity(identityId: string, args: {
1424
1474
  targetVersion: number;
1425
- changedBy: {
1426
- type: string;
1427
- id: string;
1428
- name?: string;
1429
- };
1430
1475
  }): Promise<{
1431
1476
  ok: boolean;
1432
1477
  entry?: unknown;
@@ -1465,7 +1510,7 @@ declare class IdentityApi extends ApiBase {
1465
1510
  verified: boolean;
1466
1511
  identityId?: string;
1467
1512
  /** Phase 2: how the confirm resolved — Scenario A vs B. */
1468
- action?: "merged" | "contact_verified";
1513
+ action?: "merged" | "contact_verified" | "already_confirmed";
1469
1514
  error?: string;
1470
1515
  }>;
1471
1516
  /**
@@ -1597,8 +1642,21 @@ declare class MemoryApi extends ApiBase {
1597
1642
  messageCount: number;
1598
1643
  }>;
1599
1644
  memoryLoadContext(tier?: number, topicHint?: string): Promise<{
1645
+ tier: number;
1646
+ facts: {
1647
+ subject: string;
1648
+ predicate: string;
1649
+ object: string;
1650
+ since: string;
1651
+ }[];
1652
+ memories: {
1653
+ text: string;
1654
+ topic: string;
1655
+ subtopic: string;
1656
+ score: number;
1657
+ }[];
1658
+ tokenEstimate: number;
1600
1659
  formatted: string;
1601
- [key: string]: unknown;
1602
1660
  }>;
1603
1661
  memoryLookupEntity(subject: string): Promise<{
1604
1662
  subject: string;
@@ -1830,7 +1888,7 @@ declare class TeamsApi extends ApiBase {
1830
1888
 
1831
1889
  //#endregion
1832
1890
  //#region src/index.d.ts
1833
- interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi {}
1891
+ interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi, WebhooksApi {}
1834
1892
  declare class AgentApiClient extends ApiBase {
1835
1893
  constructor(config: AgentApiClientConfig);
1836
1894
  }
@@ -1881,8 +1939,8 @@ declare const SERVER_BIN_PATH: string;
1881
1939
  type ServerProfile = 'default' | 'claude-code';
1882
1940
  interface ServerOptions {
1883
1941
  /**
1884
- * Optional override for the API client tests inject a fake so the
1885
- * server can be exercised end-to-end without real network I/O.
1942
+ * Optional pre-bound API client. Must be supplied together with `apiUrl` so
1943
+ * the client authority and the OAuth URL authority cannot diverge.
1886
1944
  */
1887
1945
  client?: AgentApiClient;
1888
1946
  /** Pre-resolved context fields. If omitted, the server calls `whoami()` itself. */
@@ -1890,7 +1948,7 @@ interface ServerOptions {
1890
1948
  agentId: string;
1891
1949
  tenantId: string;
1892
1950
  };
1893
- /** Override apiUrl reported in the ToolContext. Defaults to the resolved CLI config. */
1951
+ /** Authority bound to an injected `client`. Omit both to use resolved CLI config. */
1894
1952
  apiUrl?: string;
1895
1953
  /**
1896
1954
  * Tool surface to register. Defaults to `default` (integrations only) so
@@ -1912,9 +1970,9 @@ interface ServerOptions {
1912
1970
  * Pure construction — does not connect a transport. Callers (the bin
1913
1971
  * entry, or tests) attach `StdioServerTransport` or any other transport.
1914
1972
  *
1915
- * `resolveConfig()` is only called when neither `client` nor `apiUrl`
1916
- * is provided tests can fully construct the server without touching
1917
- * `~/.alfe/config.toml`.
1973
+ * `resolveConfig()` is only called when the main `client`/`apiUrl` pair is
1974
+ * omitted. Tests and alternate hosts can inject a complete pair without
1975
+ * touching `~/.alfe/config.toml`.
1918
1976
  */
1919
1977
  declare function createServer(opts?: ServerOptions): Promise<McpServer>;
1920
1978
  /**
@@ -1925,14 +1983,13 @@ declare function createServer(opts?: ServerOptions): Promise<McpServer>;
1925
1983
  */
1926
1984
  declare function parseProfileArg(argv: string[]): ServerProfile;
1927
1985
  /**
1928
- * Entry point boot the server on stdio. Used by `bin.ts`. Any
1929
- * startup failure is fatal: log and exit non-zero so the bundler's
1930
- * connection attempt surfaces a clear error rather than a hung
1931
- * handshake.
1986
+ * Boot the server and attach its transport. Used by `bin.ts`; tests can inject
1987
+ * an in-memory transport. Process policy (logging, exit code, signals) remains
1988
+ * in the executable boundary rather than this reusable library function.
1932
1989
  */
1933
- declare function main(opts?: {
1934
- profile?: ServerProfile;
1935
- }): Promise<void>;
1990
+ declare function main(opts?: ServerOptions & {
1991
+ transport?: Transport;
1992
+ }): Promise<McpServer>;
1936
1993
  //# sourceMappingURL=index.d.ts.map
1937
1994
 
1938
1995
  //#endregion