@corbat-tech/coco 2.39.0 → 2.40.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.
@@ -1,5 +1,5 @@
1
- import { ac as RuntimeTurnStreamEvent, I as AgentRuntime } from '../agent-runtime-DJY9FzL_.js';
2
- import '../registry-CEpl9Jq0.js';
1
+ import { A as AgentRuntime } from '../agent-runtime-Cd6pB640.js';
2
+ import { ag as RuntimeTurnStreamEvent } from '../workflow-engine-DleSoUhy.js';
3
3
  import 'zod';
4
4
 
5
5
  interface ChannelInput {
@@ -27,11 +27,23 @@ interface HttpAssistantAdapter {
27
27
  interface StreamingHttpAssistantAdapter extends HttpAssistantAdapter {
28
28
  streamMessage(input: ChannelInput): AsyncIterable<RuntimeTurnStreamEvent>;
29
29
  }
30
+ interface WhatsAppInboundMessage {
31
+ from: string;
32
+ text: string;
33
+ messageId?: string;
34
+ profileName?: string;
35
+ metadata?: Record<string, unknown>;
36
+ }
37
+ interface WhatsAppAssistantAdapter {
38
+ surface: "whatsapp";
39
+ handleInbound(input: WhatsAppInboundMessage): Promise<ChannelOutput>;
40
+ }
30
41
  declare function createHttpAssistantAdapter(runtime: AgentRuntime): HttpAssistantAdapter;
31
42
  declare function createStreamingHttpAssistantAdapter(runtime: AgentRuntime): StreamingHttpAssistantAdapter;
32
43
  declare function createWebhookAssistantAdapter(runtime: AgentRuntime, options?: {
33
44
  id?: string;
34
45
  surface?: ChannelAdapter["surface"];
35
46
  }): ChannelAdapter;
47
+ declare function createWhatsAppAssistantAdapter(runtime: AgentRuntime): WhatsAppAssistantAdapter;
36
48
 
37
- export { type ChannelAdapter, type ChannelInput, type ChannelOutput, type HttpAssistantAdapter, type StreamingHttpAssistantAdapter, createHttpAssistantAdapter, createStreamingHttpAssistantAdapter, createWebhookAssistantAdapter };
49
+ export { type ChannelAdapter, type ChannelInput, type ChannelOutput, type HttpAssistantAdapter, type StreamingHttpAssistantAdapter, type WhatsAppAssistantAdapter, type WhatsAppInboundMessage, createHttpAssistantAdapter, createStreamingHttpAssistantAdapter, createWebhookAssistantAdapter, createWhatsAppAssistantAdapter };
@@ -40,7 +40,27 @@ function createWebhookAssistantAdapter(runtime, options = {}) {
40
40
  }
41
41
  };
42
42
  }
43
+ function createWhatsAppAssistantAdapter(runtime) {
44
+ return {
45
+ surface: "whatsapp",
46
+ async handleInbound(input) {
47
+ const adapter = createHttpAssistantAdapter(runtime);
48
+ return adapter.handleMessage({
49
+ content: input.text,
50
+ userId: input.from,
51
+ metadata: {
52
+ surface: "whatsapp",
53
+ channel: "whatsapp",
54
+ phoneNumber: input.from,
55
+ profileName: input.profileName,
56
+ messageId: input.messageId,
57
+ ...input.metadata
58
+ }
59
+ });
60
+ }
61
+ };
62
+ }
43
63
 
44
- export { createHttpAssistantAdapter, createStreamingHttpAssistantAdapter, createWebhookAssistantAdapter };
64
+ export { createHttpAssistantAdapter, createStreamingHttpAssistantAdapter, createWebhookAssistantAdapter, createWhatsAppAssistantAdapter };
45
65
  //# sourceMappingURL=index.js.map
46
66
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/index.ts"],"names":[],"mappings":";AA+BO,SAAS,2BAA2B,OAAA,EAA6C;AACtF,EAAA,OAAO;AAAA,IACL,aAAA,CAAc,QAAA,GAAW,EAAC,EAAG;AAC3B,MAAA,MAAM,UAAU,OAAA,CAAQ,aAAA,CAAc,EAAE,IAAA,EAAM,KAAA,EAAO,UAAU,CAAA;AAC/D,MAAA,OAAO,EAAE,SAAA,EAAW,OAAA,CAAQ,EAAA,EAAG;AAAA,IACjC,CAAA;AAAA,IACA,MAAM,cAAc,KAAA,EAAO;AACzB,MAAA,MAAM,SAAA,GACJ,KAAA,CAAM,SAAA,IAAa,OAAA,CAAQ,aAAA,CAAc,EAAE,IAAA,EAAM,KAAA,EAAO,QAAA,EAAU,KAAA,CAAM,QAAA,EAAU,CAAA,CAAE,EAAA;AACtF,MAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,OAAA,CAAQ;AAAA,QACnC,SAAA;AAAA,QACA,SAAS,KAAA,CAAM,OAAA;AAAA,QACf,UAAU,KAAA,CAAM;AAAA,OACjB,CAAA;AACD,MAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,MAAA,CAAO,OAAA,EAAS,UAAU,EAAE,KAAA,EAAO,MAAA,CAAO,KAAA,EAAM,EAAE;AAAA,IACjF;AAAA,GACF;AACF;AAEO,SAAS,oCACd,OAAA,EAC+B;AAC/B,EAAA,MAAM,IAAA,GAAO,2BAA2B,OAAO,CAAA;AAC/C,EAAA,OAAO;AAAA,IACL,GAAG,IAAA;AAAA,IACH,OAAO,cAAc,KAAA,EAAO;AAC1B,MAAA,MAAM,SAAA,GACJ,KAAA,CAAM,SAAA,IAAa,OAAA,CAAQ,aAAA,CAAc,EAAE,IAAA,EAAM,KAAA,EAAO,QAAA,EAAU,KAAA,CAAM,QAAA,EAAU,CAAA,CAAE,EAAA;AACtF,MAAA,OAAO,QAAQ,UAAA,CAAW;AAAA,QACxB,SAAA;AAAA,QACA,SAAS,KAAA,CAAM,OAAA;AAAA,QACf,UAAU,KAAA,CAAM;AAAA,OACjB,CAAA;AAAA,IACH;AAAA,GACF;AACF;AAEO,SAAS,6BAAA,CACd,OAAA,EACA,OAAA,GAAgE,EAAC,EACjD;AAChB,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,QAAQ,EAAA,IAAM,mBAAA;AAAA,IAClB,OAAA,EAAS,QAAQ,OAAA,IAAW,KAAA;AAAA,IAC5B,MAAM,OAAO,KAAA,EAAO;AAClB,MAAA,MAAM,OAAA,GAAU,2BAA2B,OAAO,CAAA;AAClD,MAAA,OAAO,OAAA,CAAQ,cAAc,KAAK,CAAA;AAAA,IACpC;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { AgentRuntime } from \"../runtime/agent-runtime.js\";\nimport type { RuntimeTurnStreamEvent } from \"../runtime/types.js\";\n\nexport interface ChannelInput {\n sessionId?: string;\n content: string;\n userId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface ChannelOutput {\n sessionId: string;\n content: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface ChannelAdapter {\n id: string;\n surface: \"web\" | \"whatsapp\" | \"slack\" | \"api\" | \"internal\";\n handle(input: ChannelInput): Promise<ChannelOutput>;\n}\n\nexport interface HttpAssistantAdapter {\n createSession(metadata?: Record<string, unknown>): { sessionId: string };\n handleMessage(input: ChannelInput): Promise<ChannelOutput>;\n}\n\nexport interface StreamingHttpAssistantAdapter extends HttpAssistantAdapter {\n streamMessage(input: ChannelInput): AsyncIterable<RuntimeTurnStreamEvent>;\n}\n\nexport function createHttpAssistantAdapter(runtime: AgentRuntime): HttpAssistantAdapter {\n return {\n createSession(metadata = {}) {\n const session = runtime.createSession({ mode: \"ask\", metadata });\n return { sessionId: session.id };\n },\n async handleMessage(input) {\n const sessionId =\n input.sessionId ?? runtime.createSession({ mode: \"ask\", metadata: input.metadata }).id;\n const result = await runtime.runTurn({\n sessionId,\n content: input.content,\n metadata: input.metadata,\n });\n return { sessionId, content: result.content, metadata: { model: result.model } };\n },\n };\n}\n\nexport function createStreamingHttpAssistantAdapter(\n runtime: AgentRuntime,\n): StreamingHttpAssistantAdapter {\n const base = createHttpAssistantAdapter(runtime);\n return {\n ...base,\n async *streamMessage(input) {\n const sessionId =\n input.sessionId ?? runtime.createSession({ mode: \"ask\", metadata: input.metadata }).id;\n yield* runtime.streamTurn({\n sessionId,\n content: input.content,\n metadata: input.metadata,\n });\n },\n };\n}\n\nexport function createWebhookAssistantAdapter(\n runtime: AgentRuntime,\n options: { id?: string; surface?: ChannelAdapter[\"surface\"] } = {},\n): ChannelAdapter {\n return {\n id: options.id ?? \"webhook-assistant\",\n surface: options.surface ?? \"api\",\n async handle(input) {\n const adapter = createHttpAssistantAdapter(runtime);\n return adapter.handleMessage(input);\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/adapters/index.ts"],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KAAA,CAAM;AAAA,OACjB,CAAA;AAAA,IACH;AAAA,GACF;AACF;AAEO,SAAS,6BAAA,CACd,OAAA,EACA,OAAA,GAAgE,EAAC,EACjD;AAChB,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,QAAQ,EAAA,IAAM,mBAAA;AAAA,IAClB,OAAA,EAAS,QAAQ,OAAA,IAAW,KAAA;AAAA,IAC5B,MAAM,OAAO,KAAA,EAAO;AAClB,MAAA,MAAM,OAAA,GAAU,2BAA2B,OAAO,CAAA;AAClD,MAAA,OAAO,OAAA,CAAQ,cAAc,KAAK,CAAA;AAAA,IACpC;AAAA,GACF;AACF;AAEO,SAAS,+BAA+B,OAAA,EAAiD;AAC9F,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,UAAA;AAAA,IACT,MAAM,cAAc,KAAA,EAAO;AACzB,MAAA,MAAM,OAAA,GAAU,2BAA2B,OAAO,CAAA;AAClD,MAAA,OAAO,QAAQ,aAAA,CAAc;AAAA,QAC3B,SAAS,KAAA,CAAM,IAAA;AAAA,QACf,QAAQ,KAAA,CAAM,IAAA;AAAA,QACd,QAAA,EAAU;AAAA,UACR,OAAA,EAAS,UAAA;AAAA,UACT,OAAA,EAAS,UAAA;AAAA,UACT,aAAa,KAAA,CAAM,IAAA;AAAA,UACnB,aAAa,KAAA,CAAM,WAAA;AAAA,UACnB,WAAW,KAAA,CAAM,SAAA;AAAA,UACjB,GAAG,KAAA,CAAM;AAAA;AACX,OACD,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { AgentRuntime } from \"../runtime/agent-runtime.js\";\nimport type { RuntimeTurnStreamEvent } from \"../runtime/types.js\";\n\nexport interface ChannelInput {\n sessionId?: string;\n content: string;\n userId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface ChannelOutput {\n sessionId: string;\n content: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface ChannelAdapter {\n id: string;\n surface: \"web\" | \"whatsapp\" | \"slack\" | \"api\" | \"internal\";\n handle(input: ChannelInput): Promise<ChannelOutput>;\n}\n\nexport interface HttpAssistantAdapter {\n createSession(metadata?: Record<string, unknown>): { sessionId: string };\n handleMessage(input: ChannelInput): Promise<ChannelOutput>;\n}\n\nexport interface StreamingHttpAssistantAdapter extends HttpAssistantAdapter {\n streamMessage(input: ChannelInput): AsyncIterable<RuntimeTurnStreamEvent>;\n}\n\nexport interface WhatsAppInboundMessage {\n from: string;\n text: string;\n messageId?: string;\n profileName?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface WhatsAppAssistantAdapter {\n surface: \"whatsapp\";\n handleInbound(input: WhatsAppInboundMessage): Promise<ChannelOutput>;\n}\n\nexport function createHttpAssistantAdapter(runtime: AgentRuntime): HttpAssistantAdapter {\n return {\n createSession(metadata = {}) {\n const session = runtime.createSession({ mode: \"ask\", metadata });\n return { sessionId: session.id };\n },\n async handleMessage(input) {\n const sessionId =\n input.sessionId ?? runtime.createSession({ mode: \"ask\", metadata: input.metadata }).id;\n const result = await runtime.runTurn({\n sessionId,\n content: input.content,\n metadata: input.metadata,\n });\n return { sessionId, content: result.content, metadata: { model: result.model } };\n },\n };\n}\n\nexport function createStreamingHttpAssistantAdapter(\n runtime: AgentRuntime,\n): StreamingHttpAssistantAdapter {\n const base = createHttpAssistantAdapter(runtime);\n return {\n ...base,\n async *streamMessage(input) {\n const sessionId =\n input.sessionId ?? runtime.createSession({ mode: \"ask\", metadata: input.metadata }).id;\n yield* runtime.streamTurn({\n sessionId,\n content: input.content,\n metadata: input.metadata,\n });\n },\n };\n}\n\nexport function createWebhookAssistantAdapter(\n runtime: AgentRuntime,\n options: { id?: string; surface?: ChannelAdapter[\"surface\"] } = {},\n): ChannelAdapter {\n return {\n id: options.id ?? \"webhook-assistant\",\n surface: options.surface ?? \"api\",\n async handle(input) {\n const adapter = createHttpAssistantAdapter(runtime);\n return adapter.handleMessage(input);\n },\n };\n}\n\nexport function createWhatsAppAssistantAdapter(runtime: AgentRuntime): WhatsAppAssistantAdapter {\n return {\n surface: \"whatsapp\",\n async handleInbound(input) {\n const adapter = createHttpAssistantAdapter(runtime);\n return adapter.handleMessage({\n content: input.text,\n userId: input.from,\n metadata: {\n surface: \"whatsapp\",\n channel: \"whatsapp\",\n phoneNumber: input.from,\n profileName: input.profileName,\n messageId: input.messageId,\n ...input.metadata,\n },\n });\n },\n };\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import { b8 as ProviderCatalogEntry, b7 as ProviderType, b9 as ModelCatalogEntry, ba as ProviderRuntimeCapability, P as ProviderConfig, L as LLMProvider, bb as ProviderProbeResult, ap as ToolRegistry, a8 as RuntimeSessionStore, aw as WorkflowEngine, Y as PermissionPolicy, T as EventLog, af as RuntimeTurnRunner, I as AgentRuntimeOptions, J as AgentRuntimeSnapshot, a7 as RuntimeSessionCreateOptions, a6 as RuntimeSession, ad as RuntimeTurnInput, ae as RuntimeTurnResult, ag as RuntimeTurnStreamEvent, aa as RuntimeToolExecutionInput, ab as RuntimeToolExecutionResult, a3 as RuntimeMode } from './workflow-engine-DleSoUhy.js';
2
+
3
+ /** Catalog-backed provider/model registry used by runtime consumers. */
4
+ declare class ProviderRegistry {
5
+ listProviders(): ProviderCatalogEntry[];
6
+ getProvider(provider: ProviderType): ProviderCatalogEntry;
7
+ listModels(provider: ProviderType): ModelCatalogEntry[];
8
+ getModel(provider: ProviderType, model: string): ModelCatalogEntry | undefined;
9
+ getDefaultModel(provider: ProviderType): string;
10
+ getRecommendedModel(provider: ProviderType): ModelCatalogEntry;
11
+ getCapability(provider: ProviderType, model?: string): ProviderRuntimeCapability;
12
+ createProvider(provider: ProviderType, config?: ProviderConfig): Promise<LLMProvider>;
13
+ probe(provider: ProviderType, model: string | undefined, checkAvailability?: () => Promise<boolean>): Promise<ProviderProbeResult>;
14
+ }
15
+ declare function createProviderRegistry(): ProviderRegistry;
16
+
17
+ /**
18
+ * Reusable runtime facade for wiring providers, tools, permissions, sessions,
19
+ * and observability. It does not own the CLI loop; CLI/headless are adapters on
20
+ * top of this boundary.
21
+ */
22
+ declare class AgentRuntime {
23
+ private readonly options;
24
+ readonly providerRegistry: ProviderRegistry;
25
+ readonly toolRegistry: ToolRegistry;
26
+ readonly sessionStore: unknown;
27
+ readonly runtimeSessionStore: RuntimeSessionStore;
28
+ readonly workflowEngine: WorkflowEngine;
29
+ readonly permissionPolicy: PermissionPolicy;
30
+ readonly eventLog: EventLog;
31
+ readonly turnRunner: RuntimeTurnRunner;
32
+ private providerType;
33
+ private model;
34
+ private provider?;
35
+ private readonly runtimeContext?;
36
+ private readonly runtimePolicy?;
37
+ constructor(options: AgentRuntimeOptions);
38
+ initialize(): Promise<void>;
39
+ getModel(): string;
40
+ updateProvider(providerType: ProviderType, model: string | undefined, provider: LLMProvider): void;
41
+ private publishToGlobalBridge;
42
+ snapshot(): AgentRuntimeSnapshot;
43
+ createSession(options?: RuntimeSessionCreateOptions): RuntimeSession;
44
+ getSession(sessionId: string): RuntimeSession | undefined;
45
+ listSessions(): RuntimeSession[];
46
+ runTurn(input: RuntimeTurnInput): Promise<RuntimeTurnResult>;
47
+ streamTurn(input: RuntimeTurnInput): AsyncIterable<RuntimeTurnStreamEvent>;
48
+ executeTool(input: RuntimeToolExecutionInput): Promise<RuntimeToolExecutionResult>;
49
+ assertToolAllowed(mode: RuntimeMode, toolName: string, input?: Record<string, unknown>): boolean;
50
+ }
51
+ declare function createAgentRuntime(options: AgentRuntimeOptions): Promise<AgentRuntime>;
52
+
53
+ export { AgentRuntime as A, ProviderRegistry as P, createProviderRegistry as a, createAgentRuntime as c };
@@ -1,5 +1,5 @@
1
- import { aU as ProviderType, P as ProviderConfig, L as LLMProvider, R as EventLog, ab as RuntimeTurnRunner, I as AgentRuntime, a3 as RuntimeSession, a9 as RuntimeTurnInput, aa as RuntimeTurnResult } from './agent-runtime-DJY9FzL_.js';
2
- import { T as ToolRegistry } from './registry-CEpl9Jq0.js';
1
+ import { b7 as ProviderType, P as ProviderConfig, L as LLMProvider, ap as ToolRegistry, T as EventLog, af as RuntimeTurnRunner, a5 as RuntimeRequestContext, a4 as RuntimePolicy, a6 as RuntimeSession, ad as RuntimeTurnInput, ae as RuntimeTurnResult } from './workflow-engine-DleSoUhy.js';
2
+ import { A as AgentRuntime } from './agent-runtime-Cd6pB640.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  type GuardrailSeverity = "info" | "warning" | "blocked";
@@ -78,6 +78,8 @@ interface AgentRuntimeFactoryOptions {
78
78
  toolRegistry?: ToolRegistry;
79
79
  eventLog?: EventLog;
80
80
  turnRunner?: RuntimeTurnRunner;
81
+ runtimeContext?: RuntimeRequestContext;
82
+ runtimePolicy?: RuntimePolicy;
81
83
  }
82
84
  interface AgentPreset<TConfig = unknown> {
83
85
  id: string;