@agntk/core 0.2.0 → 0.3.1
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/dist/agent-v2.d.ts +48 -0
- package/dist/agent-v2.d.ts.map +1 -0
- package/dist/agent-v2.js +365 -0
- package/dist/agent-v2.js.map +1 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +61 -43
- package/dist/agent.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +16 -4
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/loader.d.ts +14 -6
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +38 -16
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +14 -14
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/guardrails/runner.d.ts.map +1 -1
- package/dist/guardrails/runner.js +4 -0
- package/dist/guardrails/runner.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/memory/engine.d.ts +130 -0
- package/dist/memory/engine.d.ts.map +1 -0
- package/dist/memory/engine.js +227 -0
- package/dist/memory/engine.js.map +1 -0
- package/dist/memory/vectra-store.d.ts +31 -0
- package/dist/memory/vectra-store.d.ts.map +1 -0
- package/dist/memory/vectra-store.js +122 -0
- package/dist/memory/vectra-store.js.map +1 -0
- package/dist/models.d.ts +24 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +50 -4
- package/dist/models.js.map +1 -1
- package/dist/pool/index.d.ts +7 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +6 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/specialist-pool.d.ts +59 -0
- package/dist/pool/specialist-pool.d.ts.map +1 -0
- package/dist/pool/specialist-pool.js +224 -0
- package/dist/pool/specialist-pool.js.map +1 -0
- package/dist/pool/tools.d.ts +63 -0
- package/dist/pool/tools.d.ts.map +1 -0
- package/dist/pool/tools.js +83 -0
- package/dist/pool/tools.js.map +1 -0
- package/dist/pool/types.d.ts +79 -0
- package/dist/pool/types.d.ts.map +1 -0
- package/dist/pool/types.js +5 -0
- package/dist/pool/types.js.map +1 -0
- package/dist/presets/index.d.ts +5 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +5 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/role-registry.d.ts +41 -0
- package/dist/presets/role-registry.d.ts.map +1 -0
- package/dist/presets/role-registry.js +213 -0
- package/dist/presets/role-registry.js.map +1 -0
- package/dist/presets/roles.d.ts +105 -0
- package/dist/presets/roles.d.ts.map +1 -0
- package/dist/presets/roles.js +207 -0
- package/dist/presets/roles.js.map +1 -0
- package/dist/presets/tools.d.ts +2 -2
- package/dist/prompts/templates.d.ts +11 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +115 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/provider-resolver.d.ts +38 -0
- package/dist/provider-resolver.d.ts.map +1 -0
- package/dist/provider-resolver.js +142 -0
- package/dist/provider-resolver.js.map +1 -0
- package/dist/reflection.d.ts +5 -2
- package/dist/reflection.d.ts.map +1 -1
- package/dist/reflection.js +8 -3
- package/dist/reflection.js.map +1 -1
- package/dist/skills/loader.d.ts +18 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +58 -2
- package/dist/skills/loader.js.map +1 -1
- package/dist/streaming/data-parts.d.ts +163 -0
- package/dist/streaming/data-parts.d.ts.map +1 -0
- package/dist/streaming/data-parts.js +14 -0
- package/dist/streaming/data-parts.js.map +1 -0
- package/dist/streaming/index.d.ts +8 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +10 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/transient.d.ts +136 -0
- package/dist/streaming/transient.d.ts.map +1 -0
- package/dist/streaming/transient.js +201 -0
- package/dist/streaming/transient.js.map +1 -0
- package/dist/system-detect.d.ts +59 -0
- package/dist/system-detect.d.ts.map +1 -0
- package/dist/system-detect.js +193 -0
- package/dist/system-detect.js.map +1 -0
- package/dist/tools/browser/tool.d.ts +2 -2
- package/dist/tools/browser/types.d.ts +2 -2
- package/dist/tools/file/tools.d.ts.map +1 -1
- package/dist/tools/file/tools.js +30 -1
- package/dist/tools/file/tools.js.map +1 -1
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/progress/index.d.ts +1 -1
- package/dist/tools/provider.d.ts +97 -0
- package/dist/tools/provider.d.ts.map +1 -0
- package/dist/tools/provider.js +178 -0
- package/dist/tools/provider.js.map +1 -0
- package/dist/tools/shell/background.d.ts.map +1 -1
- package/dist/tools/shell/background.js +45 -3
- package/dist/tools/shell/background.js.map +1 -1
- package/dist/tools/shell/tools.d.ts.map +1 -1
- package/dist/tools/shell/tools.js +9 -2
- package/dist/tools/shell/tools.js.map +1 -1
- package/dist/tools/utils/shell.d.ts +14 -0
- package/dist/tools/utils/shell.d.ts.map +1 -1
- package/dist/tools/utils/shell.js +171 -12
- package/dist/tools/utils/shell.js.map +1 -1
- package/dist/types/agent-v2.d.ts +83 -0
- package/dist/types/agent-v2.d.ts.map +1 -0
- package/dist/types/agent-v2.js +8 -0
- package/dist/types/agent-v2.js.map +1 -0
- package/dist/types/agent.d.ts +10 -0
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +35 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +149 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/workflow/builders/adapt.d.ts +20 -0
- package/dist/workflow/builders/adapt.d.ts.map +1 -0
- package/dist/workflow/builders/adapt.js +33 -0
- package/dist/workflow/builders/adapt.js.map +1 -0
- package/dist/workflow/builders/index.d.ts +8 -0
- package/dist/workflow/builders/index.d.ts.map +1 -0
- package/dist/workflow/builders/index.js +7 -0
- package/dist/workflow/builders/index.js.map +1 -0
- package/dist/workflow/builders/parallel.d.ts +25 -0
- package/dist/workflow/builders/parallel.d.ts.map +1 -0
- package/dist/workflow/builders/parallel.js +60 -0
- package/dist/workflow/builders/parallel.js.map +1 -0
- package/dist/workflow/builders/pipeline.d.ts +22 -0
- package/dist/workflow/builders/pipeline.d.ts.map +1 -0
- package/dist/workflow/builders/pipeline.js +48 -0
- package/dist/workflow/builders/pipeline.js.map +1 -0
- package/dist/workflow/builders/types.d.ts +54 -0
- package/dist/workflow/builders/types.d.ts.map +1 -0
- package/dist/workflow/builders/types.js +5 -0
- package/dist/workflow/builders/types.js.map +1 -0
- package/dist/workflow/durable-agent.d.ts +128 -0
- package/dist/workflow/durable-agent.d.ts.map +1 -0
- package/dist/workflow/durable-agent.js +323 -0
- package/dist/workflow/durable-agent.js.map +1 -0
- package/dist/workflow/schedulers.d.ts +231 -0
- package/dist/workflow/schedulers.d.ts.map +1 -0
- package/dist/workflow/schedulers.js +250 -0
- package/dist/workflow/schedulers.js.map +1 -0
- package/dist/workflow/team/create-team.d.ts +34 -0
- package/dist/workflow/team/create-team.d.ts.map +1 -0
- package/dist/workflow/team/create-team.js +242 -0
- package/dist/workflow/team/create-team.js.map +1 -0
- package/dist/workflow/team/index.d.ts +9 -0
- package/dist/workflow/team/index.d.ts.map +1 -0
- package/dist/workflow/team/index.js +8 -0
- package/dist/workflow/team/index.js.map +1 -0
- package/dist/workflow/team/machines.d.ts +152 -0
- package/dist/workflow/team/machines.d.ts.map +1 -0
- package/dist/workflow/team/machines.js +197 -0
- package/dist/workflow/team/machines.js.map +1 -0
- package/dist/workflow/team/task-board.d.ts +47 -0
- package/dist/workflow/team/task-board.d.ts.map +1 -0
- package/dist/workflow/team/task-board.js +111 -0
- package/dist/workflow/team/task-board.js.map +1 -0
- package/dist/workflow/team/tools.d.ts +66 -0
- package/dist/workflow/team/tools.d.ts.map +1 -0
- package/dist/workflow/team/tools.js +100 -0
- package/dist/workflow/team/tools.js.map +1 -0
- package/dist/workflow/team/types.d.ts +109 -0
- package/dist/workflow/team/types.d.ts.map +1 -0
- package/dist/workflow/team/types.js +5 -0
- package/dist/workflow/team/types.js.map +1 -0
- package/dist/workflow/templates.d.ts +71 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +132 -0
- package/dist/workflow/templates.js.map +1 -0
- package/package.json +13 -13
- package/LICENSE +0 -22
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Custom data part types for AI SDK streaming.
|
|
3
|
+
* These types define the shape of transient data streamed during agent execution.
|
|
4
|
+
*
|
|
5
|
+
* Usage with AI SDK:
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import type { DataStreamWriter } from 'ai';
|
|
8
|
+
*
|
|
9
|
+
* const writer: DataStreamWriter = ...;
|
|
10
|
+
* writer.writeData({ type: 'file-content', data: { path: '/foo.ts', content: '...', truncated: false } });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Union type of all custom data parts supported by the agent SDK.
|
|
15
|
+
* These are streamed transiently and not persisted to conversation context.
|
|
16
|
+
*/
|
|
17
|
+
export type AgentDataParts = {
|
|
18
|
+
/**
|
|
19
|
+
* Streaming output from a spawned sub-agent.
|
|
20
|
+
* Displayed as nested collapsible in UI.
|
|
21
|
+
*/
|
|
22
|
+
'sub-agent-stream': SubAgentStreamData;
|
|
23
|
+
/**
|
|
24
|
+
* Search results from grep/glob/codebase search.
|
|
25
|
+
*/
|
|
26
|
+
'search-result': SearchResultData;
|
|
27
|
+
/**
|
|
28
|
+
* File content streamed transiently (not added to context).
|
|
29
|
+
*/
|
|
30
|
+
'file-content': FileContentData;
|
|
31
|
+
/**
|
|
32
|
+
* Shell command execution output.
|
|
33
|
+
*/
|
|
34
|
+
'shell-output': ShellOutputData;
|
|
35
|
+
/**
|
|
36
|
+
* Progress indicator for long-running tools.
|
|
37
|
+
*/
|
|
38
|
+
'tool-progress': ToolProgressData;
|
|
39
|
+
/**
|
|
40
|
+
* Reasoning/thinking step from deep reasoning tool.
|
|
41
|
+
*/
|
|
42
|
+
'reasoning-step': ReasoningStepData;
|
|
43
|
+
/**
|
|
44
|
+
* Memory retrieval results.
|
|
45
|
+
*/
|
|
46
|
+
'memory-result': MemoryResultData;
|
|
47
|
+
};
|
|
48
|
+
/** Sub-agent streaming data. */
|
|
49
|
+
export interface SubAgentStreamData {
|
|
50
|
+
/** Unique identifier for the sub-agent instance. */
|
|
51
|
+
agentId: string;
|
|
52
|
+
/** Role of the sub-agent. */
|
|
53
|
+
role: string;
|
|
54
|
+
/** Streamed text content. */
|
|
55
|
+
text: string;
|
|
56
|
+
/** Status of the sub-agent stream. */
|
|
57
|
+
status: 'streaming' | 'complete' | 'error';
|
|
58
|
+
/** Error message if status is 'error'. */
|
|
59
|
+
error?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Search result data from file/code search. */
|
|
62
|
+
export interface SearchResultData {
|
|
63
|
+
/** File path relative to workspace root. */
|
|
64
|
+
path: string;
|
|
65
|
+
/** Matched content snippet. */
|
|
66
|
+
content: string;
|
|
67
|
+
/** Number of matches in the file. */
|
|
68
|
+
matches: number;
|
|
69
|
+
/** Line number of the first match. */
|
|
70
|
+
line?: number;
|
|
71
|
+
/** Search pattern used. */
|
|
72
|
+
pattern?: string;
|
|
73
|
+
}
|
|
74
|
+
/** File content data for transient streaming. */
|
|
75
|
+
export interface FileContentData {
|
|
76
|
+
/** Absolute or relative file path. */
|
|
77
|
+
path: string;
|
|
78
|
+
/** File content. */
|
|
79
|
+
content: string;
|
|
80
|
+
/** Whether content was truncated due to size limits. */
|
|
81
|
+
truncated: boolean;
|
|
82
|
+
/** Total file size in bytes. */
|
|
83
|
+
totalBytes?: number;
|
|
84
|
+
/** MIME type of the file. */
|
|
85
|
+
mimeType?: string;
|
|
86
|
+
/** Language identifier for syntax highlighting. */
|
|
87
|
+
language?: string;
|
|
88
|
+
/** Line range if partial content. */
|
|
89
|
+
lineRange?: {
|
|
90
|
+
start: number;
|
|
91
|
+
end: number;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Shell command output data. */
|
|
95
|
+
export interface ShellOutputData {
|
|
96
|
+
/** Command that was executed. */
|
|
97
|
+
command: string;
|
|
98
|
+
/** Command output (stdout + stderr). */
|
|
99
|
+
output: string;
|
|
100
|
+
/** Exit code of the command. */
|
|
101
|
+
exitCode: number;
|
|
102
|
+
/** Working directory where command was executed. */
|
|
103
|
+
cwd?: string;
|
|
104
|
+
/** Whether output was truncated. */
|
|
105
|
+
truncated?: boolean;
|
|
106
|
+
/** Execution duration in milliseconds. */
|
|
107
|
+
durationMs?: number;
|
|
108
|
+
}
|
|
109
|
+
/** Tool progress indicator data. */
|
|
110
|
+
export interface ToolProgressData {
|
|
111
|
+
/** Name of the tool being executed. */
|
|
112
|
+
toolName: string;
|
|
113
|
+
/** Progress percentage (0-100). */
|
|
114
|
+
progress: number;
|
|
115
|
+
/** Human-readable progress message. */
|
|
116
|
+
message: string;
|
|
117
|
+
/** Estimated time remaining in milliseconds. */
|
|
118
|
+
estimatedRemaining?: number;
|
|
119
|
+
/** Current step/total steps format. */
|
|
120
|
+
step?: {
|
|
121
|
+
current: number;
|
|
122
|
+
total: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Reasoning step from deep reasoning tool. */
|
|
126
|
+
export interface ReasoningStepData {
|
|
127
|
+
/** Step number in the reasoning chain. */
|
|
128
|
+
stepNumber: number;
|
|
129
|
+
/** Total estimated steps. */
|
|
130
|
+
totalSteps: number;
|
|
131
|
+
/** The reasoning thought content. */
|
|
132
|
+
thought: string;
|
|
133
|
+
/** Whether this is a revision of a previous thought. */
|
|
134
|
+
isRevision?: boolean;
|
|
135
|
+
/** Which thought number is being revised. */
|
|
136
|
+
revisesThought?: number;
|
|
137
|
+
/** Branch identifier for alternative reasoning paths. */
|
|
138
|
+
branchId?: string;
|
|
139
|
+
}
|
|
140
|
+
/** Memory retrieval result data. */
|
|
141
|
+
export interface MemoryResultData {
|
|
142
|
+
/** Memory entry content. */
|
|
143
|
+
content: string;
|
|
144
|
+
/** Similarity score (0-1). */
|
|
145
|
+
score: number;
|
|
146
|
+
/** Metadata associated with the memory. */
|
|
147
|
+
metadata?: Record<string, unknown>;
|
|
148
|
+
/** When the memory was stored. */
|
|
149
|
+
timestamp?: string;
|
|
150
|
+
}
|
|
151
|
+
/** Type helper to get data type for a specific part type. */
|
|
152
|
+
export type DataPartType<K extends keyof AgentDataParts> = AgentDataParts[K];
|
|
153
|
+
/** Type helper for creating typed data parts. */
|
|
154
|
+
export interface TypedDataPart<K extends keyof AgentDataParts> {
|
|
155
|
+
type: K;
|
|
156
|
+
id?: string;
|
|
157
|
+
data: AgentDataParts[K];
|
|
158
|
+
}
|
|
159
|
+
/** Union of all possible data parts. */
|
|
160
|
+
export type AnyDataPart = {
|
|
161
|
+
[K in keyof AgentDataParts]: TypedDataPart<K>;
|
|
162
|
+
}[keyof AgentDataParts];
|
|
163
|
+
//# sourceMappingURL=data-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-parts.d.ts","sourceRoot":"","sources":["../../src/streaming/data-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;IAEvC;;OAEG;IACH,eAAe,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,cAAc,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,cAAc,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,gBAAgB,EAAE,iBAAiB,CAAC;IAEpC;;OAEG;IACH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c,CAAC,CAAC,CAAC,CAAC;AAE7E,iDAAiD;AACjD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,cAAc;IAC3D,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;CACzB;AAED,wCAAwC;AACxC,MAAM,MAAM,WAAW,GAAG;KACvB,CAAC,IAAI,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC;CAC9C,CAAC,MAAM,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Custom data part types for AI SDK streaming.
|
|
3
|
+
* These types define the shape of transient data streamed during agent execution.
|
|
4
|
+
*
|
|
5
|
+
* Usage with AI SDK:
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import type { DataStreamWriter } from 'ai';
|
|
8
|
+
*
|
|
9
|
+
* const writer: DataStreamWriter = ...;
|
|
10
|
+
* writer.writeData({ type: 'file-content', data: { path: '/foo.ts', content: '...', truncated: false } });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=data-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-parts.js","sourceRoot":"","sources":["../../src/streaming/data-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Streaming Module
|
|
3
|
+
*
|
|
4
|
+
* Exports for transient streaming and custom data parts.
|
|
5
|
+
*/
|
|
6
|
+
export { type AgentDataParts, type SubAgentStreamData, type SearchResultData, type FileContentData, type ShellOutputData, type ToolProgressData, type ReasoningStepData, type MemoryResultData, type DataPartType, type TypedDataPart, type AnyDataPart, } from './data-parts.js';
|
|
7
|
+
export { withTransientStreaming, writeTransient, streamTransient, streamFileContent, streamShellOutput, streamSearchResult, streamProgress, streamReasoningStep, streamSubAgent, type TransientStreamWriter, type TransientToolContext, } from './transient.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Streaming Module
|
|
3
|
+
*
|
|
4
|
+
* Exports for transient streaming and custom data parts.
|
|
5
|
+
*/
|
|
6
|
+
// Data part types
|
|
7
|
+
export {} from './data-parts.js';
|
|
8
|
+
// Transient streaming
|
|
9
|
+
export { withTransientStreaming, writeTransient, streamTransient, streamFileContent, streamShellOutput, streamSearchResult, streamProgress, streamReasoningStep, streamSubAgent, } from './transient.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kBAAkB;AAClB,OAAO,EAYN,MAAM,cAAc,CAAC;AAEtB,sBAAsB;AACtB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,GAGf,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Transient Streaming Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Enables tools to stream data to the UI without persisting to conversation context.
|
|
5
|
+
* This keeps the context window lean while providing rich UI feedback.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool } from 'ai';
|
|
8
|
+
import type { ToolContext } from '../types/lifecycle.js';
|
|
9
|
+
import type { AgentDataParts } from './data-parts.js';
|
|
10
|
+
/**
|
|
11
|
+
* Interface for UI stream writer.
|
|
12
|
+
* Compatible with AI SDK's DataStreamWriter.
|
|
13
|
+
*/
|
|
14
|
+
export interface TransientStreamWriter {
|
|
15
|
+
writeData(data: unknown): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Enhanced tool context with transient streaming capabilities.
|
|
19
|
+
* Uses intersection type to extend ToolContext without conflicts.
|
|
20
|
+
*/
|
|
21
|
+
export type TransientToolContext = ToolContext & {
|
|
22
|
+
/** Helper to stream typed transient data */
|
|
23
|
+
stream: <K extends keyof AgentDataParts>(type: K, data: AgentDataParts[K]) => void;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Tool set is a record of tools keyed by name.
|
|
27
|
+
*/
|
|
28
|
+
type ToolSet = Record<string, Tool>;
|
|
29
|
+
/**
|
|
30
|
+
* Wrap tools to enable transient streaming.
|
|
31
|
+
*
|
|
32
|
+
* Tools wrapped with this function will have access to a `stream()` helper
|
|
33
|
+
* in their context that allows streaming data to the UI without adding
|
|
34
|
+
* it to the conversation context.
|
|
35
|
+
*
|
|
36
|
+
* @param tools - Record of tools to wrap
|
|
37
|
+
* @param writer - Stream writer for sending data to the client
|
|
38
|
+
* @returns Wrapped tools with transient streaming enabled
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const wrappedTools = withTransientStreaming(myTools, dataStream);
|
|
43
|
+
*
|
|
44
|
+
* // Inside a tool's execute function:
|
|
45
|
+
* execute: async (input, ctx) => {
|
|
46
|
+
* ctx.stream('file-content', {
|
|
47
|
+
* path: input.path,
|
|
48
|
+
* content: fileContent,
|
|
49
|
+
* truncated: false,
|
|
50
|
+
* });
|
|
51
|
+
* return `Read ${input.path}`;
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function withTransientStreaming(tools: ToolSet, writer: TransientStreamWriter): ToolSet;
|
|
56
|
+
/**
|
|
57
|
+
* Stream typed transient data to the UI.
|
|
58
|
+
*
|
|
59
|
+
* @param writer - Stream writer instance
|
|
60
|
+
* @param type - Data part type
|
|
61
|
+
* @param data - Data to stream
|
|
62
|
+
*/
|
|
63
|
+
export declare function writeTransient<K extends keyof AgentDataParts>(writer: TransientStreamWriter, type: K, data: AgentDataParts[K]): void;
|
|
64
|
+
/**
|
|
65
|
+
* Helper for tools to stream transient data from within their execute function.
|
|
66
|
+
*
|
|
67
|
+
* @param ctx - Tool context (must have writer)
|
|
68
|
+
* @param type - Data part type
|
|
69
|
+
* @param data - Data to stream
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Inside a tool's execute function:
|
|
74
|
+
* streamTransient(ctx, 'shell-output', {
|
|
75
|
+
* command: 'npm test',
|
|
76
|
+
* output: result.stdout,
|
|
77
|
+
* exitCode: result.code,
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function streamTransient<K extends keyof AgentDataParts>(ctx: ToolContext, type: K, data: AgentDataParts[K]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Stream file content transiently.
|
|
84
|
+
*/
|
|
85
|
+
export declare function streamFileContent(ctx: ToolContext, path: string, content: string, options?: {
|
|
86
|
+
truncated?: boolean;
|
|
87
|
+
totalBytes?: number;
|
|
88
|
+
language?: string;
|
|
89
|
+
lineRange?: {
|
|
90
|
+
start: number;
|
|
91
|
+
end: number;
|
|
92
|
+
};
|
|
93
|
+
}): void;
|
|
94
|
+
/**
|
|
95
|
+
* Stream shell output transiently.
|
|
96
|
+
*/
|
|
97
|
+
export declare function streamShellOutput(ctx: ToolContext, command: string, output: string, exitCode: number, options?: {
|
|
98
|
+
cwd?: string;
|
|
99
|
+
truncated?: boolean;
|
|
100
|
+
durationMs?: number;
|
|
101
|
+
}): void;
|
|
102
|
+
/**
|
|
103
|
+
* Stream search results transiently.
|
|
104
|
+
*/
|
|
105
|
+
export declare function streamSearchResult(ctx: ToolContext, path: string, content: string, matches: number, options?: {
|
|
106
|
+
line?: number;
|
|
107
|
+
pattern?: string;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* Stream tool progress update transiently.
|
|
111
|
+
*/
|
|
112
|
+
export declare function streamProgress(ctx: ToolContext, toolName: string, progress: number, message: string, options?: {
|
|
113
|
+
estimatedRemaining?: number;
|
|
114
|
+
step?: {
|
|
115
|
+
current: number;
|
|
116
|
+
total: number;
|
|
117
|
+
};
|
|
118
|
+
}): void;
|
|
119
|
+
/**
|
|
120
|
+
* Stream reasoning step transiently.
|
|
121
|
+
*
|
|
122
|
+
* @internal Forward-designed for CLI streaming feature. No production callers yet.
|
|
123
|
+
*/
|
|
124
|
+
export declare function streamReasoningStep(ctx: ToolContext, stepNumber: number, totalSteps: number, thought: string, options?: {
|
|
125
|
+
isRevision?: boolean;
|
|
126
|
+
revisesThought?: number;
|
|
127
|
+
branchId?: string;
|
|
128
|
+
}): void;
|
|
129
|
+
/**
|
|
130
|
+
* Stream sub-agent output transiently.
|
|
131
|
+
*
|
|
132
|
+
* @internal Forward-designed for CLI streaming feature. No production callers yet.
|
|
133
|
+
*/
|
|
134
|
+
export declare function streamSubAgent(ctx: ToolContext, agentId: string, role: string, text: string, status: 'streaming' | 'complete' | 'error', error?: string): void;
|
|
135
|
+
export {};
|
|
136
|
+
//# sourceMappingURL=transient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transient.d.ts","sourceRoot":"","sources":["../../src/streaming/transient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,cAAc,CAAC;AAQhE;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAC/C,4CAA4C;IAC5C,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,cAAc,EACrC,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KACpB,IAAI,CAAC;CACX,CAAC;AAEF;;GAEG;AACH,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAMpC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAQT;AA+CD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,cAAc,EAC3D,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GACtB,IAAI,CAUN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,cAAc,EAC5D,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,cAAc,CAAC,CAA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CACjC,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,EAC1C,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAQN"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Transient Streaming Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Enables tools to stream data to the UI without persisting to conversation context.
|
|
5
|
+
* This keeps the context window lean while providing rich UI feedback.
|
|
6
|
+
*/
|
|
7
|
+
import { createLogger } from '@agntk/logger';
|
|
8
|
+
const log = createLogger('@agntk/core:streaming');
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Main API: withTransientStreaming
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Wrap tools to enable transient streaming.
|
|
14
|
+
*
|
|
15
|
+
* Tools wrapped with this function will have access to a `stream()` helper
|
|
16
|
+
* in their context that allows streaming data to the UI without adding
|
|
17
|
+
* it to the conversation context.
|
|
18
|
+
*
|
|
19
|
+
* @param tools - Record of tools to wrap
|
|
20
|
+
* @param writer - Stream writer for sending data to the client
|
|
21
|
+
* @returns Wrapped tools with transient streaming enabled
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const wrappedTools = withTransientStreaming(myTools, dataStream);
|
|
26
|
+
*
|
|
27
|
+
* // Inside a tool's execute function:
|
|
28
|
+
* execute: async (input, ctx) => {
|
|
29
|
+
* ctx.stream('file-content', {
|
|
30
|
+
* path: input.path,
|
|
31
|
+
* content: fileContent,
|
|
32
|
+
* truncated: false,
|
|
33
|
+
* });
|
|
34
|
+
* return `Read ${input.path}`;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function withTransientStreaming(tools, writer) {
|
|
39
|
+
const wrappedTools = {};
|
|
40
|
+
for (const [name, tool] of Object.entries(tools)) {
|
|
41
|
+
wrappedTools[name] = wrapToolWithTransient(tool, writer, name);
|
|
42
|
+
}
|
|
43
|
+
return wrappedTools;
|
|
44
|
+
}
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Tool Wrapping
|
|
47
|
+
// ============================================================================
|
|
48
|
+
/**
|
|
49
|
+
* Wrap a single tool with transient streaming capabilities.
|
|
50
|
+
*/
|
|
51
|
+
function wrapToolWithTransient(tool, writer, toolName) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
const originalExecute = tool.execute;
|
|
54
|
+
if (!originalExecute) {
|
|
55
|
+
return tool;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
...tool,
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
execute: async (input, options) => {
|
|
61
|
+
// Create enhanced context with streaming helper
|
|
62
|
+
const enhancedContext = {
|
|
63
|
+
...(options || {}),
|
|
64
|
+
agentId: options?.agentId || 'unknown',
|
|
65
|
+
stepNumber: options?.stepNumber || 0,
|
|
66
|
+
writer,
|
|
67
|
+
stream: (type, data) => {
|
|
68
|
+
writeTransient(writer, type, data);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
return originalExecute(input, enhancedContext);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Transient Data Writers
|
|
77
|
+
// ============================================================================
|
|
78
|
+
/**
|
|
79
|
+
* Stream typed transient data to the UI.
|
|
80
|
+
*
|
|
81
|
+
* @param writer - Stream writer instance
|
|
82
|
+
* @param type - Data part type
|
|
83
|
+
* @param data - Data to stream
|
|
84
|
+
*/
|
|
85
|
+
export function writeTransient(writer, type, data) {
|
|
86
|
+
const dataPart = {
|
|
87
|
+
type,
|
|
88
|
+
data,
|
|
89
|
+
};
|
|
90
|
+
writer.writeData({
|
|
91
|
+
...dataPart,
|
|
92
|
+
transient: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Helper for tools to stream transient data from within their execute function.
|
|
97
|
+
*
|
|
98
|
+
* @param ctx - Tool context (must have writer)
|
|
99
|
+
* @param type - Data part type
|
|
100
|
+
* @param data - Data to stream
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Inside a tool's execute function:
|
|
105
|
+
* streamTransient(ctx, 'shell-output', {
|
|
106
|
+
* command: 'npm test',
|
|
107
|
+
* output: result.stdout,
|
|
108
|
+
* exitCode: result.code,
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export function streamTransient(ctx, type, data) {
|
|
113
|
+
// Cast to TransientStreamWriter - they have compatible interfaces
|
|
114
|
+
const writer = ctx.writer;
|
|
115
|
+
if (writer) {
|
|
116
|
+
writeTransient(writer, type, data);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// Specialized Streamers
|
|
121
|
+
// ============================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Stream file content transiently.
|
|
124
|
+
*/
|
|
125
|
+
export function streamFileContent(ctx, path, content, options = {}) {
|
|
126
|
+
streamTransient(ctx, 'file-content', {
|
|
127
|
+
path,
|
|
128
|
+
content,
|
|
129
|
+
truncated: options.truncated ?? false,
|
|
130
|
+
totalBytes: options.totalBytes,
|
|
131
|
+
language: options.language,
|
|
132
|
+
lineRange: options.lineRange,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Stream shell output transiently.
|
|
137
|
+
*/
|
|
138
|
+
export function streamShellOutput(ctx, command, output, exitCode, options = {}) {
|
|
139
|
+
streamTransient(ctx, 'shell-output', {
|
|
140
|
+
command,
|
|
141
|
+
output,
|
|
142
|
+
exitCode,
|
|
143
|
+
cwd: options.cwd,
|
|
144
|
+
truncated: options.truncated,
|
|
145
|
+
durationMs: options.durationMs,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Stream search results transiently.
|
|
150
|
+
*/
|
|
151
|
+
export function streamSearchResult(ctx, path, content, matches, options = {}) {
|
|
152
|
+
streamTransient(ctx, 'search-result', {
|
|
153
|
+
path,
|
|
154
|
+
content,
|
|
155
|
+
matches,
|
|
156
|
+
line: options.line,
|
|
157
|
+
pattern: options.pattern,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Stream tool progress update transiently.
|
|
162
|
+
*/
|
|
163
|
+
export function streamProgress(ctx, toolName, progress, message, options = {}) {
|
|
164
|
+
streamTransient(ctx, 'tool-progress', {
|
|
165
|
+
toolName,
|
|
166
|
+
progress,
|
|
167
|
+
message,
|
|
168
|
+
estimatedRemaining: options.estimatedRemaining,
|
|
169
|
+
step: options.step,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Stream reasoning step transiently.
|
|
174
|
+
*
|
|
175
|
+
* @internal Forward-designed for CLI streaming feature. No production callers yet.
|
|
176
|
+
*/
|
|
177
|
+
export function streamReasoningStep(ctx, stepNumber, totalSteps, thought, options = {}) {
|
|
178
|
+
streamTransient(ctx, 'reasoning-step', {
|
|
179
|
+
stepNumber,
|
|
180
|
+
totalSteps,
|
|
181
|
+
thought,
|
|
182
|
+
isRevision: options.isRevision,
|
|
183
|
+
revisesThought: options.revisesThought,
|
|
184
|
+
branchId: options.branchId,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Stream sub-agent output transiently.
|
|
189
|
+
*
|
|
190
|
+
* @internal Forward-designed for CLI streaming feature. No production callers yet.
|
|
191
|
+
*/
|
|
192
|
+
export function streamSubAgent(ctx, agentId, role, text, status, error) {
|
|
193
|
+
streamTransient(ctx, 'sub-agent-stream', {
|
|
194
|
+
agentId,
|
|
195
|
+
role,
|
|
196
|
+
text,
|
|
197
|
+
status,
|
|
198
|
+
error,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=transient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transient.js","sourceRoot":"","sources":["../../src/streaming/transient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7C,MAAM,GAAG,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AA+BlD,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAc,EACd,MAA6B;IAE7B,MAAM,YAAY,GAAY,EAAE,CAAC;IAEjC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,YAAY,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,qBAAqB,CAC5B,IAAU,EACV,MAA6B,EAC7B,QAAgB;IAEhB,8DAA8D;IAC9D,MAAM,eAAe,GAAI,IAAY,CAAC,OAAO,CAAC;IAC9C,IAAI,CAAC,eAAe,EAAE,CAAC;QACr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EAClB,UAAkB,EAClB,OAAe,EACf,UAII,EAAE;IAEN,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE;QACrC,UAAU;QACV,UAAU;QACV,OAAO;QACP,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAgB,EAChB,OAAe,EACf,IAAY,EACZ,IAAY,EACZ,MAA0C,EAC1C,KAAc;IAEd,eAAe,CAAC,GAAG,EAAE,kBAAkB,EAAE;QACvC,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview System hardware detection for automatic Ollama model selection.
|
|
3
|
+
*
|
|
4
|
+
* Detects available RAM/VRAM and selects the largest Qwen3 model the system
|
|
5
|
+
* can comfortably run. Falls back conservatively — better to run a smaller
|
|
6
|
+
* model fast than a larger model that swaps to disk.
|
|
7
|
+
*
|
|
8
|
+
* Memory thresholds (Q4_K_M quantization):
|
|
9
|
+
* qwen3:8b ~5-6 GB → needs ≥8 GB total RAM
|
|
10
|
+
* qwen3:14b ~8-10 GB → needs ≥16 GB total RAM
|
|
11
|
+
* qwen3:32b ~18-22 GB → needs ≥32 GB total RAM
|
|
12
|
+
*/
|
|
13
|
+
export interface SystemProfile {
|
|
14
|
+
/** Total system RAM in GB */
|
|
15
|
+
totalRAMGb: number;
|
|
16
|
+
/** Usable memory for models in GB (accounts for OS overhead + GPU sharing) */
|
|
17
|
+
usableForModelsGb: number;
|
|
18
|
+
/** Platform: darwin, linux, win32 */
|
|
19
|
+
platform: string;
|
|
20
|
+
/** Whether this is Apple Silicon (unified memory architecture) */
|
|
21
|
+
isAppleSilicon: boolean;
|
|
22
|
+
/** NVIDIA VRAM in GB, if detected */
|
|
23
|
+
nvidiaVRAMGb: number | null;
|
|
24
|
+
}
|
|
25
|
+
export type OllamaModelTier = 'small' | 'medium' | 'large';
|
|
26
|
+
export interface OllamaModelRecommendation {
|
|
27
|
+
/** Recommended tier */
|
|
28
|
+
tier: OllamaModelTier;
|
|
29
|
+
/** Model tag to pull/use (e.g. "qwen3:8b") */
|
|
30
|
+
fast: string;
|
|
31
|
+
standard: string;
|
|
32
|
+
reasoning: string;
|
|
33
|
+
powerful: string;
|
|
34
|
+
/** Human-readable reason */
|
|
35
|
+
reason: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Detect system hardware profile.
|
|
39
|
+
*/
|
|
40
|
+
export declare function detectSystem(): SystemProfile;
|
|
41
|
+
/**
|
|
42
|
+
* Select the best Ollama model tier based on system capabilities.
|
|
43
|
+
*
|
|
44
|
+
* Thresholds (usable memory for the model weights):
|
|
45
|
+
* < 6 GB → too small, warn user
|
|
46
|
+
* 6-10 GB → small (qwen3:8b everywhere)
|
|
47
|
+
* 10-18 GB → medium (qwen3:14b for standard+)
|
|
48
|
+
* 18+ GB → large (qwen3:32b for reasoning/powerful)
|
|
49
|
+
*/
|
|
50
|
+
export declare function recommendOllamaModels(profile?: SystemProfile): OllamaModelRecommendation;
|
|
51
|
+
/**
|
|
52
|
+
* Check which models Ollama already has pulled.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getOllamaModels(baseUrl?: string): Promise<string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Check if a specific model is available in Ollama.
|
|
57
|
+
*/
|
|
58
|
+
export declare function hasOllamaModel(model: string, baseUrl?: string): Promise<boolean>;
|
|
59
|
+
//# sourceMappingURL=system-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-detect.d.ts","sourceRoot":"","sources":["../src/system-detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,cAAc,EAAE,OAAO,CAAC;IACxB,qCAAqC;IACrC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,yBAAyB;IACxC,uBAAuB;IACvB,IAAI,EAAE,eAAe,CAAC;IACtB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAqED;;GAEG;AACH,wBAAgB,YAAY,IAAI,aAAa,CAuC5C;AAMD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,yBAAyB,CA8BxF;AAMD;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBzE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKtF"}
|