@jini-ai/integrations 0.7.1 → 0.7.2

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,15 @@
1
+ /**
2
+ * Stable error codes returned by the Composio provider and service.
3
+ */
4
+ import type { JsonObject } from './catalog.js';
5
+ export type ConnectorServiceErrorCode = 'CONNECTOR_NOT_FOUND' | 'CONNECTOR_AUTH_CONFIG_REQUIRED' | 'CONNECTOR_NOT_CONNECTED' | 'CONNECTOR_DISABLED' | 'CONNECTOR_TOOL_NOT_FOUND' | 'CONNECTOR_SAFETY_DENIED' | 'CONNECTOR_INPUT_SCHEMA_MISMATCH' | 'CONNECTOR_RATE_LIMITED' | 'CONNECTOR_OUTPUT_TOO_LARGE' | 'CONNECTOR_EXECUTION_FAILED';
6
+ /**
7
+ * Typed boundary error with an HTTP-compatible status for future adapters.
8
+ */
9
+ export declare class ConnectorServiceError extends Error {
10
+ readonly code: ConnectorServiceErrorCode;
11
+ readonly status: number;
12
+ readonly details?: JsonObject | undefined;
13
+ constructor(code: ConnectorServiceErrorCode, message: string, status: number, details?: JsonObject | undefined, options?: ErrorOptions);
14
+ }
15
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Typed boundary error with an HTTP-compatible status for future adapters.
3
+ */
4
+ export class ConnectorServiceError extends Error {
5
+ code;
6
+ status;
7
+ details;
8
+ constructor(code, message, status, details, options) {
9
+ super(message, options);
10
+ this.code = code;
11
+ this.status = status;
12
+ this.details = details;
13
+ this.name = 'ConnectorServiceError';
14
+ }
15
+ }
16
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Serializes a synchronous read-modify-write operation across store instances
3
+ * and Node processes that share the same target path.
4
+ *
5
+ * Lock ownership is a unique token bound to the created inode. Contenders
6
+ * never evict a lock based on age, and cleanup unlinks only that same owner.
7
+ *
8
+ * @complexity Time: O(w), bounded by the contention timeout. Space: O(1).
9
+ * @overallScore 96/100 — synchronous polling is deliberate for synchronous
10
+ * file-store APIs; ownership and timeout behavior remain explicit and bounded.
11
+ */
12
+ export declare function withExclusiveFileLock<T>(filePath: string, operation: () => T): T;
13
+ //# sourceMappingURL=file-lock.d.ts.map
@@ -0,0 +1,92 @@
1
+ import crypto from 'node:crypto';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ const FILE_LOCK_WAIT_MS = 10;
5
+ const FILE_LOCK_TIMEOUT_MS = 2_000;
6
+ const lockWaitBuffer = new Int32Array(new SharedArrayBuffer(4));
7
+ /**
8
+ * Serializes a synchronous read-modify-write operation across store instances
9
+ * and Node processes that share the same target path.
10
+ *
11
+ * Lock ownership is a unique token bound to the created inode. Contenders
12
+ * never evict a lock based on age, and cleanup unlinks only that same owner.
13
+ *
14
+ * @complexity Time: O(w), bounded by the contention timeout. Space: O(1).
15
+ * @overallScore 96/100 — synchronous polling is deliberate for synchronous
16
+ * file-store APIs; ownership and timeout behavior remain explicit and bounded.
17
+ */
18
+ export function withExclusiveFileLock(filePath, operation) {
19
+ const lockPath = `${filePath}.lock`;
20
+ fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
21
+ const deadline = Date.now() + FILE_LOCK_TIMEOUT_MS;
22
+ const ownership = `${process.pid}:${crypto.randomUUID()}\n`;
23
+ let descriptor;
24
+ while (descriptor === undefined) {
25
+ try {
26
+ descriptor = fs.openSync(lockPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_RDWR, 0o600);
27
+ fs.writeFileSync(descriptor, ownership, 'utf8');
28
+ }
29
+ catch (error) {
30
+ if (!isErrno(error, 'EEXIST'))
31
+ throw error;
32
+ // Contentious locks are never evicted by age: an old mtime is not proof
33
+ // that the owning process or operation is dead. There is deliberately no
34
+ // `statSync` here — an earlier version stat'd the lock and discarded the
35
+ // result, left over from the age-based eviction this comment describes
36
+ // removing. That stat threw ENOENT out of this function whenever the
37
+ // owner released between the failed `openSync` and the stat, turning the
38
+ // NORMAL release race into a hard failure instead of the retry below.
39
+ if (Date.now() >= deadline) {
40
+ throw new Error(`Timed out waiting for exclusive access to ${path.basename(filePath)}.`);
41
+ }
42
+ Atomics.wait(lockWaitBuffer, 0, 0, FILE_LOCK_WAIT_MS);
43
+ }
44
+ }
45
+ try {
46
+ return operation();
47
+ }
48
+ finally {
49
+ try {
50
+ releaseOwnedLock(lockPath, descriptor, ownership);
51
+ }
52
+ finally {
53
+ fs.closeSync(descriptor);
54
+ }
55
+ }
56
+ }
57
+ function releaseOwnedLock(lockPath, descriptor, ownership) {
58
+ const ownerStat = fs.fstatSync(descriptor);
59
+ try {
60
+ const pathStat = fs.statSync(lockPath);
61
+ if (ownerStat.dev !== pathStat.dev || ownerStat.ino !== pathStat.ino)
62
+ return;
63
+ const buffer = Buffer.alloc(Buffer.byteLength(ownership, 'utf8'));
64
+ const bytesRead = fs.readSync(descriptor, buffer, 0, buffer.length, 0);
65
+ if (buffer.subarray(0, bytesRead).toString('utf8') !== ownership)
66
+ return;
67
+ fs.unlinkSync(lockPath);
68
+ removeOwnedLockLeftAfterSuccessfulUnlink(lockPath, ownerStat);
69
+ }
70
+ catch (error) {
71
+ if (!isErrno(error, 'ENOENT'))
72
+ throw error;
73
+ removeOwnedLockLeftAfterSuccessfulUnlink(lockPath, ownerStat);
74
+ }
75
+ }
76
+ function removeOwnedLockLeftAfterSuccessfulUnlink(lockPath, ownerStat) {
77
+ try {
78
+ const remainingStat = fs.statSync(lockPath);
79
+ if (remainingStat.dev === ownerStat.dev && remainingStat.ino === ownerStat.ino) {
80
+ fs.rmSync(lockPath);
81
+ }
82
+ }
83
+ catch (error) {
84
+ if (isErrno(error, 'ENOENT'))
85
+ return;
86
+ throw error;
87
+ }
88
+ }
89
+ function isErrno(error, code) {
90
+ return Boolean(error && typeof error === 'object' && 'code' in error && error.code === code);
91
+ }
92
+ //# sourceMappingURL=file-lock.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module @jini-ai/integrations/composio
3
+ *
4
+ * Public surface for the headless Composio integration package.
5
+ */
6
+ export type { ConnectorAuthDetail, ConnectorCatalogDefinition, ConnectorCatalogToolDefinition, ConnectorDetail, ConnectorStatus, ConnectorToolApproval, ConnectorToolCuration, ConnectorToolDetail, ConnectorToolSafety, ConnectorToolSafetyClassificationInput, ConnectorToolSideEffect, ConnectorToolUseCase, JsonObject, } from './catalog.js';
7
+ export { classifyConnectorToolSafety, connectorDefinitionToDetail, defineConnectorTool, isRefreshEligibleConnectorToolSafety, } from './catalog.js';
8
+ export type { ComposioConfig, ComposioConfigStore, FileComposioConfigStoreOptions, PublicComposioConfig, } from './composio-config.js';
9
+ export { createFileComposioConfigStore } from './composio-config.js';
10
+ export type { ComposioToolkitMetadata } from './composio-descriptions.js';
11
+ export { COMPOSIO_TOOLKIT_METADATA, getComposioToolkitMetadata, } from './composio-descriptions.js';
12
+ export type { ComposioAuthConfigPrepareResult, ComposioConnectionCompletion, ComposioConnectionStart, ComposioCredentialMaterial, ComposioConnectorProviderOptions, ComposioCurationOverlay, ComposioPendingConnection, ComposioProviderEvent, ComposioToolkitCatalogEntry, StaticComposioCatalogDefinitionsOptions, } from './composio.js';
13
+ export { ComposioConnectorProvider, DOCUMENTED_COMPOSIO_TOOLKITS, FEATURED_COMPOSIO_CATALOG, getStaticComposioCatalogDefinitions, isComposioCredentialMaterial, } from './composio.js';
14
+ export type { ComposioConnectorServiceOptions, ConnectorAuthConfigPrepareResponse, ConnectorConnectResult, ConnectorConnectionRecord, ConnectorConnectionStatus, ConnectorCredentialMaterial, ConnectorCredentialRecord, ConnectorCredentialStore, ConnectorDiscoveryResult, ConnectorExecuteRequest, ConnectorExecuteResponse, ConnectorExecutionContext, ConnectorOutputProtectionResult, ConnectorStatusServiceOptions, } from './service.js';
15
+ export { COMPOSIO_AUTH_CONFIG_PREPARE_LIMIT, ComposioConnectorService, CONNECTOR_MAX_OUTPUT_BYTES, CONNECTOR_RUN_LIMIT_TTL_MS, CONNECTOR_RUN_RATE_LIMIT_CALLS, CONNECTOR_RUN_RATE_LIMIT_WINDOW_MS, CONNECTOR_RUN_TOTAL_CALL_LIMIT, ConnectorStatusService, FileConnectorCredentialStore, InMemoryConnectorCredentialStore, protectConnectorOutput, } from './service.js';
16
+ export type { ConnectorServiceErrorCode } from './errors.js';
17
+ export { ConnectorServiceError } from './errors.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ export { classifyConnectorToolSafety, connectorDefinitionToDetail, defineConnectorTool, isRefreshEligibleConnectorToolSafety, } from './catalog.js';
2
+ export { createFileComposioConfigStore } from './composio-config.js';
3
+ export { COMPOSIO_TOOLKIT_METADATA, getComposioToolkitMetadata, } from './composio-descriptions.js';
4
+ export { ComposioConnectorProvider, DOCUMENTED_COMPOSIO_TOOLKITS, FEATURED_COMPOSIO_CATALOG, getStaticComposioCatalogDefinitions, isComposioCredentialMaterial, } from './composio.js';
5
+ export { COMPOSIO_AUTH_CONFIG_PREPARE_LIMIT, ComposioConnectorService, CONNECTOR_MAX_OUTPUT_BYTES, CONNECTOR_RUN_LIMIT_TTL_MS, CONNECTOR_RUN_RATE_LIMIT_CALLS, CONNECTOR_RUN_RATE_LIMIT_WINDOW_MS, CONNECTOR_RUN_TOTAL_CALL_LIMIT, ConnectorStatusService, FileConnectorCredentialStore, InMemoryConnectorCredentialStore, protectConnectorOutput, } from './service.js';
6
+ export { ConnectorServiceError } from './errors.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @module json-schema
3
+ *
4
+ * Fail-closed validation for the bounded JSON Schema subset accepted by the
5
+ * Composio execution boundary.
6
+ */
7
+ import type { JsonValue } from '@jini-ai/protocol';
8
+ export type ConnectorJsonSchema = {
9
+ [key: string]: JsonValue;
10
+ };
11
+ interface ValidationState {
12
+ nodes: number;
13
+ }
14
+ /** Element-wise deep equality for two same-length JSON arrays. */
15
+ export declare function arraysDeepEqual(left: JsonValue[], right: JsonValue[]): boolean;
16
+ /** Key-set and value-wise deep equality for two JSON objects (order-independent). */
17
+ export declare function objectsDeepEqual(left: ConnectorJsonSchema, right: ConnectorJsonSchema): boolean;
18
+ /** The `type` keyword's declared type(s), normalized to a list (empty when `type` is absent). Shared by structural validation and evaluation. */
19
+ export declare function declaredSchemaTypes(schema: ConnectorJsonSchema): string[];
20
+ /** True when the `type` keyword is absent, a string, or a non-empty array of strings. */
21
+ export declare function isSupportedTypeKeywordShape(type: JsonValue | undefined): boolean;
22
+ /** Rejects any schema keyword outside the bounded, supported subset. */
23
+ export declare function assertSupportedKeywords(schema: ConnectorJsonSchema, path: string): void;
24
+ /** Rejects an unsupported `type` keyword shape or a declared type outside `VALID_TYPES`. */
25
+ export declare function assertTypeKeywordSupported(schema: ConnectorJsonSchema, path: string): void;
26
+ /** Rejects a malformed `enum` keyword (must be a non-empty array when present). */
27
+ export declare function assertEnumShapeSupported(schema: ConnectorJsonSchema, path: string): void;
28
+ /** Rejects malformed numeric-range keywords (`minimum`/`maximum`/`exclusiveMinimum`/`exclusiveMaximum`/`multipleOf`). */
29
+ export declare function assertNumericConstraintsSupported(schema: ConnectorJsonSchema, path: string): void;
30
+ /** Rejects malformed size keywords (`min/maxLength`, `min/maxItems`, `min/maxProperties`) and a malformed `uniqueItems`. */
31
+ export declare function assertSizeConstraintsSupported(schema: ConnectorJsonSchema, path: string): void;
32
+ /** Rejects a malformed `required` keyword (must be an array of strings when present). */
33
+ export declare function assertRequiredShapeSupported(schema: ConnectorJsonSchema, path: string): void;
34
+ /** Rejects a malformed `properties` or `additionalProperties` keyword shape (recursion into their children happens separately). */
35
+ export declare function assertPropertiesShapeSupported(schema: ConnectorJsonSchema, path: string): void;
36
+ /** Rejects a malformed `allOf`/`anyOf`/`oneOf` branch list and recurses structural validation into each branch. */
37
+ export declare function assertCombinatorBranchesSupported(schema: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
38
+ /** Recurses structural validation into `not`, `items`, each declared `properties` child, and a schema-valued `additionalProperties`. */
39
+ export declare function recurseIntoRemainingChildSchemas(schema: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
40
+ /** Runs `value` against every branch of an `allOf`/`anyOf`/`oneOf` list, returning the match count and the last mismatch seen (for `allOf`'s error). */
41
+ export declare function countMatchingBranches(value: JsonValue, branches: JsonValue[], path: string, depth: number, state: ValidationState): {
42
+ matches: number;
43
+ lastError: unknown;
44
+ };
45
+ /** Enforces the combinator's match-count rule (`allOf`: all branches, `anyOf`: at least one, `oneOf`: exactly one) given a branch-match tally. */
46
+ export declare function assertBranchListSatisfied(keyword: 'allOf' | 'anyOf' | 'oneOf', matches: number, lastError: unknown, totalBranches: number, path: string): void;
47
+ /** Rejects a value whose type doesn't match the schema's declared `type` keyword. */
48
+ export declare function assertDeclaredTypeMatches(value: JsonValue, schema: ConnectorJsonSchema, path: string): void;
49
+ /** Rejects a value that fails the schema's `enum` or `const` keyword. */
50
+ export declare function assertEnumAndConstMatch(value: JsonValue, schema: ConnectorJsonSchema, path: string): void;
51
+ /** Rejects a value that satisfies the schema's `not` sub-schema (a mismatch there is what `not` requires). */
52
+ export declare function assertNotSchemaSatisfied(value: JsonValue, schema: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
53
+ /** Rejects a number outside `minimum`/`maximum`/`exclusiveMinimum`/`exclusiveMaximum`. */
54
+ export declare function assertNumberRangeConstraints(value: number, schema: ConnectorJsonSchema, path: string): void;
55
+ /** Rejects a number that isn't a multiple of the schema's `multipleOf`. */
56
+ export declare function assertNumberMultipleOfConstraint(value: number, schema: ConnectorJsonSchema, path: string): void;
57
+ /** Validates a number value against the schema's finiteness, range, and `multipleOf` keywords. */
58
+ export declare function validateNumberValue(value: number, schema: ConnectorJsonSchema, path: string): void;
59
+ /** Validates a string value's Unicode-codepoint length against `minLength`/`maxLength`. */
60
+ export declare function validateStringValue(value: string, schema: ConnectorJsonSchema, path: string): void;
61
+ /** Rejects an array whose length falls outside `minItems`/`maxItems`. */
62
+ export declare function assertArraySizeConstraints(value: JsonValue[], schema: ConnectorJsonSchema, path: string): void;
63
+ /** When `uniqueItems` is `true`, rejects an array containing two deep-equal elements. */
64
+ export declare function assertArrayItemsUnique(value: JsonValue[], schema: ConnectorJsonSchema, path: string): void;
65
+ /** Recurses evaluation into every array element against the schema's `items` sub-schema. */
66
+ export declare function recurseIntoArrayItems(value: JsonValue[], schema: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
67
+ /** Validates an array value's size, uniqueness, and (recursively) its items. */
68
+ export declare function validateArrayValue(value: JsonValue[], schema: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
69
+ /** Rejects an object whose property count falls outside `minProperties`/`maxProperties`. */
70
+ export declare function assertObjectSizeConstraints(value: ConnectorJsonSchema, schema: ConnectorJsonSchema, path: string): void;
71
+ /** Rejects an object missing any of the schema's `required` property names. */
72
+ export declare function assertRequiredPropertiesPresent(value: ConnectorJsonSchema, schema: ConnectorJsonSchema, path: string): void;
73
+ /** Recurses evaluation into every value present in `value` whose key is declared in `properties`. */
74
+ export declare function recurseIntoDeclaredProperties(value: ConnectorJsonSchema, propertySchemas: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
75
+ /** Rejects a disallowed extra property (`additionalProperties: false`) or recurses evaluation into a schema-valued `additionalProperties`. */
76
+ export declare function assertAdditionalPropertiesAllowed(value: ConnectorJsonSchema, schema: ConnectorJsonSchema, path: string, extraKeys: string[], depth: number, state: ValidationState): void;
77
+ /** Validates an object value's size, `required` properties, declared `properties`, and `additionalProperties`. */
78
+ export declare function validateObjectValue(value: ConnectorJsonSchema, schema: ConnectorJsonSchema, path: string, depth: number, state: ValidationState): void;
79
+ /**
80
+ * Validates input or throws before any provider effect can run.
81
+ *
82
+ * Structure and evaluation use independent shared node budgets. Exhaustion is
83
+ * an indeterminate hard denial and cannot be consumed as an ordinary
84
+ * combinator mismatch.
85
+ *
86
+ * @complexity Time: O(n). Space: O(d), for bounded schema/input traversal.
87
+ * @overallScore 100/100
88
+ */
89
+ export declare function assertConnectorInputMatchesSchema(value: JsonValue, schema: ConnectorJsonSchema | undefined, path?: string): void;
90
+ /** Returns the fail-closed reason used to keep unsupported live tools uncallable. */
91
+ export declare function getConnectorSchemaSupportError(schema: JsonValue): string | undefined;
92
+ export {};
93
+ //# sourceMappingURL=json-schema.d.ts.map