portercode 0.1.4 → 0.1.11
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/LICENSE +174 -21
- package/README.md +162 -68
- package/dist/auth/index.d.ts +99 -0
- package/dist/brand/index.d.ts +7 -0
- package/dist/brand/loader.d.ts +463 -0
- package/dist/brand/rules.d.ts +25 -0
- package/dist/brand/schema.d.ts +246 -0
- package/dist/cli/auth.d.ts +14 -2
- package/dist/cli/brand.d.ts +6 -0
- package/dist/config/config.d.ts +0 -720
- package/dist/constants/index.d.ts +6 -9
- package/dist/constants/version.d.ts +5 -0
- package/dist/gateway/index.d.ts +5 -4
- package/dist/global/index.d.ts +12 -0
- package/dist/index.js +39 -1
- package/dist/prompt/template.d.ts +24 -0
- package/dist/provider/models.d.ts +0 -3
- package/dist/provider/provider.d.ts +5 -1
- package/dist/server/services/agent.d.ts +11 -0
- package/dist/session/context-cache.d.ts +75 -0
- package/dist/session/context-optimization.d.ts +5 -0
- package/dist/session/llm.d.ts +38 -1
- package/dist/session/message-optimizer.d.ts +32 -0
- package/dist/session/session.d.ts +101 -9
- package/dist/session/types.d.ts +92 -16
- package/dist/src/auth/index.d.ts +202 -0
- package/dist/src/brand/index.d.ts +7 -0
- package/dist/src/bus/bus-event.d.ts +10 -0
- package/dist/src/bus/global.d.ts +7 -0
- package/dist/src/bus/index.d.ts +26 -0
- package/dist/src/cli/auth.d.ts +23 -0
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/ui.d.ts +26 -0
- package/dist/src/command/index.d.ts +54 -0
- package/dist/src/config/config.d.ts +6036 -0
- package/dist/src/config/index.d.ts +2 -0
- package/dist/src/config/markdown.d.ts +415 -0
- package/dist/src/constants/index.d.ts +6 -0
- package/dist/src/constants/version.d.ts +5 -0
- package/dist/src/diff/engine.d.ts +15 -0
- package/dist/src/diff/index.d.ts +8 -0
- package/dist/src/diff/types.d.ts +66 -0
- package/dist/src/file/ignore.d.ts +7 -0
- package/dist/src/flag/index.d.ts +19 -0
- package/dist/src/gateway/bridge.d.ts +11 -0
- package/dist/src/gateway/handlers/llm.d.ts +7 -0
- package/dist/src/gateway/handlers/permission.d.ts +15 -0
- package/dist/src/gateway/handlers/session.d.ts +7 -0
- package/dist/src/gateway/handlers/system.d.ts +7 -0
- package/dist/src/gateway/handlers/tool.d.ts +7 -0
- package/dist/src/gateway/index.d.ts +18 -0
- package/dist/src/gateway/protocol.d.ts +159 -0
- package/dist/src/gateway/router.d.ts +7 -0
- package/dist/src/gateway/server.d.ts +24 -0
- package/dist/src/global/index.d.ts +23 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/permission/index.d.ts +2 -0
- package/dist/src/permission/permission.d.ts +172 -0
- package/dist/src/permission/types.d.ts +109 -0
- package/dist/src/project/index.d.ts +3 -0
- package/dist/src/project/instance.d.ts +33 -0
- package/dist/src/project/project.d.ts +82 -0
- package/dist/src/project/state.d.ts +4 -0
- package/dist/src/prompt/index.d.ts +5 -0
- package/dist/src/prompt/system.d.ts +29 -0
- package/dist/src/prompt/template.d.ts +24 -0
- package/dist/src/provider/index.d.ts +3 -0
- package/dist/src/provider/models.d.ts +14 -0
- package/dist/src/provider/provider.d.ts +848 -0
- package/dist/src/provider/types.d.ts +328 -0
- package/dist/src/server/index.d.ts +21 -0
- package/dist/src/server/routes/api.d.ts +2 -0
- package/dist/src/server/routes/auth.d.ts +2 -0
- package/dist/src/server/routes/events.d.ts +2 -0
- package/dist/src/server/routes/health.d.ts +2 -0
- package/dist/src/server/routes/sessions.d.ts +2 -0
- package/dist/src/server/services/agent.d.ts +40 -0
- package/dist/src/server/services/permission.d.ts +43 -0
- package/dist/src/server/sse/emitter.d.ts +57 -0
- package/dist/src/session/context-cache.d.ts +75 -0
- package/dist/src/session/context-optimization.d.ts +165 -0
- package/dist/src/session/index.d.ts +5 -0
- package/dist/src/session/llm.d.ts +68 -0
- package/dist/src/session/message-optimizer.d.ts +32 -0
- package/dist/src/session/session.d.ts +524 -0
- package/dist/src/session/title-generator.d.ts +11 -0
- package/dist/src/session/types.d.ts +713 -0
- package/dist/src/snapshot/index.d.ts +40 -0
- package/dist/src/storage/index.d.ts +1 -0
- package/dist/src/storage/storage.d.ts +34 -0
- package/dist/src/theme.d.ts +66 -0
- package/dist/src/tool/bash.d.ts +19 -0
- package/dist/src/tool/edit.d.ts +21 -0
- package/dist/src/tool/glob.d.ts +15 -0
- package/dist/src/tool/grep.d.ts +20 -0
- package/dist/src/tool/image.d.ts +22 -0
- package/dist/src/tool/index.d.ts +11 -0
- package/dist/src/tool/ls.d.ts +14 -0
- package/dist/src/tool/read.d.ts +17 -0
- package/dist/src/tool/registry.d.ts +30 -0
- package/dist/src/tool/think.d.ts +11 -0
- package/dist/src/tool/todo.d.ts +76 -0
- package/dist/src/tool/tool.d.ts +65 -0
- package/dist/src/tool/webfetch.d.ts +15 -0
- package/dist/src/tool/websearch.d.ts +18 -0
- package/dist/src/tool/write.d.ts +16 -0
- package/dist/src/tui/App.d.ts +10 -0
- package/dist/src/tui/components/Header.d.ts +13 -0
- package/dist/src/tui/components/LoadingIndicator.d.ts +26 -0
- package/dist/src/tui/components/Message/AssistantMessage.d.ts +11 -0
- package/dist/src/tui/components/Message/ReasoningMessage.d.ts +21 -0
- package/dist/src/tui/components/Message/ToolCallMessage.d.ts +26 -0
- package/dist/src/tui/components/Message/UserMessage.d.ts +12 -0
- package/dist/src/tui/components/Message/index.d.ts +16 -0
- package/dist/src/tui/components/PermissionPrompt.d.ts +6 -0
- package/dist/src/tui/components/PromptInput.d.ts +33 -0
- package/dist/src/tui/components/REPL.d.ts +22 -0
- package/dist/src/tui/components/Spinner.d.ts +13 -0
- package/dist/src/tui/components/StatusBar.d.ts +13 -0
- package/dist/src/tui/components/TodoList.d.ts +17 -0
- package/dist/src/tui/components/WelcomeBox.d.ts +13 -0
- package/dist/src/tui/components/dialogs/DiagnosticsPanel.d.ts +12 -0
- package/dist/src/tui/components/dialogs/HelpPanel.d.ts +11 -0
- package/dist/src/tui/components/dialogs/ModelSelector.d.ts +14 -0
- package/dist/src/tui/components/dialogs/PermissionPrompt.d.ts +17 -0
- package/dist/src/tui/components/dialogs/SessionPicker.d.ts +20 -0
- package/dist/src/tui/components/dialogs/index.d.ts +10 -0
- package/dist/src/tui/components/diff/DiffHunk.d.ts +12 -0
- package/dist/src/tui/components/diff/DiffLine.d.ts +14 -0
- package/dist/src/tui/components/diff/DiffStats.d.ts +12 -0
- package/dist/src/tui/components/diff/DiffView.d.ts +15 -0
- package/dist/src/tui/components/diff/index.d.ts +9 -0
- package/dist/src/tui/hooks/useAnimatedLabel.d.ts +12 -0
- package/dist/src/tui/hooks/usePermission.d.ts +34 -0
- package/dist/src/tui/hooks/useTermWidth.d.ts +13 -0
- package/dist/src/tui/index.d.ts +20 -0
- package/dist/src/tui/theme.d.ts +8 -0
- package/dist/src/tui/utils/Cursor.d.ts +37 -0
- package/dist/src/tui/utils/clipboard.d.ts +3 -0
- package/dist/src/tui/utils/keypress.d.ts +39 -0
- package/dist/src/tui/utils/markdown.d.ts +13 -0
- package/dist/src/tui/utils/openContent.d.ts +22 -0
- package/dist/src/util/ascii.d.ts +22 -0
- package/dist/src/util/bell.d.ts +14 -0
- package/dist/src/util/color.d.ts +28 -0
- package/dist/src/util/context.d.ts +10 -0
- package/dist/src/util/debug.d.ts +51 -0
- package/dist/src/util/error.d.ts +294 -0
- package/dist/src/util/example-commands.d.ts +18 -0
- package/dist/src/util/filesystem.d.ts +17 -0
- package/dist/src/util/id.d.ts +24 -0
- package/dist/src/util/iife.d.ts +1 -0
- package/dist/src/util/index.d.ts +7 -0
- package/dist/src/util/lazy.d.ts +1 -0
- package/dist/src/util/log.d.ts +26 -0
- package/dist/src/util/paths.d.ts +45 -0
- package/dist/src/util/shell.d.ts +36 -0
- package/dist/src/util/timeout.d.ts +1 -0
- package/dist/src/util/wildcard.d.ts +8 -0
- package/dist/theme.d.ts +64 -0
- package/dist/tool/image.d.ts +3 -4
- package/dist/tool/think.d.ts +11 -0
- package/dist/tool/webfetch.d.ts +15 -0
- package/dist/tool/websearch.d.ts +18 -0
- package/dist/tools/think.d.ts +2 -0
- package/dist/tui/App.d.ts +1 -1
- package/dist/tui/components/Header.d.ts +2 -1
- package/dist/tui/components/LoadingIndicator.d.ts +26 -0
- package/dist/tui/components/Message/AssistantMessage.d.ts +2 -1
- package/dist/tui/components/Message/ReasoningMessage.d.ts +2 -1
- package/dist/tui/components/Message/ToolCallMessage.d.ts +3 -2
- package/dist/tui/components/Message/UserMessage.d.ts +2 -1
- package/dist/tui/components/Message/index.d.ts +4 -1
- package/dist/tui/components/PromptInput.d.ts +2 -1
- package/dist/tui/components/REPL.d.ts +6 -1
- package/dist/tui/components/StatusBar.d.ts +2 -1
- package/dist/tui/components/dialogs/SessionPicker.d.ts +6 -1
- package/dist/tui/hooks/useAnimatedLabel.d.ts +12 -0
- package/dist/tui/hooks/usePermission.d.ts +9 -1
- package/dist/tui/hooks/useTermWidth.d.ts +13 -0
- package/dist/tui/index.d.ts +5 -0
- package/dist/tui/theme.d.ts +4 -23
- package/dist/util/ascii.d.ts +22 -0
- package/dist/util/bell.d.ts +14 -0
- package/dist/util/color.d.ts +28 -0
- package/dist/util/paths.d.ts +45 -0
- package/dist/util/shell.d.ts +36 -0
- package/package.json +21 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Template System
|
|
3
|
+
*
|
|
4
|
+
* Replaces brand placeholders in prompt templates with actual brand values
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace PromptTemplate {
|
|
7
|
+
/**
|
|
8
|
+
* Render a prompt template by replacing brand placeholders
|
|
9
|
+
*
|
|
10
|
+
* Supported placeholders:
|
|
11
|
+
* - {PRODUCT_NAME} - Product name (e.g., "Porter")
|
|
12
|
+
* - {PRODUCT_COMMAND} - Command name (e.g., "porter")
|
|
13
|
+
* - {CONFIG_DIR} - Config directory (e.g., ".porter")
|
|
14
|
+
* - {CONFIG_FILE} - Config file (e.g., "porter.jsonc")
|
|
15
|
+
* - {RULES_FILE} - Rules file (e.g., "PORTER.md")
|
|
16
|
+
* - {ENV_PREFIX} - Environment variable prefix (e.g., "PORTER_")
|
|
17
|
+
*/
|
|
18
|
+
function render(template: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Render a prompt template synchronously
|
|
21
|
+
* @deprecated Use render() instead - it's now synchronous
|
|
22
|
+
*/
|
|
23
|
+
function renderSync(template: string): string;
|
|
24
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import type { LanguageModel } from "ai";
|
|
2
|
+
import type { LanguageModel, ImageModel } from "ai";
|
|
3
3
|
import type { ModelInfo, ProviderInfo } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Provider System
|
|
@@ -20,6 +20,10 @@ export declare namespace Provider {
|
|
|
20
20
|
* Get a language model instance
|
|
21
21
|
*/
|
|
22
22
|
function getLanguageModel(providerId: string, modelId: string): Promise<LanguageModel>;
|
|
23
|
+
/**
|
|
24
|
+
* Get an image model instance
|
|
25
|
+
*/
|
|
26
|
+
function getImageModel(providerId: string, modelId: string): Promise<ImageModel>;
|
|
23
27
|
/**
|
|
24
28
|
* Get model info
|
|
25
29
|
*/
|
|
@@ -26,4 +26,15 @@ export declare namespace AgentService {
|
|
|
26
26
|
* Cancel an active generation
|
|
27
27
|
*/
|
|
28
28
|
function cancel(sessionId: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optimize context for a session by generating a summary
|
|
31
|
+
*/
|
|
32
|
+
function optimizeContext(options: {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
requestId: string;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Cancel an active context optimization
|
|
38
|
+
*/
|
|
39
|
+
function cancelOptimization(sessionId: string): boolean;
|
|
29
40
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Memoization Cache
|
|
3
|
+
*
|
|
4
|
+
* Caches frequently-accessed context information to reduce redundant tool calls:
|
|
5
|
+
* - Git status
|
|
6
|
+
* - README contents
|
|
7
|
+
* - Directory structure
|
|
8
|
+
*
|
|
9
|
+
* Cache is cleared when:
|
|
10
|
+
* - /optimize command is executed
|
|
11
|
+
* - Session is restarted
|
|
12
|
+
* - Manual invalidation
|
|
13
|
+
*/
|
|
14
|
+
export interface CachedContext {
|
|
15
|
+
gitStatus?: {
|
|
16
|
+
output: string;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
};
|
|
19
|
+
readme?: {
|
|
20
|
+
content: string;
|
|
21
|
+
path: string;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
};
|
|
24
|
+
dirStructure?: {
|
|
25
|
+
output: string;
|
|
26
|
+
depth: number;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Context Cache - Memoizes expensive context operations
|
|
32
|
+
*/
|
|
33
|
+
export declare class ContextCache {
|
|
34
|
+
private static cache;
|
|
35
|
+
private static sessionCaches;
|
|
36
|
+
/**
|
|
37
|
+
* Get cached value for a session
|
|
38
|
+
*/
|
|
39
|
+
static get<T>(sessionId: string, key: string): T | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Set cached value for a session
|
|
42
|
+
*/
|
|
43
|
+
static set<T>(sessionId: string, key: string, value: T): void;
|
|
44
|
+
/**
|
|
45
|
+
* Check if key exists in cache
|
|
46
|
+
*/
|
|
47
|
+
static has(sessionId: string, key: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Clear cache for specific session
|
|
50
|
+
*/
|
|
51
|
+
static clearSession(sessionId: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Clear specific key for session
|
|
54
|
+
*/
|
|
55
|
+
static clearKey(sessionId: string, key: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Clear all caches
|
|
58
|
+
*/
|
|
59
|
+
static clearAll(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get cache statistics
|
|
62
|
+
*/
|
|
63
|
+
static stats(): {
|
|
64
|
+
sessions: number;
|
|
65
|
+
totalEntries: number;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Cache keys for common context operations
|
|
70
|
+
*/
|
|
71
|
+
export declare const CacheKeys: {
|
|
72
|
+
readonly GIT_STATUS: "git:status";
|
|
73
|
+
readonly README: "readme:content";
|
|
74
|
+
readonly DIR_STRUCTURE: "dir:structure";
|
|
75
|
+
};
|
|
@@ -156,5 +156,10 @@ export declare const ContextOptimization: {
|
|
|
156
156
|
* Create a compacted message from a summary
|
|
157
157
|
*/
|
|
158
158
|
createCompactedMessage(summary: string): CompactedMessage;
|
|
159
|
+
/**
|
|
160
|
+
* Generate a summary of messages using LLM
|
|
161
|
+
* Always uses Sonnet 4.5 for cost efficiency
|
|
162
|
+
*/
|
|
163
|
+
compact(messages: SimpleMessage[]): Promise<CompactedMessage>;
|
|
159
164
|
};
|
|
160
165
|
export type { OverflowCheckOptions as ContextOverflowOptions };
|
package/dist/session/llm.d.ts
CHANGED
|
@@ -22,10 +22,47 @@ export declare namespace LLM {
|
|
|
22
22
|
*/
|
|
23
23
|
function stream(options: StreamOptions): Promise<ReturnType<typeof streamText>>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Token usage breakdown including cache-specific counts
|
|
26
|
+
*/
|
|
27
|
+
interface TokenUsage {
|
|
28
|
+
/** Regular input tokens (not from cache) */
|
|
29
|
+
input: number;
|
|
30
|
+
/** Output tokens generated */
|
|
31
|
+
output: number;
|
|
32
|
+
/** Tokens read from cache (cache hits) */
|
|
33
|
+
cacheRead: number;
|
|
34
|
+
/** Tokens written to cache (cache creation) */
|
|
35
|
+
cacheWrite: number;
|
|
36
|
+
/** Total tokens (input + output + cache operations) */
|
|
37
|
+
total: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Count tokens including cache-specific breakdown
|
|
41
|
+
*/
|
|
42
|
+
function countTokens(usage: {
|
|
43
|
+
inputTokens?: number;
|
|
44
|
+
outputTokens?: number;
|
|
45
|
+
cachedInputTokens?: number;
|
|
46
|
+
cacheCreationInputTokens?: number;
|
|
47
|
+
}): TokenUsage;
|
|
48
|
+
/**
|
|
49
|
+
* Count only cached tokens (reads and writes)
|
|
50
|
+
*/
|
|
51
|
+
function countCachedTokens(usage: {
|
|
52
|
+
cachedInputTokens?: number;
|
|
53
|
+
cacheCreationInputTokens?: number;
|
|
54
|
+
}): {
|
|
55
|
+
read: number;
|
|
56
|
+
write: number;
|
|
57
|
+
total: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Calculate token usage cost including cache tokens
|
|
26
61
|
*/
|
|
27
62
|
function calculateCost(model: ModelInfo, usage: {
|
|
28
63
|
inputTokens?: number;
|
|
29
64
|
outputTokens?: number;
|
|
65
|
+
cachedInputTokens?: number;
|
|
66
|
+
cacheCreationInputTokens?: number;
|
|
30
67
|
}): number;
|
|
31
68
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Optimization Module
|
|
3
|
+
*
|
|
4
|
+
* Optimizes messages before sending to LLM:
|
|
5
|
+
* - Merges consecutive tool_results to reduce message count
|
|
6
|
+
* - Filters out progress messages that add noise
|
|
7
|
+
*/
|
|
8
|
+
import type { ModelMessage } from "ai";
|
|
9
|
+
/**
|
|
10
|
+
* Merge consecutive tool result messages
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeToolResults(messages: ModelMessage[]): ModelMessage[];
|
|
13
|
+
/**
|
|
14
|
+
* Filter out progress messages
|
|
15
|
+
*/
|
|
16
|
+
export declare function filterProgressMessages(messages: ModelMessage[]): ModelMessage[];
|
|
17
|
+
/**
|
|
18
|
+
* Optimize messages for LLM
|
|
19
|
+
*/
|
|
20
|
+
export declare function optimizeMessages(messages: ModelMessage[], options?: {
|
|
21
|
+
mergeToolResults?: boolean;
|
|
22
|
+
filterProgress?: boolean;
|
|
23
|
+
}): ModelMessage[];
|
|
24
|
+
/**
|
|
25
|
+
* Statistics about message optimization
|
|
26
|
+
*/
|
|
27
|
+
export declare function getOptimizationStats(original: ModelMessage[], optimized: ModelMessage[]): {
|
|
28
|
+
originalCount: number;
|
|
29
|
+
optimizedCount: number;
|
|
30
|
+
reduction: number;
|
|
31
|
+
reductionPercent: number;
|
|
32
|
+
};
|
|
@@ -21,6 +21,11 @@ export declare namespace Session {
|
|
|
21
21
|
createdAt: number;
|
|
22
22
|
updatedAt: number;
|
|
23
23
|
parentId?: string | undefined;
|
|
24
|
+
promptHistory?: string[] | undefined;
|
|
25
|
+
tokens?: {
|
|
26
|
+
input: number;
|
|
27
|
+
output: number;
|
|
28
|
+
} | undefined;
|
|
24
29
|
}, z.ZodTypeDef, {
|
|
25
30
|
id: string;
|
|
26
31
|
directory: string;
|
|
@@ -29,6 +34,11 @@ export declare namespace Session {
|
|
|
29
34
|
createdAt: number;
|
|
30
35
|
updatedAt: number;
|
|
31
36
|
parentId?: string | undefined;
|
|
37
|
+
promptHistory?: string[] | undefined;
|
|
38
|
+
tokens?: {
|
|
39
|
+
input: number;
|
|
40
|
+
output: number;
|
|
41
|
+
} | undefined;
|
|
32
42
|
}>;
|
|
33
43
|
}, "strip", z.ZodTypeAny, {
|
|
34
44
|
info: {
|
|
@@ -39,6 +49,11 @@ export declare namespace Session {
|
|
|
39
49
|
createdAt: number;
|
|
40
50
|
updatedAt: number;
|
|
41
51
|
parentId?: string | undefined;
|
|
52
|
+
promptHistory?: string[] | undefined;
|
|
53
|
+
tokens?: {
|
|
54
|
+
input: number;
|
|
55
|
+
output: number;
|
|
56
|
+
} | undefined;
|
|
42
57
|
};
|
|
43
58
|
}, {
|
|
44
59
|
info: {
|
|
@@ -49,6 +64,11 @@ export declare namespace Session {
|
|
|
49
64
|
createdAt: number;
|
|
50
65
|
updatedAt: number;
|
|
51
66
|
parentId?: string | undefined;
|
|
67
|
+
promptHistory?: string[] | undefined;
|
|
68
|
+
tokens?: {
|
|
69
|
+
input: number;
|
|
70
|
+
output: number;
|
|
71
|
+
} | undefined;
|
|
52
72
|
};
|
|
53
73
|
}>;
|
|
54
74
|
};
|
|
@@ -63,6 +83,11 @@ export declare namespace Session {
|
|
|
63
83
|
createdAt: number;
|
|
64
84
|
updatedAt: number;
|
|
65
85
|
parentId?: string | undefined;
|
|
86
|
+
promptHistory?: string[] | undefined;
|
|
87
|
+
tokens?: {
|
|
88
|
+
input: number;
|
|
89
|
+
output: number;
|
|
90
|
+
} | undefined;
|
|
66
91
|
}, z.ZodTypeDef, {
|
|
67
92
|
id: string;
|
|
68
93
|
directory: string;
|
|
@@ -71,6 +96,11 @@ export declare namespace Session {
|
|
|
71
96
|
createdAt: number;
|
|
72
97
|
updatedAt: number;
|
|
73
98
|
parentId?: string | undefined;
|
|
99
|
+
promptHistory?: string[] | undefined;
|
|
100
|
+
tokens?: {
|
|
101
|
+
input: number;
|
|
102
|
+
output: number;
|
|
103
|
+
} | undefined;
|
|
74
104
|
}>;
|
|
75
105
|
}, "strip", z.ZodTypeAny, {
|
|
76
106
|
info: {
|
|
@@ -81,6 +111,11 @@ export declare namespace Session {
|
|
|
81
111
|
createdAt: number;
|
|
82
112
|
updatedAt: number;
|
|
83
113
|
parentId?: string | undefined;
|
|
114
|
+
promptHistory?: string[] | undefined;
|
|
115
|
+
tokens?: {
|
|
116
|
+
input: number;
|
|
117
|
+
output: number;
|
|
118
|
+
} | undefined;
|
|
84
119
|
};
|
|
85
120
|
}, {
|
|
86
121
|
info: {
|
|
@@ -91,6 +126,11 @@ export declare namespace Session {
|
|
|
91
126
|
createdAt: number;
|
|
92
127
|
updatedAt: number;
|
|
93
128
|
parentId?: string | undefined;
|
|
129
|
+
promptHistory?: string[] | undefined;
|
|
130
|
+
tokens?: {
|
|
131
|
+
input: number;
|
|
132
|
+
output: number;
|
|
133
|
+
} | undefined;
|
|
94
134
|
};
|
|
95
135
|
}>;
|
|
96
136
|
};
|
|
@@ -105,6 +145,11 @@ export declare namespace Session {
|
|
|
105
145
|
createdAt: number;
|
|
106
146
|
updatedAt: number;
|
|
107
147
|
parentId?: string | undefined;
|
|
148
|
+
promptHistory?: string[] | undefined;
|
|
149
|
+
tokens?: {
|
|
150
|
+
input: number;
|
|
151
|
+
output: number;
|
|
152
|
+
} | undefined;
|
|
108
153
|
}, z.ZodTypeDef, {
|
|
109
154
|
id: string;
|
|
110
155
|
directory: string;
|
|
@@ -113,6 +158,11 @@ export declare namespace Session {
|
|
|
113
158
|
createdAt: number;
|
|
114
159
|
updatedAt: number;
|
|
115
160
|
parentId?: string | undefined;
|
|
161
|
+
promptHistory?: string[] | undefined;
|
|
162
|
+
tokens?: {
|
|
163
|
+
input: number;
|
|
164
|
+
output: number;
|
|
165
|
+
} | undefined;
|
|
116
166
|
}>;
|
|
117
167
|
}, "strip", z.ZodTypeAny, {
|
|
118
168
|
info: {
|
|
@@ -123,6 +173,11 @@ export declare namespace Session {
|
|
|
123
173
|
createdAt: number;
|
|
124
174
|
updatedAt: number;
|
|
125
175
|
parentId?: string | undefined;
|
|
176
|
+
promptHistory?: string[] | undefined;
|
|
177
|
+
tokens?: {
|
|
178
|
+
input: number;
|
|
179
|
+
output: number;
|
|
180
|
+
} | undefined;
|
|
126
181
|
};
|
|
127
182
|
}, {
|
|
128
183
|
info: {
|
|
@@ -133,6 +188,11 @@ export declare namespace Session {
|
|
|
133
188
|
createdAt: number;
|
|
134
189
|
updatedAt: number;
|
|
135
190
|
parentId?: string | undefined;
|
|
191
|
+
promptHistory?: string[] | undefined;
|
|
192
|
+
tokens?: {
|
|
193
|
+
input: number;
|
|
194
|
+
output: number;
|
|
195
|
+
} | undefined;
|
|
136
196
|
};
|
|
137
197
|
}>;
|
|
138
198
|
};
|
|
@@ -201,21 +261,24 @@ export declare namespace Session {
|
|
|
201
261
|
sessionId: string;
|
|
202
262
|
content: string;
|
|
203
263
|
messageId: string;
|
|
264
|
+
sequence?: number | undefined;
|
|
204
265
|
} | {
|
|
205
266
|
type: "reasoning";
|
|
206
267
|
id: string;
|
|
207
268
|
sessionId: string;
|
|
208
269
|
content: string;
|
|
209
270
|
messageId: string;
|
|
271
|
+
sequence?: number | undefined;
|
|
210
272
|
} | {
|
|
273
|
+
state: "completed" | "pending" | "running" | "failed";
|
|
211
274
|
type: "tool-call";
|
|
212
275
|
id: string;
|
|
213
|
-
state: "completed" | "pending" | "running" | "failed";
|
|
214
276
|
input: Record<string, any>;
|
|
215
277
|
sessionId: string;
|
|
216
278
|
toolId: string;
|
|
217
279
|
messageId: string;
|
|
218
280
|
toolName: string;
|
|
281
|
+
sequence?: number | undefined;
|
|
219
282
|
} | {
|
|
220
283
|
type: "tool-result";
|
|
221
284
|
id: string;
|
|
@@ -224,15 +287,17 @@ export declare namespace Session {
|
|
|
224
287
|
messageId: string;
|
|
225
288
|
toolCallId: string;
|
|
226
289
|
input?: Record<string, any> | undefined;
|
|
290
|
+
sequence?: number | undefined;
|
|
227
291
|
toolName?: string | undefined;
|
|
228
292
|
metadata?: Record<string, any> | undefined;
|
|
229
293
|
} | {
|
|
230
294
|
type: "image";
|
|
231
295
|
id: string;
|
|
296
|
+
data: string;
|
|
232
297
|
sessionId: string;
|
|
233
298
|
messageId: string;
|
|
234
299
|
mimeType: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
|
|
235
|
-
|
|
300
|
+
sequence?: number | undefined;
|
|
236
301
|
filename?: string | undefined;
|
|
237
302
|
}, z.ZodTypeDef, {
|
|
238
303
|
type: "text";
|
|
@@ -240,21 +305,24 @@ export declare namespace Session {
|
|
|
240
305
|
sessionId: string;
|
|
241
306
|
content: string;
|
|
242
307
|
messageId: string;
|
|
308
|
+
sequence?: number | undefined;
|
|
243
309
|
} | {
|
|
244
310
|
type: "reasoning";
|
|
245
311
|
id: string;
|
|
246
312
|
sessionId: string;
|
|
247
313
|
content: string;
|
|
248
314
|
messageId: string;
|
|
315
|
+
sequence?: number | undefined;
|
|
249
316
|
} | {
|
|
317
|
+
state: "completed" | "pending" | "running" | "failed";
|
|
250
318
|
type: "tool-call";
|
|
251
319
|
id: string;
|
|
252
|
-
state: "completed" | "pending" | "running" | "failed";
|
|
253
320
|
input: Record<string, any>;
|
|
254
321
|
sessionId: string;
|
|
255
322
|
toolId: string;
|
|
256
323
|
messageId: string;
|
|
257
324
|
toolName: string;
|
|
325
|
+
sequence?: number | undefined;
|
|
258
326
|
} | {
|
|
259
327
|
type: "tool-result";
|
|
260
328
|
id: string;
|
|
@@ -263,15 +331,17 @@ export declare namespace Session {
|
|
|
263
331
|
messageId: string;
|
|
264
332
|
toolCallId: string;
|
|
265
333
|
input?: Record<string, any> | undefined;
|
|
334
|
+
sequence?: number | undefined;
|
|
266
335
|
toolName?: string | undefined;
|
|
267
336
|
metadata?: Record<string, any> | undefined;
|
|
268
337
|
} | {
|
|
269
338
|
type: "image";
|
|
270
339
|
id: string;
|
|
340
|
+
data: string;
|
|
271
341
|
sessionId: string;
|
|
272
342
|
messageId: string;
|
|
273
343
|
mimeType: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
|
|
274
|
-
|
|
344
|
+
sequence?: number | undefined;
|
|
275
345
|
filename?: string | undefined;
|
|
276
346
|
}>;
|
|
277
347
|
delta: z.ZodOptional<z.ZodString>;
|
|
@@ -282,21 +352,24 @@ export declare namespace Session {
|
|
|
282
352
|
sessionId: string;
|
|
283
353
|
content: string;
|
|
284
354
|
messageId: string;
|
|
355
|
+
sequence?: number | undefined;
|
|
285
356
|
} | {
|
|
286
357
|
type: "reasoning";
|
|
287
358
|
id: string;
|
|
288
359
|
sessionId: string;
|
|
289
360
|
content: string;
|
|
290
361
|
messageId: string;
|
|
362
|
+
sequence?: number | undefined;
|
|
291
363
|
} | {
|
|
364
|
+
state: "completed" | "pending" | "running" | "failed";
|
|
292
365
|
type: "tool-call";
|
|
293
366
|
id: string;
|
|
294
|
-
state: "completed" | "pending" | "running" | "failed";
|
|
295
367
|
input: Record<string, any>;
|
|
296
368
|
sessionId: string;
|
|
297
369
|
toolId: string;
|
|
298
370
|
messageId: string;
|
|
299
371
|
toolName: string;
|
|
372
|
+
sequence?: number | undefined;
|
|
300
373
|
} | {
|
|
301
374
|
type: "tool-result";
|
|
302
375
|
id: string;
|
|
@@ -305,15 +378,17 @@ export declare namespace Session {
|
|
|
305
378
|
messageId: string;
|
|
306
379
|
toolCallId: string;
|
|
307
380
|
input?: Record<string, any> | undefined;
|
|
381
|
+
sequence?: number | undefined;
|
|
308
382
|
toolName?: string | undefined;
|
|
309
383
|
metadata?: Record<string, any> | undefined;
|
|
310
384
|
} | {
|
|
311
385
|
type: "image";
|
|
312
386
|
id: string;
|
|
387
|
+
data: string;
|
|
313
388
|
sessionId: string;
|
|
314
389
|
messageId: string;
|
|
315
390
|
mimeType: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
|
|
316
|
-
|
|
391
|
+
sequence?: number | undefined;
|
|
317
392
|
filename?: string | undefined;
|
|
318
393
|
};
|
|
319
394
|
delta?: string | undefined;
|
|
@@ -324,21 +399,24 @@ export declare namespace Session {
|
|
|
324
399
|
sessionId: string;
|
|
325
400
|
content: string;
|
|
326
401
|
messageId: string;
|
|
402
|
+
sequence?: number | undefined;
|
|
327
403
|
} | {
|
|
328
404
|
type: "reasoning";
|
|
329
405
|
id: string;
|
|
330
406
|
sessionId: string;
|
|
331
407
|
content: string;
|
|
332
408
|
messageId: string;
|
|
409
|
+
sequence?: number | undefined;
|
|
333
410
|
} | {
|
|
411
|
+
state: "completed" | "pending" | "running" | "failed";
|
|
334
412
|
type: "tool-call";
|
|
335
413
|
id: string;
|
|
336
|
-
state: "completed" | "pending" | "running" | "failed";
|
|
337
414
|
input: Record<string, any>;
|
|
338
415
|
sessionId: string;
|
|
339
416
|
toolId: string;
|
|
340
417
|
messageId: string;
|
|
341
418
|
toolName: string;
|
|
419
|
+
sequence?: number | undefined;
|
|
342
420
|
} | {
|
|
343
421
|
type: "tool-result";
|
|
344
422
|
id: string;
|
|
@@ -347,15 +425,17 @@ export declare namespace Session {
|
|
|
347
425
|
messageId: string;
|
|
348
426
|
toolCallId: string;
|
|
349
427
|
input?: Record<string, any> | undefined;
|
|
428
|
+
sequence?: number | undefined;
|
|
350
429
|
toolName?: string | undefined;
|
|
351
430
|
metadata?: Record<string, any> | undefined;
|
|
352
431
|
} | {
|
|
353
432
|
type: "image";
|
|
354
433
|
id: string;
|
|
434
|
+
data: string;
|
|
355
435
|
sessionId: string;
|
|
356
436
|
messageId: string;
|
|
357
437
|
mimeType: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
|
|
358
|
-
|
|
438
|
+
sequence?: number | undefined;
|
|
359
439
|
filename?: string | undefined;
|
|
360
440
|
};
|
|
361
441
|
delta?: string | undefined;
|
|
@@ -397,6 +477,16 @@ export declare namespace Session {
|
|
|
397
477
|
* Touch a session (update timestamp)
|
|
398
478
|
*/
|
|
399
479
|
function touch(sessionId: string): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* Add a prompt to session history
|
|
482
|
+
* Most recent prompts are at the end of the array
|
|
483
|
+
*/
|
|
484
|
+
function addPromptToHistory(sessionId: string, prompt: string): Promise<void>;
|
|
485
|
+
/**
|
|
486
|
+
* Get prompt history for a session
|
|
487
|
+
* Returns array with most recent prompts at the end
|
|
488
|
+
*/
|
|
489
|
+
function getPromptHistory(sessionId: string): Promise<string[]>;
|
|
400
490
|
/**
|
|
401
491
|
* List all sessions for current project, sorted by updatedAt (most recent first)
|
|
402
492
|
*/
|
|
@@ -423,8 +513,10 @@ export declare namespace Session {
|
|
|
423
513
|
function removePart(sessionId: string, messageId: string, partId: string): Promise<void>;
|
|
424
514
|
/**
|
|
425
515
|
* Get all messages for a session
|
|
516
|
+
* @param sessionId - The session ID
|
|
517
|
+
* @param limit - Optional limit to return only the last N messages (for performance)
|
|
426
518
|
*/
|
|
427
|
-
function messages(sessionId: string): Promise<MessageWithParts[]>;
|
|
519
|
+
function messages(sessionId: string, limit?: number): Promise<MessageWithParts[]>;
|
|
428
520
|
/**
|
|
429
521
|
* Get the most recent session
|
|
430
522
|
*/
|