moeba-sdk 1.0.0

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 (41) hide show
  1. package/dist/client.d.ts +57 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +137 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/components/index.d.ts +4 -0
  6. package/dist/components/index.d.ts.map +1 -0
  7. package/dist/components/index.js +10 -0
  8. package/dist/components/index.js.map +1 -0
  9. package/dist/components/oauth.d.ts +26 -0
  10. package/dist/components/oauth.d.ts.map +1 -0
  11. package/dist/components/oauth.js +53 -0
  12. package/dist/components/oauth.js.map +1 -0
  13. package/dist/components/secret.d.ts +15 -0
  14. package/dist/components/secret.d.ts.map +1 -0
  15. package/dist/components/secret.js +25 -0
  16. package/dist/components/secret.js.map +1 -0
  17. package/dist/components/workflow.d.ts +63 -0
  18. package/dist/components/workflow.d.ts.map +1 -0
  19. package/dist/components/workflow.js +118 -0
  20. package/dist/components/workflow.js.map +1 -0
  21. package/dist/handler.d.ts +43 -0
  22. package/dist/handler.d.ts.map +1 -0
  23. package/dist/handler.js +136 -0
  24. package/dist/handler.js.map +1 -0
  25. package/dist/index.d.ts +7 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +22 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/response.d.ts +36 -0
  30. package/dist/response.d.ts.map +1 -0
  31. package/dist/response.js +84 -0
  32. package/dist/response.js.map +1 -0
  33. package/dist/security.d.ts +17 -0
  34. package/dist/security.d.ts.map +1 -0
  35. package/dist/security.js +63 -0
  36. package/dist/security.js.map +1 -0
  37. package/dist/types.d.ts +192 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/types.js +6 -0
  40. package/dist/types.js.map +1 -0
  41. package/package.json +22 -0
@@ -0,0 +1,57 @@
1
+ import type { MoebaClientOptions, SendMessagePayload, SendResponse, OAuthTokenResponse, Component } from './types';
2
+ /**
3
+ * Client for agent-initiated communication with Moeba.
4
+ *
5
+ * Usage:
6
+ * const moeba = new MoebaClient({ apiKey: 'mba_...' });
7
+ * await moeba.send(connectionId, 'Hello!');
8
+ * await moeba.progress(connectionId, 'Thinking...');
9
+ */
10
+ export declare class MoebaClient {
11
+ private apiKey;
12
+ private baseUrl;
13
+ private timeout;
14
+ private lastProgressAt;
15
+ constructor(options: MoebaClientOptions);
16
+ /**
17
+ * Send a message to a user by connectionId.
18
+ * @param connectionId - The connection to send to
19
+ * @param message - A string or { text, components } payload
20
+ */
21
+ send(connectionId: string, message: string | SendMessagePayload): Promise<SendResponse>;
22
+ /**
23
+ * Send a message to a user by phone number.
24
+ * Creates a connection if one doesn't exist.
25
+ * @param phoneNumber - E.164 format phone number
26
+ * @param message - A string or { text, components } payload
27
+ */
28
+ sendToPhone(phoneNumber: string, message: string | SendMessagePayload): Promise<SendResponse>;
29
+ /**
30
+ * Send a message with components (workflow, OAuth, secret input).
31
+ */
32
+ sendWithComponents(connectionId: string, text: string, components: Component[]): Promise<SendResponse>;
33
+ /**
34
+ * Show a progress indicator to the user.
35
+ * Auto-throttled to 1 update per second per connectionId.
36
+ * @param connectionId - The connection to update
37
+ * @param text - Progress text shown to the user
38
+ * @returns The response, or null if throttled
39
+ */
40
+ progress(connectionId: string, text: string): Promise<SendResponse | null>;
41
+ /**
42
+ * Refresh an OAuth token via Moeba (which holds client secrets).
43
+ * @param businessId - The business ID (from oauth_complete action data)
44
+ * @param provider - OAuth provider name (gmail, office365, github)
45
+ * @param refreshToken - The refresh token to exchange
46
+ * @param webhookSecret - Your webhook secret for HMAC signing
47
+ */
48
+ refreshOAuthToken(businessId: string, provider: string, refreshToken: string, webhookSecret: string): Promise<OAuthTokenResponse>;
49
+ private post;
50
+ private fetch;
51
+ }
52
+ export declare class MoebaApiError extends Error {
53
+ statusCode: number;
54
+ responseBody: string;
55
+ constructor(message: string, statusCode: number, responseBody: string);
56
+ }
57
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0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;CAK9B"}
package/dist/client.js ADDED
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MoebaApiError = exports.MoebaClient = void 0;
4
+ const security_1 = require("./security");
5
+ const DEFAULT_BASE_URL = 'https://moeba-api-999642860678.africa-south1.run.app';
6
+ const DEFAULT_TIMEOUT = 30_000;
7
+ const PROGRESS_THROTTLE_MS = 1_000;
8
+ /**
9
+ * Client for agent-initiated communication with Moeba.
10
+ *
11
+ * Usage:
12
+ * const moeba = new MoebaClient({ apiKey: 'mba_...' });
13
+ * await moeba.send(connectionId, 'Hello!');
14
+ * await moeba.progress(connectionId, 'Thinking...');
15
+ */
16
+ class MoebaClient {
17
+ apiKey;
18
+ baseUrl;
19
+ timeout;
20
+ lastProgressAt = new Map();
21
+ constructor(options) {
22
+ this.apiKey = options.apiKey;
23
+ this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
24
+ this.timeout = options.timeout || DEFAULT_TIMEOUT;
25
+ }
26
+ /**
27
+ * Send a message to a user by connectionId.
28
+ * @param connectionId - The connection to send to
29
+ * @param message - A string or { text, components } payload
30
+ */
31
+ async send(connectionId, message) {
32
+ const body = {
33
+ connectionId,
34
+ message: typeof message === 'string' ? { text: message } : message,
35
+ };
36
+ return this.post('/api/agent/send', body);
37
+ }
38
+ /**
39
+ * Send a message to a user by phone number.
40
+ * Creates a connection if one doesn't exist.
41
+ * @param phoneNumber - E.164 format phone number
42
+ * @param message - A string or { text, components } payload
43
+ */
44
+ async sendToPhone(phoneNumber, message) {
45
+ const body = {
46
+ phoneNumber,
47
+ message: typeof message === 'string' ? { text: message } : message,
48
+ };
49
+ return this.post('/api/agent/send', body);
50
+ }
51
+ /**
52
+ * Send a message with components (workflow, OAuth, secret input).
53
+ */
54
+ async sendWithComponents(connectionId, text, components) {
55
+ return this.send(connectionId, { text, components });
56
+ }
57
+ /**
58
+ * Show a progress indicator to the user.
59
+ * Auto-throttled to 1 update per second per connectionId.
60
+ * @param connectionId - The connection to update
61
+ * @param text - Progress text shown to the user
62
+ * @returns The response, or null if throttled
63
+ */
64
+ async progress(connectionId, text) {
65
+ const now = Date.now();
66
+ const lastSent = this.lastProgressAt.get(connectionId) || 0;
67
+ if (now - lastSent < PROGRESS_THROTTLE_MS) {
68
+ return null; // Throttled
69
+ }
70
+ this.lastProgressAt.set(connectionId, now);
71
+ const body = {
72
+ connectionId,
73
+ message: { text },
74
+ type: 'progress',
75
+ };
76
+ return this.post('/api/agent/send', body);
77
+ }
78
+ /**
79
+ * Refresh an OAuth token via Moeba (which holds client secrets).
80
+ * @param businessId - The business ID (from oauth_complete action data)
81
+ * @param provider - OAuth provider name (gmail, office365, github)
82
+ * @param refreshToken - The refresh token to exchange
83
+ * @param webhookSecret - Your webhook secret for HMAC signing
84
+ */
85
+ async refreshOAuthToken(businessId, provider, refreshToken, webhookSecret) {
86
+ const payload = { businessId, provider, refresh_token: refreshToken };
87
+ const signature = (0, security_1.signPayload)(payload, webhookSecret);
88
+ const url = `${this.baseUrl}/oauth/refresh`;
89
+ const response = await this.fetch(url, {
90
+ method: 'POST',
91
+ headers: {
92
+ 'Content-Type': 'application/json',
93
+ 'X-Moeba-Signature': signature,
94
+ },
95
+ body: JSON.stringify(payload),
96
+ });
97
+ if (!response.ok) {
98
+ const text = await response.text();
99
+ throw new MoebaApiError(`OAuth refresh failed: ${response.status}`, response.status, text);
100
+ }
101
+ return response.json();
102
+ }
103
+ async post(path, body) {
104
+ const url = `${this.baseUrl}${path}`;
105
+ const response = await this.fetch(url, {
106
+ method: 'POST',
107
+ headers: {
108
+ 'Content-Type': 'application/json',
109
+ 'X-Moeba-Agent-Key': this.apiKey,
110
+ },
111
+ body: JSON.stringify(body),
112
+ });
113
+ if (!response.ok) {
114
+ const text = await response.text();
115
+ throw new MoebaApiError(`Request failed: ${response.status}`, response.status, text);
116
+ }
117
+ return response.json();
118
+ }
119
+ fetch(url, init) {
120
+ const controller = new AbortController();
121
+ const timer = setTimeout(() => controller.abort(), this.timeout);
122
+ return fetch(url, { ...init, signal: controller.signal }).finally(() => clearTimeout(timer));
123
+ }
124
+ }
125
+ exports.MoebaClient = MoebaClient;
126
+ class MoebaApiError extends Error {
127
+ statusCode;
128
+ responseBody;
129
+ constructor(message, statusCode, responseBody) {
130
+ super(message);
131
+ this.statusCode = statusCode;
132
+ this.responseBody = responseBody;
133
+ this.name = 'MoebaApiError';
134
+ }
135
+ }
136
+ exports.MoebaApiError = MoebaApiError;
137
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AASzC,MAAM,gBAAgB,GAAG,sDAAsD,CAAC;AAChF,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAa,WAAW;IACd,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEnD,YAAY,OAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,YAAoB,EAAE,OAAoC;QACnE,MAAM,IAAI,GAAQ;YAChB,YAAY;YACZ,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO;SACnE,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB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aAAa,CAAC,mBAAmB,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAA2B,CAAC;IAClD,CAAC;IAEO,KAAK,CAAC,GAAW,EAAE,IAAiB;QAC1C,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjE,OAAO,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF;AArID,kCAqIC;AAED,MAAa,aAAc,SAAQ,KAAK;IAG7B;IACA;IAHT,YACE,OAAe,EACR,UAAkB,EAClB,YAAoB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;QAG3B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AATD,sCASC"}
@@ -0,0 +1,4 @@
1
+ export { WorkflowBuilder } from './workflow';
2
+ export { OAuthConnect } from './oauth';
3
+ export { SecretInput } from './secret';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecretInput = exports.OAuthConnect = exports.WorkflowBuilder = void 0;
4
+ var workflow_1 = require("./workflow");
5
+ Object.defineProperty(exports, "WorkflowBuilder", { enumerable: true, get: function () { return workflow_1.WorkflowBuilder; } });
6
+ var oauth_1 = require("./oauth");
7
+ Object.defineProperty(exports, "OAuthConnect", { enumerable: true, get: function () { return oauth_1.OAuthConnect; } });
8
+ var secret_1 = require("./secret");
9
+ Object.defineProperty(exports, "SecretInput", { enumerable: true, get: function () { return secret_1.SecretInput; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAApC,2GAAA,eAAe,OAAA;AACxB,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AACrB,mCAAuC;AAA9B,qGAAA,WAAW,OAAA"}
@@ -0,0 +1,26 @@
1
+ import type { OAuthConnectComponent } from '../types';
2
+ interface OAuthOptions {
3
+ label?: string;
4
+ description?: string;
5
+ scopes?: string[];
6
+ }
7
+ /**
8
+ * Factory for OAuth connect components.
9
+ *
10
+ * Usage:
11
+ * OAuthConnect.gmail({ scopes: ['https://www.googleapis.com/auth/gmail.readonly'] })
12
+ * OAuthConnect.office365()
13
+ * OAuthConnect.github()
14
+ */
15
+ export declare class OAuthConnect {
16
+ /** Connect to Gmail / Google APIs. */
17
+ static gmail(opts?: OAuthOptions): OAuthConnectComponent;
18
+ /** Connect to Microsoft 365 / Outlook. */
19
+ static office365(opts?: OAuthOptions): OAuthConnectComponent;
20
+ /** Connect to GitHub. */
21
+ static github(opts?: OAuthOptions): OAuthConnectComponent;
22
+ /** Create a custom OAuth connect component. */
23
+ static create(provider: 'gmail' | 'office365' | 'github', opts?: OAuthOptions): OAuthConnectComponent;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/components/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,sCAAsC;IACtC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,qBAAqB;IAQxD,0CAA0C;IAC1C,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,qBAAqB;IAQ5D,yBAAyB;IACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,qBAAqB;IAQzD,+CAA+C;IAC/C,MAAM,CAAC,MAAM,CACX,QAAQ,EAAE,OAAO,GAAG,WAAW,GAAG,QAAQ,EAC1C,IAAI,CAAC,EAAE,YAAY,GAClB,qBAAqB;CAYzB"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OAuthConnect = void 0;
4
+ /**
5
+ * Factory for OAuth connect components.
6
+ *
7
+ * Usage:
8
+ * OAuthConnect.gmail({ scopes: ['https://www.googleapis.com/auth/gmail.readonly'] })
9
+ * OAuthConnect.office365()
10
+ * OAuthConnect.github()
11
+ */
12
+ class OAuthConnect {
13
+ /** Connect to Gmail / Google APIs. */
14
+ static gmail(opts) {
15
+ return OAuthConnect.create('gmail', {
16
+ label: 'Google',
17
+ description: 'Connect your Gmail account',
18
+ ...opts,
19
+ });
20
+ }
21
+ /** Connect to Microsoft 365 / Outlook. */
22
+ static office365(opts) {
23
+ return OAuthConnect.create('office365', {
24
+ label: 'Microsoft 365',
25
+ description: 'Connect your Microsoft 365 account',
26
+ ...opts,
27
+ });
28
+ }
29
+ /** Connect to GitHub. */
30
+ static github(opts) {
31
+ return OAuthConnect.create('github', {
32
+ label: 'GitHub',
33
+ description: 'Connect your GitHub account',
34
+ ...opts,
35
+ });
36
+ }
37
+ /** Create a custom OAuth connect component. */
38
+ static create(provider, opts) {
39
+ const component = {
40
+ type: 'oauthConnect',
41
+ provider,
42
+ };
43
+ if (opts?.label)
44
+ component.label = opts.label;
45
+ if (opts?.description)
46
+ component.description = opts.description;
47
+ if (opts?.scopes)
48
+ component.scopes = opts.scopes;
49
+ return component;
50
+ }
51
+ }
52
+ exports.OAuthConnect = OAuthConnect;
53
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/components/oauth.ts"],"names":[],"mappings":";;;AAQA;;;;;;;GAOG;AACH,MAAa,YAAY;IACvB,sCAAsC;IACtC,MAAM,CAAC,KAAK,CAAC,IAAmB;QAC9B,OAAO,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE;YAClC,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,4BAA4B;YACzC,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC;IAED,0CAA0C;IAC1C,MAAM,CAAC,SAAS,CAAC,IAAmB;QAClC,OAAO,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE;YACtC,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,oCAAoC;YACjD,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC;IAED,yBAAyB;IACzB,MAAM,CAAC,MAAM,CAAC,IAAmB;QAC/B,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE;YACnC,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,6BAA6B;YAC1C,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC;IAED,+CAA+C;IAC/C,MAAM,CAAC,MAAM,CACX,QAA0C,EAC1C,IAAmB;QAEnB,MAAM,SAAS,GAA0B;YACvC,IAAI,EAAE,cAAc;YACpB,QAAQ;SACT,CAAC;QAEF,IAAI,IAAI,EAAE,KAAK;YAAE,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9C,IAAI,IAAI,EAAE,WAAW;YAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAChE,IAAI,IAAI,EAAE,MAAM;YAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAEjD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5CD,oCA4CC"}
@@ -0,0 +1,15 @@
1
+ import type { SecretInputComponent } from '../types';
2
+ /**
3
+ * Factory for secret input components.
4
+ *
5
+ * Usage:
6
+ * SecretInput.create('openweathermap-api', 'API Key', {
7
+ * description: 'Get your key at https://openweathermap.org/appid'
8
+ * })
9
+ */
10
+ export declare class SecretInput {
11
+ static create(name: string, label: string, opts?: {
12
+ description?: string;
13
+ }): SecretInputComponent;
14
+ }
15
+ //# sourceMappingURL=secret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../src/components/secret.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9B,oBAAoB;CAWxB"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecretInput = void 0;
4
+ /**
5
+ * Factory for secret input components.
6
+ *
7
+ * Usage:
8
+ * SecretInput.create('openweathermap-api', 'API Key', {
9
+ * description: 'Get your key at https://openweathermap.org/appid'
10
+ * })
11
+ */
12
+ class SecretInput {
13
+ static create(name, label, opts) {
14
+ const component = {
15
+ type: 'secretInput',
16
+ name,
17
+ label,
18
+ };
19
+ if (opts?.description)
20
+ component.description = opts.description;
21
+ return component;
22
+ }
23
+ }
24
+ exports.SecretInput = SecretInput;
25
+ //# sourceMappingURL=secret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.js","sourceRoot":"","sources":["../../src/components/secret.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,MAAa,WAAW;IACtB,MAAM,CAAC,MAAM,CACX,IAAY,EACZ,KAAa,EACb,IAA+B;QAE/B,MAAM,SAAS,GAAyB;YACtC,IAAI,EAAE,aAAa;YACnB,IAAI;YACJ,KAAK;SACN,CAAC;QAEF,IAAI,IAAI,EAAE,WAAW;YAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAEhE,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAhBD,kCAgBC"}
@@ -0,0 +1,63 @@
1
+ import type { WorkflowComponent, WorkflowTemplate, SelectOption, FieldValidation } from '../types';
2
+ interface StepOptions {
3
+ description?: string;
4
+ required?: boolean;
5
+ canSkip?: boolean;
6
+ placeholder?: string;
7
+ validation?: FieldValidation;
8
+ }
9
+ interface PhotoStepOptions extends StepOptions {
10
+ maxCount?: number;
11
+ requireGeoTag?: boolean;
12
+ }
13
+ interface LocationStepOptions extends StepOptions {
14
+ requireHighAccuracy?: boolean;
15
+ }
16
+ /**
17
+ * Fluent builder for workflow components.
18
+ *
19
+ * Usage:
20
+ * WorkflowBuilder.create('Trip Booking', 'TRIP')
21
+ * .text('destination', 'Where to?', { placeholder: 'e.g. Paris' })
22
+ * .date('departure', 'When?')
23
+ * .select('budget', 'Budget', [
24
+ * { label: 'Budget', value: 'budget' },
25
+ * { label: 'Mid-range', value: 'mid' },
26
+ * ])
27
+ * .build()
28
+ */
29
+ export declare class WorkflowBuilder {
30
+ private _name;
31
+ private _referencePrefix;
32
+ private _steps;
33
+ private _order;
34
+ private constructor();
35
+ static create(name: string, referencePrefix: string): WorkflowBuilder;
36
+ /** Single-line text input. */
37
+ text(name: string, title: string, opts?: StepOptions): this;
38
+ /** Email input with keyboard optimization. */
39
+ email(name: string, title: string, opts?: StepOptions): this;
40
+ /** Phone number input with numeric keyboard. */
41
+ phone(name: string, title: string, opts?: StepOptions): this;
42
+ /** Numeric input with numeric keyboard. */
43
+ number(name: string, title: string, opts?: StepOptions): this;
44
+ /** Date picker. Returns ISO 8601 string. */
45
+ date(name: string, title: string, opts?: StepOptions): this;
46
+ /** Multi-line text area. */
47
+ textarea(name: string, title: string, opts?: StepOptions): this;
48
+ /** Option buttons. Requires options array. */
49
+ select(name: string, title: string, options: SelectOption[], opts?: StepOptions): this;
50
+ /** Yes/No toggle. */
51
+ checkbox(name: string, title: string, opts?: StepOptions): this;
52
+ /** Camera/gallery photo capture. */
53
+ photo(name: string, title: string, opts?: PhotoStepOptions): this;
54
+ /** GPS location capture. */
55
+ location(name: string, title: string, opts?: LocationStepOptions): this;
56
+ /** Build the workflow component ready to attach to a response. */
57
+ build(): WorkflowComponent;
58
+ /** Build just the template (without the component wrapper). */
59
+ buildTemplate(): WorkflowTemplate;
60
+ private addStep;
61
+ }
62
+ export {};
63
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/components/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAGhB,YAAY,EACZ,eAAe,EAGhB,MAAM,UAAU,CAAC;AAElB,UAAU,WAAW;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED,UAAU,gBAAiB,SAAQ,WAAW;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAA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I;IAItF,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI;IAI/D,oCAAoC;IACpC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAQjE,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,IAAI;IAOvE,kEAAkE;IAClE,KAAK,IAAI,iBAAiB;IAO1B,+DAA+D;IAC/D,aAAa,IAAI,gBAAgB;IAQjC,OAAO,CAAC,OAAO;CAsBhB"}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowBuilder = void 0;
4
+ /**
5
+ * Fluent builder for workflow components.
6
+ *
7
+ * Usage:
8
+ * WorkflowBuilder.create('Trip Booking', 'TRIP')
9
+ * .text('destination', 'Where to?', { placeholder: 'e.g. Paris' })
10
+ * .date('departure', 'When?')
11
+ * .select('budget', 'Budget', [
12
+ * { label: 'Budget', value: 'budget' },
13
+ * { label: 'Mid-range', value: 'mid' },
14
+ * ])
15
+ * .build()
16
+ */
17
+ class WorkflowBuilder {
18
+ _name;
19
+ _referencePrefix;
20
+ _steps = [];
21
+ _order = 0;
22
+ constructor(name, referencePrefix) {
23
+ this._name = name;
24
+ this._referencePrefix = referencePrefix;
25
+ }
26
+ static create(name, referencePrefix) {
27
+ return new WorkflowBuilder(name, referencePrefix);
28
+ }
29
+ /** Single-line text input. */
30
+ text(name, title, opts) {
31
+ return this.addStep(name, title, 'text', opts);
32
+ }
33
+ /** Email input with keyboard optimization. */
34
+ email(name, title, opts) {
35
+ return this.addStep(name, title, 'email', opts);
36
+ }
37
+ /** Phone number input with numeric keyboard. */
38
+ phone(name, title, opts) {
39
+ return this.addStep(name, title, 'phone', opts);
40
+ }
41
+ /** Numeric input with numeric keyboard. */
42
+ number(name, title, opts) {
43
+ return this.addStep(name, title, 'number', opts);
44
+ }
45
+ /** Date picker. Returns ISO 8601 string. */
46
+ date(name, title, opts) {
47
+ return this.addStep(name, title, 'date', opts);
48
+ }
49
+ /** Multi-line text area. */
50
+ textarea(name, title, opts) {
51
+ return this.addStep(name, title, 'textarea', opts);
52
+ }
53
+ /** Option buttons. Requires options array. */
54
+ select(name, title, options, opts) {
55
+ return this.addStep(name, title, 'select', { ...opts, _options: options });
56
+ }
57
+ /** Yes/No toggle. */
58
+ checkbox(name, title, opts) {
59
+ return this.addStep(name, title, 'checkbox', opts);
60
+ }
61
+ /** Camera/gallery photo capture. */
62
+ photo(name, title, opts) {
63
+ const photoConfig = {
64
+ maxCount: opts?.maxCount ?? 1,
65
+ requireGeoTag: opts?.requireGeoTag ?? false,
66
+ };
67
+ return this.addStep(name, title, 'photo', { ...opts, _photoConfig: photoConfig });
68
+ }
69
+ /** GPS location capture. */
70
+ location(name, title, opts) {
71
+ const locationConfig = {
72
+ requireHighAccuracy: opts?.requireHighAccuracy ?? false,
73
+ };
74
+ return this.addStep(name, title, 'location', { ...opts, _locationConfig: locationConfig });
75
+ }
76
+ /** Build the workflow component ready to attach to a response. */
77
+ build() {
78
+ return {
79
+ type: 'workflow',
80
+ template: this.buildTemplate(),
81
+ };
82
+ }
83
+ /** Build just the template (without the component wrapper). */
84
+ buildTemplate() {
85
+ return {
86
+ name: this._name,
87
+ referencePrefix: this._referencePrefix,
88
+ steps: [...this._steps],
89
+ };
90
+ }
91
+ addStep(name, title, type, opts) {
92
+ this._order++;
93
+ const step = {
94
+ order: this._order,
95
+ name,
96
+ title,
97
+ type,
98
+ required: opts?.required ?? true,
99
+ canSkip: opts?.canSkip ?? false,
100
+ };
101
+ if (opts?.description)
102
+ step.description = opts.description;
103
+ if (opts?.placeholder)
104
+ step.placeholder = opts.placeholder;
105
+ if (opts?.validation)
106
+ step.validation = opts.validation;
107
+ if (opts?._options)
108
+ step.options = opts._options;
109
+ if (opts?._photoConfig)
110
+ step.photoConfig = opts._photoConfig;
111
+ if (opts?._locationConfig)
112
+ step.locationConfig = opts._locationConfig;
113
+ this._steps.push(step);
114
+ return this;
115
+ }
116
+ }
117
+ exports.WorkflowBuilder = WorkflowBuilder;
118
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/components/workflow.ts"],"names":[],"mappings":";;;AA4BA;;;;;;;;;;;;GAYG;AACH,MAAa,eAAe;IAClB,KAAK,CAAS;IACd,gBAAgB,CAAS;IACzB,MAAM,GAAmB,EAAE,CAAC;IAC5B,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAoB,IAAY,EAAE,eAAuB;QACvD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,eAAuB;QACjD,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IAED,8BAA8B;IAC9B,IAAI,CAAC,IAAY,EAAE,KAAa,EAAE,IAAkB;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,8CAA8C;IAC9C,KAAK,CAAC,IAAY,EAAE,KAAa,EAAE,IAAkB;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,gDAAgD;IAChD,KAAK,CAAC,IAAY,EAAE,KAAa,EAAE,IAAkB;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;I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AAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QACjD,IAAI,IAAI,EAAE,YAAY;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QAC7D,IAAI,IAAI,EAAE,eAAe;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC;QAEtE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/GD,0CA+GC"}
@@ -0,0 +1,43 @@
1
+ import type { JsonRpcResponse, WebhookHandlerOptions, IncomingHeaders } from './types';
2
+ /**
3
+ * Framework-agnostic webhook handler for processing Moeba A2A requests.
4
+ *
5
+ * Usage:
6
+ * const handler = new WebhookHandler({
7
+ * webhookSecret: 'whsec_...',
8
+ * onMessage: async (message, ctx) => ctx.reply(`You said: ${message.text}`),
9
+ * });
10
+ *
11
+ * // In your framework route:
12
+ * const response = await handler.handle(rawBodyString, headers);
13
+ * res.json(response);
14
+ */
15
+ export declare class WebhookHandler {
16
+ private secret;
17
+ private onMessage;
18
+ private onAction;
19
+ private onPing;
20
+ constructor(options: WebhookHandlerOptions);
21
+ /**
22
+ * Process an incoming webhook request.
23
+ *
24
+ * @param rawBody - The raw request body string (must be unparsed for signature verification)
25
+ * @param headers - Request headers (needs x-moeba-signature at minimum)
26
+ * @returns JSON-RPC response object ready to send back
27
+ */
28
+ handle(rawBody: string, headers: IncomingHeaders): Promise<JsonRpcResponse>;
29
+ private handlePing;
30
+ private handleMessage;
31
+ private handleAction;
32
+ private buildContext;
33
+ /**
34
+ * Normalize handler return values:
35
+ * - string → { message: { text } }
36
+ * - ResponseBuilder → .build()
37
+ * - object with .build() → call .build()
38
+ * - plain object → wrap as result
39
+ */
40
+ private normalizeResult;
41
+ private errorResponse;
42
+ }
43
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAEf,qBAAqB,EACrB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,MAAM,CAAkC;gBAEpC,OAAO,EAAE,qBAAqB;IAO1C;;;;;;OAMG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;YAqCnE,UAAU;YAQV,aAAa;YASb,YAAY;IAS1B,OAAO,CAAC,YAAY;IAcpB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IA6BvB,OAAO,CAAC,aAAa;CAGtB"}