@zihin/piece-zihin 0.1.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 ADDED
@@ -0,0 +1,40 @@
1
+ # @zihin/piece-zihin
2
+
3
+ Piece do **Activepieces** para invocar agentes **Zihin** — sobre o núcleo
4
+ [`@zihin/agent-client`](../agent-client). Terceiro shell do padrão (ao lado de n8n e Paperclip).
5
+
6
+ ## O que faz
7
+
8
+ - **Auth (Zihin):** API Key (`zhn_live_*`, tenant embutido) + Base URL opcional + **Allow custom base URL**
9
+ (opt-in explícito p/ domínio fora da whitelist) + Allow HTTP (dev). Strings de UI em **inglês**.
10
+ - **Action `Invoke Agent`:** dropdown de agentes (via `listAgents()`), `Message`, `Session ID`
11
+ (continuidade), e Options (temperature / max tokens / timeout / include raw). Roda
12
+ `invokeAgent` e devolve `{ content, sessionId, model, usage, sources }`.
13
+
14
+ ```ts
15
+ // pseudo: a action chama
16
+ const r = await createClient({ apiKey, baseUrl, allowHttp }).invokeAgent({ agentId, message, sessionId });
17
+ ```
18
+
19
+ ## Por que depende do núcleo (e não bundla)
20
+
21
+ Ao contrário do nó verificado do n8n (que **não** pode ter dependência de runtime → bundla o núcleo),
22
+ pieces do Activepieces **são pacotes npm que podem declarar dependências**. Então esta piece depende de
23
+ `@zihin/agent-client` normalmente. Quando o núcleo for publicado, fixe `^0.1.0` no lugar do `*`.
24
+
25
+ ## Notas de integração
26
+
27
+ - Compila para **CJS** (tsc). Por isso usa **named import** do núcleo (`import { createClient }`) — o
28
+ default import não resolve o núcleo CJS (`__esModule` sem `default`).
29
+ - `logoUrl` é um placeholder (`https://www.zihin.ai/favicon.svg`) — apontar para um logo hospedado.
30
+ - Para publicar/usar no Activepieces: alinhar `@activepieces/pieces-framework` à versão do alvo e
31
+ empacotar conforme o fluxo deles (nx/`pieces`), ou instalar como community piece.
32
+
33
+ ## Dev
34
+
35
+ ```bash
36
+ npm run build && npm test # smoke test offline (mocka fetch) — 11/11 (inclui gate de whitelist)
37
+ ```
38
+
39
+ Validado também headless contra o BE real: dropdown + caminho de erro (ECONNREFUSED → erro limpo com
40
+ endpoint). Happy path: mesmo caminho `/stream` já provado no n8n e no Paperclip.
@@ -0,0 +1,8 @@
1
+ import { zihinAuth } from './lib/auth';
2
+ export { zihinAuth };
3
+ export declare const zihin: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
4
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ allowCustomBaseUrl: import("@activepieces/pieces-framework").CheckboxProperty<false>;
7
+ allowHttp: import("@activepieces/pieces-framework").CheckboxProperty<false>;
8
+ }>>;
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zihin = exports.zihinAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const shared_1 = require("@activepieces/shared");
6
+ const auth_1 = require("./lib/auth");
7
+ Object.defineProperty(exports, "zihinAuth", { enumerable: true, get: function () { return auth_1.zihinAuth; } });
8
+ const invoke_agent_1 = require("./lib/actions/invoke-agent");
9
+ exports.zihin = (0, pieces_framework_1.createPiece)({
10
+ displayName: 'Zihin',
11
+ description: 'Invoke hosted Zihin agents — full agent loop (tools, MCP, memory, HITL) under your tenant RBAC, quota and audit.',
12
+ auth: auth_1.zihinAuth,
13
+ // Validated against @activepieces/pieces-framework 0.32.x; keep a conservative floor and
14
+ // confirm against the target Activepieces release at publish time.
15
+ minimumSupportedRelease: '0.30.0',
16
+ // TODO: host the logo and point logoUrl at a public, stable URL (Activepieces requires it).
17
+ logoUrl: 'https://www.zihin.ai/favicon.svg',
18
+ categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
19
+ authors: ['Zihin AI'],
20
+ actions: [invoke_agent_1.invokeAgent],
21
+ triggers: [],
22
+ });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,iDAAqD;AACrD,qCAAuC;AAG9B,0FAHA,gBAAS,OAGA;AAFlB,6DAAyD;AAI5C,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,OAAO;IACpB,WAAW,EACV,kHAAkH;IACnH,IAAI,EAAE,gBAAS;IACf,yFAAyF;IACzF,mEAAmE;IACnE,uBAAuB,EAAE,QAAQ;IACjC,4FAA4F;IAC5F,OAAO,EAAE,kCAAkC;IAC3C,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE,CAAC,0BAAW,CAAC;IACtB,QAAQ,EAAE,EAAE;CACZ,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare const invokeAgent: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ allowCustomBaseUrl: import("@activepieces/pieces-framework").CheckboxProperty<false>;
5
+ allowHttp: import("@activepieces/pieces-framework").CheckboxProperty<false>;
6
+ }>, {
7
+ agentId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
8
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
9
+ baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
+ allowCustomBaseUrl: import("@activepieces/pieces-framework").CheckboxProperty<false>;
11
+ allowHttp: import("@activepieces/pieces-framework").CheckboxProperty<false>;
12
+ }>>;
13
+ message: import("@activepieces/pieces-framework").LongTextProperty<true>;
14
+ sessionId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
15
+ temperature: import("@activepieces/pieces-framework").NumberProperty<false>;
16
+ maxTokens: import("@activepieces/pieces-framework").NumberProperty<false>;
17
+ timeoutMs: import("@activepieces/pieces-framework").NumberProperty<false>;
18
+ includeRaw: import("@activepieces/pieces-framework").CheckboxProperty<false>;
19
+ }>;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invokeAgent = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const agent_client_1 = require("@zihin/agent-client");
6
+ const auth_1 = require("../auth");
7
+ const common_1 = require("../common");
8
+ exports.invokeAgent = (0, pieces_framework_1.createAction)({
9
+ name: 'invoke_agent',
10
+ auth: auth_1.zihinAuth,
11
+ displayName: 'Invoke Agent',
12
+ description: 'Send a message to a hosted Zihin agent and return its result.',
13
+ props: {
14
+ agentId: pieces_framework_1.Property.Dropdown({
15
+ displayName: 'Agent',
16
+ description: 'The agent to invoke (loaded from your tenant).',
17
+ required: true,
18
+ refreshers: [],
19
+ auth: auth_1.zihinAuth,
20
+ options: async ({ auth }) => {
21
+ if (!auth) {
22
+ return { disabled: true, options: [], placeholder: 'Connect your Zihin account first' };
23
+ }
24
+ try {
25
+ const client = (0, common_1.buildClient)(auth);
26
+ const agents = await client.listAgents();
27
+ return {
28
+ disabled: false,
29
+ options: agents
30
+ .filter((a) => a.id)
31
+ .map((a) => ({ label: a.commercialName || a.name || a.id, value: a.id })),
32
+ };
33
+ }
34
+ catch (e) {
35
+ const msg = e instanceof agent_client_1.ZihinAgentError ? e.message : 'Could not load agents';
36
+ return { disabled: true, options: [], placeholder: msg };
37
+ }
38
+ },
39
+ }),
40
+ message: pieces_framework_1.Property.LongText({
41
+ displayName: 'Message',
42
+ description: 'The message to send to the agent.',
43
+ required: true,
44
+ }),
45
+ sessionId: pieces_framework_1.Property.ShortText({
46
+ displayName: 'Session ID',
47
+ description: 'Reuse to continue a conversation. The output returns the session ID to reuse.',
48
+ required: false,
49
+ }),
50
+ temperature: pieces_framework_1.Property.Number({ displayName: 'Temperature', required: false }),
51
+ maxTokens: pieces_framework_1.Property.Number({ displayName: 'Max Tokens', required: false }),
52
+ timeoutMs: pieces_framework_1.Property.Number({ displayName: 'Timeout (ms)', required: false }),
53
+ includeRaw: pieces_framework_1.Property.Checkbox({
54
+ displayName: 'Include Raw Events',
55
+ description: 'Include the raw SSE events in the output (debugging).',
56
+ required: false,
57
+ defaultValue: false,
58
+ }),
59
+ },
60
+ async run(context) {
61
+ const { agentId, message, sessionId, temperature, maxTokens, timeoutMs, includeRaw } = context.propsValue;
62
+ const client = (0, common_1.buildClient)(context.auth, {
63
+ timeoutMs: timeoutMs ?? undefined,
64
+ });
65
+ try {
66
+ const result = await client.invokeAgent({
67
+ agentId: String(agentId),
68
+ message: String(message),
69
+ sessionId: sessionId || undefined,
70
+ includeRaw: includeRaw === true,
71
+ options: {
72
+ temperature: temperature ?? undefined,
73
+ maxTokens: maxTokens ?? undefined,
74
+ },
75
+ });
76
+ return {
77
+ content: result.content,
78
+ sessionId: result.sessionId,
79
+ model: result.model,
80
+ usage: result.usage,
81
+ sources: result.sources,
82
+ ...(includeRaw ? { raw: result.raw } : {}),
83
+ };
84
+ }
85
+ catch (e) {
86
+ // ZihinAgentError already carries a sanitized message; sanitize anything else
87
+ // so we never surface a raw key / request-id / stack to the workflow.
88
+ const errMessage = e instanceof agent_client_1.ZihinAgentError ? e.message : (0, agent_client_1.sanitizeApiError)(e).message;
89
+ throw new Error(errMessage);
90
+ }
91
+ },
92
+ });
93
+ //# sourceMappingURL=invoke-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke-agent.js","sourceRoot":"","sources":["../../../src/lib/actions/invoke-agent.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,sDAAwE;AACxE,kCAAoC;AACpC,sCAAwD;AAE3C,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,cAAc;IACpB,I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,SAAS,IAAI,SAAS;gBACjC,UAAU,EAAE,UAAU,KAAK,IAAI;gBAC/B,OAAO,EAAE;oBACR,WAAW,EAAE,WAAW,IAAI,SAAS;oBACrC,SAAS,EAAE,SAAS,IAAI,SAAS;iBACjC;aACD,CAAC,CAAC;YAEH,OAAO;gBACN,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,8EAA8E;YAC9E,sEAAsE;YACtE,MAAM,UAAU,GAAG,CAAC,YAAY,8BAAe,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,+BAAgB,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC1F,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const zihinAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ allowCustomBaseUrl: import("@activepieces/pieces-framework").CheckboxProperty<false>;
5
+ allowHttp: import("@activepieces/pieces-framework").CheckboxProperty<false>;
6
+ }>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zihinAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const common_1 = require("./common");
6
+ // Defined here (not in index) to break the import cycle: actions import `zihinAuth` to pass
7
+ // it to Property.Dropdown (which uses `auth` to type its options).
8
+ exports.zihinAuth = pieces_framework_1.PieceAuth.CustomAuth({
9
+ description: 'Connect your Zihin account. The API key embeds the tenant — use an admin/editor key for full access.',
10
+ required: true,
11
+ props: {
12
+ apiKey: pieces_framework_1.PieceAuth.SecretText({
13
+ displayName: 'API Key',
14
+ description: 'zhn_live_* / zhn_test_* (the tenant is embedded in the key).',
15
+ required: true,
16
+ }),
17
+ baseUrl: pieces_framework_1.Property.ShortText({
18
+ displayName: 'Base URL',
19
+ description: 'Defaults to https://llm.zihin.ai. For a private deployment outside the Zihin domain, also enable "Allow custom base URL".',
20
+ required: false,
21
+ defaultValue: 'https://llm.zihin.ai',
22
+ }),
23
+ allowCustomBaseUrl: pieces_framework_1.Property.Checkbox({
24
+ displayName: 'Allow custom base URL',
25
+ description: 'Allow a base URL outside the Zihin domain whitelist. Your API key is sent to that host — only enable for a trusted private deployment.',
26
+ required: false,
27
+ defaultValue: false,
28
+ }),
29
+ allowHttp: pieces_framework_1.Property.Checkbox({
30
+ displayName: 'Allow HTTP / localhost (dev only)',
31
+ description: 'Allow http/localhost — development only (the API key travels in plaintext).',
32
+ required: false,
33
+ defaultValue: false,
34
+ }),
35
+ },
36
+ validate: async ({ auth }) => {
37
+ try {
38
+ await (0, common_1.buildClient)(auth).listAgents();
39
+ return { valid: true };
40
+ }
41
+ catch (e) {
42
+ return { valid: false, error: e?.message || 'Failed to validate the credentials.' };
43
+ }
44
+ },
45
+ });
46
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,qCAAuD;AAEvD,4FAA4F;AAC5F,mEAAmE;AACtD,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EACV,sGAAsG;IACvG,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACN,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC5B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,8DAA8D;YAC3E,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EACV,2HAA2H;YAC5H,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,sBAAsB;SACpC,CAAC;QACF,kBAAkB,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACrC,WAAW,EAAE,uBAAuB;YACpC,WAAW,EACV,wIAAwI;YACzI,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACnB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC5B,WAAW,EAAE,mCAAmC;YAChD,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACnB,CAAC;KACF;IACD,QAAQ,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,IAAI,CAAC;YACJ,MAAM,IAAA,oBAAW,EAAC,IAAiC,CAAC,CAAC,UAAU,EAAE,CAAC;YAClE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAG,CAAW,EAAE,OAAO,IAAI,qCAAqC,EAAE,CAAC;QAChG,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface ZihinAuthValue {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ allowCustomBaseUrl?: boolean;
5
+ allowHttp?: boolean;
6
+ }
7
+ export declare function buildClient(auth: ZihinAuthValue, extra?: {
8
+ timeoutMs?: number;
9
+ }): import("@zihin/agent-client").ZihinAgentClient;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildClient = buildClient;
4
+ // Shared helper: build the core client from the piece auth value.
5
+ // Named import — this piece compiles to CJS (tsc), where the named import resolves the
6
+ // core's exports (CJS with __esModule, no default). Works in ESM too.
7
+ const agent_client_1 = require("@zihin/agent-client");
8
+ function buildClient(auth, extra = {}) {
9
+ return (0, agent_client_1.createClient)({
10
+ apiKey: String(auth.apiKey || ''),
11
+ baseUrl: auth.baseUrl || undefined,
12
+ // Explicit opt-in (mirrors the n8n node and the Paperclip adapter). Never derive
13
+ // this from the presence of a base URL: the default base URL is always set, which
14
+ // would permanently disable the core's SSRF/domain whitelist.
15
+ allowCustomBaseUrl: auth.allowCustomBaseUrl === true,
16
+ allowHttp: auth.allowHttp === true,
17
+ timeoutMs: extra.timeoutMs,
18
+ });
19
+ }
20
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/lib/common.ts"],"names":[],"mappings":";;AAYA,kCAWC;AAvBD,kEAAkE;AAClE,uFAAuF;AACvF,sEAAsE;AACtE,sDAAmD;AASnD,SAAgB,WAAW,CAAC,IAAoB,EAAE,QAAgC,EAAE;IACnF,OAAO,IAAA,2BAAY,EAAC;QACnB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,iFAAiF;QACjF,kFAAkF;QAClF,8DAA8D;QAC9D,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,KAAK,IAAI;QACpD,SAAS,EAAE,IAAI,CAAC,SAAS,KAAK,IAAI;QAClC,SAAS,EAAE,KAAK,CAAC,SAAS;KAC1B,CAAC,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@zihin/piece-zihin",
3
+ "version": "0.1.0",
4
+ "description": "Activepieces piece for Zihin — invoke hosted agents over @zihin/agent-client.",
5
+ "keywords": [
6
+ "activepieces",
7
+ "piece",
8
+ "zihin",
9
+ "agent",
10
+ "ai"
11
+ ],
12
+ "license": "MIT",
13
+ "homepage": "https://zihin.ai",
14
+ "author": {
15
+ "name": "Zihin AI Inc.",
16
+ "email": "support@zihin.ai"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/zihin-ai/zihin-integrations.git",
21
+ "directory": "packages/activepieces-piece-zihin"
22
+ },
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json",
36
+ "dev": "tsc -p tsconfig.json --watch",
37
+ "test": "node test/smoke.js",
38
+ "prepublishOnly": "npm run build && npm test"
39
+ },
40
+ "dependencies": {
41
+ "@zihin/agent-client": "^0.1.0"
42
+ },
43
+ "devDependencies": {
44
+ "@activepieces/pieces-framework": "~0.32.0",
45
+ "@activepieces/shared": "~0.95.1",
46
+ "@types/node": ">=18",
47
+ "typescript": "^5.4.0"
48
+ }
49
+ }