samva 0.47.0 → 0.49.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.
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +2 -1
- package/dist/agent/runtime.js +26 -5
- package/dist/agent/types.d.ts +27 -0
- package/dist/client/sdk.gen.d.ts +234 -34
- package/dist/client/sdk.gen.js +574 -60
- package/dist/client/types.gen.d.ts +1363 -164
- package/dist/effect/accounts.d.ts +6 -6
- package/dist/effect/agents.d.ts +13 -13
- package/dist/effect/analytics.d.ts +6 -6
- package/dist/effect/api-keys.d.ts +13 -11
- package/dist/effect/approval-requests.d.ts +4 -4
- package/dist/effect/attachments.d.ts +4 -4
- package/dist/effect/brands.d.ts +6 -6
- package/dist/effect/campaigns.d.ts +15 -15
- package/dist/effect/contact-groups.d.ts +10 -10
- package/dist/effect/contacts.d.ts +25 -25
- package/dist/effect/conversations.d.ts +13 -13
- package/dist/effect/custom-fields.d.ts +4 -4
- package/dist/effect/descriptors/integrations-catalog.d.ts +134 -0
- package/dist/effect/descriptors/integrations-catalog.js +122 -0
- package/dist/effect/descriptors/mailboxes.d.ts +32 -12
- package/dist/effect/descriptors/mailboxes.js +32 -12
- package/dist/effect/email.d.ts +61 -61
- package/dist/effect/events.d.ts +2 -2
- package/dist/effect/feedback.d.ts +1 -1
- package/dist/effect/generated/accounts.d.ts +1 -3
- package/dist/effect/generated/accounts.js +2 -7
- package/dist/effect/generated/api-keys.d.ts +30 -15
- package/dist/effect/generated/api-keys.js +2 -0
- package/dist/effect/generated/attachments.js +1 -1
- package/dist/effect/generated/integrations-catalog.d.ts +2702 -1
- package/dist/effect/generated/integrations-catalog.js +578 -3
- package/dist/effect/generated/journeys.d.ts +105 -107
- package/dist/effect/generated/journeys.js +6 -12
- package/dist/effect/generated/mailboxes.d.ts +752 -463
- package/dist/effect/generated/mailboxes.js +163 -98
- package/dist/effect/generated/messages.d.ts +109 -4
- package/dist/effect/generated/messages.js +41 -8
- package/dist/effect/generated/shared.d.ts +255 -59
- package/dist/effect/generated/shared.js +64 -18
- package/dist/effect/generated/template-registrations.d.ts +53 -4
- package/dist/effect/generated/template-registrations.js +13 -5
- package/dist/effect/generated/templates.d.ts +77 -15
- package/dist/effect/generated/templates.js +26 -17
- package/dist/effect/generated/webhooks.d.ts +19 -19
- package/dist/effect/generated/webhooks.js +8 -8
- package/dist/effect/generated/whoami.d.ts +4 -4
- package/dist/effect/generated-metadata.d.ts +114 -18
- package/dist/effect/generated-metadata.js +362 -340
- package/dist/effect/integrations-catalog.d.ts +228 -3
- package/dist/effect/integrations-catalog.js +29 -1
- package/dist/effect/integrations.d.ts +7 -7
- package/dist/effect/internal/client.d.ts +7 -3
- package/dist/effect/internal/operation.d.ts +10 -6
- package/dist/effect/internal/operation.js +3 -3
- package/dist/effect/journeys.d.ts +14 -14
- package/dist/effect/mailboxes.d.ts +117 -91
- package/dist/effect/mailboxes.js +11 -7
- package/dist/effect/media.d.ts +5 -5
- package/dist/effect/messages.d.ts +9 -9
- package/dist/effect/namespaces.d.ts +11 -11
- package/dist/effect/newsletter-domains.d.ts +4 -4
- package/dist/effect/newsletter-issues.d.ts +11 -11
- package/dist/effect/newsletters.d.ts +5 -5
- package/dist/effect/operations.d.ts +3 -3
- package/dist/effect/organizations.d.ts +12 -12
- package/dist/effect/policies.d.ts +3 -3
- package/dist/effect/retry.js +1 -1
- package/dist/effect/scheduled-messages.d.ts +5 -5
- package/dist/effect/subscriptions.d.ts +1 -1
- package/dist/effect/template-registrations.d.ts +9 -3
- package/dist/effect/template-share-links.d.ts +5 -5
- package/dist/effect/templates.d.ts +46 -37
- package/dist/effect/topic-forms.d.ts +5 -5
- package/dist/effect/topics.d.ts +9 -9
- package/dist/effect/webhooks.d.ts +15 -15
- package/dist/effect/whatsapp-flows.d.ts +10 -10
- package/dist/effect/whatsapp-setup-links.d.ts +4 -4
- package/dist/effect/whatsapp.d.ts +12 -12
- package/dist/effect/whoami.d.ts +1 -1
- package/dist/inline-attachments.d.ts +0 -5
- package/dist/mailbox-events.d.ts +1 -5
- package/dist/mailbox-events.js +2 -2
- package/dist/package.js +1 -1
- package/dist/promises/client.d.ts +4 -4
- package/dist/promises/client.js +8 -4
- package/dist/promises/types.gen.d.ts +1 -1
- package/dist/service-map.d.ts +83 -9
- package/package.json +2 -2
package/dist/agent/index.d.ts
CHANGED
|
@@ -53,4 +53,5 @@ export declare function defineAgent<const Tools extends Readonly<Record<string,
|
|
|
53
53
|
readonly tools?: Tools;
|
|
54
54
|
readonly events?: Readonly<Record<string, AgentEventHandler>>;
|
|
55
55
|
readonly schedules?: Readonly<Record<string, AgentScheduleHandler>>;
|
|
56
|
+
readonly workflows?: ReadonlyArray<string>;
|
|
56
57
|
}): AgentDefinition<Tools>;
|
package/dist/agent/index.js
CHANGED
package/dist/agent/runtime.js
CHANGED
|
@@ -27,14 +27,29 @@ async function invokeAgent(agent, operation, capability, authority) {
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
const counts = /* @__PURE__ */ new Map();
|
|
30
|
+
const samva = operation.kind === "event" ? clientWithIdempotency(client, (method) => {
|
|
31
|
+
const count = (counts.get(method) ?? 0) + 1;
|
|
32
|
+
counts.set(method, count);
|
|
33
|
+
return `${capability.agentId}:${operation.event.id}:${method}:${count}`;
|
|
34
|
+
}) : client;
|
|
35
|
+
const state = (call) => authority.state ? authority.state(call) : Promise.reject(/* @__PURE__ */ new Error("Agent module state is unavailable"));
|
|
30
36
|
const ctx = {
|
|
31
37
|
capability,
|
|
32
|
-
samva
|
|
33
|
-
const count = (counts.get(method) ?? 0) + 1;
|
|
34
|
-
counts.set(method, count);
|
|
35
|
-
return `${capability.agentId}:${operation.event.id}:${method}:${count}`;
|
|
36
|
-
}) : client,
|
|
38
|
+
samva,
|
|
37
39
|
connections: { call: (integrationId, tool, input) => authority.connection(integrationId, tool, input) },
|
|
40
|
+
workflows: { start: (input) => authority.startWorkflow ? authority.startWorkflow(input) : Promise.reject(/* @__PURE__ */ new Error("Agent workflows are unavailable")) },
|
|
41
|
+
state: {
|
|
42
|
+
agent: { call: (name, input) => state({
|
|
43
|
+
scope: "agent",
|
|
44
|
+
operation: name,
|
|
45
|
+
input
|
|
46
|
+
}) },
|
|
47
|
+
conversation: { call: (name, input) => state({
|
|
48
|
+
scope: "conversation",
|
|
49
|
+
operation: name,
|
|
50
|
+
input
|
|
51
|
+
}) }
|
|
52
|
+
},
|
|
38
53
|
memory: {
|
|
39
54
|
search: (query) => authority.searchMemory(query),
|
|
40
55
|
remember: (content) => authority.remember(content)
|
|
@@ -53,6 +68,12 @@ async function invokeAgent(agent, operation, capability, authority) {
|
|
|
53
68
|
if (skill === void 0) throw new Error(`Unknown agent skill: ${operation.name}`);
|
|
54
69
|
return skill;
|
|
55
70
|
}
|
|
71
|
+
case "schedule": {
|
|
72
|
+
if (capability.trigger.kind !== "schedule" || capability.trigger.cron !== operation.cron || capability.trigger.scheduledAt !== operation.scheduledAt) throw new Error("The agent schedule does not match its call capability");
|
|
73
|
+
const handler = agent.schedules[operation.cron];
|
|
74
|
+
if (handler === void 0) throw new Error("Unknown agent schedule");
|
|
75
|
+
return await handler(ctx) ?? null;
|
|
76
|
+
}
|
|
56
77
|
case "event": {
|
|
57
78
|
if (capability.trigger.kind !== "event" || capability.trigger.eventId !== operation.event.id || capability.trigger.eventType !== operation.event.type || capability.trigger.attempt !== operation.attempt) throw new Error("The agent event does not match its call capability");
|
|
58
79
|
const handler = agent.events[operation.event.type];
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -54,12 +54,32 @@ export interface AgentContext {
|
|
|
54
54
|
readonly connections: {
|
|
55
55
|
call(integrationId: string, tool: string, input: Readonly<Record<string, unknown>>): Promise<unknown>;
|
|
56
56
|
};
|
|
57
|
+
readonly workflows?: {
|
|
58
|
+
start(input: AgentWorkflowStart): Promise<string>;
|
|
59
|
+
};
|
|
60
|
+
readonly state?: {
|
|
61
|
+
readonly agent: AgentState;
|
|
62
|
+
readonly conversation: AgentState;
|
|
63
|
+
};
|
|
57
64
|
readonly memory: {
|
|
58
65
|
search(query: string): Promise<ReadonlyArray<AgentMemoryMatch>>;
|
|
59
66
|
remember(content: string): Promise<void>;
|
|
60
67
|
};
|
|
61
68
|
log(...values: ReadonlyArray<unknown>): void;
|
|
62
69
|
}
|
|
70
|
+
export interface AgentWorkflowStart {
|
|
71
|
+
readonly exportName: string;
|
|
72
|
+
readonly idempotencyKey: string;
|
|
73
|
+
readonly input: Schema.Json;
|
|
74
|
+
}
|
|
75
|
+
export interface AgentState {
|
|
76
|
+
call(operation: string, input: Schema.Json): Promise<Schema.Json>;
|
|
77
|
+
}
|
|
78
|
+
export interface AgentStateCall {
|
|
79
|
+
readonly scope: "agent" | "conversation";
|
|
80
|
+
readonly operation: string;
|
|
81
|
+
readonly input: Schema.Json;
|
|
82
|
+
}
|
|
63
83
|
export interface AgentEvent<Data = unknown> {
|
|
64
84
|
readonly id: string;
|
|
65
85
|
readonly type: string;
|
|
@@ -83,6 +103,7 @@ export interface AgentDefinition<Tools extends Readonly<Record<string, AgentTool
|
|
|
83
103
|
readonly tools: Tools;
|
|
84
104
|
readonly events: Readonly<Record<string, AgentEventHandler>>;
|
|
85
105
|
readonly schedules: Readonly<Record<string, AgentScheduleHandler>>;
|
|
106
|
+
readonly workflows?: ReadonlyArray<string>;
|
|
86
107
|
}
|
|
87
108
|
/** The host calls one operation with one call-local authority over Workers RPC. */
|
|
88
109
|
export type AgentModuleOperation = {
|
|
@@ -102,6 +123,10 @@ export type AgentModuleOperation = {
|
|
|
102
123
|
readonly kind: "event";
|
|
103
124
|
readonly event: AgentEvent;
|
|
104
125
|
readonly attempt: number;
|
|
126
|
+
} | {
|
|
127
|
+
readonly kind: "schedule";
|
|
128
|
+
readonly cron: string;
|
|
129
|
+
readonly scheduledAt: number;
|
|
105
130
|
};
|
|
106
131
|
export interface AgentModuleRequest {
|
|
107
132
|
readonly method: string;
|
|
@@ -120,4 +145,6 @@ export interface AgentModuleAuthority {
|
|
|
120
145
|
searchMemory(query: string): Promise<ReadonlyArray<AgentMemoryMatch>>;
|
|
121
146
|
remember(content: string): Promise<void>;
|
|
122
147
|
log(values: ReadonlyArray<unknown>): Promise<void>;
|
|
148
|
+
state?(call: AgentStateCall): Promise<Schema.Json>;
|
|
149
|
+
startWorkflow?(input: AgentWorkflowStart): Promise<string>;
|
|
123
150
|
}
|