@elizaos/agent 2.0.0-alpha.414 → 2.0.0-alpha.416

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.
Files changed (33) hide show
  1. package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.js +1 -90
  2. package/package.json +4 -4
  3. package/packages/agent/src/actions/index.d.ts +0 -1
  4. package/packages/agent/src/actions/index.d.ts.map +1 -1
  5. package/packages/agent/src/actions/index.js +0 -1
  6. package/packages/agent/src/api/accounts-routes.d.ts +31 -0
  7. package/packages/agent/src/api/accounts-routes.d.ts.map +1 -0
  8. package/packages/agent/src/api/accounts-routes.js +745 -0
  9. package/packages/agent/src/api/index.d.ts +1 -0
  10. package/packages/agent/src/api/index.d.ts.map +1 -1
  11. package/packages/agent/src/api/index.js +1 -0
  12. package/packages/agent/src/api/server.d.ts.map +1 -1
  13. package/packages/agent/src/api/server.js +14 -0
  14. package/packages/agent/src/api/subscription-routes.d.ts.map +1 -1
  15. package/packages/agent/src/api/subscription-routes.js +48 -1
  16. package/packages/agent/src/auth/credentials.d.ts.map +1 -1
  17. package/packages/agent/src/auth/credentials.js +14 -3
  18. package/packages/agent/src/providers/page-scoped-context.js +1 -1
  19. package/packages/agent/src/runtime/eliza-plugin.d.ts.map +1 -1
  20. package/packages/agent/src/runtime/eliza-plugin.js +0 -3
  21. package/packages/agent/src/runtime/plugin-collector.js +3 -4
  22. package/packages/app-core/src/components/pages/page-scoped-conversations.js +1 -1
  23. package/packages/app-core/src/services/auth-store.js +1 -1
  24. package/packages/shared/src/contracts/lifeops.d.ts +5 -4
  25. package/packages/shared/src/contracts/lifeops.d.ts.map +1 -1
  26. package/packages/typescript/src/generated/action-docs.d.ts +0 -15
  27. package/packages/typescript/src/generated/action-docs.d.ts.map +1 -1
  28. package/packages/typescript/src/generated/action-docs.js +0 -34
  29. package/packages/typescript/src/utils/context-catalog.d.ts.map +1 -1
  30. package/packages/typescript/src/utils/context-catalog.js +2 -3
  31. package/packages/agent/src/actions/app-control.d.ts +0 -23
  32. package/packages/agent/src/actions/app-control.d.ts.map +0 -1
  33. package/packages/agent/src/actions/app-control.js +0 -775
@@ -1,102 +1,13 @@
1
- // @ts-nocheck — mixin: type safety is enforced on the composed class
2
- import fs from "node:fs";
3
- import path from "node:path";
4
1
  import { fail } from "./service-normalize.js";
5
2
  import { drainWhatsAppInboundBuffer, parseAndBufferWhatsAppWebhookMessages, peekWhatsAppInboundBuffer, readWhatsAppCredentialsFromEnv, sendWhatsAppMessage as sendWhatsAppMessageRequest, WhatsAppError, } from "./whatsapp-client.js";
6
- function asRecord(value) {
7
- return value && typeof value === "object"
8
- ? value
9
- : null;
10
- }
11
- function nonEmptyString(value) {
12
- return typeof value === "string" && value.trim().length > 0
13
- ? value.trim()
14
- : null;
15
- }
16
- function readRuntimeSetting(runtime, key) {
17
- const getter = runtime;
18
- return (nonEmptyString(getter.getSetting?.(key)) ?? nonEmptyString(process.env[key]));
19
- }
20
- function getConnectorSetupService(runtime) {
21
- const service = runtime.getService("connector-setup");
22
- if (!service || typeof service !== "object") {
23
- return null;
24
- }
25
- const candidate = service;
26
- return typeof candidate.getConfig === "function" ? candidate : null;
27
- }
28
- function readWhatsAppConfigAuthDir(config) {
29
- const connectors = asRecord(config.connectors);
30
- const whatsapp = asRecord(connectors?.whatsapp);
31
- if (!whatsapp) {
32
- return null;
33
- }
34
- const directAuthDir = nonEmptyString(whatsapp.authDir) ?? nonEmptyString(whatsapp.sessionPath);
35
- if (directAuthDir) {
36
- return directAuthDir;
37
- }
38
- const accounts = asRecord(whatsapp.accounts);
39
- if (!accounts) {
40
- return null;
41
- }
42
- for (const account of Object.values(accounts)) {
43
- const accountConfig = asRecord(account);
44
- if (!accountConfig || accountConfig.enabled === false) {
45
- continue;
46
- }
47
- const accountAuthDir = nonEmptyString(accountConfig.authDir) ??
48
- nonEmptyString(accountConfig.sessionPath);
49
- if (accountAuthDir) {
50
- return accountAuthDir;
51
- }
52
- }
53
- return null;
54
- }
55
- function whatsappAuthExists(authDir) {
56
- if (!authDir) {
57
- return false;
58
- }
59
- return fs.existsSync(path.join(authDir, "creds.json"));
60
- }
61
- function resolveWhatsAppLocalAuthDir(args) {
62
- const serviceAuthDir = nonEmptyString(args.whatsappService?.config?.authDir);
63
- if (serviceAuthDir) {
64
- return serviceAuthDir;
65
- }
66
- const settingAuthDir = readRuntimeSetting(args.runtime, "WHATSAPP_AUTH_DIR") ??
67
- readRuntimeSetting(args.runtime, "WHATSAPP_SESSION_PATH") ??
68
- readRuntimeSetting(args.runtime, "ELIZA_WHATSAPP_SESSION_PATH");
69
- if (settingAuthDir) {
70
- return settingAuthDir;
71
- }
72
- const configAuthDir = args.setupService
73
- ? readWhatsAppConfigAuthDir(args.setupService.getConfig())
74
- : null;
75
- if (configAuthDir) {
76
- return configAuthDir;
77
- }
78
- const workspaceDir = args.setupService?.getWorkspaceDir?.();
79
- return workspaceDir
80
- ? path.join(workspaceDir, "whatsapp-auth", "default")
81
- : null;
82
- }
83
3
  /** @internal */
84
4
  export function withWhatsApp(Base) {
85
5
  class LifeOpsWhatsAppServiceMixin extends Base {
86
6
  async getWhatsAppConnectorStatus() {
87
7
  const creds = readWhatsAppCredentialsFromEnv();
88
- const whatsappService = this.runtime.getService("whatsapp");
89
- const setupService = getConnectorSetupService(this.runtime);
90
- const localAuthDir = resolveWhatsAppLocalAuthDir({
91
- runtime: this.runtime,
92
- setupService,
93
- whatsappService,
94
- });
95
- const localAuthExists = whatsappAuthExists(localAuthDir);
96
- const serviceConnected = Boolean(whatsappService?.connected);
97
8
  return {
98
9
  provider: "whatsapp",
99
- connected: creds !== null || localAuthExists || serviceConnected,
10
+ connected: creds !== null,
100
11
  inbound: true,
101
12
  ...(creds?.phoneNumberId ? { phoneNumberId: creds.phoneNumberId } : {}),
102
13
  lastCheckedAt: new Date().toISOString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/agent",
3
- "version": "2.0.0-alpha.414",
3
+ "version": "2.0.0-alpha.416",
4
4
  "description": "Standalone elizaOS-based agent and backend server package.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -467,7 +467,7 @@
467
467
  "@elizaos/app-steward": "^0.0.0",
468
468
  "@elizaos/app-task-coordinator": "^0.0.0",
469
469
  "@elizaos/app-training": "^0.0.1",
470
- "@elizaos/core": "^2.0.0-alpha.414",
470
+ "@elizaos/core": "^2.0.0-alpha.416",
471
471
  "@elizaos/plugin-agent-orchestrator": "^0.6.2-alpha.0",
472
472
  "@elizaos/plugin-browser-bridge": "^0.1.0",
473
473
  "@elizaos/plugin-local-embedding": "^2.0.0-alpha.12",
@@ -476,8 +476,8 @@
476
476
  "@elizaos/plugin-solana": "^2.0.0-alpha.6",
477
477
  "@elizaos/plugin-sql": "^2.0.0-alpha.19",
478
478
  "@elizaos/plugin-wechat": "^0.1.0",
479
- "@elizaos/shared": "^2.0.0-alpha.414",
480
- "@elizaos/skills": "^2.0.0-alpha.414",
479
+ "@elizaos/shared": "^2.0.0-alpha.416",
480
+ "@elizaos/skills": "^2.0.0-alpha.416",
481
481
  "@hapi/boom": "^10.0.1",
482
482
  "@noble/curves": "^2.0.1",
483
483
  "@solana/web3.js": "^1.98.4",
@@ -1,5 +1,4 @@
1
1
  export * from "./agent-inbox.js";
2
- export * from "./app-control.js";
3
2
  export * from "./configure-plugin.js";
4
3
  export * from "./connector-control.js";
5
4
  export * from "./context-signal.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export * from "./agent-inbox.js";
2
- export * from "./app-control.js";
3
2
  export * from "./configure-plugin.js";
4
3
  export * from "./connector-control.js";
5
4
  export * from "./context-signal.js";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Multi-account credentials CRUD + OAuth-from-UI routes.
3
+ *
4
+ * The HTTP surface this exposes (under `/api/accounts/...`) is the
5
+ * source of truth for the React settings page. It joins three sources:
6
+ *
7
+ * - the on-disk credential records under `~/.eliza/auth/...`
8
+ * (`account-storage.ts`),
9
+ * - the live `LinkedAccountConfig` rows in `milady.json` (which own
10
+ * `label`, `enabled`, `priority`, `health`, etc.),
11
+ * - the in-flight OAuth flow registry (`auth/oauth-flow.ts`) used by
12
+ * the `oauth/start` + SSE `oauth/status` + `oauth/cancel` trio.
13
+ *
14
+ * Provider-level account selection strategy lives in a dedicated
15
+ * top-level config key, `accountStrategies` (see `applyStrategyPatch`
16
+ * below). It's a separate slot from the per-capability
17
+ * `serviceRouting[capability].strategy` so the UI can express
18
+ * "always prefer my Pro Anthropic account before falling back to my
19
+ * Max one" without having to know which capability each provider
20
+ * powers.
21
+ */
22
+ import type { ElizaConfig } from "../config/types.eliza.js";
23
+ import type { RouteRequestContext } from "./route-helpers.js";
24
+ export interface AccountsRouteContext extends RouteRequestContext {
25
+ state: {
26
+ config: ElizaConfig;
27
+ };
28
+ saveConfig: (config: ElizaConfig) => void;
29
+ }
30
+ export declare function handleAccountsRoutes(ctx: AccountsRouteContext): Promise<boolean>;
31
+ //# sourceMappingURL=accounts-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts-routes.d.ts","sourceRoot":"","sources":["../../../../../src/api/accounts-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAsBH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAqW9D,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,KAAK,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,CAAC;IAC/B,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC3C;AAKD,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,OAAO,CAAC,CAoFlB"}