jiva-core 0.2.2 → 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/.dockerignore +53 -0
- package/.gcloudignore +49 -0
- package/CONTRIBUTING.md +92 -0
- package/Dockerfile +63 -0
- package/LICENSE +21 -0
- package/README.md +248 -102
- package/cloud-run-deploy.yaml +135 -0
- package/cloud-run.yaml +135 -0
- package/cloud-run.yaml.template +143 -0
- package/deploy.sh +107 -0
- package/dist/core/agent-spawner.d.ts +89 -0
- package/dist/core/agent-spawner.d.ts.map +1 -0
- package/dist/core/agent-spawner.js +195 -0
- package/dist/core/agent-spawner.js.map +1 -0
- package/dist/core/client-agent.d.ts +82 -0
- package/dist/core/client-agent.d.ts.map +1 -0
- package/dist/core/client-agent.js +406 -0
- package/dist/core/client-agent.js.map +1 -0
- package/dist/core/config.d.ts +59 -10
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +19 -2
- package/dist/core/config.js.map +1 -1
- package/dist/core/conversation-manager.d.ts +10 -18
- package/dist/core/conversation-manager.d.ts.map +1 -1
- package/dist/core/conversation-manager.js +28 -60
- package/dist/core/conversation-manager.js.map +1 -1
- package/dist/core/dual-agent.d.ts +24 -3
- package/dist/core/dual-agent.d.ts.map +1 -1
- package/dist/core/dual-agent.js +112 -19
- package/dist/core/dual-agent.js.map +1 -1
- package/dist/core/manager-agent.d.ts +3 -1
- package/dist/core/manager-agent.d.ts.map +1 -1
- package/dist/core/manager-agent.js +66 -14
- package/dist/core/manager-agent.js.map +1 -1
- package/dist/core/worker-agent.d.ts +15 -1
- package/dist/core/worker-agent.d.ts.map +1 -1
- package/dist/core/worker-agent.js +244 -11
- package/dist/core/worker-agent.js.map +1 -1
- package/dist/core/workspace.d.ts +5 -0
- package/dist/core/workspace.d.ts.map +1 -1
- package/dist/core/workspace.js +47 -7
- package/dist/core/workspace.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/cli/index.js +376 -44
- package/dist/interfaces/cli/index.js.map +1 -1
- package/dist/interfaces/cli/repl.d.ts.map +1 -1
- package/dist/interfaces/cli/repl.js +6 -0
- package/dist/interfaces/cli/repl.js.map +1 -1
- package/dist/interfaces/http/index.d.ts +22 -0
- package/dist/interfaces/http/index.d.ts.map +1 -0
- package/dist/interfaces/http/index.js +135 -0
- package/dist/interfaces/http/index.js.map +1 -0
- package/dist/interfaces/http/middleware/auth.d.ts +32 -0
- package/dist/interfaces/http/middleware/auth.d.ts.map +1 -0
- package/dist/interfaces/http/middleware/auth.js +176 -0
- package/dist/interfaces/http/middleware/auth.js.map +1 -0
- package/dist/interfaces/http/routes/chat.d.ts +7 -0
- package/dist/interfaces/http/routes/chat.d.ts.map +1 -0
- package/dist/interfaces/http/routes/chat.js +144 -0
- package/dist/interfaces/http/routes/chat.js.map +1 -0
- package/dist/interfaces/http/routes/health.d.ts +6 -0
- package/dist/interfaces/http/routes/health.d.ts.map +1 -0
- package/dist/interfaces/http/routes/health.js +25 -0
- package/dist/interfaces/http/routes/health.js.map +1 -0
- package/dist/interfaces/http/routes/session.d.ts +7 -0
- package/dist/interfaces/http/routes/session.d.ts.map +1 -0
- package/dist/interfaces/http/routes/session.js +114 -0
- package/dist/interfaces/http/routes/session.js.map +1 -0
- package/dist/interfaces/http/session-manager.d.ts +76 -0
- package/dist/interfaces/http/session-manager.d.ts.map +1 -0
- package/dist/interfaces/http/session-manager.js +339 -0
- package/dist/interfaces/http/session-manager.js.map +1 -0
- package/dist/interfaces/http/websocket-handler.d.ts +18 -0
- package/dist/interfaces/http/websocket-handler.d.ts.map +1 -0
- package/dist/interfaces/http/websocket-handler.js +146 -0
- package/dist/interfaces/http/websocket-handler.js.map +1 -0
- package/dist/mcp/client.d.ts +11 -2
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +44 -19
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/server-manager.d.ts +1 -1
- package/dist/mcp/server-manager.d.ts.map +1 -1
- package/dist/mcp/server-manager.js +12 -2
- package/dist/mcp/server-manager.js.map +1 -1
- package/dist/personas/index.d.ts +13 -0
- package/dist/personas/index.d.ts.map +1 -0
- package/dist/personas/index.js +13 -0
- package/dist/personas/index.js.map +1 -0
- package/dist/personas/persona-loader.d.ts +30 -0
- package/dist/personas/persona-loader.d.ts.map +1 -0
- package/dist/personas/persona-loader.js +246 -0
- package/dist/personas/persona-loader.js.map +1 -0
- package/dist/personas/persona-manager.d.ts +82 -0
- package/dist/personas/persona-manager.d.ts.map +1 -0
- package/dist/personas/persona-manager.js +211 -0
- package/dist/personas/persona-manager.js.map +1 -0
- package/dist/personas/skill-loader.d.ts +35 -0
- package/dist/personas/skill-loader.d.ts.map +1 -0
- package/dist/personas/skill-loader.js +144 -0
- package/dist/personas/skill-loader.js.map +1 -0
- package/dist/personas/skill-packager.d.ts +25 -0
- package/dist/personas/skill-packager.d.ts.map +1 -0
- package/dist/personas/skill-packager.js +233 -0
- package/dist/personas/skill-packager.js.map +1 -0
- package/dist/personas/types.d.ts +134 -0
- package/dist/personas/types.d.ts.map +1 -0
- package/dist/personas/types.js +7 -0
- package/dist/personas/types.js.map +1 -0
- package/dist/personas/validator.d.ts +22 -0
- package/dist/personas/validator.d.ts.map +1 -0
- package/dist/personas/validator.js +144 -0
- package/dist/personas/validator.js.map +1 -0
- package/dist/storage/factory.d.ts +51 -0
- package/dist/storage/factory.d.ts.map +1 -0
- package/dist/storage/factory.js +154 -0
- package/dist/storage/factory.js.map +1 -0
- package/dist/storage/gcp-bucket-provider.d.ts +59 -0
- package/dist/storage/gcp-bucket-provider.d.ts.map +1 -0
- package/dist/storage/gcp-bucket-provider.js +275 -0
- package/dist/storage/gcp-bucket-provider.js.map +1 -0
- package/dist/storage/index.d.ts +33 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +37 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/local-provider.d.ts +36 -0
- package/dist/storage/local-provider.d.ts.map +1 -0
- package/dist/storage/local-provider.js +219 -0
- package/dist/storage/local-provider.js.map +1 -0
- package/dist/storage/provider.d.ts +137 -0
- package/dist/storage/provider.d.ts.map +1 -0
- package/dist/storage/provider.js +136 -0
- package/dist/storage/provider.js.map +1 -0
- package/dist/storage/types.d.ts +78 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +14 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/utils/orchestration-logger.d.ts +36 -0
- package/dist/utils/orchestration-logger.d.ts.map +1 -0
- package/dist/utils/orchestration-logger.js +224 -0
- package/dist/utils/orchestration-logger.js.map +1 -0
- package/jiva-new-demo.gif +0 -0
- package/package.json +30 -2
- package/.fluen/cache/state.json +0 -7
- package/actions/action_registry.py +0 -75
- package/actions/python_coder.py +0 -470
- package/api/main.py +0 -269
- package/downloaded_image.avif +0 -0
- package/downloads/snipping_tool.avif +0 -0
- package/image.avif +0 -0
- package/ms_image.avif +0 -0
- package/screenshot.png +0 -0
- package/snipping_tool.avif +0 -0
- package/tmp_image.avif +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StorageProvider - Abstract interface for state persistence
|
|
3
|
+
*
|
|
4
|
+
* Enables Jiva to run on:
|
|
5
|
+
* - Local filesystem (CLI, Desktop)
|
|
6
|
+
* - Cloud storage (GCP Bucket, AWS S3)
|
|
7
|
+
* - In-memory caches (Redis)
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: Context (tenantId, sessionId) must be set before operations
|
|
10
|
+
* - CLI mode: Uses defaults automatically
|
|
11
|
+
* - Cloud mode: Must call setContext() with values from JWT/auth
|
|
12
|
+
*/
|
|
13
|
+
import { StorageInfraConfig, StorageContext, SavedConversation, ConversationMetadata, LogEntry, JivaState } from './types.js';
|
|
14
|
+
export declare abstract class StorageProvider {
|
|
15
|
+
protected infraConfig: StorageInfraConfig;
|
|
16
|
+
protected context: StorageContext | null;
|
|
17
|
+
protected logBuffer: LogEntry[];
|
|
18
|
+
protected initialized: boolean;
|
|
19
|
+
constructor(infraConfig: StorageInfraConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the storage provider (connect, verify access, etc.)
|
|
22
|
+
*/
|
|
23
|
+
abstract initialize(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if provider is ready
|
|
26
|
+
*/
|
|
27
|
+
isInitialized(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Set the tenant and session context
|
|
30
|
+
* MUST be called before any tenant-specific operations in cloud mode
|
|
31
|
+
*
|
|
32
|
+
* @param context - Contains tenantId and sessionId from authenticated request
|
|
33
|
+
*/
|
|
34
|
+
setContext(context: StorageContext): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get current context
|
|
37
|
+
*/
|
|
38
|
+
getContext(): StorageContext | null;
|
|
39
|
+
/**
|
|
40
|
+
* Check if context is set and valid
|
|
41
|
+
*/
|
|
42
|
+
hasContext(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Ensure context is set before operations
|
|
45
|
+
* @throws Error if context not set
|
|
46
|
+
*/
|
|
47
|
+
protected requireContext(): StorageContext;
|
|
48
|
+
/**
|
|
49
|
+
* Get a configuration value
|
|
50
|
+
*/
|
|
51
|
+
abstract getConfig<T>(key: string): Promise<T | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Set a configuration value
|
|
54
|
+
*/
|
|
55
|
+
abstract setConfig<T>(key: string, value: T): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Get all configuration as object
|
|
58
|
+
*/
|
|
59
|
+
abstract getAllConfig(): Promise<Record<string, any>>;
|
|
60
|
+
/**
|
|
61
|
+
* Save a conversation
|
|
62
|
+
* @returns The conversation ID
|
|
63
|
+
*/
|
|
64
|
+
abstract saveConversation(conversation: SavedConversation): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Load a conversation by ID
|
|
67
|
+
*/
|
|
68
|
+
abstract loadConversation(id: string): Promise<SavedConversation | null>;
|
|
69
|
+
/**
|
|
70
|
+
* List all conversations for the tenant
|
|
71
|
+
*/
|
|
72
|
+
abstract listConversations(): Promise<ConversationMetadata[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete a conversation
|
|
75
|
+
*/
|
|
76
|
+
abstract deleteConversation(id: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Load directive content for a workspace
|
|
79
|
+
* @param workspacePath - The workspace identifier/path
|
|
80
|
+
*/
|
|
81
|
+
abstract loadDirective(workspacePath: string): Promise<string | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Save directive content (for cloud scenarios where directive is uploaded)
|
|
84
|
+
*/
|
|
85
|
+
abstract saveDirective(workspacePath: string, content: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Append a log entry to the buffer
|
|
88
|
+
* Logs are held in memory until flush() is called
|
|
89
|
+
*/
|
|
90
|
+
appendLog(entry: LogEntry): void;
|
|
91
|
+
/**
|
|
92
|
+
* Flush buffered logs to persistent storage
|
|
93
|
+
*/
|
|
94
|
+
abstract flushLogs(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get current log buffer (for debugging)
|
|
97
|
+
*/
|
|
98
|
+
getLogBuffer(): LogEntry[];
|
|
99
|
+
/**
|
|
100
|
+
* Clear the log buffer
|
|
101
|
+
*/
|
|
102
|
+
clearLogBuffer(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Export complete state for cloud function handoff
|
|
105
|
+
*/
|
|
106
|
+
abstract exportState(): Promise<JivaState>;
|
|
107
|
+
/**
|
|
108
|
+
* Import state from a previous export
|
|
109
|
+
*/
|
|
110
|
+
abstract importState(state: JivaState): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Get the base path for a tenant
|
|
113
|
+
* Format: {tenantId}/
|
|
114
|
+
*/
|
|
115
|
+
protected getTenantPath(): string;
|
|
116
|
+
/**
|
|
117
|
+
* Get the path for a session
|
|
118
|
+
* Format: {tenantId}/sessions/{sessionId}/
|
|
119
|
+
*/
|
|
120
|
+
protected getSessionPath(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Get the path for conversations
|
|
123
|
+
* Format: {tenantId}/conversations/
|
|
124
|
+
*/
|
|
125
|
+
protected getConversationsPath(): string;
|
|
126
|
+
/**
|
|
127
|
+
* Get the path for config
|
|
128
|
+
* Format: {tenantId}/config.json
|
|
129
|
+
*/
|
|
130
|
+
protected getConfigPath(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Get the path for logs
|
|
133
|
+
* Format: {tenantId}/logs/{sessionId}/
|
|
134
|
+
*/
|
|
135
|
+
protected getLogsPath(): string;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/storage/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,8BAAsB,eAAe;IACnC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC;IAC1C,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAQ;IAChD,SAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAM;IACrC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAS;gBAE3B,WAAW,EAAE,kBAAkB;IAI3C;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAEpC;;OAEG;IACH,aAAa,IAAI,OAAO;IAQxB;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAOzC;;OAEG;IACH,UAAU,IAAI,cAAc,GAAG,IAAI;IAInC;;OAEG;IACH,UAAU,IAAI,OAAO;IAMrB;;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AAC,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD;;;OAGG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IAKjC;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,MAAM;IAKlC;;;OAGG;IACH,SAAS,CAAC,oBAAoB,IAAI,MAAM;IAKxC;;;OAGG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IAKjC;;;OAGG;IACH,SAAS,CAAC,WAAW,IAAI,MAAM;CAIhC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StorageProvider - Abstract interface for state persistence
|
|
3
|
+
*
|
|
4
|
+
* Enables Jiva to run on:
|
|
5
|
+
* - Local filesystem (CLI, Desktop)
|
|
6
|
+
* - Cloud storage (GCP Bucket, AWS S3)
|
|
7
|
+
* - In-memory caches (Redis)
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: Context (tenantId, sessionId) must be set before operations
|
|
10
|
+
* - CLI mode: Uses defaults automatically
|
|
11
|
+
* - Cloud mode: Must call setContext() with values from JWT/auth
|
|
12
|
+
*/
|
|
13
|
+
export class StorageProvider {
|
|
14
|
+
infraConfig;
|
|
15
|
+
context = null;
|
|
16
|
+
logBuffer = [];
|
|
17
|
+
initialized = false;
|
|
18
|
+
constructor(infraConfig) {
|
|
19
|
+
this.infraConfig = infraConfig;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if provider is ready
|
|
23
|
+
*/
|
|
24
|
+
isInitialized() {
|
|
25
|
+
return this.initialized;
|
|
26
|
+
}
|
|
27
|
+
// ─────────────────────────────────────────────────────────────
|
|
28
|
+
// Context Management (CRITICAL for multi-tenancy)
|
|
29
|
+
// ─────────────────────────────────────────────────────────────
|
|
30
|
+
/**
|
|
31
|
+
* Set the tenant and session context
|
|
32
|
+
* MUST be called before any tenant-specific operations in cloud mode
|
|
33
|
+
*
|
|
34
|
+
* @param context - Contains tenantId and sessionId from authenticated request
|
|
35
|
+
*/
|
|
36
|
+
setContext(context) {
|
|
37
|
+
if (!context.tenantId || !context.sessionId) {
|
|
38
|
+
throw new Error('Both tenantId and sessionId are required in StorageContext');
|
|
39
|
+
}
|
|
40
|
+
this.context = context;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get current context
|
|
44
|
+
*/
|
|
45
|
+
getContext() {
|
|
46
|
+
return this.context;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if context is set and valid
|
|
50
|
+
*/
|
|
51
|
+
hasContext() {
|
|
52
|
+
return this.context !== null &&
|
|
53
|
+
!!this.context.tenantId &&
|
|
54
|
+
!!this.context.sessionId;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Ensure context is set before operations
|
|
58
|
+
* @throws Error if context not set
|
|
59
|
+
*/
|
|
60
|
+
requireContext() {
|
|
61
|
+
if (!this.context) {
|
|
62
|
+
throw new Error('Storage context not set. Call setContext({tenantId, sessionId}) before performing operations. ' +
|
|
63
|
+
'In cloud mode, extract these from the authenticated JWT.');
|
|
64
|
+
}
|
|
65
|
+
return this.context;
|
|
66
|
+
}
|
|
67
|
+
// ─────────────────────────────────────────────────────────────
|
|
68
|
+
// Logging (session-level, buffered)
|
|
69
|
+
// ─────────────────────────────────────────────────────────────
|
|
70
|
+
/**
|
|
71
|
+
* Append a log entry to the buffer
|
|
72
|
+
* Logs are held in memory until flush() is called
|
|
73
|
+
*/
|
|
74
|
+
appendLog(entry) {
|
|
75
|
+
this.logBuffer.push({
|
|
76
|
+
...entry,
|
|
77
|
+
timestamp: entry.timestamp || new Date().toISOString(),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get current log buffer (for debugging)
|
|
82
|
+
*/
|
|
83
|
+
getLogBuffer() {
|
|
84
|
+
return [...this.logBuffer];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Clear the log buffer
|
|
88
|
+
*/
|
|
89
|
+
clearLogBuffer() {
|
|
90
|
+
this.logBuffer = [];
|
|
91
|
+
}
|
|
92
|
+
// ─────────────────────────────────────────────────────────────
|
|
93
|
+
// Path Helpers (for implementations)
|
|
94
|
+
// ─────────────────────────────────────────────────────────────
|
|
95
|
+
/**
|
|
96
|
+
* Get the base path for a tenant
|
|
97
|
+
* Format: {tenantId}/
|
|
98
|
+
*/
|
|
99
|
+
getTenantPath() {
|
|
100
|
+
const ctx = this.requireContext();
|
|
101
|
+
return `${ctx.tenantId}/`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the path for a session
|
|
105
|
+
* Format: {tenantId}/sessions/{sessionId}/
|
|
106
|
+
*/
|
|
107
|
+
getSessionPath() {
|
|
108
|
+
const ctx = this.requireContext();
|
|
109
|
+
return `${ctx.tenantId}/sessions/${ctx.sessionId}/`;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get the path for conversations
|
|
113
|
+
* Format: {tenantId}/conversations/
|
|
114
|
+
*/
|
|
115
|
+
getConversationsPath() {
|
|
116
|
+
const ctx = this.requireContext();
|
|
117
|
+
return `${ctx.tenantId}/conversations/`;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get the path for config
|
|
121
|
+
* Format: {tenantId}/config.json
|
|
122
|
+
*/
|
|
123
|
+
getConfigPath() {
|
|
124
|
+
const ctx = this.requireContext();
|
|
125
|
+
return `${ctx.tenantId}/config.json`;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get the path for logs
|
|
129
|
+
* Format: {tenantId}/logs/{sessionId}/
|
|
130
|
+
*/
|
|
131
|
+
getLogsPath() {
|
|
132
|
+
const ctx = this.requireContext();
|
|
133
|
+
return `${ctx.tenantId}/logs/${ctx.sessionId}/`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/storage/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,MAAM,OAAgB,eAAe;IACzB,WAAW,CAAqB;IAChC,OAAO,GAA0B,IAAI,CAAC;IACtC,SAAS,GAAe,EAAE,CAAC;IAC3B,WAAW,GAAY,KAAK,CAAC;IAEvC,YAAY,WAA+B;QACzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAOD;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,gEAAgE;IAChE,kDAAkD;IAClD,gEAAgE;IAEhE;;;;;OAKG;IACH,UAAU,CAAC,OAAuB;QAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI;YACrB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ;YACvB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,CAAC;IAED;;;OAGG;IACO,cAAc;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,gGAAgG;gBAChG,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IA6DD,gEAAgE;IAChE,oCAAoC;IACpC,gEAAgE;IAEhE;;;OAGG;IACH,SAAS,CAAC,KAAe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
|
+
*/
|
|
4
|
+
import { Message } from '../models/base.js';
|
|
5
|
+
/**
|
|
6
|
+
* Tenant and session identification for multi-tenancy support
|
|
7
|
+
* These MUST be provided by the caller (from JWT, API key, etc.) in cloud mode
|
|
8
|
+
* In CLI mode, defaults are used for backward compatibility
|
|
9
|
+
*/
|
|
10
|
+
export interface StorageContext {
|
|
11
|
+
tenantId: string;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Conversation metadata (lightweight, for listing)
|
|
16
|
+
*/
|
|
17
|
+
export interface ConversationMetadata {
|
|
18
|
+
id: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
created: string;
|
|
21
|
+
updated: string;
|
|
22
|
+
messageCount: number;
|
|
23
|
+
workspace?: string;
|
|
24
|
+
summary?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Full conversation with messages
|
|
28
|
+
*/
|
|
29
|
+
export interface SavedConversation {
|
|
30
|
+
metadata: ConversationMetadata;
|
|
31
|
+
messages: Message[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Log entry for orchestration events
|
|
35
|
+
*/
|
|
36
|
+
export interface LogEntry {
|
|
37
|
+
timestamp: string;
|
|
38
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
39
|
+
event: string;
|
|
40
|
+
data?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Complete Jiva state snapshot for cloud function state transfer
|
|
44
|
+
*/
|
|
45
|
+
export interface JivaState {
|
|
46
|
+
version: string;
|
|
47
|
+
tenantId: string;
|
|
48
|
+
sessionId: string;
|
|
49
|
+
exportedAt: string;
|
|
50
|
+
config: Record<string, any>;
|
|
51
|
+
conversation: SavedConversation | null;
|
|
52
|
+
directive?: string;
|
|
53
|
+
logBuffer: LogEntry[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Infrastructure configuration for storage providers
|
|
57
|
+
* These come from environment variables or deployment config
|
|
58
|
+
* NOT from user requests - these are deployment-time settings
|
|
59
|
+
*/
|
|
60
|
+
export interface StorageInfraConfig {
|
|
61
|
+
basePath?: string;
|
|
62
|
+
gcpBucketName?: string;
|
|
63
|
+
gcpProjectId?: string;
|
|
64
|
+
gcpKeyFilePath?: string;
|
|
65
|
+
s3BucketName?: string;
|
|
66
|
+
s3Region?: string;
|
|
67
|
+
redisUrl?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Provider type enum
|
|
71
|
+
*/
|
|
72
|
+
export declare enum StorageProviderType {
|
|
73
|
+
LOCAL = "local",
|
|
74
|
+
GCP_BUCKET = "gcp-bucket",
|
|
75
|
+
AWS_S3 = "aws-s3",
|
|
76
|
+
REDIS = "redis"
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IAGnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAG5B,YAAY,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAGvC,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,oBAAY,mBAAmB;IAC7B,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Types - Core type definitions for the storage abstraction layer
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Provider type enum
|
|
6
|
+
*/
|
|
7
|
+
export var StorageProviderType;
|
|
8
|
+
(function (StorageProviderType) {
|
|
9
|
+
StorageProviderType["LOCAL"] = "local";
|
|
10
|
+
StorageProviderType["GCP_BUCKET"] = "gcp-bucket";
|
|
11
|
+
StorageProviderType["AWS_S3"] = "aws-s3";
|
|
12
|
+
StorageProviderType["REDIS"] = "redis";
|
|
13
|
+
})(StorageProviderType || (StorageProviderType = {}));
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyFH;;GAEG;AACH,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,sCAAe,CAAA;IACf,gDAAyB,CAAA;IACzB,wCAAiB,CAAA;IACjB,sCAAe,CAAA;AACjB,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Logger - Tracks Manager/Worker coordination
|
|
3
|
+
*
|
|
4
|
+
* Writes detailed logs to understand how tasks flow through the dual-agent system.
|
|
5
|
+
* Logs are written to: ~/.jiva/logs/orchestration-{timestamp}.log
|
|
6
|
+
*/
|
|
7
|
+
declare class OrchestrationLogger {
|
|
8
|
+
private static instance;
|
|
9
|
+
private logFilePath;
|
|
10
|
+
private logStream;
|
|
11
|
+
private sessionStart;
|
|
12
|
+
private constructor();
|
|
13
|
+
static getInstance(): OrchestrationLogger;
|
|
14
|
+
private initializeLogFile;
|
|
15
|
+
private writeHeader;
|
|
16
|
+
private writeEvent;
|
|
17
|
+
logUserMessage(message: string): void;
|
|
18
|
+
logPhaseStart(phase: 'PLANNING' | 'EXECUTION' | 'SYNTHESIS'): void;
|
|
19
|
+
logPhaseEnd(phase: 'PLANNING' | 'EXECUTION' | 'SYNTHESIS', durationMs: number): void;
|
|
20
|
+
logFinalResponse(response: string, totalIterations: number, toolsUsed: string[]): void;
|
|
21
|
+
logManagerCreatePlan(task: string, context: string): void;
|
|
22
|
+
logManagerPlanCreated(subtasks: string[], reasoning: string): void;
|
|
23
|
+
logManagerReview(subtask: string, workerResult: string): void;
|
|
24
|
+
logManagerDecision(isComplete: boolean, reasoning: string, nextAction?: string): void;
|
|
25
|
+
logManagerSynthesize(resultsCount: number): void;
|
|
26
|
+
logWorkerStart(subtask: string, context: string): void;
|
|
27
|
+
logWorkerIteration(iteration: number, maxIterations: number): void;
|
|
28
|
+
logWorkerToolCall(toolName: string, args: Record<string, any>): void;
|
|
29
|
+
logWorkerToolResult(toolName: string, success: boolean, hasImages: boolean): void;
|
|
30
|
+
logWorkerComplete(success: boolean, toolsUsed: string[], iterations: number): void;
|
|
31
|
+
getLogFilePath(): string | null;
|
|
32
|
+
close(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const orchestrationLogger: OrchestrationLogger;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=orchestration-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-logger.d.ts","sourceRoot":"","sources":["../../src/utils/orchestration-logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAsB;IAC7C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,YAAY,CAAO;IAE3B,OAAO;IAKP,MAAM,CAAC,WAAW,IAAI,mBAAmB;IAOzC,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,UAAU;IAclB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IASrC,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,IAAI;IASlE,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IASpF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAetF,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IASzD,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAalE,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAa7D,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAarF,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAUhD,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAStD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IASlE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IASpE,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IASjF,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAelF,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,KAAK,IAAI,IAAI;CAed;AAED,eAAO,MAAM,mBAAmB,qBAAoC,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Logger - Tracks Manager/Worker coordination
|
|
3
|
+
*
|
|
4
|
+
* Writes detailed logs to understand how tasks flow through the dual-agent system.
|
|
5
|
+
* Logs are written to: ~/.jiva/logs/orchestration-{timestamp}.log
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import * as os from 'os';
|
|
10
|
+
class OrchestrationLogger {
|
|
11
|
+
static instance;
|
|
12
|
+
logFilePath = null;
|
|
13
|
+
logStream = null;
|
|
14
|
+
sessionStart;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.sessionStart = new Date();
|
|
17
|
+
this.initializeLogFile();
|
|
18
|
+
}
|
|
19
|
+
static getInstance() {
|
|
20
|
+
if (!OrchestrationLogger.instance) {
|
|
21
|
+
OrchestrationLogger.instance = new OrchestrationLogger();
|
|
22
|
+
}
|
|
23
|
+
return OrchestrationLogger.instance;
|
|
24
|
+
}
|
|
25
|
+
initializeLogFile() {
|
|
26
|
+
try {
|
|
27
|
+
// Create logs directory in ~/.jiva/logs/
|
|
28
|
+
const jivaDir = path.join(os.homedir(), '.jiva', 'logs');
|
|
29
|
+
fs.mkdirSync(jivaDir, { recursive: true });
|
|
30
|
+
// Create timestamped log file
|
|
31
|
+
const timestamp = this.sessionStart.toISOString().replace(/[:.]/g, '-');
|
|
32
|
+
this.logFilePath = path.join(jivaDir, `orchestration-${timestamp}.log`);
|
|
33
|
+
// Create write stream
|
|
34
|
+
this.logStream = fs.createWriteStream(this.logFilePath, { flags: 'a' });
|
|
35
|
+
// Write header
|
|
36
|
+
this.writeHeader();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('Failed to initialize orchestration log file:', error);
|
|
40
|
+
this.logFilePath = null;
|
|
41
|
+
this.logStream = null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
writeHeader() {
|
|
45
|
+
if (!this.logStream)
|
|
46
|
+
return;
|
|
47
|
+
const header = [
|
|
48
|
+
'='.repeat(80),
|
|
49
|
+
'JIVA ORCHESTRATION LOG',
|
|
50
|
+
`Session started: ${this.sessionStart.toISOString()}`,
|
|
51
|
+
'='.repeat(80),
|
|
52
|
+
'',
|
|
53
|
+
].join('\n');
|
|
54
|
+
this.logStream.write(header);
|
|
55
|
+
}
|
|
56
|
+
writeEvent(event) {
|
|
57
|
+
if (!this.logStream)
|
|
58
|
+
return;
|
|
59
|
+
const line = [
|
|
60
|
+
`[${event.timestamp}]`,
|
|
61
|
+
`[${event.phase}]`,
|
|
62
|
+
event.event,
|
|
63
|
+
Object.keys(event.details).length > 0 ? JSON.stringify(event.details, null, 2) : '',
|
|
64
|
+
].filter(Boolean).join(' ');
|
|
65
|
+
this.logStream.write(line + '\n');
|
|
66
|
+
}
|
|
67
|
+
// DualAgent events
|
|
68
|
+
logUserMessage(message) {
|
|
69
|
+
this.writeEvent({
|
|
70
|
+
timestamp: new Date().toISOString(),
|
|
71
|
+
phase: 'DUAL_AGENT',
|
|
72
|
+
event: 'USER_MESSAGE',
|
|
73
|
+
details: { message },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
logPhaseStart(phase) {
|
|
77
|
+
this.writeEvent({
|
|
78
|
+
timestamp: new Date().toISOString(),
|
|
79
|
+
phase: 'DUAL_AGENT',
|
|
80
|
+
event: `PHASE_START_${phase}`,
|
|
81
|
+
details: {},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
logPhaseEnd(phase, durationMs) {
|
|
85
|
+
this.writeEvent({
|
|
86
|
+
timestamp: new Date().toISOString(),
|
|
87
|
+
phase: 'DUAL_AGENT',
|
|
88
|
+
event: `PHASE_END_${phase}`,
|
|
89
|
+
details: { durationMs },
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
logFinalResponse(response, totalIterations, toolsUsed) {
|
|
93
|
+
this.writeEvent({
|
|
94
|
+
timestamp: new Date().toISOString(),
|
|
95
|
+
phase: 'DUAL_AGENT',
|
|
96
|
+
event: 'FINAL_RESPONSE',
|
|
97
|
+
details: {
|
|
98
|
+
responseLength: response.length,
|
|
99
|
+
totalIterations,
|
|
100
|
+
toolsUsed,
|
|
101
|
+
uniqueTools: [...new Set(toolsUsed)],
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Manager events
|
|
106
|
+
logManagerCreatePlan(task, context) {
|
|
107
|
+
this.writeEvent({
|
|
108
|
+
timestamp: new Date().toISOString(),
|
|
109
|
+
phase: 'MANAGER',
|
|
110
|
+
event: 'CREATE_PLAN',
|
|
111
|
+
details: { task, context },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
logManagerPlanCreated(subtasks, reasoning) {
|
|
115
|
+
this.writeEvent({
|
|
116
|
+
timestamp: new Date().toISOString(),
|
|
117
|
+
phase: 'MANAGER',
|
|
118
|
+
event: 'PLAN_CREATED',
|
|
119
|
+
details: {
|
|
120
|
+
subtaskCount: subtasks.length,
|
|
121
|
+
subtasks,
|
|
122
|
+
reasoning,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
logManagerReview(subtask, workerResult) {
|
|
127
|
+
this.writeEvent({
|
|
128
|
+
timestamp: new Date().toISOString(),
|
|
129
|
+
phase: 'MANAGER',
|
|
130
|
+
event: 'REVIEW_SUBTASK',
|
|
131
|
+
details: {
|
|
132
|
+
subtask,
|
|
133
|
+
workerResultLength: workerResult.length,
|
|
134
|
+
workerResultPreview: workerResult.substring(0, 200),
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
logManagerDecision(isComplete, reasoning, nextAction) {
|
|
139
|
+
this.writeEvent({
|
|
140
|
+
timestamp: new Date().toISOString(),
|
|
141
|
+
phase: 'MANAGER',
|
|
142
|
+
event: 'DECISION',
|
|
143
|
+
details: {
|
|
144
|
+
isComplete,
|
|
145
|
+
reasoning,
|
|
146
|
+
nextAction,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
logManagerSynthesize(resultsCount) {
|
|
151
|
+
this.writeEvent({
|
|
152
|
+
timestamp: new Date().toISOString(),
|
|
153
|
+
phase: 'MANAGER',
|
|
154
|
+
event: 'SYNTHESIZE',
|
|
155
|
+
details: { resultsCount },
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
// Worker events
|
|
159
|
+
logWorkerStart(subtask, context) {
|
|
160
|
+
this.writeEvent({
|
|
161
|
+
timestamp: new Date().toISOString(),
|
|
162
|
+
phase: 'WORKER',
|
|
163
|
+
event: 'START_SUBTASK',
|
|
164
|
+
details: { subtask, context },
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
logWorkerIteration(iteration, maxIterations) {
|
|
168
|
+
this.writeEvent({
|
|
169
|
+
timestamp: new Date().toISOString(),
|
|
170
|
+
phase: 'WORKER',
|
|
171
|
+
event: 'ITERATION',
|
|
172
|
+
details: { iteration, maxIterations },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
logWorkerToolCall(toolName, args) {
|
|
176
|
+
this.writeEvent({
|
|
177
|
+
timestamp: new Date().toISOString(),
|
|
178
|
+
phase: 'WORKER',
|
|
179
|
+
event: 'TOOL_CALL',
|
|
180
|
+
details: { toolName, args },
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
logWorkerToolResult(toolName, success, hasImages) {
|
|
184
|
+
this.writeEvent({
|
|
185
|
+
timestamp: new Date().toISOString(),
|
|
186
|
+
phase: 'WORKER',
|
|
187
|
+
event: 'TOOL_RESULT',
|
|
188
|
+
details: { toolName, success, hasImages },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
logWorkerComplete(success, toolsUsed, iterations) {
|
|
192
|
+
this.writeEvent({
|
|
193
|
+
timestamp: new Date().toISOString(),
|
|
194
|
+
phase: 'WORKER',
|
|
195
|
+
event: 'COMPLETE',
|
|
196
|
+
details: {
|
|
197
|
+
success,
|
|
198
|
+
toolsUsed,
|
|
199
|
+
iterations,
|
|
200
|
+
uniqueTools: [...new Set(toolsUsed)],
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// Utility
|
|
205
|
+
getLogFilePath() {
|
|
206
|
+
return this.logFilePath;
|
|
207
|
+
}
|
|
208
|
+
close() {
|
|
209
|
+
if (this.logStream) {
|
|
210
|
+
const footer = [
|
|
211
|
+
'',
|
|
212
|
+
'='.repeat(80),
|
|
213
|
+
`Session ended: ${new Date().toISOString()}`,
|
|
214
|
+
`Duration: ${Date.now() - this.sessionStart.getTime()}ms`,
|
|
215
|
+
'='.repeat(80),
|
|
216
|
+
].join('\n');
|
|
217
|
+
this.logStream.write(footer);
|
|
218
|
+
this.logStream.end();
|
|
219
|
+
this.logStream = null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export const orchestrationLogger = OrchestrationLogger.getInstance();
|
|
224
|
+
//# sourceMappingURL=orchestration-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-logger.js","sourceRoot":"","sources":["../../src/utils/orchestration-logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AASzB,MAAM,mBAAmB;IACf,MAAM,CAAC,QAAQ,CAAsB;IACrC,WAAW,GAAkB,IAAI,CAAC;IAClC,SAAS,GAA0B,IAAI,CAAC;IACxC,YAAY,CAAO;IAE3B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC;YAClC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAC3D,CAAC;QACD,OAAO,mBAAmB,CAAC,QAAQ,CAAC;IACtC,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC;YACH,yCAAyC;YACzC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,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