@allternit/gizzi-code 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WORKSPACE_INTEGRATION.md +290 -0
- package/chat-sessions/sessions-index.json +98 -0
- package/package.json +43 -0
- package/package.json.original +31 -0
- package/package.json.publish +47 -0
- package/src/bootstrap/state.d.ts +169 -0
- package/src/bootstrap/state.js +261 -0
- package/src/bootstrap/state.ts +371 -0
- package/src/context/pack-builder.d.ts +24 -0
- package/src/context/pack-builder.js +281 -0
- package/src/context/pack-builder.ts +334 -0
- package/src/hooks/useExitOnCtrlCD.d.ts +86 -0
- package/src/hooks/useExitOnCtrlCD.js +130 -0
- package/src/hooks/useExitOnCtrlCD.ts +202 -0
- package/src/hooks/useKeybinding.d.ts +89 -0
- package/src/hooks/useKeybinding.js +163 -0
- package/src/hooks/useKeybinding.ts +226 -0
- package/src/hooks/useTerminalSize.d.ts +41 -0
- package/src/hooks/useTerminalSize.js +90 -0
- package/src/hooks/useTerminalSize.ts +117 -0
- package/src/index.d.ts +23 -0
- package/src/index.js +24 -0
- package/src/index.ts +132 -0
- package/src/runtime/brand/brand.d.ts +488 -0
- package/src/runtime/brand/brand.js +464 -0
- package/src/runtime/brand/brand.ts +667 -0
- package/src/runtime/services/tokenEstimation.d.ts +187 -0
- package/src/runtime/services/tokenEstimation.js +423 -0
- package/src/runtime/services/tokenEstimation.ts +547 -0
- package/src/runtime/tools/Tool.d.ts +239 -0
- package/src/runtime/tools/Tool.js +285 -0
- package/src/runtime/tools/Tool.ts +524 -0
- package/src/scheduler/TaskScheduler.d.ts +98 -0
- package/src/scheduler/TaskScheduler.js +201 -0
- package/src/scheduler/TaskScheduler.ts +259 -0
- package/src/state/AppStateStore.d.ts +347 -0
- package/src/state/AppStateStore.js +439 -0
- package/src/state/AppStateStore.ts +658 -0
- package/src/state/WorkspaceStateStore.d.ts +43 -0
- package/src/state/WorkspaceStateStore.js +224 -0
- package/src/state/WorkspaceStateStore.ts +297 -0
- package/src/types/message.d.ts +190 -0
- package/src/types/message.js +77 -0
- package/src/types/message.ts +277 -0
- package/src/utils/format.d.ts +126 -0
- package/src/utils/format.js +230 -0
- package/src/utils/format.ts +336 -0
- package/src/utils/fullscreen.d.ts +161 -0
- package/src/utils/fullscreen.js +277 -0
- package/src/utils/fullscreen.ts +382 -0
- package/src/utils/sessionStorage.d.ts +210 -0
- package/src/utils/sessionStorage.js +435 -0
- package/src/utils/sessionStorage.ts +559 -0
- package/src/watcher/WorkspaceWatcher.d.ts +70 -0
- package/src/watcher/WorkspaceWatcher.js +191 -0
- package/src/watcher/WorkspaceWatcher.ts +251 -0
- package/src/workspace/loader.d.ts +30 -0
- package/src/workspace/loader.js +117 -0
- package/src/workspace/loader.ts +171 -0
- package/src/workspace/types.d.ts +91 -0
- package/src/workspace/types.js +7 -0
- package/src/workspace/types.ts +122 -0
- package/threads/thread_1775361175022.json +9 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gizzi Workspace Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads agent workspace files and integrates with Gizzi state
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { WorkspaceSession, ContextPack, WorkspaceFile } from './types';
|
|
8
|
+
import { buildContextPack, getStartupTasks } from '../context/pack-builder';
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// File System Abstraction
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
export interface FileSystem {
|
|
15
|
+
readFile(path: string): Promise<string>;
|
|
16
|
+
listDirectory(path: string): Promise<{ name: string; type: 'file' | 'directory' }[]>;
|
|
17
|
+
exists(path: string): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Workspace File Patterns
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
const WORKSPACE_FILE_PATTERNS = [
|
|
25
|
+
'.allternit/manifest.json',
|
|
26
|
+
'.allternit/brain/BRAIN.md',
|
|
27
|
+
'.allternit/memory/MEMORY.md',
|
|
28
|
+
'.allternit/memory/active-tasks.md',
|
|
29
|
+
'.allternit/memory/daily.md',
|
|
30
|
+
'.allternit/memory/lessons.md',
|
|
31
|
+
'.allternit/memory/self-review.md',
|
|
32
|
+
'.allternit/identity/IDENTITY.md',
|
|
33
|
+
'.allternit/identity/SOUL.md',
|
|
34
|
+
'.allternit/identity/USER.md',
|
|
35
|
+
'.allternit/identity/VOICE.md',
|
|
36
|
+
'.allternit/identity/POLICY.md',
|
|
37
|
+
'.allternit/governance/PLAYBOOK.md',
|
|
38
|
+
'.allternit/governance/TOOLS.md',
|
|
39
|
+
'.allternit/governance/HEARTBEAT.md',
|
|
40
|
+
'.allternit/governance/SYSTEM.md',
|
|
41
|
+
'.allternit/governance/CHANNELS.md',
|
|
42
|
+
'.allternit/skills/**',
|
|
43
|
+
'.allternit/business/CLIENTS.md',
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Workspace Loader
|
|
48
|
+
// ============================================================================
|
|
49
|
+
|
|
50
|
+
export interface LoadWorkspaceOptions {
|
|
51
|
+
agentId: string;
|
|
52
|
+
agentName: string;
|
|
53
|
+
sessionId: string;
|
|
54
|
+
fs: FileSystem;
|
|
55
|
+
basePath: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface LoadedWorkspace {
|
|
59
|
+
files: Map<string, string>;
|
|
60
|
+
contextPack: ContextPack;
|
|
61
|
+
startupTasks: ReturnType<typeof getStartupTasks>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function loadWorkspace(
|
|
65
|
+
options: LoadWorkspaceOptions
|
|
66
|
+
): Promise<LoadedWorkspace | null> {
|
|
67
|
+
const { agentId, agentName, sessionId, fs, basePath } = options;
|
|
68
|
+
|
|
69
|
+
console.log('[Gizzi Workspace] Loading workspace for agent:', agentId);
|
|
70
|
+
|
|
71
|
+
const files = new Map<string, string>();
|
|
72
|
+
|
|
73
|
+
// Load core files
|
|
74
|
+
for (const pattern of WORKSPACE_FILE_PATTERNS) {
|
|
75
|
+
if (pattern.includes('**')) continue;
|
|
76
|
+
|
|
77
|
+
const fullPath = `${basePath}/${pattern}`;
|
|
78
|
+
try {
|
|
79
|
+
if (await fs.exists(fullPath)) {
|
|
80
|
+
const content = await fs.readFile(fullPath);
|
|
81
|
+
files.set(pattern, content);
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
// File doesn't exist, skip
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Load skill files
|
|
89
|
+
try {
|
|
90
|
+
const skillsPath = `${basePath}/.allternit/skills`;
|
|
91
|
+
if (await fs.exists(skillsPath)) {
|
|
92
|
+
const entries = await fs.listDirectory(skillsPath);
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (entry.type === 'file' && (entry.name.endsWith('.md') || entry.name.endsWith('.json'))) {
|
|
95
|
+
const content = await fs.readFile(`${skillsPath}/${entry.name}`);
|
|
96
|
+
files.set(`.allternit/skills/${entry.name}`, content);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
// Skills directory doesn't exist
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (files.size === 0) {
|
|
105
|
+
console.log('[Gizzi Workspace] No workspace files found');
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log(`[Gizzi Workspace] Loaded ${files.size} files`);
|
|
110
|
+
|
|
111
|
+
// Build context pack
|
|
112
|
+
const contextPack = buildContextPack({
|
|
113
|
+
sessionId,
|
|
114
|
+
agentId,
|
|
115
|
+
agentName,
|
|
116
|
+
files,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Get startup tasks
|
|
120
|
+
const startupTasks = getStartupTasks(contextPack);
|
|
121
|
+
console.log(`[Gizzi Workspace] ${startupTasks.length} startup tasks to execute`);
|
|
122
|
+
|
|
123
|
+
return { files, contextPack, startupTasks };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Execute Startup Tasks
|
|
128
|
+
// ============================================================================
|
|
129
|
+
|
|
130
|
+
export async function executeStartupTasks(
|
|
131
|
+
tasks: LoadedWorkspace['startupTasks'],
|
|
132
|
+
sendMessage: (content: string) => void
|
|
133
|
+
): Promise<void> {
|
|
134
|
+
for (const task of tasks) {
|
|
135
|
+
console.log(`[Gizzi Workspace] Executing startup task: ${task.action}`);
|
|
136
|
+
|
|
137
|
+
// Execute the task
|
|
138
|
+
// For now, just log it - in production this would perform actual actions
|
|
139
|
+
try {
|
|
140
|
+
// Simulate task execution
|
|
141
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
142
|
+
|
|
143
|
+
// Optionally send a message about the task
|
|
144
|
+
if (task.action.toLowerCase().includes('greet') || task.action.toLowerCase().includes('introduce')) {
|
|
145
|
+
// Don't auto-send, let the agent handle it naturally
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
task.lastExecuted = new Date().toISOString();
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error(`[Gizzi Workspace] Task failed:`, error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// Session Enhancement
|
|
157
|
+
// ============================================================================
|
|
158
|
+
|
|
159
|
+
export function enhanceSessionWithWorkspace(
|
|
160
|
+
session: WorkspaceSession,
|
|
161
|
+
workspace: LoadedWorkspace
|
|
162
|
+
): WorkspaceSession {
|
|
163
|
+
return {
|
|
164
|
+
...session,
|
|
165
|
+
mode: 'agent',
|
|
166
|
+
contextPack: workspace.contextPack,
|
|
167
|
+
contextHash: workspace.contextPack.hash,
|
|
168
|
+
contextRefreshedAt: new Date().toISOString(),
|
|
169
|
+
workspaceFiles: Array.from(workspace.files.keys()),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gizzi Workspace Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for agent workspace system
|
|
5
|
+
* mirrors the Allternit platform implementation
|
|
6
|
+
*/
|
|
7
|
+
export type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
8
|
+
export interface WorkspaceFile {
|
|
9
|
+
path: string;
|
|
10
|
+
name: string;
|
|
11
|
+
content: string;
|
|
12
|
+
type: 'manifest' | 'brain' | 'memory' | 'identity' | 'soul' | 'user' | 'voice' | 'policy' | 'playbook' | 'tools' | 'heartbeat' | 'system' | 'channels' | 'skill' | 'business' | 'knowledge' | 'config';
|
|
13
|
+
size: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TrustTier {
|
|
16
|
+
level: 1 | 2 | 3;
|
|
17
|
+
name: string;
|
|
18
|
+
rules: string[];
|
|
19
|
+
enforce: 'always' | 'contextual' | 'permission';
|
|
20
|
+
}
|
|
21
|
+
export interface ScheduledTask {
|
|
22
|
+
id: string;
|
|
23
|
+
frequency: 'on-session-start' | 'daily' | 'weekly' | 'monthly' | 'on-event';
|
|
24
|
+
action: string;
|
|
25
|
+
condition?: string;
|
|
26
|
+
lastExecuted?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ToolDefinition {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
requiresPermission: boolean;
|
|
32
|
+
permissionLevel: 1 | 2 | 3;
|
|
33
|
+
}
|
|
34
|
+
export interface ContextPack {
|
|
35
|
+
version: '1.0.0';
|
|
36
|
+
agentId: string;
|
|
37
|
+
agentName: string;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
identity: {
|
|
40
|
+
name: string;
|
|
41
|
+
purpose: string;
|
|
42
|
+
backstory: string;
|
|
43
|
+
personalityTraits: string[];
|
|
44
|
+
};
|
|
45
|
+
trustTiers: {
|
|
46
|
+
tier1: TrustTier;
|
|
47
|
+
tier2: TrustTier;
|
|
48
|
+
tier3: TrustTier;
|
|
49
|
+
};
|
|
50
|
+
governance: {
|
|
51
|
+
playbook: string;
|
|
52
|
+
availableTools: ToolDefinition[];
|
|
53
|
+
hardBans: string[];
|
|
54
|
+
escalation: string[];
|
|
55
|
+
};
|
|
56
|
+
heartbeat: {
|
|
57
|
+
tasks: ScheduledTask[];
|
|
58
|
+
lastCheck: string;
|
|
59
|
+
};
|
|
60
|
+
memory: {
|
|
61
|
+
brain: string;
|
|
62
|
+
activeTasks: string[];
|
|
63
|
+
lessons: string[];
|
|
64
|
+
userPreferences: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
voice: {
|
|
67
|
+
style: string;
|
|
68
|
+
tone: {
|
|
69
|
+
formality: number;
|
|
70
|
+
enthusiasm: number;
|
|
71
|
+
empathy: number;
|
|
72
|
+
directness: number;
|
|
73
|
+
};
|
|
74
|
+
rules: string[];
|
|
75
|
+
};
|
|
76
|
+
systemPrompt: string;
|
|
77
|
+
hash: string;
|
|
78
|
+
createdAt: string;
|
|
79
|
+
expiresAt: string;
|
|
80
|
+
}
|
|
81
|
+
export interface WorkspaceSession {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
mode: 'regular' | 'agent';
|
|
85
|
+
agentId?: string;
|
|
86
|
+
agentName?: string;
|
|
87
|
+
contextPack?: ContextPack;
|
|
88
|
+
contextHash?: string;
|
|
89
|
+
contextRefreshedAt?: string;
|
|
90
|
+
workspaceFiles?: string[];
|
|
91
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gizzi Workspace Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for agent workspace system
|
|
5
|
+
* mirrors the Allternit platform implementation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
9
|
+
|
|
10
|
+
export interface WorkspaceFile {
|
|
11
|
+
path: string;
|
|
12
|
+
name: string;
|
|
13
|
+
content: string;
|
|
14
|
+
type:
|
|
15
|
+
| 'manifest'
|
|
16
|
+
| 'brain'
|
|
17
|
+
| 'memory'
|
|
18
|
+
| 'identity'
|
|
19
|
+
| 'soul'
|
|
20
|
+
| 'user'
|
|
21
|
+
| 'voice'
|
|
22
|
+
| 'policy'
|
|
23
|
+
| 'playbook'
|
|
24
|
+
| 'tools'
|
|
25
|
+
| 'heartbeat'
|
|
26
|
+
| 'system'
|
|
27
|
+
| 'channels'
|
|
28
|
+
| 'skill'
|
|
29
|
+
| 'business'
|
|
30
|
+
| 'knowledge'
|
|
31
|
+
| 'config';
|
|
32
|
+
size: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TrustTier {
|
|
36
|
+
level: 1 | 2 | 3;
|
|
37
|
+
name: string;
|
|
38
|
+
rules: string[];
|
|
39
|
+
enforce: 'always' | 'contextual' | 'permission';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ScheduledTask {
|
|
43
|
+
id: string;
|
|
44
|
+
frequency: 'on-session-start' | 'daily' | 'weekly' | 'monthly' | 'on-event';
|
|
45
|
+
action: string;
|
|
46
|
+
condition?: string;
|
|
47
|
+
lastExecuted?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ToolDefinition {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
requiresPermission: boolean;
|
|
54
|
+
permissionLevel: 1 | 2 | 3;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ContextPack {
|
|
58
|
+
version: '1.0.0';
|
|
59
|
+
agentId: string;
|
|
60
|
+
agentName: string;
|
|
61
|
+
sessionId: string;
|
|
62
|
+
|
|
63
|
+
identity: {
|
|
64
|
+
name: string;
|
|
65
|
+
purpose: string;
|
|
66
|
+
backstory: string;
|
|
67
|
+
personalityTraits: string[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
trustTiers: {
|
|
71
|
+
tier1: TrustTier;
|
|
72
|
+
tier2: TrustTier;
|
|
73
|
+
tier3: TrustTier;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
governance: {
|
|
77
|
+
playbook: string;
|
|
78
|
+
availableTools: ToolDefinition[];
|
|
79
|
+
hardBans: string[];
|
|
80
|
+
escalation: string[];
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
heartbeat: {
|
|
84
|
+
tasks: ScheduledTask[];
|
|
85
|
+
lastCheck: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
memory: {
|
|
89
|
+
brain: string;
|
|
90
|
+
activeTasks: string[];
|
|
91
|
+
lessons: string[];
|
|
92
|
+
userPreferences: Record<string, unknown>;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
voice: {
|
|
96
|
+
style: string;
|
|
97
|
+
tone: {
|
|
98
|
+
formality: number;
|
|
99
|
+
enthusiasm: number;
|
|
100
|
+
empathy: number;
|
|
101
|
+
directness: number;
|
|
102
|
+
};
|
|
103
|
+
rules: string[];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
systemPrompt: string;
|
|
107
|
+
hash: string;
|
|
108
|
+
createdAt: string;
|
|
109
|
+
expiresAt: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface WorkspaceSession {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
mode: 'regular' | 'agent';
|
|
116
|
+
agentId?: string;
|
|
117
|
+
agentName?: string;
|
|
118
|
+
contextPack?: ContextPack;
|
|
119
|
+
contextHash?: string;
|
|
120
|
+
contextRefreshedAt?: string;
|
|
121
|
+
workspaceFiles?: string[];
|
|
122
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"jsx": "react-jsx"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|