@automagik/omni 2.260409.6 → 2.260421.3
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/db/drizzle/0018_supreme_puma.sql +6 -0
- package/db/drizzle/0019_idle_chat_follow_up.sql +23 -0
- package/db/drizzle/0020_follow_up_config.sql +2 -0
- package/db/drizzle/0021_idle_follow_up_seed.sql +51 -0
- package/db/drizzle/0022_idle_follow_up_prompt_v2.sql +34 -0
- package/db/drizzle/0023_dispatcher_inbound_age.sql +8 -0
- package/db/drizzle/0024_quiet_gabe_jones.sql +23 -0
- package/db/drizzle/0025_panoramic_sinister_six.sql +5 -0
- package/db/drizzle/0026_agent_key_profiles.sql +19 -0
- package/db/drizzle/0027_bridge_tmux_session.sql +13 -0
- package/db/drizzle/meta/{0014_snapshot.json → 0018_snapshot.json} +678 -430
- package/db/drizzle/meta/{0013_snapshot.json → 0019_snapshot.json} +919 -445
- package/db/drizzle/meta/0020_snapshot.json +7240 -0
- package/db/drizzle/meta/0021_snapshot.json +7240 -0
- package/db/drizzle/meta/0024_snapshot.json +7240 -0
- package/db/drizzle/meta/0025_snapshot.json +7240 -0
- package/db/drizzle/meta/0026_snapshot.json +7274 -0
- package/db/drizzle/meta/_journal.json +70 -0
- package/dist/__tests__/mock-api.d.ts +24 -0
- package/dist/__tests__/mock-api.d.ts.map +1 -1
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/doctor.d.ts +24 -15
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/events.d.ts +25 -0
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/commands/follow-up.d.ts +13 -0
- package/dist/commands/follow-up.d.ts.map +1 -0
- package/dist/commands/install.d.ts +28 -29
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/instances.d.ts.map +1 -1
- package/dist/commands/keys.d.ts +43 -0
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/update.d.ts +12 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/voice.d.ts +11 -0
- package/dist/commands/voice.d.ts.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +94536 -65466
- package/dist/install-helpers.d.ts +32 -0
- package/dist/install-helpers.d.ts.map +1 -0
- package/dist/nats-install.d.ts +11 -0
- package/dist/nats-install.d.ts.map +1 -0
- package/dist/output.d.ts +14 -5
- package/dist/output.d.ts.map +1 -1
- package/dist/pm2.d.ts +46 -0
- package/dist/pm2.d.ts.map +1 -1
- package/dist/server/davey.linux-x64-gnu-vevevdy2.node +0 -0
- package/dist/server/davey.linux-x64-musl-3vkb94zg.node +0 -0
- package/dist/server/index.js +97148 -13518
- package/package.json +10 -10
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
ALTER TABLE "instances" RENAME COLUMN "gupshup_api_key" TO "gupshup_callback_url";
|
|
2
|
+
ALTER TABLE "instances" RENAME COLUMN "gupshup_app_name" TO "gupshup_auth_token";
|
|
3
|
+
ALTER TABLE "instances" RENAME COLUMN "gupshup_source_phone" TO "gupshup_event_id";
|
|
4
|
+
ALTER TABLE "instances" ALTER COLUMN "gupshup_callback_url" SET DATA TYPE text;
|
|
5
|
+
ALTER TABLE "instances" ALTER COLUMN "gupshup_auth_token" SET DATA TYPE text;
|
|
6
|
+
ALTER TABLE "instances" ALTER COLUMN "gupshup_event_id" SET DATA TYPE varchar(255);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
CREATE TABLE "chat_follow_up_state" (
|
|
2
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
+
"chat_id" uuid NOT NULL,
|
|
4
|
+
"instance_id" uuid NOT NULL,
|
|
5
|
+
"agent_id" uuid,
|
|
6
|
+
"sequence_config" jsonb NOT NULL,
|
|
7
|
+
"sequence_index" integer DEFAULT 0 NOT NULL,
|
|
8
|
+
"last_agent_message_at" timestamp with time zone NOT NULL,
|
|
9
|
+
"last_inbound_customer_message_at" timestamp with time zone,
|
|
10
|
+
"next_fire_at" timestamp with time zone,
|
|
11
|
+
"disarm_reason" varchar(32),
|
|
12
|
+
"disarmed_at" timestamp with time zone,
|
|
13
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
14
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
15
|
+
);
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "chat_follow_up_state" ADD CONSTRAINT "chat_follow_up_state_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
18
|
+
ALTER TABLE "chat_follow_up_state" ADD CONSTRAINT "chat_follow_up_state_instance_id_instances_id_fk" FOREIGN KEY ("instance_id") REFERENCES "public"."instances"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
19
|
+
ALTER TABLE "chat_follow_up_state" ADD CONSTRAINT "chat_follow_up_state_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
20
|
+
CREATE INDEX "chat_follow_up_state_sweeper_idx" ON "chat_follow_up_state" USING btree ("next_fire_at","disarm_reason");--> statement-breakpoint
|
|
21
|
+
CREATE UNIQUE INDEX "chat_follow_up_state_chat_instance_unique" ON "chat_follow_up_state" USING btree ("chat_id","instance_id");--> statement-breakpoint
|
|
22
|
+
CREATE INDEX "chat_follow_up_state_chat_idx" ON "chat_follow_up_state" USING btree ("chat_id");--> statement-breakpoint
|
|
23
|
+
CREATE INDEX "chat_follow_up_state_instance_idx" ON "chat_follow_up_state" USING btree ("instance_id");
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
-- Seed the default idle-chat follow-up automation.
|
|
2
|
+
-- The follow-up sweeper publishes `chat.idle_timeout`; without an
|
|
3
|
+
-- automation subscribed to that event, arming is a no-op in production.
|
|
4
|
+
-- Source of truth for the structure lives at
|
|
5
|
+
-- docs/examples/automations/idle-follow-up.yaml.
|
|
6
|
+
|
|
7
|
+
INSERT INTO "automations" (
|
|
8
|
+
"id",
|
|
9
|
+
"name",
|
|
10
|
+
"description",
|
|
11
|
+
"trigger_event_type",
|
|
12
|
+
"trigger_conditions",
|
|
13
|
+
"condition_logic",
|
|
14
|
+
"actions",
|
|
15
|
+
"enabled",
|
|
16
|
+
"priority",
|
|
17
|
+
"created_at",
|
|
18
|
+
"updated_at"
|
|
19
|
+
)
|
|
20
|
+
SELECT
|
|
21
|
+
'00000000-0000-4000-8000-000000000f04'::uuid,
|
|
22
|
+
'Idle chat follow-up',
|
|
23
|
+
'Ask the agent to draft a follow-up when a customer goes idle after an agent reply. Paired with per-agent/per-instance follow-up config (see omni follow-up set ...).',
|
|
24
|
+
'chat.idle_timeout',
|
|
25
|
+
'[]'::jsonb,
|
|
26
|
+
'and',
|
|
27
|
+
'[
|
|
28
|
+
{
|
|
29
|
+
"type": "call_agent",
|
|
30
|
+
"config": {
|
|
31
|
+
"agentId": "{{payload.agentId}}",
|
|
32
|
+
"promptOverride": "The customer has been idle for {{minutes}} minutes since your last reply. This is follow-up #{{sequenceIndex}} in the sequence.\n\n{{syntheticPrompt}}\n\nWrite a short, warm follow-up message to {{chatName}} in their preferred language. Do not mention that this is an automated follow-up.",
|
|
33
|
+
"responseAs": "followUpReply"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "send_message",
|
|
38
|
+
"config": {
|
|
39
|
+
"instanceId": "{{payload.instanceId}}",
|
|
40
|
+
"to": "{{payload.chatId}}",
|
|
41
|
+
"contentTemplate": "{{followUpReply}}"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]'::jsonb,
|
|
45
|
+
true,
|
|
46
|
+
100,
|
|
47
|
+
NOW(),
|
|
48
|
+
NOW()
|
|
49
|
+
WHERE NOT EXISTS (
|
|
50
|
+
SELECT 1 FROM "automations" WHERE "name" = 'Idle chat follow-up'
|
|
51
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Upgrade the "Idle chat follow-up" automation promptOverride to use
|
|
2
|
+
-- 1-based `{{attemptNumber}}` / `{{totalAttempts}}` placeholders instead of the
|
|
3
|
+
-- zero-based `{{sequenceIndex}}`.
|
|
4
|
+
--
|
|
5
|
+
-- Context: in production the agent was reading "This is follow-up #0" and
|
|
6
|
+
-- confusing itself into emitting meta-commentary ("_(limite atingido)_") from
|
|
7
|
+
-- its own session memory. The new wrapper uses natural 1-based numbering and
|
|
8
|
+
-- explicitly forbids stage directions / parenthetical notes.
|
|
9
|
+
--
|
|
10
|
+
-- Idempotent: only rewrites the built-in row. User-authored automations are
|
|
11
|
+
-- untouched.
|
|
12
|
+
|
|
13
|
+
UPDATE "automations"
|
|
14
|
+
SET
|
|
15
|
+
"actions" = '[
|
|
16
|
+
{
|
|
17
|
+
"type": "call_agent",
|
|
18
|
+
"config": {
|
|
19
|
+
"agentId": "{{payload.agentId}}",
|
|
20
|
+
"promptOverride": "Follow-up context: attempt {{attemptNumber}} of {{totalAttempts}} — {{minutes}} minutes of silence since your last message to {{chatName}}.\n\n{{syntheticPrompt}}\n\nRespond with ONLY the customer-facing message. Plain text, no italics, no parentheses, no stage directions, no meta-commentary. Do not refer to yourself as an automation or follow-up bot.",
|
|
21
|
+
"responseAs": "followUpReply"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "send_message",
|
|
26
|
+
"config": {
|
|
27
|
+
"instanceId": "{{payload.instanceId}}",
|
|
28
|
+
"to": "{{payload.chatId}}",
|
|
29
|
+
"contentTemplate": "{{followUpReply}}"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]'::jsonb,
|
|
33
|
+
"updated_at" = NOW()
|
|
34
|
+
WHERE "id" = '00000000-0000-4000-8000-000000000f04'::uuid;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- Add `inbound_max_age_minutes` to `instances`. Drops inbound
|
|
2
|
+
-- `message.received` events for the agent dispatcher when the platform-native
|
|
3
|
+
-- timestamp (e.g. WhatsApp `messageTimestamp`) is older than this value.
|
|
4
|
+
--
|
|
5
|
+
-- Guards against history-sync replays and NATS redelivery of stale messages
|
|
6
|
+
-- after reconnect/restart. Default: 10 minutes.
|
|
7
|
+
|
|
8
|
+
ALTER TABLE "instances" ADD COLUMN "inbound_max_age_minutes" integer DEFAULT 10 NOT NULL;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- Add `handoff_logs` table to persist every agent→human handoff with full payload.
|
|
2
|
+
-- Records instanceId, chatId, toPhone, text, extraInfo, agentId, and externalMessageId
|
|
3
|
+
-- so handoffs can be queried, audited, and correlated with omni_events.
|
|
4
|
+
|
|
5
|
+
CREATE TABLE "handoff_logs" (
|
|
6
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
7
|
+
"instance_id" uuid REFERENCES "instances"("id") ON DELETE SET NULL,
|
|
8
|
+
"chat_uuid" uuid REFERENCES "chats"("id") ON DELETE SET NULL,
|
|
9
|
+
"chat_id" varchar(255) NOT NULL,
|
|
10
|
+
"to_phone" varchar(100) NOT NULL,
|
|
11
|
+
"text" text NOT NULL,
|
|
12
|
+
"extra_info" text,
|
|
13
|
+
"agent_id" uuid REFERENCES "agents"("id") ON DELETE SET NULL,
|
|
14
|
+
"external_message_id" varchar(255),
|
|
15
|
+
"sent_at" timestamp DEFAULT now() NOT NULL,
|
|
16
|
+
"metadata" jsonb
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE INDEX "handoff_logs_instance_idx" ON "handoff_logs" ("instance_id");
|
|
20
|
+
CREATE INDEX "handoff_logs_chat_uuid_idx" ON "handoff_logs" ("chat_uuid");
|
|
21
|
+
CREATE INDEX "handoff_logs_chat_id_idx" ON "handoff_logs" ("chat_id");
|
|
22
|
+
CREATE INDEX "handoff_logs_sent_at_idx" ON "handoff_logs" ("sent_at");
|
|
23
|
+
CREATE INDEX "handoff_logs_agent_idx" ON "handoff_logs" ("agent_id");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- Add `handoff_fields` jsonb column to `handoff_logs`.
|
|
2
|
+
-- Stores structured key-value pairs from the agent for Gupshup flow variable mapping
|
|
3
|
+
-- (e.g. nome → var_global.name, temperatura_lead → var_global.calor_do_lead).
|
|
4
|
+
|
|
5
|
+
ALTER TABLE "handoff_logs" ADD COLUMN "handoff_fields" jsonb;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Omni scope profiles: add profile + allowlist columns to `api_keys`.
|
|
2
|
+
--
|
|
3
|
+
-- Existing keys are backfilled as follows:
|
|
4
|
+
-- * `profile` stays NULL — they keep their hand-authored `scopes`
|
|
5
|
+
-- * `profile_overrides` defaults to `'{}'::jsonb`
|
|
6
|
+
-- * `chat_allowlist` / `instance_allowlist` / `outbound_recipient_allowlist`
|
|
7
|
+
-- default to empty arrays. For NULL-profile keys the enforcer treats `[]`
|
|
8
|
+
-- as "no lock" (backward compat). For profile keys that declare
|
|
9
|
+
-- `requiresLocks`, `[]` means "deny all" — see docs/profiles.md.
|
|
10
|
+
|
|
11
|
+
ALTER TABLE "api_keys" ADD COLUMN "profile" varchar(32);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
ALTER TABLE "api_keys" ADD COLUMN "profile_overrides" jsonb DEFAULT '{}'::jsonb NOT NULL;
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
ALTER TABLE "api_keys" ADD COLUMN "chat_allowlist" text[] DEFAULT ARRAY[]::text[] NOT NULL;
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "api_keys" ADD COLUMN "instance_allowlist" uuid[] DEFAULT ARRAY[]::uuid[] NOT NULL;
|
|
18
|
+
--> statement-breakpoint
|
|
19
|
+
ALTER TABLE "api_keys" ADD COLUMN "outbound_recipient_allowlist" text[] DEFAULT ARRAY[]::text[] NOT NULL;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- Per-instance bridge tmux session override for the genie `nats-genie` provider.
|
|
2
|
+
--
|
|
3
|
+
-- When set, the provider propagates this value via the NATS message env as
|
|
4
|
+
-- `GENIE_TMUX_SESSION`; the consumer genie bridge uses it as the highest-
|
|
5
|
+
-- priority override in its three-layer tmux-session resolution chain.
|
|
6
|
+
-- NULL keeps today's behavior (no override, genie falls back to agent-level
|
|
7
|
+
-- or name-based defaults).
|
|
8
|
+
--
|
|
9
|
+
-- Enables one-agent-many-instances fan-out — e.g. a single "scout" agent
|
|
10
|
+
-- hooked to N inbound numbers lands each instance's dispatches in its own
|
|
11
|
+
-- tmux session for isolation and live-intelligence observability.
|
|
12
|
+
|
|
13
|
+
ALTER TABLE "instances" ADD COLUMN "bridge_tmux_session" text;
|