@juspay/neurolink 9.63.1 → 9.64.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/CHANGELOG.md +6 -0
- package/dist/adapters/video/vertexVideoHandler.js +9 -2
- package/dist/browser/neurolink.min.js +1014 -1018
- package/dist/cli/factories/commandFactory.d.ts +14 -0
- package/dist/cli/factories/commandFactory.js +50 -25
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/loop/optionsSchema.js +12 -0
- package/dist/core/baseProvider.d.ts +1 -1
- package/dist/core/modules/MessageBuilder.js +20 -0
- package/dist/factories/providerRegistry.js +5 -1
- package/dist/lib/adapters/video/vertexVideoHandler.js +9 -2
- package/dist/lib/core/baseProvider.d.ts +1 -1
- package/dist/lib/core/modules/MessageBuilder.js +20 -0
- package/dist/lib/factories/providerRegistry.js +5 -1
- package/dist/lib/memory/hippocampusInitializer.d.ts +2 -2
- package/dist/lib/memory/hippocampusInitializer.js +32 -2
- package/dist/lib/middleware/builtin/lifecycle.js +19 -48
- package/dist/lib/neurolink.js +49 -2
- package/dist/lib/providers/googleAiStudio.d.ts +11 -3
- package/dist/lib/providers/googleAiStudio.js +292 -339
- package/dist/lib/providers/googleNativeGemini3.d.ts +83 -1
- package/dist/lib/providers/googleNativeGemini3.js +208 -4
- package/dist/lib/providers/googleVertex.d.ts +116 -129
- package/dist/lib/providers/googleVertex.js +2826 -1968
- package/dist/lib/providers/openRouter.js +7 -3
- package/dist/lib/types/aliases.d.ts +14 -0
- package/dist/lib/types/common.d.ts +0 -3
- package/dist/lib/types/conversation.d.ts +10 -3
- package/dist/lib/types/generate.d.ts +14 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/memory.d.ts +96 -0
- package/dist/lib/types/memory.js +23 -0
- package/dist/lib/types/providers.d.ts +140 -2
- package/dist/lib/types/stream.d.ts +6 -0
- package/dist/lib/utils/lifecycleCallbacks.d.ts +13 -0
- package/dist/lib/utils/lifecycleCallbacks.js +44 -0
- package/dist/lib/utils/messageBuilder.d.ts +10 -0
- package/dist/lib/utils/messageBuilder.js +40 -5
- package/dist/lib/utils/modelDetection.d.ts +11 -0
- package/dist/lib/utils/modelDetection.js +27 -0
- package/dist/lib/utils/providerHealth.js +7 -7
- package/dist/lib/utils/schemaConversion.d.ts +1 -1
- package/dist/lib/utils/schemaConversion.js +59 -4
- package/dist/lib/utils/tokenLimits.js +23 -32
- package/dist/memory/hippocampusInitializer.d.ts +2 -2
- package/dist/memory/hippocampusInitializer.js +32 -2
- package/dist/middleware/builtin/lifecycle.js +19 -48
- package/dist/neurolink.js +49 -2
- package/dist/providers/googleAiStudio.d.ts +11 -3
- package/dist/providers/googleAiStudio.js +291 -339
- package/dist/providers/googleNativeGemini3.d.ts +83 -1
- package/dist/providers/googleNativeGemini3.js +208 -4
- package/dist/providers/googleVertex.d.ts +116 -129
- package/dist/providers/googleVertex.js +2824 -1967
- package/dist/providers/openRouter.js +7 -3
- package/dist/types/aliases.d.ts +14 -0
- package/dist/types/common.d.ts +0 -3
- package/dist/types/conversation.d.ts +10 -3
- package/dist/types/generate.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/memory.d.ts +96 -0
- package/dist/types/memory.js +22 -0
- package/dist/types/providers.d.ts +140 -2
- package/dist/types/stream.d.ts +6 -0
- package/dist/utils/lifecycleCallbacks.d.ts +13 -0
- package/dist/utils/lifecycleCallbacks.js +43 -0
- package/dist/utils/messageBuilder.d.ts +10 -0
- package/dist/utils/messageBuilder.js +40 -5
- package/dist/utils/modelDetection.d.ts +11 -0
- package/dist/utils/modelDetection.js +27 -0
- package/dist/utils/providerHealth.js +7 -7
- package/dist/utils/schemaConversion.d.ts +1 -1
- package/dist/utils/schemaConversion.js +59 -4
- package/dist/utils/tokenLimits.js +23 -32
- package/package.json +11 -4
|
@@ -32,15 +32,19 @@ const getOpenRouterConfig = () => {
|
|
|
32
32
|
*
|
|
33
33
|
* OpenRouter uses a 'provider/model' format for model names.
|
|
34
34
|
* For example:
|
|
35
|
-
* - 'anthropic/claude-
|
|
35
|
+
* - 'anthropic/claude-sonnet-4.5'
|
|
36
36
|
* - 'openai/gpt-4o'
|
|
37
|
-
* - 'google/gemini-2.
|
|
37
|
+
* - 'google/gemini-2.5-flash'
|
|
38
38
|
* - 'meta-llama/llama-3-70b-instruct'
|
|
39
39
|
*
|
|
40
40
|
* You can override the default by setting the OPENROUTER_MODEL environment variable.
|
|
41
|
+
*
|
|
42
|
+
* Default updated from `anthropic/claude-3-5-sonnet` to `anthropic/claude-sonnet-4.5`
|
|
43
|
+
* because OpenRouter sunset the Claude 3.5 Sonnet endpoint upstream — every
|
|
44
|
+
* call against the old default returned `No endpoints found` 404s.
|
|
41
45
|
*/
|
|
42
46
|
const getDefaultOpenRouterModel = () => {
|
|
43
|
-
return getProviderModel("OPENROUTER_MODEL", "anthropic/claude-
|
|
47
|
+
return getProviderModel("OPENROUTER_MODEL", "anthropic/claude-sonnet-4.5");
|
|
44
48
|
};
|
|
45
49
|
/**
|
|
46
50
|
* OpenRouter Provider - BaseProvider Implementation
|
|
@@ -19,6 +19,20 @@ export type ZodUnknownSchema = ZodTypeAny;
|
|
|
19
19
|
* through `unknown` to this type at the third-party boundary.
|
|
20
20
|
*/
|
|
21
21
|
export type ZodToJsonSchemaInput = Parameters<typeof zodToJsonSchema>[0];
|
|
22
|
+
/**
|
|
23
|
+
* Dialects accepted by Zod 4's native `z.toJSONSchema(schema, { target })`.
|
|
24
|
+
* Note the `.` in `"openapi-3.0"`: this differs from the `zod-to-json-schema`
|
|
25
|
+
* package's `"openApi3"` form. The schemaConversion helper maps between the
|
|
26
|
+
* two so internal call sites can use a single `"openApi3"` identifier.
|
|
27
|
+
*/
|
|
28
|
+
export type Zod4NativeTarget = "draft-07" | "openapi-3.0";
|
|
29
|
+
/**
|
|
30
|
+
* Subset of Zod 4's `ToJSONSchemaParams` we forward through. Kept minimal so
|
|
31
|
+
* the type stays stable even if Zod 4 grows the surface in future releases.
|
|
32
|
+
*/
|
|
33
|
+
export type Zod4NativeParams = {
|
|
34
|
+
target?: Zod4NativeTarget;
|
|
35
|
+
};
|
|
22
36
|
/**
|
|
23
37
|
* Union type for schema validation (Zod or AI SDK schema)
|
|
24
38
|
* Commonly used in provider interfaces and validation functions
|
|
@@ -399,9 +399,6 @@ export type StreamingParser = {
|
|
|
399
399
|
/** Reset parser state for new stream */
|
|
400
400
|
reset(): void;
|
|
401
401
|
};
|
|
402
|
-
export type HippocampusMemory = import("@juspay/hippocampus").HippocampusConfig & {
|
|
403
|
-
enabled?: boolean;
|
|
404
|
-
};
|
|
405
402
|
/** Value types accepted as session variables by the loop REPL. */
|
|
406
403
|
export type SessionVariableValue = string | number | boolean;
|
|
407
404
|
/** State snapshot for the active REPL loop session. */
|
|
@@ -32,10 +32,17 @@
|
|
|
32
32
|
* - Current time (Unix ms): `Date.now()`
|
|
33
33
|
* - Current time (ISO): `new Date().toISOString()`
|
|
34
34
|
*/
|
|
35
|
-
import type { HippocampusMemory } from "./
|
|
35
|
+
import type { HippocampusMemory, HippocampusStorageConfig } from "./memory.js";
|
|
36
36
|
import type { ObservabilityConfig } from "./observability.js";
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Legacy public alias for the Hippocampus storage configuration.
|
|
39
|
+
* The structural definition lives in `./memory.ts`; this re-export keeps
|
|
40
|
+
* the SDK surface stable for callers who imported `StorageConfig` from
|
|
41
|
+
* the package barrel. Defined as a `type` alias rather than a re-export
|
|
42
|
+
* so the canonical `HippocampusStorageConfig` name is the one ESLint
|
|
43
|
+
* uniqueness checks see.
|
|
44
|
+
*/
|
|
45
|
+
export type StorageConfig = HippocampusStorageConfig;
|
|
39
46
|
/**
|
|
40
47
|
* Configuration for conversation memory feature
|
|
41
48
|
*/
|
|
@@ -217,6 +217,12 @@ export type GenerateOptions = {
|
|
|
217
217
|
region?: string;
|
|
218
218
|
temperature?: number;
|
|
219
219
|
maxTokens?: number;
|
|
220
|
+
/** Top-p (nucleus) sampling parameter. Controls diversity of generated tokens. */
|
|
221
|
+
topP?: number;
|
|
222
|
+
/** Top-k sampling parameter. Limits the number of tokens considered. (Google/Gemini models only) */
|
|
223
|
+
topK?: number;
|
|
224
|
+
/** Stop sequences that will halt generation when encountered. */
|
|
225
|
+
stopSequences?: string[];
|
|
220
226
|
systemPrompt?: string;
|
|
221
227
|
/**
|
|
222
228
|
* Zod schema for structured output validation
|
|
@@ -753,6 +759,12 @@ export type TextGenerationOptions = {
|
|
|
753
759
|
region?: string;
|
|
754
760
|
temperature?: number;
|
|
755
761
|
maxTokens?: number;
|
|
762
|
+
/** Top-p (nucleus) sampling parameter. Controls diversity of generated tokens. */
|
|
763
|
+
topP?: number;
|
|
764
|
+
/** Top-k sampling parameter. Limits the number of tokens considered. (Google/Gemini models only) */
|
|
765
|
+
topK?: number;
|
|
766
|
+
/** Stop sequences that will halt generation when encountered. */
|
|
767
|
+
stopSequences?: string[];
|
|
756
768
|
systemPrompt?: string;
|
|
757
769
|
schema?: ZodUnknownSchema | Schema<unknown>;
|
|
758
770
|
/**
|
|
@@ -926,6 +938,8 @@ export type TextGenerationOptions = {
|
|
|
926
938
|
conversationMemoryConfig?: Partial<ConversationMemoryConfig>;
|
|
927
939
|
originalPrompt?: string;
|
|
928
940
|
middleware?: MiddlewareFactoryOptions;
|
|
941
|
+
onFinish?: OnFinishCallback;
|
|
942
|
+
onError?: OnErrorCallback;
|
|
929
943
|
expectedOutcome?: string;
|
|
930
944
|
evaluationCriteria?: string[];
|
|
931
945
|
csvOptions?: {
|
package/dist/lib/types/index.js
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local structural types for the optional @juspay/hippocampus integration.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the public shapes that ship with @juspay/hippocampus's
|
|
5
|
+
* `dist/types.d.ts` so NeuroLink's public type surface stays compatible
|
|
6
|
+
* for consumers that already configure memory, while the runtime package
|
|
7
|
+
* itself becomes an optional peer dependency. The previous setup (a hard
|
|
8
|
+
* value import of @juspay/hippocampus) made pnpm pull a registry copy of
|
|
9
|
+
* @juspay/neurolink to satisfy Hippocampus's peer, which transitively
|
|
10
|
+
* dragged @ai-sdk/google + @ai-sdk/google-vertex into the production
|
|
11
|
+
* dependency graph.
|
|
12
|
+
*
|
|
13
|
+
* Naming:
|
|
14
|
+
* - Hippocampus's own `StorageType` and `RedisStorageConfig` collide with
|
|
15
|
+
* NeuroLink's in-house Redis manager types in `common.ts` /
|
|
16
|
+
* `conversation.ts`. To satisfy the `unique-type-names` ESLint rule,
|
|
17
|
+
* the storage variants get a `Memory*` prefix here.
|
|
18
|
+
* - `HippocampusMemory` (consumer-facing) and `StorageConfig` (legacy
|
|
19
|
+
* re-export) keep their original public names — only their definitions
|
|
20
|
+
* move from `import("@juspay/hippocampus").Foo` to local structural form.
|
|
21
|
+
*/
|
|
22
|
+
export type MemorySqliteStorageConfig = {
|
|
23
|
+
type: "sqlite";
|
|
24
|
+
/** Path to SQLite file. Default: ./data/hippocampus.sqlite */
|
|
25
|
+
path?: string;
|
|
26
|
+
};
|
|
27
|
+
export type MemoryRedisStorageConfig = {
|
|
28
|
+
type: "redis";
|
|
29
|
+
host?: string;
|
|
30
|
+
port?: number;
|
|
31
|
+
password?: string;
|
|
32
|
+
db?: number;
|
|
33
|
+
keyPrefix?: string;
|
|
34
|
+
ttl?: number;
|
|
35
|
+
};
|
|
36
|
+
export type MemoryS3StorageConfig = {
|
|
37
|
+
type: "s3";
|
|
38
|
+
bucket: string;
|
|
39
|
+
prefix?: string;
|
|
40
|
+
};
|
|
41
|
+
export type MemoryCustomStorageConfig = {
|
|
42
|
+
type: "custom";
|
|
43
|
+
onGet: (ownerId: string) => Promise<string | null>;
|
|
44
|
+
onSet: (ownerId: string, memory: string) => Promise<void>;
|
|
45
|
+
onDelete: (ownerId: string) => Promise<void>;
|
|
46
|
+
onClose?: () => Promise<void>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Storage configuration accepted by the optional Hippocampus client.
|
|
50
|
+
* Re-exported with the legacy `StorageConfig` name from `conversation.ts`
|
|
51
|
+
* to preserve the existing public type surface.
|
|
52
|
+
*/
|
|
53
|
+
export type HippocampusStorageConfig = MemorySqliteStorageConfig | MemoryRedisStorageConfig | MemoryS3StorageConfig | MemoryCustomStorageConfig;
|
|
54
|
+
/** Per-call options accepted by `Hippocampus.add`. */
|
|
55
|
+
export type HippocampusAddOptions = {
|
|
56
|
+
prompt?: string;
|
|
57
|
+
maxWords?: number;
|
|
58
|
+
};
|
|
59
|
+
/** Constructor config accepted by the Hippocampus class. */
|
|
60
|
+
export type HippocampusConfig = {
|
|
61
|
+
storage?: HippocampusStorageConfig;
|
|
62
|
+
prompt?: string;
|
|
63
|
+
neurolink?: {
|
|
64
|
+
provider?: string;
|
|
65
|
+
model?: string;
|
|
66
|
+
temperature?: number;
|
|
67
|
+
};
|
|
68
|
+
maxWords?: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Subset of the @juspay/hippocampus client surface that NeuroLink core
|
|
72
|
+
* actually calls. Defining this locally lets the initializer / SDK code
|
|
73
|
+
* avoid a value or even a type import from the optional package.
|
|
74
|
+
*/
|
|
75
|
+
export type HippocampusLike = {
|
|
76
|
+
add: (ownerId: string, content: string, options?: HippocampusAddOptions) => Promise<string>;
|
|
77
|
+
get: (ownerId: string) => Promise<string | null>;
|
|
78
|
+
delete: (ownerId: string) => Promise<void>;
|
|
79
|
+
close: () => Promise<void>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Consumer-facing memory config. Same shape as before — the `enabled`
|
|
83
|
+
* flag toggles activation while the rest is passed straight through to
|
|
84
|
+
* the Hippocampus constructor when the optional package is installed.
|
|
85
|
+
*/
|
|
86
|
+
export type HippocampusMemory = HippocampusConfig & {
|
|
87
|
+
enabled?: boolean;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Shape of the dynamically-required `@juspay/hippocampus` module surface
|
|
91
|
+
* that NeuroLink's lazy initializer reaches for. Only the constructor is
|
|
92
|
+
* surfaced here; the rest of the module is irrelevant to core.
|
|
93
|
+
*/
|
|
94
|
+
export type HippocampusModule = {
|
|
95
|
+
Hippocampus: new (config?: HippocampusConfig) => HippocampusLike;
|
|
96
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local structural types for the optional @juspay/hippocampus integration.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the public shapes that ship with @juspay/hippocampus's
|
|
5
|
+
* `dist/types.d.ts` so NeuroLink's public type surface stays compatible
|
|
6
|
+
* for consumers that already configure memory, while the runtime package
|
|
7
|
+
* itself becomes an optional peer dependency. The previous setup (a hard
|
|
8
|
+
* value import of @juspay/hippocampus) made pnpm pull a registry copy of
|
|
9
|
+
* @juspay/neurolink to satisfy Hippocampus's peer, which transitively
|
|
10
|
+
* dragged @ai-sdk/google + @ai-sdk/google-vertex into the production
|
|
11
|
+
* dependency graph.
|
|
12
|
+
*
|
|
13
|
+
* Naming:
|
|
14
|
+
* - Hippocampus's own `StorageType` and `RedisStorageConfig` collide with
|
|
15
|
+
* NeuroLink's in-house Redis manager types in `common.ts` /
|
|
16
|
+
* `conversation.ts`. To satisfy the `unique-type-names` ESLint rule,
|
|
17
|
+
* the storage variants get a `Memory*` prefix here.
|
|
18
|
+
* - `HippocampusMemory` (consumer-facing) and `StorageConfig` (legacy
|
|
19
|
+
* re-export) keep their original public names — only their definitions
|
|
20
|
+
* move from `import("@juspay/hippocampus").Foo` to local structural form.
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -703,6 +703,15 @@ export type GenAIModelsAPI = {
|
|
|
703
703
|
}>;
|
|
704
704
|
config?: Record<string, unknown>;
|
|
705
705
|
}) => Promise<GenAIGenerateContentResponse>;
|
|
706
|
+
embedContent: (params: {
|
|
707
|
+
model: string;
|
|
708
|
+
contents: string | string[];
|
|
709
|
+
config?: Record<string, unknown>;
|
|
710
|
+
}) => Promise<{
|
|
711
|
+
embeddings?: Array<{
|
|
712
|
+
values?: number[];
|
|
713
|
+
}>;
|
|
714
|
+
}>;
|
|
706
715
|
};
|
|
707
716
|
/**
|
|
708
717
|
* Google AI client interface
|
|
@@ -713,17 +722,52 @@ export type GenAIClient = {
|
|
|
713
722
|
};
|
|
714
723
|
models: GenAIModelsAPI;
|
|
715
724
|
};
|
|
725
|
+
/**
|
|
726
|
+
* HTTP options for Google GenAI SDK
|
|
727
|
+
* Allows custom fetch implementation for proxy support
|
|
728
|
+
*/
|
|
729
|
+
export type GoogleGenAIHttpOptions = {
|
|
730
|
+
/** Custom fetch implementation for proxy support */
|
|
731
|
+
fetch?: typeof fetch;
|
|
732
|
+
};
|
|
716
733
|
/**
|
|
717
734
|
* Google GenAI constructor type
|
|
718
735
|
* Supports both API key (Google AI Studio) and Vertex AI configurations
|
|
719
736
|
*/
|
|
720
737
|
export type GoogleGenAIClass = new (cfg: {
|
|
721
738
|
apiKey: string;
|
|
739
|
+
httpOptions?: GoogleGenAIHttpOptions;
|
|
722
740
|
} | {
|
|
723
741
|
vertexai: boolean;
|
|
724
742
|
project: string;
|
|
725
743
|
location: string;
|
|
744
|
+
httpOptions?: GoogleGenAIHttpOptions;
|
|
726
745
|
}) => GenAIClient;
|
|
746
|
+
/**
|
|
747
|
+
* Google Vertex AI provider settings for native SDK configuration
|
|
748
|
+
* Used with @google/genai SDK in vertexai mode
|
|
749
|
+
*
|
|
750
|
+
* Note: Authentication is handled via environment variables (GOOGLE_APPLICATION_CREDENTIALS)
|
|
751
|
+
* or the temporary credentials file approach, not through these settings fields.
|
|
752
|
+
*/
|
|
753
|
+
export type GoogleVertexProviderSettings = {
|
|
754
|
+
/** Google Cloud project ID */
|
|
755
|
+
project: string;
|
|
756
|
+
/** Google Cloud region/location (e.g., 'us-central1') */
|
|
757
|
+
location: string;
|
|
758
|
+
/** Optional custom fetch implementation */
|
|
759
|
+
fetch?: typeof fetch;
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* Anthropic Vertex AI settings for Claude models on Vertex
|
|
763
|
+
* Used with @anthropic-ai/vertex-sdk
|
|
764
|
+
*/
|
|
765
|
+
export type AnthropicVertexSettings = {
|
|
766
|
+
/** Google Cloud project ID */
|
|
767
|
+
projectId: string;
|
|
768
|
+
/** Google Cloud region for Anthropic models (e.g., 'us-east5') */
|
|
769
|
+
region: string;
|
|
770
|
+
};
|
|
727
771
|
/**
|
|
728
772
|
* OpenAI-compatible models endpoint response structure
|
|
729
773
|
*/
|
|
@@ -1499,8 +1543,8 @@ export type ToolWithLegacyParams = {
|
|
|
1499
1543
|
* factory functions.
|
|
1500
1544
|
*/
|
|
1501
1545
|
export type ProviderConstructor = {
|
|
1502
|
-
new (modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string): AIProvider;
|
|
1503
|
-
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string) => Promise<AIProvider>);
|
|
1546
|
+
new (modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string, credentials?: UnknownRecord): AIProvider;
|
|
1547
|
+
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string, credentials?: UnknownRecord) => Promise<AIProvider>);
|
|
1504
1548
|
/** Provider registration entry held by ProviderFactory. */
|
|
1505
1549
|
export type ProviderRegistration = {
|
|
1506
1550
|
constructor: ProviderConstructor;
|
|
@@ -1603,6 +1647,9 @@ export type GoogleLiveAudioQueueItem = {
|
|
|
1603
1647
|
/**
|
|
1604
1648
|
* Single part inside a Google Vertex "native" (non-AI-SDK) generateContent
|
|
1605
1649
|
* payload — either inline text or an inline base64 data blob.
|
|
1650
|
+
*
|
|
1651
|
+
* Despite the "Vertex" prefix, the shape is identical for the Google AI
|
|
1652
|
+
* Studio native path (`@google/genai` SDK), so AI Studio re-uses this type.
|
|
1606
1653
|
*/
|
|
1607
1654
|
export type VertexNativePart = {
|
|
1608
1655
|
text: string;
|
|
@@ -1612,6 +1659,21 @@ export type VertexNativePart = {
|
|
|
1612
1659
|
data: string;
|
|
1613
1660
|
};
|
|
1614
1661
|
};
|
|
1662
|
+
/**
|
|
1663
|
+
* Subset of `GenerateOptions["input"]` consumed by the shared Gemini-native
|
|
1664
|
+
* multimodal-parts builder. Kept narrow so the helper doesn't depend on the
|
|
1665
|
+
* full `GenerateOptions` shape. The `images` field mirrors the public
|
|
1666
|
+
* `GenerateOptions["input"].images` shape so the helper accepts the same
|
|
1667
|
+
* value SDK callers pass in (plain Buffer/string or `ImageWithAltText`).
|
|
1668
|
+
*/
|
|
1669
|
+
export type GeminiMultimodalInput = {
|
|
1670
|
+
text?: string;
|
|
1671
|
+
pdfFiles?: Array<Buffer | string>;
|
|
1672
|
+
images?: Array<Buffer | string | {
|
|
1673
|
+
data: Buffer | string;
|
|
1674
|
+
altText?: string;
|
|
1675
|
+
}>;
|
|
1676
|
+
};
|
|
1615
1677
|
/**
|
|
1616
1678
|
* Internal helpers used by the conversation-history builder in
|
|
1617
1679
|
* providers/googleVertex.ts to merge interleaved tool call / result turns.
|
|
@@ -1627,3 +1689,79 @@ export type VertexRegularSegment = {
|
|
|
1627
1689
|
parts: unknown[];
|
|
1628
1690
|
};
|
|
1629
1691
|
export type VertexSegment = VertexToolStep | VertexRegularSegment;
|
|
1692
|
+
/**
|
|
1693
|
+
* Function declaration shape accepted by the @google/genai SDK when tools are
|
|
1694
|
+
* attached to a Vertex generateContent call.
|
|
1695
|
+
*/
|
|
1696
|
+
export type VertexGenaiFunctionDeclaration = {
|
|
1697
|
+
name: string;
|
|
1698
|
+
description: string;
|
|
1699
|
+
parametersJsonSchema?: Record<string, unknown>;
|
|
1700
|
+
};
|
|
1701
|
+
/**
|
|
1702
|
+
* Message payload passed to the Anthropic Vertex SDK — mirrors the Anthropic
|
|
1703
|
+
* Messages API shape (role + structured content blocks).
|
|
1704
|
+
*/
|
|
1705
|
+
export type VertexAnthropicMessage = {
|
|
1706
|
+
role: "user" | "assistant";
|
|
1707
|
+
content: string | Array<{
|
|
1708
|
+
type: "text";
|
|
1709
|
+
text: string;
|
|
1710
|
+
} | {
|
|
1711
|
+
type: "image";
|
|
1712
|
+
source: {
|
|
1713
|
+
type: "base64";
|
|
1714
|
+
media_type: string;
|
|
1715
|
+
data: string;
|
|
1716
|
+
};
|
|
1717
|
+
} | {
|
|
1718
|
+
type: "document";
|
|
1719
|
+
source: {
|
|
1720
|
+
type: "base64";
|
|
1721
|
+
media_type: string;
|
|
1722
|
+
data: string;
|
|
1723
|
+
};
|
|
1724
|
+
} | {
|
|
1725
|
+
type: "tool_use";
|
|
1726
|
+
id: string;
|
|
1727
|
+
name: string;
|
|
1728
|
+
input: unknown;
|
|
1729
|
+
} | {
|
|
1730
|
+
type: "tool_result";
|
|
1731
|
+
tool_use_id: string;
|
|
1732
|
+
content: string;
|
|
1733
|
+
} | {
|
|
1734
|
+
type: "thinking";
|
|
1735
|
+
thinking: string;
|
|
1736
|
+
} | {
|
|
1737
|
+
type: "redacted_thinking";
|
|
1738
|
+
data: string;
|
|
1739
|
+
}>;
|
|
1740
|
+
};
|
|
1741
|
+
/** Tool definition accepted by the Anthropic Vertex SDK. */
|
|
1742
|
+
export type VertexAnthropicTool = {
|
|
1743
|
+
name: string;
|
|
1744
|
+
description: string;
|
|
1745
|
+
input_schema: {
|
|
1746
|
+
type: "object";
|
|
1747
|
+
properties?: Record<string, unknown>;
|
|
1748
|
+
required?: string[];
|
|
1749
|
+
};
|
|
1750
|
+
};
|
|
1751
|
+
/**
|
|
1752
|
+
* Content block variants returned by the Anthropic Vertex SDK during streaming
|
|
1753
|
+
* and generation — used to narrow responses before handing tool calls back.
|
|
1754
|
+
*/
|
|
1755
|
+
export type VertexAnthropicContentBlock = {
|
|
1756
|
+
type: "text";
|
|
1757
|
+
text: string;
|
|
1758
|
+
} | {
|
|
1759
|
+
type: "tool_use";
|
|
1760
|
+
id: string;
|
|
1761
|
+
name: string;
|
|
1762
|
+
input: Record<string, unknown>;
|
|
1763
|
+
} | {
|
|
1764
|
+
type: "tool_result";
|
|
1765
|
+
tool_use_id: string;
|
|
1766
|
+
content: string;
|
|
1767
|
+
};
|
|
@@ -314,6 +314,12 @@ export type StreamOptions = {
|
|
|
314
314
|
region?: string;
|
|
315
315
|
temperature?: number;
|
|
316
316
|
maxTokens?: number;
|
|
317
|
+
/** Top-p (nucleus) sampling parameter. Controls diversity of generated tokens. */
|
|
318
|
+
topP?: number;
|
|
319
|
+
/** Top-k sampling parameter. Limits the number of tokens considered. (Google/Gemini models only) */
|
|
320
|
+
topK?: number;
|
|
321
|
+
/** Stop sequences that will halt generation when encountered. */
|
|
322
|
+
stopSequences?: string[];
|
|
317
323
|
systemPrompt?: string;
|
|
318
324
|
schema?: ValidationSchema;
|
|
319
325
|
tools?: Record<string, Tool>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dedupes per-error invocations of the user-supplied `onError` lifecycle
|
|
3
|
+
* callback. The same thrown error can travel through both the middleware
|
|
4
|
+
* pipeline (which fires `onError` then re-throws) and the top-level
|
|
5
|
+
* generate/stream catch in `neurolink.ts` — without a guard, the consumer
|
|
6
|
+
* callback would fire twice for one logical failure.
|
|
7
|
+
*
|
|
8
|
+
* Strategy: stamp a non-enumerable Symbol on the error object the first
|
|
9
|
+
* time a firing site is reached, skip subsequent firings. Symbol.for
|
|
10
|
+
* lets us share the same key across modules without import gymnastics.
|
|
11
|
+
*/
|
|
12
|
+
import type { LifecycleErrorPayload, OnErrorCallback } from "../types/index.js";
|
|
13
|
+
export declare function fireOnErrorOnce(onError: OnErrorCallback | undefined, error: unknown, payload: LifecycleErrorPayload): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dedupes per-error invocations of the user-supplied `onError` lifecycle
|
|
3
|
+
* callback. The same thrown error can travel through both the middleware
|
|
4
|
+
* pipeline (which fires `onError` then re-throws) and the top-level
|
|
5
|
+
* generate/stream catch in `neurolink.ts` — without a guard, the consumer
|
|
6
|
+
* callback would fire twice for one logical failure.
|
|
7
|
+
*
|
|
8
|
+
* Strategy: stamp a non-enumerable Symbol on the error object the first
|
|
9
|
+
* time a firing site is reached, skip subsequent firings. Symbol.for
|
|
10
|
+
* lets us share the same key across modules without import gymnastics.
|
|
11
|
+
*/
|
|
12
|
+
const ON_ERROR_FIRED = Symbol.for("neurolink.onErrorFired");
|
|
13
|
+
export function fireOnErrorOnce(onError, error, payload) {
|
|
14
|
+
if (typeof onError !== "function") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (error && typeof error === "object") {
|
|
18
|
+
const errAsRecord = error;
|
|
19
|
+
if (errAsRecord[ON_ERROR_FIRED]) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
Object.defineProperty(error, ON_ERROR_FIRED, {
|
|
24
|
+
value: true,
|
|
25
|
+
enumerable: false,
|
|
26
|
+
writable: false,
|
|
27
|
+
configurable: false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Frozen/sealed error object — proceed without the stamp; the
|
|
32
|
+
// worst case is a single duplicate fire if multiple sites observe
|
|
33
|
+
// the same frozen value, which is the pre-existing behaviour.
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const result = onError(payload);
|
|
38
|
+
Promise.resolve(result).catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Consumer callback errors must not poison the original throw.
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=lifecycleCallbacks.js.map
|
|
@@ -17,6 +17,16 @@ export declare function convertToModelMessages(messages: MultimodalChatMessage[]
|
|
|
17
17
|
* Enhanced with CSV file processing support
|
|
18
18
|
*/
|
|
19
19
|
export declare function buildMessagesArray(options: TextGenerationOptions | StreamOptions): Promise<ModelMessage[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Process the unified files array with auto-detection.
|
|
22
|
+
* Handles lazy file registration, full processing, and preview injection.
|
|
23
|
+
*
|
|
24
|
+
* Exported so providers that bypass BaseProvider.generate() (e.g.
|
|
25
|
+
* GoogleVertex's native @google/genai path) can still preprocess
|
|
26
|
+
* `input.files` — without this, mimetype-hint and text-file inputs
|
|
27
|
+
* would silently never reach the model on those paths.
|
|
28
|
+
*/
|
|
29
|
+
export declare function processUnifiedFilesArray(options: GenerateOptions, maxSize: number, provider: string): Promise<void>;
|
|
20
30
|
/**
|
|
21
31
|
* Build multimodal message array with image support
|
|
22
32
|
* Detects when images are present and routes through provider adapter
|
|
@@ -534,8 +534,13 @@ export async function buildMessagesArray(options) {
|
|
|
534
534
|
csvSection += metadataText + `\n\n`;
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
|
|
537
|
+
// Put the actual CSV content BEFORE the tool instructions —
|
|
538
|
+
// buildCSVToolInstructions references "the CSV data shown above"
|
|
539
|
+
// and the trailing position keeps that reference accurate.
|
|
540
|
+
// Vertex Gemini misreads CSV-only prompts as "no files attached"
|
|
541
|
+
// when the NOTE-then-data order makes the reference dangle.
|
|
538
542
|
csvSection += result.content;
|
|
543
|
+
csvSection += buildCSVToolInstructions(filePath);
|
|
539
544
|
csvContent += csvSection;
|
|
540
545
|
logger.info(`[CSV] ✅ Processed: ${filename}`, result.metadata);
|
|
541
546
|
}
|
|
@@ -664,8 +669,11 @@ function appendDetectedFileResult(result, file, options) {
|
|
|
664
669
|
csvSection += metadataText + `\n\n`;
|
|
665
670
|
}
|
|
666
671
|
}
|
|
667
|
-
|
|
672
|
+
// Put the actual CSV content BEFORE the tool instructions —
|
|
673
|
+
// buildCSVToolInstructions references "the CSV data shown above" and
|
|
674
|
+
// the trailing position keeps that reference accurate.
|
|
668
675
|
csvSection += result.content;
|
|
676
|
+
csvSection += buildCSVToolInstructions(filePath);
|
|
669
677
|
options.input.text += csvSection;
|
|
670
678
|
logger.info(`[FileDetector] ✅ CSV: ${filename}`);
|
|
671
679
|
}
|
|
@@ -771,8 +779,13 @@ function appendDetectedFileResult(result, file, options) {
|
|
|
771
779
|
/**
|
|
772
780
|
* Process the unified files array with auto-detection.
|
|
773
781
|
* Handles lazy file registration, full processing, and preview injection.
|
|
782
|
+
*
|
|
783
|
+
* Exported so providers that bypass BaseProvider.generate() (e.g.
|
|
784
|
+
* GoogleVertex's native @google/genai path) can still preprocess
|
|
785
|
+
* `input.files` — without this, mimetype-hint and text-file inputs
|
|
786
|
+
* would silently never reach the model on those paths.
|
|
774
787
|
*/
|
|
775
|
-
async function processUnifiedFilesArray(options, maxSize, provider) {
|
|
788
|
+
export async function processUnifiedFilesArray(options, maxSize, provider) {
|
|
776
789
|
if (!options.input.files || options.input.files.length === 0) {
|
|
777
790
|
return;
|
|
778
791
|
}
|
|
@@ -864,6 +877,24 @@ async function processUnifiedFilesArray(options, maxSize, provider) {
|
|
|
864
877
|
}
|
|
865
878
|
}
|
|
866
879
|
logger.info(`[NEUROLINK] File processing complete: ${includedCount}/${totalFiles} files included in message`);
|
|
880
|
+
// Augment options.systemPrompt with file-handling guidance so providers
|
|
881
|
+
// that bypass the message-builder's system message and read
|
|
882
|
+
// `options.systemPrompt` directly (e.g. GoogleVertex's native @google/genai
|
|
883
|
+
// path uses `config.systemInstruction = options.systemPrompt`) still see
|
|
884
|
+
// the "treat inlined CSV/PDF as the actual file" guidance. Without this,
|
|
885
|
+
// Vertex Gemini 2.5 reliably responds with "no files attached" even
|
|
886
|
+
// though the CSV content is fully embedded in the user prompt.
|
|
887
|
+
if (includedCount > 0) {
|
|
888
|
+
const filePromptAugmentation = `\n\nIMPORTANT FILE HANDLING INSTRUCTIONS:
|
|
889
|
+
- The full content of the user's local file(s) is INLINED in this message under "## CSV Data from ..." / "## PDF Data from ..." / "## File: ..." headings — it is the actual file the user is asking about.
|
|
890
|
+
- TREAT THE INLINED CONTENT AS IF IT WERE AN ATTACHMENT. Do NOT respond with "no files attached" or ask the user to re-upload — the data is already here.
|
|
891
|
+
- DO NOT use GitHub tools (get_file_contents, search_code, etc.) for local files - they only work for remote repository files.
|
|
892
|
+
- Analyze the inlined file content directly without attempting to fetch or read files using tools.`;
|
|
893
|
+
const existingSystem = (options.systemPrompt || "").trim();
|
|
894
|
+
options.systemPrompt = existingSystem
|
|
895
|
+
? `${existingSystem}${filePromptAugmentation}`
|
|
896
|
+
: filePromptAugmentation.trim();
|
|
897
|
+
}
|
|
867
898
|
});
|
|
868
899
|
}
|
|
869
900
|
/**
|
|
@@ -891,8 +922,11 @@ async function processExplicitCsvFiles(options) {
|
|
|
891
922
|
csvSection += metadataText + `\n\n`;
|
|
892
923
|
}
|
|
893
924
|
}
|
|
894
|
-
|
|
925
|
+
// Put the actual CSV content BEFORE the tool instructions —
|
|
926
|
+
// buildCSVToolInstructions references "the CSV data shown above"
|
|
927
|
+
// and the trailing position keeps that reference accurate.
|
|
895
928
|
csvSection += result.content;
|
|
929
|
+
csvSection += buildCSVToolInstructions(filePath);
|
|
896
930
|
options.input.text += csvSection;
|
|
897
931
|
logger.info(`[CSV] ✅ Processed: ${filename}`);
|
|
898
932
|
}
|
|
@@ -1001,7 +1035,8 @@ function buildMultimodalSystemPrompt(options, hasPDFFiles) {
|
|
|
1001
1035
|
fileTypes.push("CSVs");
|
|
1002
1036
|
}
|
|
1003
1037
|
systemPrompt += `\n\nIMPORTANT FILE HANDLING INSTRUCTIONS:
|
|
1004
|
-
-
|
|
1038
|
+
- The full content of the user's local ${fileTypes.join(", ")} (and any images) is INLINED in this message under the "## CSV Data from ..." / "## PDF Data from ..." headings — it is the actual file the user is asking about.
|
|
1039
|
+
- TREAT THE INLINED CONTENT AS IF IT WERE AN ATTACHMENT. Do NOT respond with "no files attached" or ask the user to re-upload — the data is already here.
|
|
1005
1040
|
- DO NOT use GitHub tools (get_file_contents, search_code, etc.) for local files - they only work for remote repository files
|
|
1006
1041
|
- Analyze the provided file content directly without attempting to fetch or read files using tools
|
|
1007
1042
|
- GitHub MCP tools are ONLY for remote repository operations, not local filesystem access
|
|
@@ -7,3 +7,14 @@ export declare function supportsThinkingConfig(modelName: string): boolean;
|
|
|
7
7
|
export declare function supportsPromptCaching(modelName: string): boolean;
|
|
8
8
|
export declare function getMaxThinkingBudgetTokens(modelName: string): number;
|
|
9
9
|
export declare function getModelFamily(modelName: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Check if a model has restricted output token limit (32768 max)
|
|
12
|
+
* This applies to:
|
|
13
|
+
* - All Gemini 3 models (gemini-3-flash, gemini-3-pro, etc.)
|
|
14
|
+
* - Image generation models (gemini-2.5-flash-image, gemini-3-pro-image-preview)
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasRestrictedOutputLimit(modelName: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Get the max output tokens for a model (32768 for restricted models)
|
|
19
|
+
*/
|
|
20
|
+
export declare const RESTRICTED_OUTPUT_TOKEN_LIMIT = 32768;
|