@andreprado/agentkit 0.1.0-alpha.15 → 0.1.0-alpha.17
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/README.md +8 -0
- package/docs/guides/add-channel.md +65 -0
- package/docs/guides/add-managed-composio.md +137 -0
- package/docs/guides/channel-security.md +32 -0
- package/docs/guides/channels-production-handoff.md +1 -1
- package/docs/guides/connect-telegram.md +60 -0
- package/docs/guides/connect-whatsapp-zapster.md +65 -0
- package/docs/guides/prepare-deploy.md +3 -1
- package/docs/llms-full.txt +13 -1
- package/docs/llms.txt +7 -0
- package/package.json +1 -1
- package/src/cli/commands/channels.ts +121 -7
- package/src/cli/commands/transcribe.ts +171 -0
- package/src/cli/deploy-readiness.ts +59 -3
- package/src/cli/help.ts +15 -0
- package/src/cli/index.ts +130 -0
- package/src/create-project.ts +4 -32
- package/src/index.ts +231 -0
- package/src/runtime/channel-test-harness.ts +2 -0
- package/src/runtime/channels/telegram.ts +326 -10
- package/src/runtime/channels/whatsapp-zapster.ts +319 -0
- package/src/runtime/channels.ts +47 -1
- package/src/runtime/chat.ts +2 -1
- package/src/runtime/config.ts +214 -4
- package/src/runtime/core/manifest.ts +61 -2
- package/src/runtime/deploy-readiness.ts +31 -1
- package/src/runtime/dev-server.ts +72 -4
- package/src/runtime/inspect.ts +142 -4
- package/src/runtime/integrations/composio.ts +257 -0
- package/src/runtime/skills.ts +95 -0
- package/src/runtime/targets/cloudflare/build.ts +162 -5
- package/src/runtime/tool-runner.ts +2 -1
- package/src/runtime/transcription.ts +483 -0
- package/src/templates/skills/agentkit-capsule/SKILL.md +1 -0
- package/src/templates/skills/agentkit-channels/SKILL.md +36 -1
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +16 -1
- package/src/templates/skills/agentkit-channels/references/telegram.md +34 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +29 -0
- package/src/templates/skills/agentkit-deploy/SKILL.md +1 -1
- package/src/templates/skills/agentkit-integrations/SKILL.md +66 -0
- package/src/templates/skills/agentkit-troubleshooting/SKILL.md +3 -2
|
@@ -36,7 +36,9 @@ export type AgentManifest = {
|
|
|
36
36
|
prompt: SharedAgentManifest["prompt"];
|
|
37
37
|
secrets: SharedAgentManifest["secrets"];
|
|
38
38
|
tools: SharedAgentManifest["tools"];
|
|
39
|
+
integrations: SharedAgentManifest["integrations"];
|
|
39
40
|
channels: SharedAgentManifest["channels"];
|
|
41
|
+
transcription: SharedAgentManifest["transcription"];
|
|
40
42
|
knowledge: SharedAgentManifest["knowledge"];
|
|
41
43
|
access: SharedAgentManifest["access"];
|
|
42
44
|
storage: {
|
|
@@ -197,7 +199,9 @@ function buildManifest(
|
|
|
197
199
|
prompt: shared.prompt,
|
|
198
200
|
secrets: shared.secrets,
|
|
199
201
|
tools: shared.tools,
|
|
202
|
+
integrations: shared.integrations,
|
|
200
203
|
channels: shared.channels,
|
|
204
|
+
transcription: shared.transcription,
|
|
201
205
|
knowledge: shared.knowledge,
|
|
202
206
|
access: shared.access,
|
|
203
207
|
storage: {
|
|
@@ -381,6 +385,23 @@ export function defineTool(tool) {
|
|
|
381
385
|
return tool;
|
|
382
386
|
}
|
|
383
387
|
|
|
388
|
+
export function composioManaged(input) {
|
|
389
|
+
const name = normalizeIntegrationName(input.name ?? "composio", "composio integration name");
|
|
390
|
+
const toolkits = normalizeToolkitList(input.toolkits, "composioManaged.toolkits");
|
|
391
|
+
const tools = input.tools ? normalizeComposioToolMap(input.tools, toolkits) : undefined;
|
|
392
|
+
const tags = input.tags ? normalizeIntegrationTags(input.tags) : undefined;
|
|
393
|
+
|
|
394
|
+
return {
|
|
395
|
+
type: "composio",
|
|
396
|
+
provider: "composio",
|
|
397
|
+
mode: "managed",
|
|
398
|
+
name,
|
|
399
|
+
toolkits,
|
|
400
|
+
...(tools ? { tools } : {}),
|
|
401
|
+
...(tags ? { tags } : {}),
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
384
405
|
export function websiteChannel(input) {
|
|
385
406
|
return {
|
|
386
407
|
type: "website",
|
|
@@ -438,6 +459,105 @@ function normalizeChannelSecrets(secrets, context) {
|
|
|
438
459
|
return Array.from(uniqueSecrets).sort();
|
|
439
460
|
}
|
|
440
461
|
|
|
462
|
+
function normalizeIntegrationName(value, context) {
|
|
463
|
+
const name = value.trim();
|
|
464
|
+
|
|
465
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
466
|
+
throw new Error(\`\${context} must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens.\`);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return name;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function normalizeToolkitList(values, context) {
|
|
473
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
474
|
+
throw new Error(\`\${context} must include at least one toolkit slug.\`);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const toolkits = new Set();
|
|
478
|
+
|
|
479
|
+
for (const value of values) {
|
|
480
|
+
if (typeof value !== "string") {
|
|
481
|
+
throw new Error(\`\${context} entries must be toolkit slug strings.\`);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const toolkit = value.trim().toLowerCase();
|
|
485
|
+
|
|
486
|
+
if (!/^[a-z][a-z0-9_-]*$/.test(toolkit)) {
|
|
487
|
+
throw new Error(\`\${context} entries must start with a letter and contain only letters, numbers, underscores, and hyphens.\`);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
toolkits.add(toolkit);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return Array.from(toolkits).sort();
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function normalizeComposioToolMap(values, toolkits) {
|
|
497
|
+
const toolkitSet = new Set(toolkits);
|
|
498
|
+
const normalized = {};
|
|
499
|
+
|
|
500
|
+
for (const [rawToolkit, rawTools] of Object.entries(values)) {
|
|
501
|
+
const toolkit = rawToolkit.trim().toLowerCase();
|
|
502
|
+
|
|
503
|
+
if (!toolkitSet.has(toolkit)) {
|
|
504
|
+
throw new Error(\`composioManaged.tools.\${rawToolkit} must reference a toolkit listed in composioManaged.toolkits.\`);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (!Array.isArray(rawTools) || rawTools.length === 0) {
|
|
508
|
+
throw new Error(\`composioManaged.tools.\${rawToolkit} must include at least one Composio action slug.\`);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const tools = new Set();
|
|
512
|
+
|
|
513
|
+
for (const rawTool of rawTools) {
|
|
514
|
+
if (typeof rawTool !== "string") {
|
|
515
|
+
throw new Error(\`composioManaged.tools.\${rawToolkit} entries must be Composio action slug strings.\`);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const tool = rawTool.trim().toUpperCase();
|
|
519
|
+
|
|
520
|
+
if (!/^[A-Z][A-Z0-9_]*$/.test(tool)) {
|
|
521
|
+
throw new Error(\`composioManaged.tools.\${rawToolkit} entries must be uppercase Composio action slugs.\`);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
tools.add(tool);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
normalized[toolkit] = Array.from(tools).sort();
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function normalizeIntegrationTags(tags) {
|
|
534
|
+
const normalized = {};
|
|
535
|
+
|
|
536
|
+
if (tags.enable !== undefined) {
|
|
537
|
+
normalized.enable = normalizeTagList(tags.enable, "composioManaged.tags.enable");
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (tags.disable !== undefined) {
|
|
541
|
+
normalized.disable = normalizeTagList(tags.disable, "composioManaged.tags.disable");
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return normalized;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function normalizeTagList(values, context) {
|
|
548
|
+
if (!Array.isArray(values)) {
|
|
549
|
+
throw new Error(\`\${context} must be an array of tag strings.\`);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return Array.from(new Set(values.map((value) => {
|
|
553
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
554
|
+
throw new Error(\`\${context} entries must be non-empty strings.\`);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return value.trim();
|
|
558
|
+
}))).sort();
|
|
559
|
+
}
|
|
560
|
+
|
|
441
561
|
function normalizeChannelBuffer(input, context) {
|
|
442
562
|
if (input.mode === "off") {
|
|
443
563
|
return { mode: "off" };
|
|
@@ -540,17 +660,18 @@ function renderCloudflareWorker(input: { manifest: AgentManifest; instructions:
|
|
|
540
660
|
const instructionsJson = JSON.stringify(input.instructions);
|
|
541
661
|
const configImportPath = JSON.stringify(input.configPath);
|
|
542
662
|
const providerImportPath = JSON.stringify(resolve(moduleDir, "../../../providers/index.ts"));
|
|
663
|
+
const composioIntegrationImportPath = JSON.stringify(resolve(moduleDir, "../../integrations/composio.ts"));
|
|
543
664
|
const promptContextImportPath = JSON.stringify(resolve(moduleDir, "../../prompt-context.ts"));
|
|
544
665
|
|
|
545
666
|
return `import { DurableObject } from "cloudflare:workers";
|
|
546
667
|
import agentConfig from ${configImportPath};
|
|
547
668
|
import { getProviderAdapter } from ${providerImportPath};
|
|
669
|
+
import { MANAGED_COMPOSIO_USER_ID_BINDING, createManagedComposioTools } from ${composioIntegrationImportPath};
|
|
548
670
|
import { appendRuntimePromptContext, buildRuntimeClockContext } from ${promptContextImportPath};
|
|
549
671
|
|
|
550
672
|
const manifest = ${manifestJson};
|
|
551
673
|
const instructions = ${instructionsJson};
|
|
552
674
|
const hostedKnowledgeTool = manifest.knowledge.enabled ? createHostedKnowledgeSearchTool() : null;
|
|
553
|
-
const hostedTools = hostedKnowledgeTool ? [hostedKnowledgeTool, ...(agentConfig.tools ?? [])] : (agentConfig.tools ?? []);
|
|
554
675
|
const DEFAULT_TOOL_TIMEOUT_MS = 30000;
|
|
555
676
|
|
|
556
677
|
export class AgentKitConversationStore extends DurableObject {
|
|
@@ -719,13 +840,16 @@ export default {
|
|
|
719
840
|
return auth;
|
|
720
841
|
}
|
|
721
842
|
|
|
843
|
+
const hostedTools = createHostedTools(env);
|
|
844
|
+
|
|
722
845
|
return Response.json({
|
|
723
846
|
agent: manifest.name,
|
|
724
847
|
runtime: manifest.runtime,
|
|
725
848
|
target: manifest.target,
|
|
726
849
|
provider: manifest.provider,
|
|
727
850
|
prompt: manifest.prompt,
|
|
728
|
-
tools:
|
|
851
|
+
tools: hostedTools.map((tool) => tool.name),
|
|
852
|
+
integrations: hostedIntegrations(env),
|
|
729
853
|
channels: manifest.channels.map((channel) => ({
|
|
730
854
|
name: channel.name,
|
|
731
855
|
type: channel.type,
|
|
@@ -1127,6 +1251,7 @@ function isRecord(value) {
|
|
|
1127
1251
|
|
|
1128
1252
|
async function callHostedProvider(env, messages, signal) {
|
|
1129
1253
|
const adapter = getProviderAdapter(manifest.provider);
|
|
1254
|
+
const hostedTools = createHostedTools(env);
|
|
1130
1255
|
const clock = buildRuntimeClockContext({
|
|
1131
1256
|
timeZone: manifest.timeZone,
|
|
1132
1257
|
env,
|
|
@@ -1624,18 +1749,49 @@ function inspectHostedDatabase() {
|
|
|
1624
1749
|
}
|
|
1625
1750
|
|
|
1626
1751
|
function hostedManagedSecrets() {
|
|
1627
|
-
|
|
1628
|
-
|
|
1752
|
+
const secrets = [];
|
|
1753
|
+
|
|
1754
|
+
if (manifest.storage.database.driver === "turso") {
|
|
1755
|
+
secrets.push("TURSO_AUTH_TOKEN", "TURSO_DATABASE_URL");
|
|
1629
1756
|
}
|
|
1630
1757
|
|
|
1631
|
-
|
|
1758
|
+
if (manifest.integrations.some((integration) => integration.provider === "composio" && integration.mode === "managed")) {
|
|
1759
|
+
secrets.push("COMPOSIO_API_KEY");
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
return secrets.sort();
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
function createHostedTools(env) {
|
|
1766
|
+
return [
|
|
1767
|
+
...(hostedKnowledgeTool ? [hostedKnowledgeTool] : []),
|
|
1768
|
+
...createManagedComposioTools(agentConfig, { userId: env[MANAGED_COMPOSIO_USER_ID_BINDING] }),
|
|
1769
|
+
...(agentConfig.tools ?? []),
|
|
1770
|
+
];
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
function hostedIntegrations(env) {
|
|
1774
|
+
const userId = env[MANAGED_COMPOSIO_USER_ID_BINDING];
|
|
1775
|
+
|
|
1776
|
+
if (!userId) {
|
|
1777
|
+
return manifest.integrations;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
return manifest.integrations.map((integration) =>
|
|
1781
|
+
integration.provider === "composio" && integration.mode === "managed"
|
|
1782
|
+
? { ...integration, userId }
|
|
1783
|
+
: integration,
|
|
1784
|
+
);
|
|
1632
1785
|
}
|
|
1633
1786
|
|
|
1634
1787
|
function createHostedProviderToolRuntime(env, signal, clock) {
|
|
1788
|
+
const hostedTools = createHostedTools(env);
|
|
1789
|
+
|
|
1635
1790
|
return {
|
|
1636
1791
|
definitions: hostedTools,
|
|
1637
1792
|
execute(request) {
|
|
1638
1793
|
return executeHostedTool({
|
|
1794
|
+
tools: hostedTools,
|
|
1639
1795
|
name: request.name,
|
|
1640
1796
|
input: request.input,
|
|
1641
1797
|
env,
|
|
@@ -1648,6 +1804,7 @@ function createHostedProviderToolRuntime(env, signal, clock) {
|
|
|
1648
1804
|
}
|
|
1649
1805
|
|
|
1650
1806
|
async function executeHostedTool(request) {
|
|
1807
|
+
const hostedTools = request.tools ?? createHostedTools(request.env);
|
|
1651
1808
|
const tool = hostedTools.find((candidate) => candidate.name === request.name);
|
|
1652
1809
|
const id = crypto.randomUUID();
|
|
1653
1810
|
|
|
@@ -2,6 +2,7 @@ import { loadAgentCapsule } from "./config";
|
|
|
2
2
|
import { openPreparedCapsuleStore } from "./database";
|
|
3
3
|
import { loadCapsuleEnv } from "./env";
|
|
4
4
|
import { isAgentKitError } from "./errors";
|
|
5
|
+
import { createManagedComposioTools } from "./integrations/composio";
|
|
5
6
|
import { buildRuntimeClockContext } from "./prompt-context";
|
|
6
7
|
import { createToolRuntime, type ToolCallResult } from "./tools";
|
|
7
8
|
|
|
@@ -26,7 +27,7 @@ export async function runToolFromCwd(cwd: string, options: RunToolOptions): Prom
|
|
|
26
27
|
model: capsule.config.provider.model,
|
|
27
28
|
});
|
|
28
29
|
const toolRuntime = createToolRuntime({
|
|
29
|
-
tools: capsule.config.tools ?? [],
|
|
30
|
+
tools: [...createManagedComposioTools(capsule.config), ...(capsule.config.tools ?? [])],
|
|
30
31
|
store,
|
|
31
32
|
runId: run.id,
|
|
32
33
|
conversationId: conversation.id,
|