@agentick/connector 0.5.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/README.md +272 -0
- package/dist/connector-session.d.ts +56 -0
- package/dist/connector-session.d.ts.map +1 -0
- package/dist/connector-session.js +271 -0
- package/dist/connector-session.js.map +1 -0
- package/dist/content-pipeline.d.ts +23 -0
- package/dist/content-pipeline.d.ts.map +1 -0
- package/dist/content-pipeline.js +125 -0
- package/dist/content-pipeline.js.map +1 -0
- package/dist/create-connector.d.ts +16 -0
- package/dist/create-connector.d.ts.map +1 -0
- package/dist/create-connector.js +83 -0
- package/dist/create-connector.js.map +1 -0
- package/dist/delivery-buffer.d.ts +63 -0
- package/dist/delivery-buffer.d.ts.map +1 -0
- package/dist/delivery-buffer.js +138 -0
- package/dist/delivery-buffer.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/message-splitter.d.ts +16 -0
- package/dist/message-splitter.d.ts.map +1 -0
- package/dist/message-splitter.js +41 -0
- package/dist/message-splitter.js.map +1 -0
- package/dist/text-utils.d.ts +19 -0
- package/dist/text-utils.d.ts.map +1 -0
- package/dist/text-utils.js +41 -0
- package/dist/text-utils.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
- package/src/index.ts +34 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ChatMessage, RenderMode, ConfirmationPolicy } from "@agentick/client";
|
|
2
|
+
import type { SendInput, ToolConfirmationRequest, ToolConfirmationResponse } from "@agentick/shared";
|
|
3
|
+
import type { ToolSummarizer } from "./content-pipeline.js";
|
|
4
|
+
export type ConnectorStatus = "disconnected" | "connecting" | "connected" | "error";
|
|
5
|
+
export interface ConnectorStatusEvent {
|
|
6
|
+
status: ConnectorStatus;
|
|
7
|
+
/** Present when status is "error". */
|
|
8
|
+
error?: Error;
|
|
9
|
+
/** Human-readable detail. */
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Controls what content reaches the platform.
|
|
14
|
+
*
|
|
15
|
+
* - `"full"` — pass through unchanged
|
|
16
|
+
* - `"text-only"` — strip tool_use/tool_result blocks, keep text + images
|
|
17
|
+
* - `"summarized"` — collapse tool calls into brief summaries, keep text
|
|
18
|
+
* - Function — full control over filtering/transformation
|
|
19
|
+
*/
|
|
20
|
+
export type ContentPolicy = "full" | "text-only" | "summarized" | ContentPolicyFn;
|
|
21
|
+
export type ContentPolicyFn = (message: ChatMessage) => ChatMessage | null;
|
|
22
|
+
/**
|
|
23
|
+
* Controls when messages are delivered to the platform.
|
|
24
|
+
*
|
|
25
|
+
* - `"immediate"` — deliver on every state change
|
|
26
|
+
* - `"on-idle"` — deliver only when execution completes
|
|
27
|
+
* - `"debounced"` — deliver after N ms of no new content
|
|
28
|
+
*/
|
|
29
|
+
export type DeliveryStrategy = "immediate" | "on-idle" | "debounced";
|
|
30
|
+
export interface RateLimitConfig {
|
|
31
|
+
/** Maximum inbound messages per minute. */
|
|
32
|
+
maxPerMinute?: number;
|
|
33
|
+
/** Maximum inbound messages per day. */
|
|
34
|
+
maxPerDay?: number;
|
|
35
|
+
/** Called when a message is rate-limited. Return a string to reply, or void to silently drop. */
|
|
36
|
+
onLimited?: (info: {
|
|
37
|
+
remaining: number;
|
|
38
|
+
resetMs: number;
|
|
39
|
+
}) => string | void;
|
|
40
|
+
}
|
|
41
|
+
export interface RetryConfig {
|
|
42
|
+
/** Maximum delivery attempts before giving up. Default: 3. */
|
|
43
|
+
maxAttempts?: number;
|
|
44
|
+
/** Base delay in ms for exponential backoff. Default: 1000. */
|
|
45
|
+
baseDelay?: number;
|
|
46
|
+
/** Maximum delay in ms. Default: 30000. */
|
|
47
|
+
maxDelay?: number;
|
|
48
|
+
/** Called when all retries are exhausted. */
|
|
49
|
+
onExhausted?: (error: Error, output: ConnectorOutput) => void;
|
|
50
|
+
}
|
|
51
|
+
export interface ConnectorConfig {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
contentPolicy?: ContentPolicy;
|
|
54
|
+
deliveryStrategy?: DeliveryStrategy;
|
|
55
|
+
debounceMs?: number;
|
|
56
|
+
renderMode?: RenderMode;
|
|
57
|
+
confirmationPolicy?: ConfirmationPolicy;
|
|
58
|
+
autoSubscribe?: boolean;
|
|
59
|
+
rateLimit?: RateLimitConfig;
|
|
60
|
+
/** Custom tool summarizer for the "summarized" content policy. */
|
|
61
|
+
toolSummarizer?: ToolSummarizer;
|
|
62
|
+
/** Retry config for failed outbound deliveries. */
|
|
63
|
+
retry?: RetryConfig;
|
|
64
|
+
}
|
|
65
|
+
export interface ConnectorOutput {
|
|
66
|
+
messages: ChatMessage[];
|
|
67
|
+
isComplete: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Interface for external platform adapters (Telegram, iMessage, etc).
|
|
71
|
+
* Receives a bridge on start that it uses to send messages in and receive
|
|
72
|
+
* processed output.
|
|
73
|
+
*/
|
|
74
|
+
export interface ConnectorPlatform {
|
|
75
|
+
start(bridge: ConnectorBridge): void | Promise<void>;
|
|
76
|
+
stop(): void | Promise<void>;
|
|
77
|
+
/** Optional — platform reports its own health. */
|
|
78
|
+
readonly status?: ConnectorStatus;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Bridge provided by the framework to the platform adapter.
|
|
82
|
+
* The platform uses this to push inbound messages and receive
|
|
83
|
+
* delivery-ready output.
|
|
84
|
+
*/
|
|
85
|
+
export interface ConnectorBridge {
|
|
86
|
+
send(text: string): void;
|
|
87
|
+
sendInput(input: SendInput): void;
|
|
88
|
+
onDeliver(handler: (output: ConnectorOutput) => void | Promise<void>): () => void;
|
|
89
|
+
onConfirmation(handler: (request: ToolConfirmationRequest, respond: (r: ToolConfirmationResponse) => void) => void): () => void;
|
|
90
|
+
/** Platform reports status changes to the framework. */
|
|
91
|
+
reportStatus(status: ConnectorStatus, error?: Error): void;
|
|
92
|
+
/** Register a handler called when an execution starts. Returns unsubscribe. */
|
|
93
|
+
onExecutionStart(handler: () => void): () => void;
|
|
94
|
+
/** Register a handler called when an execution ends. Returns unsubscribe. */
|
|
95
|
+
onExecutionEnd(handler: () => void): () => void;
|
|
96
|
+
abort(reason?: string): void;
|
|
97
|
+
destroy(): void;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EACV,SAAS,EACT,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM5D,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAEpF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB,sCAAsC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,CAAC;AAClF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,WAAW,GAAG,IAAI,CAAC;AAM3E;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAMrE,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,Y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,CAAC,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC;IAClF,cAAc,CACZ,OAAO,EAAE,CACP,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,CAAC,CAAC,EAAE,wBAAwB,KAAK,IAAI,KAC3C,IAAI,GACR,MAAM,IAAI,CAAC;IACd,wDAAwD;IACxD,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3D,+EAA+E;IAC/E,gBAAgB,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAClD,6EAA6E;IAC7E,cAAc,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAChD,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentick/connector",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Bridge external platforms to Agentick sessions",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent",
|
|
7
|
+
"ai",
|
|
8
|
+
"bridge",
|
|
9
|
+
"connector",
|
|
10
|
+
"platform"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Ryan Lindgren",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/agenticklabs/agentick.git",
|
|
17
|
+
"directory": "packages/connector"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "src/index.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./src/index.ts"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"test": "echo \"Tests run from workspace root\"",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
42
|
+
"lint": "oxlint src/",
|
|
43
|
+
"format:check": "oxfmt --check src/",
|
|
44
|
+
"clean": "rm -rf dist tsconfig.build.tsbuildinfo",
|
|
45
|
+
"prepublishOnly": "pnpm build",
|
|
46
|
+
"dev": "tsc --watch"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@agentick/client": "workspace:*",
|
|
50
|
+
"@agentick/shared": "workspace:*"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"typescript": "^5.8.3"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { ConnectorSession } from "./connector-session.js";
|
|
2
|
+
export { createConnector } from "./create-connector.js";
|
|
3
|
+
export type { ConnectorHandle } from "./create-connector.js";
|
|
4
|
+
export {
|
|
5
|
+
buildContentFilter,
|
|
6
|
+
applyContentPolicy,
|
|
7
|
+
createToolSummarizer,
|
|
8
|
+
} from "./content-pipeline.js";
|
|
9
|
+
export type { ToolSummarizer } from "./content-pipeline.js";
|
|
10
|
+
export { DeliveryBuffer, RateLimiter } from "./delivery-buffer.js";
|
|
11
|
+
export { splitMessage } from "./message-splitter.js";
|
|
12
|
+
|
|
13
|
+
export type {
|
|
14
|
+
ContentPolicy,
|
|
15
|
+
ContentPolicyFn,
|
|
16
|
+
DeliveryStrategy,
|
|
17
|
+
RateLimitConfig,
|
|
18
|
+
RetryConfig,
|
|
19
|
+
ConnectorConfig,
|
|
20
|
+
ConnectorOutput,
|
|
21
|
+
ConnectorPlatform,
|
|
22
|
+
ConnectorBridge,
|
|
23
|
+
ConnectorStatus,
|
|
24
|
+
ConnectorStatusEvent,
|
|
25
|
+
} from "./types.js";
|
|
26
|
+
|
|
27
|
+
export type { DeliveryBufferOptions } from "./delivery-buffer.js";
|
|
28
|
+
export type { SplitOptions } from "./message-splitter.js";
|
|
29
|
+
|
|
30
|
+
// Re-export extractText from shared — the canonical implementation lives there.
|
|
31
|
+
// Connector-specific text utilities (confirmation parsing/formatting) live here.
|
|
32
|
+
export { extractText } from "@agentick/shared";
|
|
33
|
+
|
|
34
|
+
export { parseTextConfirmation, formatConfirmationMessage } from "./text-utils.js";
|