@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
|
@@ -53,10 +53,10 @@ export declare const sceneGuidanceRequestSchema: z.ZodObject<{
|
|
|
53
53
|
rhythmWindowKind: z.ZodOptional<z.ZodEnum<{
|
|
54
54
|
quiet: "quiet";
|
|
55
55
|
social: "social";
|
|
56
|
+
maintenance: "maintenance";
|
|
56
57
|
work: "work";
|
|
57
58
|
exploration: "exploration";
|
|
58
59
|
reflection: "reflection";
|
|
59
|
-
maintenance: "maintenance";
|
|
60
60
|
}>>;
|
|
61
61
|
riskLevel: z.ZodEnum<{
|
|
62
62
|
medium: "medium";
|
|
@@ -107,10 +107,10 @@ export declare const outreachDraftRequestSchema: z.ZodObject<{
|
|
|
107
107
|
rhythmWindowKind: z.ZodOptional<z.ZodEnum<{
|
|
108
108
|
quiet: "quiet";
|
|
109
109
|
social: "social";
|
|
110
|
+
maintenance: "maintenance";
|
|
110
111
|
work: "work";
|
|
111
112
|
exploration: "exploration";
|
|
112
113
|
reflection: "reflection";
|
|
113
|
-
maintenance: "maintenance";
|
|
114
114
|
}>>;
|
|
115
115
|
riskLevel: z.ZodEnum<{
|
|
116
116
|
medium: "medium";
|
|
@@ -205,7 +205,7 @@ export declare function safeParseOutreachDraftRequest(input: unknown): z.ZodSafe
|
|
|
205
205
|
excerptHash?: string | undefined;
|
|
206
206
|
observedAt?: string | undefined;
|
|
207
207
|
}[];
|
|
208
|
-
rhythmWindowKind?: "quiet" | "social" | "
|
|
208
|
+
rhythmWindowKind?: "quiet" | "social" | "maintenance" | "work" | "exploration" | "reflection" | undefined;
|
|
209
209
|
deliveryContext?: {
|
|
210
210
|
deliveryVerdict: "target_none" | "channel_missing" | "host_unsupported" | "delivery_failed" | "target_available";
|
|
211
211
|
wordingMode: "sendable" | "not_sent_fallback_candidate";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ObservabilityDatabase } from "./db/index.js";
|
|
2
|
+
export interface InventorySnapshot {
|
|
3
|
+
auditId: string;
|
|
4
|
+
snapshotId: string;
|
|
5
|
+
scanned: number;
|
|
6
|
+
registered: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
conflicts: Array<{
|
|
9
|
+
connectorId: string;
|
|
10
|
+
reason: string;
|
|
11
|
+
}>;
|
|
12
|
+
validationErrors: Array<{
|
|
13
|
+
connectorId: string;
|
|
14
|
+
errors: string[];
|
|
15
|
+
}>;
|
|
16
|
+
trustSummary: Record<string, number>;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class ConnectorInventoryLedger {
|
|
20
|
+
private obs;
|
|
21
|
+
constructor(obs: ObservabilityDatabase);
|
|
22
|
+
private now;
|
|
23
|
+
private generateId;
|
|
24
|
+
recordAudit(input: {
|
|
25
|
+
snapshotId: string;
|
|
26
|
+
scanned: number;
|
|
27
|
+
registered: number;
|
|
28
|
+
skipped: number;
|
|
29
|
+
conflicts?: Array<{
|
|
30
|
+
connectorId: string;
|
|
31
|
+
reason: string;
|
|
32
|
+
}>;
|
|
33
|
+
validationErrors?: Array<{
|
|
34
|
+
connectorId: string;
|
|
35
|
+
errors: string[];
|
|
36
|
+
}>;
|
|
37
|
+
trustSummary?: Record<string, number>;
|
|
38
|
+
}): Promise<string>;
|
|
39
|
+
getLatestAudit(snapshotId: string): Promise<InventorySnapshot | undefined>;
|
|
40
|
+
listAudits(opts?: {
|
|
41
|
+
limit?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
}): Promise<InventorySnapshot[]>;
|
|
44
|
+
private rowToSnapshot;
|
|
45
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { eq, desc } from "drizzle-orm";
|
|
2
|
+
import { connectorInventoryAudit } from "./db/schema/index.js";
|
|
3
|
+
export class ConnectorInventoryLedger {
|
|
4
|
+
obs;
|
|
5
|
+
constructor(obs) {
|
|
6
|
+
this.obs = obs;
|
|
7
|
+
}
|
|
8
|
+
now() {
|
|
9
|
+
return new Date().toISOString();
|
|
10
|
+
}
|
|
11
|
+
generateId() {
|
|
12
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
13
|
+
}
|
|
14
|
+
async recordAudit(input) {
|
|
15
|
+
const auditId = this.generateId();
|
|
16
|
+
const createdAt = this.now();
|
|
17
|
+
await this.obs.db
|
|
18
|
+
.insert(connectorInventoryAudit)
|
|
19
|
+
.values({
|
|
20
|
+
auditId,
|
|
21
|
+
snapshotId: input.snapshotId,
|
|
22
|
+
scanned: input.scanned,
|
|
23
|
+
registered: input.registered,
|
|
24
|
+
skipped: input.skipped,
|
|
25
|
+
conflictsJson: JSON.stringify(input.conflicts ?? []),
|
|
26
|
+
validationErrorsJson: JSON.stringify(input.validationErrors ?? []),
|
|
27
|
+
trustSummaryJson: JSON.stringify(input.trustSummary ?? {}),
|
|
28
|
+
createdAt,
|
|
29
|
+
})
|
|
30
|
+
.execute();
|
|
31
|
+
return auditId;
|
|
32
|
+
}
|
|
33
|
+
async getLatestAudit(snapshotId) {
|
|
34
|
+
const result = await this.obs.db
|
|
35
|
+
.select()
|
|
36
|
+
.from(connectorInventoryAudit)
|
|
37
|
+
.where(eq(connectorInventoryAudit.snapshotId, snapshotId))
|
|
38
|
+
.orderBy(desc(connectorInventoryAudit.createdAt))
|
|
39
|
+
.limit(1)
|
|
40
|
+
.execute();
|
|
41
|
+
if (!result || result.length === 0)
|
|
42
|
+
return undefined;
|
|
43
|
+
const row = result[0];
|
|
44
|
+
return this.rowToSnapshot(row);
|
|
45
|
+
}
|
|
46
|
+
async listAudits(opts) {
|
|
47
|
+
const limit = opts?.limit ?? 100;
|
|
48
|
+
const offset = opts?.offset ?? 0;
|
|
49
|
+
const rows = await this.obs.db
|
|
50
|
+
.select()
|
|
51
|
+
.from(connectorInventoryAudit)
|
|
52
|
+
.orderBy(desc(connectorInventoryAudit.createdAt))
|
|
53
|
+
.limit(limit)
|
|
54
|
+
.offset(offset)
|
|
55
|
+
.execute();
|
|
56
|
+
return rows.map((r) => this.rowToSnapshot(r));
|
|
57
|
+
}
|
|
58
|
+
rowToSnapshot(row) {
|
|
59
|
+
const r = row;
|
|
60
|
+
return {
|
|
61
|
+
auditId: String(r.auditId),
|
|
62
|
+
snapshotId: String(r.snapshotId),
|
|
63
|
+
scanned: Number(r.scanned),
|
|
64
|
+
registered: Number(r.registered),
|
|
65
|
+
skipped: Number(r.skipped),
|
|
66
|
+
conflicts: JSON.parse(String(r.conflictsJson ?? "[]")),
|
|
67
|
+
validationErrors: JSON.parse(String(r.validationErrorsJson ?? "[]")),
|
|
68
|
+
trustSummary: JSON.parse(String(r.trustSummaryJson ?? "{}")),
|
|
69
|
+
createdAt: String(r.createdAt),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -83,6 +83,19 @@ const OBSERVABILITY_SCHEMA_SQL = `
|
|
|
83
83
|
conflict_records_json TEXT NOT NULL,
|
|
84
84
|
full_report_json TEXT NOT NULL
|
|
85
85
|
);
|
|
86
|
+
CREATE TABLE IF NOT EXISTS connector_inventory_audit (
|
|
87
|
+
audit_id TEXT PRIMARY KEY,
|
|
88
|
+
snapshot_id TEXT NOT NULL,
|
|
89
|
+
scanned INTEGER NOT NULL,
|
|
90
|
+
registered INTEGER NOT NULL,
|
|
91
|
+
skipped INTEGER NOT NULL,
|
|
92
|
+
conflicts_json TEXT NOT NULL,
|
|
93
|
+
validation_errors_json TEXT NOT NULL,
|
|
94
|
+
trust_summary_json TEXT NOT NULL,
|
|
95
|
+
created_at TEXT NOT NULL
|
|
96
|
+
);
|
|
97
|
+
CREATE INDEX IF NOT EXISTS connector_inventory_snapshot_idx ON connector_inventory_audit(snapshot_id);
|
|
98
|
+
CREATE INDEX IF NOT EXISTS connector_inventory_created_at_idx ON connector_inventory_audit(created_at);
|
|
86
99
|
`;
|
|
87
100
|
function resolveDbPath(filename) {
|
|
88
101
|
if (path.isAbsolute(filename) || filename === ":memory:") {
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export declare const connectorInventoryAudit: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
2
|
+
name: "connector_inventory_audit";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
auditId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: "audit_id";
|
|
7
|
+
tableName: "connector_inventory_audit";
|
|
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
|
+
snapshotId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
25
|
+
name: "snapshot_id";
|
|
26
|
+
tableName: "connector_inventory_audit";
|
|
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
|
+
scanned: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
44
|
+
name: "scanned";
|
|
45
|
+
tableName: "connector_inventory_audit";
|
|
46
|
+
dataType: "number";
|
|
47
|
+
columnType: "SQLiteInteger";
|
|
48
|
+
data: number;
|
|
49
|
+
driverParam: number;
|
|
50
|
+
notNull: true;
|
|
51
|
+
hasDefault: false;
|
|
52
|
+
isPrimaryKey: false;
|
|
53
|
+
isAutoincrement: false;
|
|
54
|
+
hasRuntimeDefault: false;
|
|
55
|
+
enumValues: undefined;
|
|
56
|
+
baseColumn: never;
|
|
57
|
+
identity: undefined;
|
|
58
|
+
generated: undefined;
|
|
59
|
+
}, {}, {}>;
|
|
60
|
+
registered: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
61
|
+
name: "registered";
|
|
62
|
+
tableName: "connector_inventory_audit";
|
|
63
|
+
dataType: "number";
|
|
64
|
+
columnType: "SQLiteInteger";
|
|
65
|
+
data: number;
|
|
66
|
+
driverParam: number;
|
|
67
|
+
notNull: true;
|
|
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
|
+
skipped: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
78
|
+
name: "skipped";
|
|
79
|
+
tableName: "connector_inventory_audit";
|
|
80
|
+
dataType: "number";
|
|
81
|
+
columnType: "SQLiteInteger";
|
|
82
|
+
data: number;
|
|
83
|
+
driverParam: number;
|
|
84
|
+
notNull: true;
|
|
85
|
+
hasDefault: false;
|
|
86
|
+
isPrimaryKey: false;
|
|
87
|
+
isAutoincrement: false;
|
|
88
|
+
hasRuntimeDefault: false;
|
|
89
|
+
enumValues: undefined;
|
|
90
|
+
baseColumn: never;
|
|
91
|
+
identity: undefined;
|
|
92
|
+
generated: undefined;
|
|
93
|
+
}, {}, {}>;
|
|
94
|
+
conflictsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
95
|
+
name: "conflicts_json";
|
|
96
|
+
tableName: "connector_inventory_audit";
|
|
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
|
+
validationErrorsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
114
|
+
name: "validation_errors_json";
|
|
115
|
+
tableName: "connector_inventory_audit";
|
|
116
|
+
dataType: "string";
|
|
117
|
+
columnType: "SQLiteText";
|
|
118
|
+
data: string;
|
|
119
|
+
driverParam: string;
|
|
120
|
+
notNull: true;
|
|
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
|
+
trustSummaryJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
133
|
+
name: "trust_summary_json";
|
|
134
|
+
tableName: "connector_inventory_audit";
|
|
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
|
+
createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
152
|
+
name: "created_at";
|
|
153
|
+
tableName: "connector_inventory_audit";
|
|
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 ConnectorInventoryAuditRow = typeof connectorInventoryAudit.$inferSelect;
|
|
174
|
+
export type NewConnectorInventoryAuditRow = typeof connectorInventoryAudit.$inferInsert;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { index, sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
2
|
+
export const connectorInventoryAudit = sqliteTable("connector_inventory_audit", {
|
|
3
|
+
auditId: text("audit_id").primaryKey(),
|
|
4
|
+
snapshotId: text("snapshot_id").notNull(),
|
|
5
|
+
scanned: integer("scanned").notNull(),
|
|
6
|
+
registered: integer("registered").notNull(),
|
|
7
|
+
skipped: integer("skipped").notNull(),
|
|
8
|
+
conflictsJson: text("conflicts_json").notNull(),
|
|
9
|
+
validationErrorsJson: text("validation_errors_json").notNull(),
|
|
10
|
+
trustSummaryJson: text("trust_summary_json").notNull(),
|
|
11
|
+
createdAt: text("created_at").notNull(),
|
|
12
|
+
}, (table) => [
|
|
13
|
+
index("connector_inventory_snapshot_idx").on(table.snapshotId),
|
|
14
|
+
index("connector_inventory_created_at_idx").on(table.createdAt),
|
|
15
|
+
]);
|
|
@@ -945,3 +945,4 @@ export type NewGovernanceAuditDb = typeof governanceAudit.$inferInsert;
|
|
|
945
945
|
export type RedactionManifestDb = typeof redactionManifest.$inferSelect;
|
|
946
946
|
export type NewRedactionManifestDb = typeof redactionManifest.$inferInsert;
|
|
947
947
|
export { hostCapabilityReports, type HostCapabilityReportRow, type NewHostCapabilityReportRow, } from "./host-capability-reports.js";
|
|
948
|
+
export { connectorInventoryAudit, type ConnectorInventoryAuditRow, type NewConnectorInventoryAuditRow, } from "./connector-inventory.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { StateDatabase } from "../db/index.js";
|
|
2
|
+
export type ChronicleEventKind = "heartbeat" | "connector_action" | "outreach" | "owner_reply" | "dream_run" | "maintenance";
|
|
3
|
+
export interface SourceRef {
|
|
4
|
+
sourceId: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
snippet?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface OwnerReplySignal {
|
|
10
|
+
tone?: string;
|
|
11
|
+
delayMinutes?: number;
|
|
12
|
+
topics?: string[];
|
|
13
|
+
explicitPreference?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SessionChronicleEntry {
|
|
16
|
+
entryId: string;
|
|
17
|
+
eventKind: ChronicleEventKind;
|
|
18
|
+
actor: "agent" | "owner" | "system";
|
|
19
|
+
occurredAt: string;
|
|
20
|
+
summary: string;
|
|
21
|
+
result: "succeeded" | "failed" | "skipped" | "no_reply" | "partial";
|
|
22
|
+
sourceRefs: SourceRef[];
|
|
23
|
+
relatedDecisionId?: string;
|
|
24
|
+
relatedDreamRunId?: string;
|
|
25
|
+
ownerReply?: OwnerReplySignal;
|
|
26
|
+
}
|
|
27
|
+
export interface ChronicleQuery {
|
|
28
|
+
eventKinds?: ChronicleEventKind[];
|
|
29
|
+
from?: string;
|
|
30
|
+
to?: string;
|
|
31
|
+
actor?: "agent" | "owner" | "system";
|
|
32
|
+
limit?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ChronicleWriteAck {
|
|
35
|
+
entryId: string;
|
|
36
|
+
status: "acknowledged" | "degraded";
|
|
37
|
+
}
|
|
38
|
+
export interface SessionChronicleStore {
|
|
39
|
+
appendSessionChronicle(entry: SessionChronicleEntry): Promise<ChronicleWriteAck>;
|
|
40
|
+
loadSessionChronicle(query: ChronicleQuery): Promise<SessionChronicleEntry[]>;
|
|
41
|
+
}
|
|
42
|
+
export declare function createSessionChronicleStore(database: StateDatabase): SessionChronicleStore;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { eq, gte, lte, inArray, desc, and } from "drizzle-orm";
|
|
2
|
+
import { sessionChronicle } from "../db/schema/session-chronicle.js";
|
|
3
|
+
function rowToEntry(row) {
|
|
4
|
+
return {
|
|
5
|
+
entryId: row.entryId,
|
|
6
|
+
eventKind: row.eventKind,
|
|
7
|
+
actor: row.actor,
|
|
8
|
+
occurredAt: row.occurredAt,
|
|
9
|
+
summary: row.summary,
|
|
10
|
+
result: row.result,
|
|
11
|
+
sourceRefs: safeParseJson(row.sourceRefsJson, []),
|
|
12
|
+
relatedDecisionId: row.relatedDecisionId ?? undefined,
|
|
13
|
+
relatedDreamRunId: row.relatedDreamRunId ?? undefined,
|
|
14
|
+
ownerReply: row.ownerReplyJson ? safeParseJson(row.ownerReplyJson, undefined) : undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function safeParseJson(json, fallback) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(json);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return fallback;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function createSessionChronicleStore(database) {
|
|
26
|
+
const db = database.db;
|
|
27
|
+
return {
|
|
28
|
+
async appendSessionChronicle(entry) {
|
|
29
|
+
await db.insert(sessionChronicle).values({
|
|
30
|
+
entryId: entry.entryId,
|
|
31
|
+
eventKind: entry.eventKind,
|
|
32
|
+
actor: entry.actor,
|
|
33
|
+
occurredAt: entry.occurredAt,
|
|
34
|
+
summary: entry.summary,
|
|
35
|
+
result: entry.result,
|
|
36
|
+
sourceRefsJson: JSON.stringify(entry.sourceRefs),
|
|
37
|
+
relatedDecisionId: entry.relatedDecisionId ?? null,
|
|
38
|
+
relatedDreamRunId: entry.relatedDreamRunId ?? null,
|
|
39
|
+
ownerReplyJson: entry.ownerReply ? JSON.stringify(entry.ownerReply) : null,
|
|
40
|
+
});
|
|
41
|
+
return { entryId: entry.entryId, status: "acknowledged" };
|
|
42
|
+
},
|
|
43
|
+
async loadSessionChronicle(query) {
|
|
44
|
+
const conditions = [];
|
|
45
|
+
if (query.eventKinds && query.eventKinds.length > 0) {
|
|
46
|
+
conditions.push(inArray(sessionChronicle.eventKind, query.eventKinds));
|
|
47
|
+
}
|
|
48
|
+
if (query.from) {
|
|
49
|
+
conditions.push(gte(sessionChronicle.occurredAt, query.from));
|
|
50
|
+
}
|
|
51
|
+
if (query.to) {
|
|
52
|
+
conditions.push(lte(sessionChronicle.occurredAt, query.to));
|
|
53
|
+
}
|
|
54
|
+
if (query.actor) {
|
|
55
|
+
conditions.push(eq(sessionChronicle.actor, query.actor));
|
|
56
|
+
}
|
|
57
|
+
const rows = await db
|
|
58
|
+
.select()
|
|
59
|
+
.from(sessionChronicle)
|
|
60
|
+
.where(conditions.length > 0 ? and(...conditions) : undefined)
|
|
61
|
+
.orderBy(desc(sessionChronicle.occurredAt))
|
|
62
|
+
.limit(query.limit ?? 100);
|
|
63
|
+
return rows.map(rowToEntry);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -99,6 +99,81 @@ const STATE_SCHEMA_SQL = `
|
|
|
99
99
|
created_at TEXT NOT NULL
|
|
100
100
|
);
|
|
101
101
|
CREATE INDEX IF NOT EXISTS operator_fallback_decision_idx ON operator_fallback_artifacts(decision_id);
|
|
102
|
+
CREATE TABLE IF NOT EXISTS session_chronicle (
|
|
103
|
+
entry_id TEXT PRIMARY KEY,
|
|
104
|
+
event_kind TEXT NOT NULL,
|
|
105
|
+
actor TEXT NOT NULL,
|
|
106
|
+
occurred_at TEXT NOT NULL,
|
|
107
|
+
summary TEXT NOT NULL,
|
|
108
|
+
result TEXT NOT NULL,
|
|
109
|
+
source_refs_json TEXT NOT NULL,
|
|
110
|
+
related_decision_id TEXT,
|
|
111
|
+
related_dream_run_id TEXT,
|
|
112
|
+
owner_reply_json TEXT
|
|
113
|
+
);
|
|
114
|
+
CREATE INDEX IF NOT EXISTS session_chronicle_event_kind_idx ON session_chronicle(event_kind);
|
|
115
|
+
CREATE INDEX IF NOT EXISTS session_chronicle_occurred_at_idx ON session_chronicle(occurred_at);
|
|
116
|
+
CREATE INDEX IF NOT EXISTS session_chronicle_actor_idx ON session_chronicle(actor);
|
|
117
|
+
CREATE INDEX IF NOT EXISTS session_chronicle_decision_idx ON session_chronicle(related_decision_id);
|
|
118
|
+
CREATE TABLE IF NOT EXISTS narrative_state (
|
|
119
|
+
narrative_id TEXT PRIMARY KEY,
|
|
120
|
+
revision INTEGER NOT NULL DEFAULT 1,
|
|
121
|
+
focus TEXT NOT NULL,
|
|
122
|
+
progress_json TEXT NOT NULL,
|
|
123
|
+
next_intent TEXT NOT NULL,
|
|
124
|
+
confidence INTEGER NOT NULL DEFAULT 0,
|
|
125
|
+
source_refs_json TEXT NOT NULL,
|
|
126
|
+
unsupported_claims_json TEXT NOT NULL,
|
|
127
|
+
status TEXT NOT NULL,
|
|
128
|
+
updated_at TEXT NOT NULL
|
|
129
|
+
);
|
|
130
|
+
CREATE INDEX IF NOT EXISTS narrative_state_status_idx ON narrative_state(status);
|
|
131
|
+
CREATE INDEX IF NOT EXISTS narrative_state_updated_at_idx ON narrative_state(updated_at);
|
|
132
|
+
CREATE TABLE IF NOT EXISTS relationship_memory (
|
|
133
|
+
relationship_id TEXT PRIMARY KEY,
|
|
134
|
+
revision INTEGER NOT NULL DEFAULT 1,
|
|
135
|
+
tone_preference TEXT NOT NULL,
|
|
136
|
+
average_reply_delay_minutes INTEGER,
|
|
137
|
+
no_reply_count INTEGER NOT NULL DEFAULT 0,
|
|
138
|
+
topic_affinities_json TEXT NOT NULL,
|
|
139
|
+
last_interaction_at TEXT,
|
|
140
|
+
source_refs_json TEXT NOT NULL,
|
|
141
|
+
updated_at TEXT NOT NULL
|
|
142
|
+
);
|
|
143
|
+
CREATE INDEX IF NOT EXISTS relationship_memory_updated_at_idx ON relationship_memory(updated_at);
|
|
144
|
+
CREATE TABLE IF NOT EXISTS agent_goal (
|
|
145
|
+
goal_id TEXT PRIMARY KEY,
|
|
146
|
+
kind TEXT NOT NULL,
|
|
147
|
+
status TEXT NOT NULL,
|
|
148
|
+
origin TEXT NOT NULL,
|
|
149
|
+
description TEXT NOT NULL,
|
|
150
|
+
completion_criteria TEXT NOT NULL,
|
|
151
|
+
risk TEXT NOT NULL,
|
|
152
|
+
priority_hint INTEGER NOT NULL DEFAULT 0,
|
|
153
|
+
source_refs_json TEXT NOT NULL,
|
|
154
|
+
accepted_by TEXT,
|
|
155
|
+
created_at TEXT NOT NULL,
|
|
156
|
+
updated_at TEXT NOT NULL
|
|
157
|
+
);
|
|
158
|
+
CREATE INDEX IF NOT EXISTS agent_goal_status_idx ON agent_goal(status);
|
|
159
|
+
CREATE INDEX IF NOT EXISTS agent_goal_origin_idx ON agent_goal(origin);
|
|
160
|
+
CREATE INDEX IF NOT EXISTS agent_goal_updated_at_idx ON agent_goal(updated_at);
|
|
161
|
+
CREATE TABLE IF NOT EXISTS memory_store (
|
|
162
|
+
memory_store_id TEXT PRIMARY KEY,
|
|
163
|
+
lifecycle_status TEXT NOT NULL,
|
|
164
|
+
created_at TEXT NOT NULL,
|
|
165
|
+
input_memory_store_id TEXT,
|
|
166
|
+
dream_run_id TEXT,
|
|
167
|
+
canonical_entries_json TEXT NOT NULL,
|
|
168
|
+
insights_json TEXT NOT NULL,
|
|
169
|
+
narrative_snapshot_json TEXT,
|
|
170
|
+
relationship_snapshot_json TEXT,
|
|
171
|
+
validation_json TEXT NOT NULL
|
|
172
|
+
);
|
|
173
|
+
CREATE INDEX IF NOT EXISTS memory_store_lifecycle_idx ON memory_store(lifecycle_status);
|
|
174
|
+
CREATE INDEX IF NOT EXISTS memory_store_created_at_idx ON memory_store(created_at);
|
|
175
|
+
CREATE INDEX IF NOT EXISTS memory_store_input_idx ON memory_store(input_memory_store_id);
|
|
176
|
+
CREATE INDEX IF NOT EXISTS memory_store_dream_run_idx ON memory_store(dream_run_id);
|
|
102
177
|
`;
|
|
103
178
|
function resolveDbPath(filename) {
|
|
104
179
|
if (path.isAbsolute(filename) || filename === ":memory:") {
|