@hasna/connectors 1.1.17 → 1.2.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.
@@ -0,0 +1,53 @@
1
+ import type { Database } from "bun:sqlite";
2
+ export interface ConnectorJob {
3
+ id: string;
4
+ name: string;
5
+ connector: string;
6
+ command: string;
7
+ args: string[];
8
+ cron: string;
9
+ enabled: boolean;
10
+ strip: boolean;
11
+ created_at: string;
12
+ last_run_at: string | null;
13
+ }
14
+ export interface ConnectorJobRun {
15
+ id: string;
16
+ job_id: string;
17
+ started_at: string;
18
+ finished_at: string | null;
19
+ exit_code: number | null;
20
+ raw_output: string | null;
21
+ stripped_output: string | null;
22
+ }
23
+ export declare function createJob(input: {
24
+ name: string;
25
+ connector: string;
26
+ command: string;
27
+ args?: string[];
28
+ cron: string;
29
+ strip?: boolean;
30
+ }, db?: Database): ConnectorJob;
31
+ export declare function getJob(id: string, db?: Database): ConnectorJob | null;
32
+ export declare function getJobByName(name: string, db?: Database): ConnectorJob | null;
33
+ export declare function listJobs(db?: Database): ConnectorJob[];
34
+ export declare function listEnabledJobs(db?: Database): ConnectorJob[];
35
+ export declare function updateJob(id: string, input: Partial<{
36
+ name: string;
37
+ connector: string;
38
+ command: string;
39
+ args: string[];
40
+ cron: string;
41
+ enabled: boolean;
42
+ strip: boolean;
43
+ }>, db?: Database): ConnectorJob;
44
+ export declare function deleteJob(id: string, db?: Database): boolean;
45
+ export declare function touchJobLastRun(id: string, db?: Database): void;
46
+ export declare function createJobRun(jobId: string, db?: Database): ConnectorJobRun;
47
+ export declare function finishJobRun(id: string, result: {
48
+ exit_code: number;
49
+ raw_output: string;
50
+ stripped_output?: string;
51
+ }, db?: Database): void;
52
+ export declare function getLatestRun(jobId: string, db?: Database): ConnectorJobRun | null;
53
+ export declare function listJobRuns(jobId: string, limit?: number, db?: Database): ConnectorJobRun[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { Database } from "bun:sqlite";
2
+ export interface WorkflowStep {
3
+ connector: string;
4
+ command: string;
5
+ args?: string[];
6
+ }
7
+ export interface ConnectorWorkflow {
8
+ id: string;
9
+ name: string;
10
+ steps: WorkflowStep[];
11
+ enabled: boolean;
12
+ created_at: string;
13
+ }
14
+ export declare function createWorkflow(input: {
15
+ name: string;
16
+ steps: WorkflowStep[];
17
+ }, db?: Database): ConnectorWorkflow;
18
+ export declare function getWorkflow(id: string, db?: Database): ConnectorWorkflow | null;
19
+ export declare function getWorkflowByName(name: string, db?: Database): ConnectorWorkflow | null;
20
+ export declare function listWorkflows(db?: Database): ConnectorWorkflow[];
21
+ export declare function updateWorkflow(id: string, input: Partial<{
22
+ name: string;
23
+ steps: WorkflowStep[];
24
+ enabled: boolean;
25
+ }>, db?: Database): ConnectorWorkflow;
26
+ export declare function deleteWorkflow(id: string, db?: Database): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Provider-agnostic LLM client for open-connectors.
3
+ *
4
+ * Supports: cerebras, groq, openai, anthropic
5
+ * Config stored at: ~/.connectors/llm.json
6
+ *
7
+ * Cerebras and Groq are OpenAI-compatible (same SDK, different base URLs).
8
+ * Anthropic has its own API format.
9
+ */
10
+ export type LLMProvider = "cerebras" | "groq" | "openai" | "anthropic";
11
+ export interface LLMConfig {
12
+ provider: LLMProvider;
13
+ model: string;
14
+ api_key: string;
15
+ strip: boolean;
16
+ }
17
+ export interface LLMResponse {
18
+ content: string;
19
+ provider: LLMProvider;
20
+ model: string;
21
+ latency_ms: number;
22
+ }
23
+ export declare const PROVIDER_DEFAULTS: Record<LLMProvider, {
24
+ model: string;
25
+ }>;
26
+ export declare function getLlmConfig(): LLMConfig | null;
27
+ export declare function saveLlmConfig(config: LLMConfig): void;
28
+ export declare function setLlmStrip(enabled: boolean): void;
29
+ export declare function isStripEnabled(): boolean;
30
+ /** Mask API key for display: show first 8 chars + *** */
31
+ export declare function maskKey(key: string): string;
32
+ export declare class LLMClient {
33
+ private config;
34
+ constructor(config: LLMConfig);
35
+ static fromConfig(): LLMClient | null;
36
+ complete(prompt: string, content: string): Promise<LLMResponse>;
37
+ private _anthropicComplete;
38
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Connector job scheduler.
3
+ *
4
+ * Checks enabled jobs against their cron expressions and runs them
5
+ * when due. Runs in-process as part of `connectors serve`.
6
+ *
7
+ * Cron format: minute hour day month weekday (5-field standard)
8
+ * Uses a lightweight cron matcher — no external dep needed.
9
+ */
10
+ import type { Database } from "bun:sqlite";
11
+ import { type ConnectorJob } from "../db/jobs.js";
12
+ /** Start the scheduler. Checks every 30s, fires jobs when cron matches. */
13
+ export declare function startScheduler(db: Database): void;
14
+ export declare function stopScheduler(): void;
15
+ /** Manually trigger a job by ID (for CLI 'connectors jobs run') */
16
+ export declare function triggerJob(job: ConnectorJob, db: Database): Promise<{
17
+ run_id: string;
18
+ exit_code: number;
19
+ output: string;
20
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Global output stripping middleware.
3
+ *
4
+ * When strip is enabled in ~/.connectors/llm.json, every output surface
5
+ * (MCP, REST, CLI) passes through maybeStrip() before returning to the caller.
6
+ * This reduces token consumption for AI agents consuming connector output.
7
+ *
8
+ * If strip is disabled or no LLM config exists, output is returned as-is.
9
+ */
10
+ export type StripType = "json" | "text";
11
+ /**
12
+ * Conditionally strip output through LLM if strip is enabled.
13
+ * Returns output unchanged if strip is disabled or LLM not configured.
14
+ */
15
+ export declare function maybeStrip(output: string, _type?: StripType): Promise<string>;
16
+ /**
17
+ * Synchronous passthrough check — returns true if stripping is active.
18
+ * Use this to decide whether to await maybeStrip or skip it.
19
+ */
20
+ export declare function isStrippingActive(): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Workflow runner — executes sequential connector pipelines.
3
+ *
4
+ * Each step receives the previous step's output as additional context
5
+ * injected into its args as --input <previous_output>.
6
+ */
7
+ import type { ConnectorWorkflow } from "../db/workflows.js";
8
+ export interface WorkflowStepResult {
9
+ step: number;
10
+ connector: string;
11
+ command: string;
12
+ exit_code: number;
13
+ output: string;
14
+ }
15
+ export interface WorkflowResult {
16
+ workflow_id: string;
17
+ workflow_name: string;
18
+ steps: WorkflowStepResult[];
19
+ success: boolean;
20
+ final_output: string;
21
+ }
22
+ export declare function runWorkflow(workflow: ConnectorWorkflow): Promise<WorkflowResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/connectors",
3
- "version": "1.1.17",
3
+ "version": "1.2.0",
4
4
  "description": "Open source connector library - Install API connectors with a single command",
5
5
  "type": "module",
6
6
  "bin": {