@haaaiawd/second-nature 0.1.22 → 0.1.24
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/runtime/cli/commands/connector-init.d.ts +19 -0
- package/runtime/cli/commands/connector-init.js +168 -0
- package/runtime/cli/commands/connector-status.d.ts +12 -0
- package/runtime/cli/commands/connector-status.js +156 -0
- package/runtime/cli/commands/index.js +40 -0
- package/runtime/cli/index.js +52 -0
- package/runtime/cli/ops/ops-router.d.ts +5 -0
- package/runtime/cli/ops/ops-router.js +34 -0
- package/runtime/cli/ops/workspace-heartbeat-runner.js +22 -0
- package/runtime/connectors/agent-network/agent-world/adapter.d.ts +11 -0
- package/runtime/connectors/agent-network/agent-world/adapter.js +58 -0
- package/runtime/connectors/agent-network/agent-world/index.d.ts +2 -0
- package/runtime/connectors/agent-network/agent-world/index.js +2 -0
- package/runtime/connectors/agent-network/agent-world/manifest.d.ts +2 -0
- package/runtime/connectors/agent-network/agent-world/manifest.js +7 -0
- package/runtime/connectors/base/manifest.d.ts +13 -0
- package/runtime/connectors/base/manifest.js +47 -0
- package/runtime/connectors/manifest/manifest-parser.d.ts +16 -0
- package/runtime/connectors/manifest/manifest-parser.js +35 -0
- package/runtime/connectors/manifest/manifest-schema.d.ts +145 -0
- package/runtime/connectors/manifest/manifest-schema.js +51 -0
- package/runtime/connectors/registry/dynamic-connector-registry.d.ts +29 -0
- package/runtime/connectors/registry/dynamic-connector-registry.js +123 -0
- package/runtime/connectors/registry/index.d.ts +3 -0
- package/runtime/connectors/registry/index.js +3 -0
- package/runtime/connectors/registry/manifest-scanner.d.ts +9 -0
- package/runtime/connectors/registry/manifest-scanner.js +29 -0
- package/runtime/connectors/registry/trust-policy.d.ts +13 -0
- package/runtime/connectors/registry/trust-policy.js +37 -0
- package/runtime/connectors/services/connector-executor-adapter.js +49 -0
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +3 -0
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +52 -1
- package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +3 -0
- package/runtime/core/second-nature/orchestrator/goal-priority.d.ts +19 -0
- package/runtime/core/second-nature/orchestrator/goal-priority.js +67 -0
- package/runtime/core/second-nature/orchestrator/intent-planner.js +8 -0
- package/runtime/core/second-nature/orchestrator/narrative-update.d.ts +27 -0
- package/runtime/core/second-nature/orchestrator/narrative-update.js +107 -0
- package/runtime/core/second-nature/types.d.ts +4 -0
- package/runtime/guidance/draft-narrative-outreach.d.ts +36 -0
- package/runtime/guidance/draft-narrative-outreach.js +84 -0
- package/runtime/guidance/index.d.ts +1 -0
- package/runtime/guidance/index.js +1 -0
- package/runtime/guidance/outreach-draft-schema.d.ts +3 -3
- package/runtime/observability/connector-inventory-ledger.d.ts +45 -0
- package/runtime/observability/connector-inventory-ledger.js +72 -0
- package/runtime/observability/db/index.js +13 -0
- package/runtime/observability/db/schema/connector-inventory.d.ts +174 -0
- package/runtime/observability/db/schema/connector-inventory.js +15 -0
- package/runtime/observability/db/schema/index.d.ts +1 -0
- package/runtime/observability/db/schema/index.js +1 -0
- package/runtime/storage/chronicle/session-chronicle-store.d.ts +42 -0
- package/runtime/storage/chronicle/session-chronicle-store.js +66 -0
- package/runtime/storage/db/index.js +75 -0
- package/runtime/storage/db/schema/agent-goal.d.ts +235 -0
- package/runtime/storage/db/schema/agent-goal.js +19 -0
- package/runtime/storage/db/schema/index.d.ts +5 -0
- package/runtime/storage/db/schema/index.js +5 -0
- package/runtime/storage/db/schema/memory-store.d.ts +199 -0
- package/runtime/storage/db/schema/memory-store.js +18 -0
- package/runtime/storage/db/schema/narrative-state.d.ts +195 -0
- package/runtime/storage/db/schema/narrative-state.js +16 -0
- package/runtime/storage/db/schema/relationship-memory.d.ts +174 -0
- package/runtime/storage/db/schema/relationship-memory.js +14 -0
- package/runtime/storage/db/schema/session-chronicle.d.ts +199 -0
- package/runtime/storage/db/schema/session-chronicle.js +18 -0
- package/runtime/storage/goal/agent-goal-store.d.ts +57 -0
- package/runtime/storage/goal/agent-goal-store.js +109 -0
- package/runtime/storage/index.d.ts +5 -0
- package/runtime/storage/index.js +5 -0
- package/runtime/storage/memory-store/memory-store-lifecycle.d.ts +70 -0
- package/runtime/storage/memory-store/memory-store-lifecycle.js +113 -0
- package/runtime/storage/narrative/narrative-state-store.d.ts +40 -0
- package/runtime/storage/narrative/narrative-state-store.js +79 -0
- package/runtime/storage/relationship/relationship-memory-store.d.ts +42 -0
- package/runtime/storage/relationship/relationship-memory-store.js +76 -0
- package/workspace-ops-bridge.js +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { index, sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
2
|
+
export const narrativeState = sqliteTable("narrative_state", {
|
|
3
|
+
narrativeId: text("narrative_id").primaryKey(),
|
|
4
|
+
revision: integer("revision").notNull().default(1),
|
|
5
|
+
focus: text("focus").notNull(),
|
|
6
|
+
progressJson: text("progress_json").notNull(),
|
|
7
|
+
nextIntent: text("next_intent").notNull(),
|
|
8
|
+
confidence: integer("confidence").notNull().default(0),
|
|
9
|
+
sourceRefsJson: text("source_refs_json").notNull(),
|
|
10
|
+
unsupportedClaimsJson: text("unsupported_claims_json").notNull(),
|
|
11
|
+
status: text("status").notNull(),
|
|
12
|
+
updatedAt: text("updated_at").notNull(),
|
|
13
|
+
}, (table) => [
|
|
14
|
+
index("narrative_state_status_idx").on(table.status),
|
|
15
|
+
index("narrative_state_updated_at_idx").on(table.updatedAt),
|
|
16
|
+
]);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export declare const relationshipMemory: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
2
|
+
name: "relationship_memory";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
relationshipId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: "relationship_id";
|
|
7
|
+
tableName: "relationship_memory";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "SQLiteText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {
|
|
22
|
+
length: number | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
revision: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
25
|
+
name: "revision";
|
|
26
|
+
tableName: "relationship_memory";
|
|
27
|
+
dataType: "number";
|
|
28
|
+
columnType: "SQLiteInteger";
|
|
29
|
+
data: number;
|
|
30
|
+
driverParam: number;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: true;
|
|
33
|
+
isPrimaryKey: false;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: false;
|
|
36
|
+
enumValues: undefined;
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {}>;
|
|
41
|
+
tonePreference: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
42
|
+
name: "tone_preference";
|
|
43
|
+
tableName: "relationship_memory";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "SQLiteText";
|
|
46
|
+
data: string;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: [string, ...string[]];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {
|
|
58
|
+
length: number | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
averageReplyDelayMinutes: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
61
|
+
name: "average_reply_delay_minutes";
|
|
62
|
+
tableName: "relationship_memory";
|
|
63
|
+
dataType: "number";
|
|
64
|
+
columnType: "SQLiteInteger";
|
|
65
|
+
data: number;
|
|
66
|
+
driverParam: number;
|
|
67
|
+
notNull: false;
|
|
68
|
+
hasDefault: false;
|
|
69
|
+
isPrimaryKey: false;
|
|
70
|
+
isAutoincrement: false;
|
|
71
|
+
hasRuntimeDefault: false;
|
|
72
|
+
enumValues: undefined;
|
|
73
|
+
baseColumn: never;
|
|
74
|
+
identity: undefined;
|
|
75
|
+
generated: undefined;
|
|
76
|
+
}, {}, {}>;
|
|
77
|
+
noReplyCount: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
78
|
+
name: "no_reply_count";
|
|
79
|
+
tableName: "relationship_memory";
|
|
80
|
+
dataType: "number";
|
|
81
|
+
columnType: "SQLiteInteger";
|
|
82
|
+
data: number;
|
|
83
|
+
driverParam: number;
|
|
84
|
+
notNull: true;
|
|
85
|
+
hasDefault: true;
|
|
86
|
+
isPrimaryKey: false;
|
|
87
|
+
isAutoincrement: false;
|
|
88
|
+
hasRuntimeDefault: false;
|
|
89
|
+
enumValues: undefined;
|
|
90
|
+
baseColumn: never;
|
|
91
|
+
identity: undefined;
|
|
92
|
+
generated: undefined;
|
|
93
|
+
}, {}, {}>;
|
|
94
|
+
topicAffinitiesJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
95
|
+
name: "topic_affinities_json";
|
|
96
|
+
tableName: "relationship_memory";
|
|
97
|
+
dataType: "string";
|
|
98
|
+
columnType: "SQLiteText";
|
|
99
|
+
data: string;
|
|
100
|
+
driverParam: string;
|
|
101
|
+
notNull: true;
|
|
102
|
+
hasDefault: false;
|
|
103
|
+
isPrimaryKey: false;
|
|
104
|
+
isAutoincrement: false;
|
|
105
|
+
hasRuntimeDefault: false;
|
|
106
|
+
enumValues: [string, ...string[]];
|
|
107
|
+
baseColumn: never;
|
|
108
|
+
identity: undefined;
|
|
109
|
+
generated: undefined;
|
|
110
|
+
}, {}, {
|
|
111
|
+
length: number | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
lastInteractionAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
114
|
+
name: "last_interaction_at";
|
|
115
|
+
tableName: "relationship_memory";
|
|
116
|
+
dataType: "string";
|
|
117
|
+
columnType: "SQLiteText";
|
|
118
|
+
data: string;
|
|
119
|
+
driverParam: string;
|
|
120
|
+
notNull: false;
|
|
121
|
+
hasDefault: false;
|
|
122
|
+
isPrimaryKey: false;
|
|
123
|
+
isAutoincrement: false;
|
|
124
|
+
hasRuntimeDefault: false;
|
|
125
|
+
enumValues: [string, ...string[]];
|
|
126
|
+
baseColumn: never;
|
|
127
|
+
identity: undefined;
|
|
128
|
+
generated: undefined;
|
|
129
|
+
}, {}, {
|
|
130
|
+
length: number | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
sourceRefsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
133
|
+
name: "source_refs_json";
|
|
134
|
+
tableName: "relationship_memory";
|
|
135
|
+
dataType: "string";
|
|
136
|
+
columnType: "SQLiteText";
|
|
137
|
+
data: string;
|
|
138
|
+
driverParam: string;
|
|
139
|
+
notNull: true;
|
|
140
|
+
hasDefault: false;
|
|
141
|
+
isPrimaryKey: false;
|
|
142
|
+
isAutoincrement: false;
|
|
143
|
+
hasRuntimeDefault: false;
|
|
144
|
+
enumValues: [string, ...string[]];
|
|
145
|
+
baseColumn: never;
|
|
146
|
+
identity: undefined;
|
|
147
|
+
generated: undefined;
|
|
148
|
+
}, {}, {
|
|
149
|
+
length: number | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
152
|
+
name: "updated_at";
|
|
153
|
+
tableName: "relationship_memory";
|
|
154
|
+
dataType: "string";
|
|
155
|
+
columnType: "SQLiteText";
|
|
156
|
+
data: string;
|
|
157
|
+
driverParam: string;
|
|
158
|
+
notNull: true;
|
|
159
|
+
hasDefault: false;
|
|
160
|
+
isPrimaryKey: false;
|
|
161
|
+
isAutoincrement: false;
|
|
162
|
+
hasRuntimeDefault: false;
|
|
163
|
+
enumValues: [string, ...string[]];
|
|
164
|
+
baseColumn: never;
|
|
165
|
+
identity: undefined;
|
|
166
|
+
generated: undefined;
|
|
167
|
+
}, {}, {
|
|
168
|
+
length: number | undefined;
|
|
169
|
+
}>;
|
|
170
|
+
};
|
|
171
|
+
dialect: "sqlite";
|
|
172
|
+
}>;
|
|
173
|
+
export type RelationshipMemoryRow = typeof relationshipMemory.$inferSelect;
|
|
174
|
+
export type NewRelationshipMemoryRow = typeof relationshipMemory.$inferInsert;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { index, sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
2
|
+
export const relationshipMemory = sqliteTable("relationship_memory", {
|
|
3
|
+
relationshipId: text("relationship_id").primaryKey(),
|
|
4
|
+
revision: integer("revision").notNull().default(1),
|
|
5
|
+
tonePreference: text("tone_preference").notNull(),
|
|
6
|
+
averageReplyDelayMinutes: integer("average_reply_delay_minutes"),
|
|
7
|
+
noReplyCount: integer("no_reply_count").notNull().default(0),
|
|
8
|
+
topicAffinitiesJson: text("topic_affinities_json").notNull(),
|
|
9
|
+
lastInteractionAt: text("last_interaction_at"),
|
|
10
|
+
sourceRefsJson: text("source_refs_json").notNull(),
|
|
11
|
+
updatedAt: text("updated_at").notNull(),
|
|
12
|
+
}, (table) => [
|
|
13
|
+
index("relationship_memory_updated_at_idx").on(table.updatedAt),
|
|
14
|
+
]);
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export declare const sessionChronicle: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
2
|
+
name: "session_chronicle";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
entryId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: "entry_id";
|
|
7
|
+
tableName: "session_chronicle";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "SQLiteText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {
|
|
22
|
+
length: number | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
eventKind: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
25
|
+
name: "event_kind";
|
|
26
|
+
tableName: "session_chronicle";
|
|
27
|
+
dataType: "string";
|
|
28
|
+
columnType: "SQLiteText";
|
|
29
|
+
data: string;
|
|
30
|
+
driverParam: string;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: false;
|
|
33
|
+
isPrimaryKey: false;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: false;
|
|
36
|
+
enumValues: [string, ...string[]];
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {
|
|
41
|
+
length: number | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
actor: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
44
|
+
name: "actor";
|
|
45
|
+
tableName: "session_chronicle";
|
|
46
|
+
dataType: "string";
|
|
47
|
+
columnType: "SQLiteText";
|
|
48
|
+
data: string;
|
|
49
|
+
driverParam: string;
|
|
50
|
+
notNull: true;
|
|
51
|
+
hasDefault: false;
|
|
52
|
+
isPrimaryKey: false;
|
|
53
|
+
isAutoincrement: false;
|
|
54
|
+
hasRuntimeDefault: false;
|
|
55
|
+
enumValues: [string, ...string[]];
|
|
56
|
+
baseColumn: never;
|
|
57
|
+
identity: undefined;
|
|
58
|
+
generated: undefined;
|
|
59
|
+
}, {}, {
|
|
60
|
+
length: number | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
occurredAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
63
|
+
name: "occurred_at";
|
|
64
|
+
tableName: "session_chronicle";
|
|
65
|
+
dataType: "string";
|
|
66
|
+
columnType: "SQLiteText";
|
|
67
|
+
data: string;
|
|
68
|
+
driverParam: string;
|
|
69
|
+
notNull: true;
|
|
70
|
+
hasDefault: false;
|
|
71
|
+
isPrimaryKey: false;
|
|
72
|
+
isAutoincrement: false;
|
|
73
|
+
hasRuntimeDefault: false;
|
|
74
|
+
enumValues: [string, ...string[]];
|
|
75
|
+
baseColumn: never;
|
|
76
|
+
identity: undefined;
|
|
77
|
+
generated: undefined;
|
|
78
|
+
}, {}, {
|
|
79
|
+
length: number | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
summary: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
82
|
+
name: "summary";
|
|
83
|
+
tableName: "session_chronicle";
|
|
84
|
+
dataType: "string";
|
|
85
|
+
columnType: "SQLiteText";
|
|
86
|
+
data: string;
|
|
87
|
+
driverParam: string;
|
|
88
|
+
notNull: true;
|
|
89
|
+
hasDefault: false;
|
|
90
|
+
isPrimaryKey: false;
|
|
91
|
+
isAutoincrement: false;
|
|
92
|
+
hasRuntimeDefault: false;
|
|
93
|
+
enumValues: [string, ...string[]];
|
|
94
|
+
baseColumn: never;
|
|
95
|
+
identity: undefined;
|
|
96
|
+
generated: undefined;
|
|
97
|
+
}, {}, {
|
|
98
|
+
length: number | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
result: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
101
|
+
name: "result";
|
|
102
|
+
tableName: "session_chronicle";
|
|
103
|
+
dataType: "string";
|
|
104
|
+
columnType: "SQLiteText";
|
|
105
|
+
data: string;
|
|
106
|
+
driverParam: string;
|
|
107
|
+
notNull: true;
|
|
108
|
+
hasDefault: false;
|
|
109
|
+
isPrimaryKey: false;
|
|
110
|
+
isAutoincrement: false;
|
|
111
|
+
hasRuntimeDefault: false;
|
|
112
|
+
enumValues: [string, ...string[]];
|
|
113
|
+
baseColumn: never;
|
|
114
|
+
identity: undefined;
|
|
115
|
+
generated: undefined;
|
|
116
|
+
}, {}, {
|
|
117
|
+
length: number | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
sourceRefsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
120
|
+
name: "source_refs_json";
|
|
121
|
+
tableName: "session_chronicle";
|
|
122
|
+
dataType: "string";
|
|
123
|
+
columnType: "SQLiteText";
|
|
124
|
+
data: string;
|
|
125
|
+
driverParam: string;
|
|
126
|
+
notNull: true;
|
|
127
|
+
hasDefault: false;
|
|
128
|
+
isPrimaryKey: false;
|
|
129
|
+
isAutoincrement: false;
|
|
130
|
+
hasRuntimeDefault: false;
|
|
131
|
+
enumValues: [string, ...string[]];
|
|
132
|
+
baseColumn: never;
|
|
133
|
+
identity: undefined;
|
|
134
|
+
generated: undefined;
|
|
135
|
+
}, {}, {
|
|
136
|
+
length: number | undefined;
|
|
137
|
+
}>;
|
|
138
|
+
relatedDecisionId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
139
|
+
name: "related_decision_id";
|
|
140
|
+
tableName: "session_chronicle";
|
|
141
|
+
dataType: "string";
|
|
142
|
+
columnType: "SQLiteText";
|
|
143
|
+
data: string;
|
|
144
|
+
driverParam: string;
|
|
145
|
+
notNull: false;
|
|
146
|
+
hasDefault: false;
|
|
147
|
+
isPrimaryKey: false;
|
|
148
|
+
isAutoincrement: false;
|
|
149
|
+
hasRuntimeDefault: false;
|
|
150
|
+
enumValues: [string, ...string[]];
|
|
151
|
+
baseColumn: never;
|
|
152
|
+
identity: undefined;
|
|
153
|
+
generated: undefined;
|
|
154
|
+
}, {}, {
|
|
155
|
+
length: number | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
relatedDreamRunId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
158
|
+
name: "related_dream_run_id";
|
|
159
|
+
tableName: "session_chronicle";
|
|
160
|
+
dataType: "string";
|
|
161
|
+
columnType: "SQLiteText";
|
|
162
|
+
data: string;
|
|
163
|
+
driverParam: string;
|
|
164
|
+
notNull: false;
|
|
165
|
+
hasDefault: false;
|
|
166
|
+
isPrimaryKey: false;
|
|
167
|
+
isAutoincrement: false;
|
|
168
|
+
hasRuntimeDefault: false;
|
|
169
|
+
enumValues: [string, ...string[]];
|
|
170
|
+
baseColumn: never;
|
|
171
|
+
identity: undefined;
|
|
172
|
+
generated: undefined;
|
|
173
|
+
}, {}, {
|
|
174
|
+
length: number | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
ownerReplyJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
177
|
+
name: "owner_reply_json";
|
|
178
|
+
tableName: "session_chronicle";
|
|
179
|
+
dataType: "string";
|
|
180
|
+
columnType: "SQLiteText";
|
|
181
|
+
data: string;
|
|
182
|
+
driverParam: string;
|
|
183
|
+
notNull: false;
|
|
184
|
+
hasDefault: false;
|
|
185
|
+
isPrimaryKey: false;
|
|
186
|
+
isAutoincrement: false;
|
|
187
|
+
hasRuntimeDefault: false;
|
|
188
|
+
enumValues: [string, ...string[]];
|
|
189
|
+
baseColumn: never;
|
|
190
|
+
identity: undefined;
|
|
191
|
+
generated: undefined;
|
|
192
|
+
}, {}, {
|
|
193
|
+
length: number | undefined;
|
|
194
|
+
}>;
|
|
195
|
+
};
|
|
196
|
+
dialect: "sqlite";
|
|
197
|
+
}>;
|
|
198
|
+
export type SessionChronicleRow = typeof sessionChronicle.$inferSelect;
|
|
199
|
+
export type NewSessionChronicleRow = typeof sessionChronicle.$inferInsert;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { index, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
2
|
+
export const sessionChronicle = sqliteTable("session_chronicle", {
|
|
3
|
+
entryId: text("entry_id").primaryKey(),
|
|
4
|
+
eventKind: text("event_kind").notNull(),
|
|
5
|
+
actor: text("actor").notNull(),
|
|
6
|
+
occurredAt: text("occurred_at").notNull(),
|
|
7
|
+
summary: text("summary").notNull(),
|
|
8
|
+
result: text("result").notNull(),
|
|
9
|
+
sourceRefsJson: text("source_refs_json").notNull(),
|
|
10
|
+
relatedDecisionId: text("related_decision_id"),
|
|
11
|
+
relatedDreamRunId: text("related_dream_run_id"),
|
|
12
|
+
ownerReplyJson: text("owner_reply_json"),
|
|
13
|
+
}, (table) => [
|
|
14
|
+
index("session_chronicle_event_kind_idx").on(table.eventKind),
|
|
15
|
+
index("session_chronicle_occurred_at_idx").on(table.occurredAt),
|
|
16
|
+
index("session_chronicle_actor_idx").on(table.actor),
|
|
17
|
+
index("session_chronicle_decision_idx").on(table.relatedDecisionId),
|
|
18
|
+
]);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { StateDatabase } from "../db/index.js";
|
|
2
|
+
export interface SourceRef {
|
|
3
|
+
sourceId: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
snippet?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AgentGoal {
|
|
9
|
+
goalId: string;
|
|
10
|
+
kind: "short_term" | "long_term";
|
|
11
|
+
status: "proposal" | "accepted" | "rejected" | "completed" | "paused";
|
|
12
|
+
origin: "owner_set" | "agent_proposed" | "policy_seeded";
|
|
13
|
+
description: string;
|
|
14
|
+
completionCriteria: string;
|
|
15
|
+
risk: "low" | "medium" | "high";
|
|
16
|
+
priorityHint: number;
|
|
17
|
+
sourceRefs: SourceRef[];
|
|
18
|
+
acceptedBy?: "owner" | "policy_allowlist";
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AgentGoalWrite {
|
|
23
|
+
goalId: string;
|
|
24
|
+
kind: "short_term" | "long_term";
|
|
25
|
+
status: "proposal" | "accepted" | "rejected" | "completed" | "paused";
|
|
26
|
+
origin: "owner_set" | "agent_proposed" | "policy_seeded";
|
|
27
|
+
description: string;
|
|
28
|
+
completionCriteria: string;
|
|
29
|
+
risk: "low" | "medium" | "high";
|
|
30
|
+
priorityHint: number;
|
|
31
|
+
sourceRefs: SourceRef[];
|
|
32
|
+
acceptedBy?: "owner" | "policy_allowlist";
|
|
33
|
+
createdAt: string;
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AgentGoalStatusTransition {
|
|
37
|
+
goalId: string;
|
|
38
|
+
newStatus: "proposal" | "accepted" | "rejected" | "completed" | "paused";
|
|
39
|
+
acceptedBy?: "owner" | "policy_allowlist";
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
}
|
|
42
|
+
export interface AgentGoalQuery {
|
|
43
|
+
statuses?: AgentGoal["status"][];
|
|
44
|
+
origins?: AgentGoal["origin"][];
|
|
45
|
+
limit?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface AgentGoalWriteAck {
|
|
48
|
+
goalId: string;
|
|
49
|
+
status: "acknowledged" | "degraded";
|
|
50
|
+
}
|
|
51
|
+
export interface AgentGoalStore {
|
|
52
|
+
upsertAgentGoal(goal: AgentGoalWrite): Promise<AgentGoalWriteAck>;
|
|
53
|
+
listAgentGoals(query: AgentGoalQuery): Promise<AgentGoal[]>;
|
|
54
|
+
transitionGoalStatus(input: AgentGoalStatusTransition): Promise<AgentGoalWriteAck>;
|
|
55
|
+
loadAgentGoal(goalId: string): Promise<AgentGoal | null>;
|
|
56
|
+
}
|
|
57
|
+
export declare function createAgentGoalStore(database: StateDatabase): AgentGoalStore;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { eq, inArray, desc, and } from "drizzle-orm";
|
|
2
|
+
import { agentGoal } from "../db/schema/agent-goal.js";
|
|
3
|
+
function safeParseJson(json, fallback) {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(json);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return fallback;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function rowToGoal(row) {
|
|
12
|
+
return {
|
|
13
|
+
goalId: row.goalId,
|
|
14
|
+
kind: row.kind,
|
|
15
|
+
status: row.status,
|
|
16
|
+
origin: row.origin,
|
|
17
|
+
description: row.description,
|
|
18
|
+
completionCriteria: row.completionCriteria,
|
|
19
|
+
risk: row.risk,
|
|
20
|
+
priorityHint: row.priorityHint,
|
|
21
|
+
sourceRefs: safeParseJson(row.sourceRefsJson, []),
|
|
22
|
+
acceptedBy: row.acceptedBy ? row.acceptedBy : undefined,
|
|
23
|
+
createdAt: row.createdAt,
|
|
24
|
+
updatedAt: row.updatedAt,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function createAgentGoalStore(database) {
|
|
28
|
+
const db = database.db;
|
|
29
|
+
return {
|
|
30
|
+
async upsertAgentGoal(goal) {
|
|
31
|
+
const existing = await db
|
|
32
|
+
.select()
|
|
33
|
+
.from(agentGoal)
|
|
34
|
+
.where(eq(agentGoal.goalId, goal.goalId))
|
|
35
|
+
.limit(1);
|
|
36
|
+
if (existing.length > 0) {
|
|
37
|
+
await db
|
|
38
|
+
.update(agentGoal)
|
|
39
|
+
.set({
|
|
40
|
+
kind: goal.kind,
|
|
41
|
+
status: goal.status,
|
|
42
|
+
origin: goal.origin,
|
|
43
|
+
description: goal.description,
|
|
44
|
+
completionCriteria: goal.completionCriteria,
|
|
45
|
+
risk: goal.risk,
|
|
46
|
+
priorityHint: goal.priorityHint,
|
|
47
|
+
sourceRefsJson: JSON.stringify(goal.sourceRefs),
|
|
48
|
+
acceptedBy: goal.acceptedBy ?? null,
|
|
49
|
+
updatedAt: goal.updatedAt,
|
|
50
|
+
})
|
|
51
|
+
.where(eq(agentGoal.goalId, goal.goalId));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
await db.insert(agentGoal).values({
|
|
55
|
+
goalId: goal.goalId,
|
|
56
|
+
kind: goal.kind,
|
|
57
|
+
status: goal.status,
|
|
58
|
+
origin: goal.origin,
|
|
59
|
+
description: goal.description,
|
|
60
|
+
completionCriteria: goal.completionCriteria,
|
|
61
|
+
risk: goal.risk,
|
|
62
|
+
priorityHint: goal.priorityHint,
|
|
63
|
+
sourceRefsJson: JSON.stringify(goal.sourceRefs),
|
|
64
|
+
acceptedBy: goal.acceptedBy ?? null,
|
|
65
|
+
createdAt: goal.createdAt,
|
|
66
|
+
updatedAt: goal.updatedAt,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return { goalId: goal.goalId, status: "acknowledged" };
|
|
70
|
+
},
|
|
71
|
+
async listAgentGoals(query) {
|
|
72
|
+
const conditions = [];
|
|
73
|
+
if (query.statuses && query.statuses.length > 0) {
|
|
74
|
+
conditions.push(inArray(agentGoal.status, query.statuses));
|
|
75
|
+
}
|
|
76
|
+
if (query.origins && query.origins.length > 0) {
|
|
77
|
+
conditions.push(inArray(agentGoal.origin, query.origins));
|
|
78
|
+
}
|
|
79
|
+
const rows = await db
|
|
80
|
+
.select()
|
|
81
|
+
.from(agentGoal)
|
|
82
|
+
.where(conditions.length > 0 ? and(...conditions) : undefined)
|
|
83
|
+
.orderBy(desc(agentGoal.updatedAt))
|
|
84
|
+
.limit(query.limit ?? 100);
|
|
85
|
+
return rows.map(rowToGoal);
|
|
86
|
+
},
|
|
87
|
+
async transitionGoalStatus(input) {
|
|
88
|
+
await db
|
|
89
|
+
.update(agentGoal)
|
|
90
|
+
.set({
|
|
91
|
+
status: input.newStatus,
|
|
92
|
+
acceptedBy: input.acceptedBy ?? null,
|
|
93
|
+
updatedAt: input.updatedAt,
|
|
94
|
+
})
|
|
95
|
+
.where(eq(agentGoal.goalId, input.goalId));
|
|
96
|
+
return { goalId: input.goalId, status: "acknowledged" };
|
|
97
|
+
},
|
|
98
|
+
async loadAgentGoal(goalId) {
|
|
99
|
+
const rows = await db
|
|
100
|
+
.select()
|
|
101
|
+
.from(agentGoal)
|
|
102
|
+
.where(eq(agentGoal.goalId, goalId))
|
|
103
|
+
.limit(1);
|
|
104
|
+
if (rows.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
return rowToGoal(rows[0]);
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -17,6 +17,11 @@ export { probeNativeSqliteLoad } from "./bootstrap/native-sqlite-probe.js";
|
|
|
17
17
|
export { runStorageModeSmoke, type StorageModeSmokeReport, type RunStorageModeSmokeOptions, } from "./bootstrap/storage-mode-smoke.js";
|
|
18
18
|
export { repairStateIndexes, type RepairSummary, type RepairStateIndexesOptions, type RepairGateStatus, } from "./bootstrap/repair-gate.js";
|
|
19
19
|
export { createStateAPI, type StateAPI, type MemoryReadPort, type MemoryWritePort, type CredentialContextPort, type IntentCommitPort, type ProvenancePort } from "./state-api.js";
|
|
20
|
+
export { createSessionChronicleStore, type SessionChronicleStore, type SessionChronicleEntry, type ChronicleQuery, type ChronicleWriteAck, type ChronicleEventKind, } from "./chronicle/session-chronicle-store.js";
|
|
21
|
+
export { createNarrativeStateStore, type NarrativeStateStore, type NarrativeState, type NarrativeStateUpdate, type NarrativeStateWriteAck, } from "./narrative/narrative-state-store.js";
|
|
22
|
+
export { createRelationshipMemoryStore, type RelationshipMemoryStore, type RelationshipMemory, type RelationshipMemoryUpdate, type RelationshipMemoryWriteAck, type TopicAffinity, } from "./relationship/relationship-memory-store.js";
|
|
23
|
+
export { createAgentGoalStore, type AgentGoalStore, type AgentGoal, type AgentGoalWrite, type AgentGoalStatusTransition, type AgentGoalQuery, type AgentGoalWriteAck, } from "./goal/agent-goal-store.js";
|
|
24
|
+
export { createMemoryStoreLifecycle, type MemoryStorePort, type MemoryStore, type MemoryStoreWrite, type MemoryStoreLifecycleTransition, type MemoryStoreAck, type CanonicalMemoryEntry, type DreamInsight, type MemoryStoreValidation, } from "./memory-store/memory-store-lifecycle.js";
|
|
20
25
|
export type { LifeEvidence, LifeEvidenceCandidate, LifeEvidenceType, LifeEvidenceWriteAck, Sensitivity, SourceRef, } from "./life-evidence/types.js";
|
|
21
26
|
export { appendLifeEvidence, type AppendLifeEvidenceOptions } from "./life-evidence/append-life-evidence.js";
|
|
22
27
|
export { loadRhythmPolicySnapshot, type RhythmPolicySnapshot } from "./rhythm/rhythm-policy-snapshot.js";
|
package/runtime/storage/index.js
CHANGED
|
@@ -17,6 +17,11 @@ export { probeNativeSqliteLoad } from "./bootstrap/native-sqlite-probe.js";
|
|
|
17
17
|
export { runStorageModeSmoke, } from "./bootstrap/storage-mode-smoke.js";
|
|
18
18
|
export { repairStateIndexes, } from "./bootstrap/repair-gate.js";
|
|
19
19
|
export { createStateAPI } from "./state-api.js";
|
|
20
|
+
export { createSessionChronicleStore, } from "./chronicle/session-chronicle-store.js";
|
|
21
|
+
export { createNarrativeStateStore, } from "./narrative/narrative-state-store.js";
|
|
22
|
+
export { createRelationshipMemoryStore, } from "./relationship/relationship-memory-store.js";
|
|
23
|
+
export { createAgentGoalStore, } from "./goal/agent-goal-store.js";
|
|
24
|
+
export { createMemoryStoreLifecycle, } from "./memory-store/memory-store-lifecycle.js";
|
|
20
25
|
export { appendLifeEvidence } from "./life-evidence/append-life-evidence.js";
|
|
21
26
|
export { loadRhythmPolicySnapshot } from "./rhythm/rhythm-policy-snapshot.js";
|
|
22
27
|
export { loadLifeEvidenceSnapshot } from "./snapshots/life-evidence-snapshot.js";
|