@poncho-ai/harness 0.35.0 → 0.36.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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +12 -11
  2. package/CHANGELOG.md +25 -0
  3. package/dist/index.d.ts +485 -29
  4. package/dist/index.js +2839 -2114
  5. package/dist/isolate-TCWTUVG4.js +1532 -0
  6. package/package.json +23 -4
  7. package/scripts/migrate-to-engine.mjs +556 -0
  8. package/src/config.ts +106 -1
  9. package/src/harness.ts +226 -91
  10. package/src/index.ts +5 -0
  11. package/src/isolate/bindings.ts +206 -0
  12. package/src/isolate/bundler.ts +179 -0
  13. package/src/isolate/index.ts +10 -0
  14. package/src/isolate/polyfills.ts +796 -0
  15. package/src/isolate/run-code-tool.ts +220 -0
  16. package/src/isolate/runtime.ts +286 -0
  17. package/src/isolate/type-stubs.ts +196 -0
  18. package/src/memory.ts +129 -198
  19. package/src/reminder-store.ts +3 -237
  20. package/src/secrets-store.ts +2 -91
  21. package/src/state.ts +11 -1302
  22. package/src/storage/engine.ts +106 -0
  23. package/src/storage/index.ts +59 -0
  24. package/src/storage/memory-engine.ts +588 -0
  25. package/src/storage/postgres-engine.ts +139 -0
  26. package/src/storage/schema.ts +145 -0
  27. package/src/storage/sql-dialect.ts +963 -0
  28. package/src/storage/sqlite-engine.ts +99 -0
  29. package/src/storage/store-adapters.ts +100 -0
  30. package/src/todo-tools.ts +1 -136
  31. package/src/upload-store.ts +1 -0
  32. package/src/vfs/bash-manager.ts +120 -0
  33. package/src/vfs/bash-tool.ts +59 -0
  34. package/src/vfs/create-bash-fs.ts +32 -0
  35. package/src/vfs/edit-file-tool.ts +72 -0
  36. package/src/vfs/index.ts +5 -0
  37. package/src/vfs/poncho-fs-adapter.ts +267 -0
  38. package/src/vfs/protected-fs.ts +177 -0
  39. package/src/vfs/read-file-tool.ts +103 -0
  40. package/src/vfs/write-file-tool.ts +49 -0
  41. package/test/harness.test.ts +30 -36
  42. package/test/isolate-vfs.test.ts +453 -0
  43. package/test/isolate.test.ts +252 -0
  44. package/test/state.test.ts +4 -27
  45. package/test/storage-engine.test.ts +250 -0
  46. package/test/vfs.test.ts +242 -0
  47. package/.turbo/turbo-lint.log +0 -6
  48. package/.turbo/turbo-test.log +0 -11931
  49. package/src/kv-store.ts +0 -216
@@ -0,0 +1,106 @@
1
+ import type {
2
+ Conversation,
3
+ ConversationSummary,
4
+ PendingSubagentResult,
5
+ } from "../state.js";
6
+ import type { MainMemory } from "../memory.js";
7
+ import type { TodoItem } from "../todo-tools.js";
8
+ import type { Reminder } from "../reminder-store.js";
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // VFS types
12
+ // ---------------------------------------------------------------------------
13
+
14
+ export interface VfsStat {
15
+ type: "file" | "directory" | "symlink";
16
+ size: number;
17
+ mode: number;
18
+ mimeType?: string;
19
+ symlinkTarget?: string;
20
+ createdAt: number;
21
+ updatedAt: number;
22
+ }
23
+
24
+ export interface VfsDirEntry {
25
+ name: string;
26
+ type: "file" | "directory" | "symlink";
27
+ }
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // StorageEngine – single interface replacing all KV stores
31
+ // ---------------------------------------------------------------------------
32
+
33
+ export interface StorageEngine {
34
+ /** Run migrations and prepare the storage backend. */
35
+ initialize(): Promise<void>;
36
+ /** Gracefully release resources. */
37
+ close(): Promise<void>;
38
+
39
+ // --- Conversations (replaces ConversationStore) ---
40
+ conversations: {
41
+ list(ownerId?: string, tenantId?: string | null): Promise<ConversationSummary[]>;
42
+ get(conversationId: string): Promise<Conversation | undefined>;
43
+ create(ownerId?: string, title?: string, tenantId?: string | null): Promise<Conversation>;
44
+ update(conversation: Conversation): Promise<void>;
45
+ rename(conversationId: string, title: string): Promise<Conversation | undefined>;
46
+ delete(conversationId: string): Promise<boolean>;
47
+ search(query: string, tenantId?: string | null): Promise<ConversationSummary[]>;
48
+ appendSubagentResult(
49
+ conversationId: string,
50
+ result: PendingSubagentResult,
51
+ ): Promise<void>;
52
+ clearCallbackLock(conversationId: string): Promise<Conversation | undefined>;
53
+ };
54
+
55
+ // --- Memory (replaces MemoryStore) ---
56
+ memory: {
57
+ get(tenantId?: string | null): Promise<MainMemory>;
58
+ update(content: string, tenantId?: string | null): Promise<MainMemory>;
59
+ };
60
+
61
+ // --- Todos (replaces TodoStore) ---
62
+ todos: {
63
+ get(conversationId: string): Promise<TodoItem[]>;
64
+ set(conversationId: string, todos: TodoItem[]): Promise<void>;
65
+ };
66
+
67
+ // --- Reminders (replaces ReminderStore) ---
68
+ reminders: {
69
+ list(tenantId?: string | null): Promise<Reminder[]>;
70
+ create(input: {
71
+ task: string;
72
+ scheduledAt: number;
73
+ timezone?: string;
74
+ conversationId: string;
75
+ ownerId?: string;
76
+ tenantId?: string | null;
77
+ }): Promise<Reminder>;
78
+ cancel(id: string): Promise<Reminder>;
79
+ delete(id: string): Promise<void>;
80
+ };
81
+
82
+ // --- Virtual Filesystem (replaces UploadStore + new VFS) ---
83
+ vfs: {
84
+ readFile(tenantId: string, path: string): Promise<Uint8Array>;
85
+ writeFile(
86
+ tenantId: string,
87
+ path: string,
88
+ content: Uint8Array,
89
+ mimeType?: string,
90
+ ): Promise<void>;
91
+ appendFile(tenantId: string, path: string, content: Uint8Array): Promise<void>;
92
+ deleteFile(tenantId: string, path: string): Promise<void>;
93
+ deleteDir(tenantId: string, path: string, recursive?: boolean): Promise<void>;
94
+ stat(tenantId: string, path: string): Promise<VfsStat | undefined>;
95
+ readdir(tenantId: string, path: string): Promise<VfsDirEntry[]>;
96
+ mkdir(tenantId: string, path: string, recursive?: boolean): Promise<void>;
97
+ rename(tenantId: string, oldPath: string, newPath: string): Promise<void>;
98
+ chmod(tenantId: string, path: string, mode: number): Promise<void>;
99
+ utimes(tenantId: string, path: string, mtime: Date): Promise<void>;
100
+ symlink(tenantId: string, target: string, linkPath: string): Promise<void>;
101
+ readlink(tenantId: string, path: string): Promise<string>;
102
+ lstat(tenantId: string, path: string): Promise<VfsStat | undefined>;
103
+ listAllPaths(tenantId: string): string[];
104
+ getUsage(tenantId: string): Promise<{ fileCount: number; totalBytes: number }>;
105
+ };
106
+ }
@@ -0,0 +1,59 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Storage engine factory + re-exports
3
+ // ---------------------------------------------------------------------------
4
+
5
+ export type { StorageEngine, VfsDirEntry, VfsStat } from "./engine.js";
6
+ export { InMemoryEngine } from "./memory-engine.js";
7
+ export { SqliteEngine } from "./sqlite-engine.js";
8
+ export { PostgresEngine } from "./postgres-engine.js";
9
+
10
+ import type { StorageEngine } from "./engine.js";
11
+ import { InMemoryEngine } from "./memory-engine.js";
12
+ import { SqliteEngine } from "./sqlite-engine.js";
13
+ import { PostgresEngine } from "./postgres-engine.js";
14
+
15
+ export type StorageProvider = "memory" | "sqlite" | "postgresql" | "local";
16
+
17
+ export interface StorageFactoryOptions {
18
+ provider?: StorageProvider;
19
+ workingDir: string;
20
+ agentId: string;
21
+ /** Env var name for the PostgreSQL connection URL (default: DATABASE_URL). */
22
+ urlEnv?: string;
23
+ /** Override the SQLite database file path. */
24
+ dbPath?: string;
25
+ }
26
+
27
+ export function createStorageEngine(options: StorageFactoryOptions): StorageEngine {
28
+ const provider = options.provider ?? "sqlite";
29
+
30
+ switch (provider) {
31
+ case "memory":
32
+ return new InMemoryEngine(options.agentId);
33
+
34
+ case "local":
35
+ case "sqlite":
36
+ return new SqliteEngine({
37
+ workingDir: options.workingDir,
38
+ agentId: options.agentId,
39
+ dbPath: options.dbPath,
40
+ });
41
+
42
+ case "postgresql":
43
+ return new PostgresEngine({
44
+ agentId: options.agentId,
45
+ urlEnv: options.urlEnv,
46
+ });
47
+
48
+ default: {
49
+ const deprecated = ["redis", "upstash", "dynamodb"];
50
+ if (deprecated.includes(provider)) {
51
+ throw new Error(
52
+ `Storage provider '${provider}' is no longer supported. ` +
53
+ `Please migrate to 'sqlite' or 'postgresql'.`,
54
+ );
55
+ }
56
+ throw new Error(`Unknown storage provider: ${provider}`);
57
+ }
58
+ }
59
+ }