@dorokuma/herdsman 0.6.6 → 0.8.6
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/README.ja.md +2 -2
- package/README.md +4 -4
- package/dist/src/agent-history/antigravity-proto.d.ts +7 -0
- package/dist/src/agent-history/antigravity-proto.d.ts.map +1 -0
- package/dist/src/agent-history/antigravity-proto.js +124 -0
- package/dist/src/agent-history/antigravity-proto.js.map +1 -0
- package/dist/src/agent-history/antigravity-reader.d.ts +11 -0
- package/dist/src/agent-history/antigravity-reader.d.ts.map +1 -0
- package/dist/src/agent-history/antigravity-reader.js +72 -0
- package/dist/src/agent-history/antigravity-reader.js.map +1 -0
- package/dist/src/agent-history/discovery.d.ts +2 -1
- package/dist/src/agent-history/discovery.d.ts.map +1 -1
- package/dist/src/agent-history/discovery.js +124 -1
- package/dist/src/agent-history/discovery.js.map +1 -1
- package/dist/src/agent-history/grok-reader.d.ts +11 -0
- package/dist/src/agent-history/grok-reader.d.ts.map +1 -0
- package/dist/src/agent-history/grok-reader.js +54 -0
- package/dist/src/agent-history/grok-reader.js.map +1 -0
- package/dist/src/agent-history/readers.d.ts +13 -0
- package/dist/src/agent-history/readers.d.ts.map +1 -1
- package/dist/src/agent-history/readers.js +30 -3
- package/dist/src/agent-history/readers.js.map +1 -1
- package/dist/src/agent-history/service.d.ts +1 -0
- package/dist/src/agent-history/service.d.ts.map +1 -1
- package/dist/src/agent-history/service.js +39 -5
- package/dist/src/agent-history/service.js.map +1 -1
- package/dist/src/agent-history/tool-compaction.js +2 -2
- package/dist/src/agent-history/tool-compaction.js.map +1 -1
- package/dist/src/cli/herdsman.d.ts +5 -0
- package/dist/src/cli/herdsman.d.ts.map +1 -1
- package/dist/src/cli/herdsman.js +7 -9
- package/dist/src/cli/herdsman.js.map +1 -1
- package/dist/src/config/runtime.d.ts.map +1 -1
- package/dist/src/config/runtime.js +1 -4
- package/dist/src/config/runtime.js.map +1 -1
- package/dist/src/daemon/agent-event-reconciler.d.ts +26 -0
- package/dist/src/daemon/agent-event-reconciler.d.ts.map +1 -0
- package/dist/src/daemon/agent-event-reconciler.js +117 -0
- package/dist/src/daemon/agent-event-reconciler.js.map +1 -0
- package/dist/src/daemon/client.d.ts.map +1 -1
- package/dist/src/daemon/client.js +6 -1
- package/dist/src/daemon/client.js.map +1 -1
- package/dist/src/daemon/observability-server.d.ts +18 -0
- package/dist/src/daemon/observability-server.d.ts.map +1 -1
- package/dist/src/daemon/observability-server.js +91 -8
- package/dist/src/daemon/observability-server.js.map +1 -1
- package/dist/src/daemon/service.d.ts.map +1 -1
- package/dist/src/daemon/service.js +14 -0
- package/dist/src/daemon/service.js.map +1 -1
- package/dist/src/db/agent-events.d.ts +24 -0
- package/dist/src/db/agent-events.d.ts.map +1 -1
- package/dist/src/db/agent-events.js +128 -11
- package/dist/src/db/agent-events.js.map +1 -1
- package/dist/src/db/agent-orchestrator-scopes.d.ts +15 -0
- package/dist/src/db/agent-orchestrator-scopes.d.ts.map +1 -1
- package/dist/src/db/agent-orchestrator-scopes.js +43 -0
- package/dist/src/db/agent-orchestrator-scopes.js.map +1 -1
- package/dist/src/db/agents.d.ts +5 -0
- package/dist/src/db/agents.d.ts.map +1 -1
- package/dist/src/db/agents.js +67 -11
- package/dist/src/db/agents.js.map +1 -1
- package/dist/src/db/schema.d.ts +146 -0
- package/dist/src/db/schema.d.ts.map +1 -1
- package/dist/src/db/schema.js +12 -1
- package/dist/src/db/schema.js.map +1 -1
- package/dist/src/observability/agent-context-service.d.ts +1 -0
- package/dist/src/observability/agent-context-service.d.ts.map +1 -1
- package/dist/src/observability/agent-context-service.js +12 -7
- package/dist/src/observability/agent-context-service.js.map +1 -1
- package/dist/src/observability/agent-index-service.d.ts +2 -0
- package/dist/src/observability/agent-index-service.d.ts.map +1 -1
- package/dist/src/observability/agent-index-service.js +116 -19
- package/dist/src/observability/agent-index-service.js.map +1 -1
- package/dist/src/observability/agent-orchestrator-service.d.ts.map +1 -1
- package/dist/src/observability/agent-orchestrator-service.js +72 -9
- package/dist/src/observability/agent-orchestrator-service.js.map +1 -1
- package/dist/src/observability/contracts.d.ts +16 -1
- package/dist/src/observability/contracts.d.ts.map +1 -1
- package/dist/src/observability/contracts.js.map +1 -1
- package/dist/src/observability/errors.d.ts +53 -0
- package/dist/src/observability/errors.d.ts.map +1 -0
- package/dist/src/observability/errors.js +30 -0
- package/dist/src/observability/errors.js.map +1 -0
- package/dist/src/observability/schemas.d.ts +7 -0
- package/dist/src/observability/schemas.d.ts.map +1 -1
- package/dist/src/observability/schemas.js +7 -0
- package/dist/src/observability/schemas.js.map +1 -1
- package/dist/src/observability/turn-completion.d.ts +45 -0
- package/dist/src/observability/turn-completion.d.ts.map +1 -0
- package/dist/src/observability/turn-completion.js +85 -0
- package/dist/src/observability/turn-completion.js.map +1 -0
- package/drizzle/0006_grok_home.sql +1 -0
- package/drizzle/0007_moaning_guardian.sql +10 -0
- package/drizzle/meta/0006_snapshot.json +686 -0
- package/drizzle/meta/0007_snapshot.json +762 -0
- package/drizzle/meta/_journal.json +57 -7
- package/package.json +2 -2
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -382,6 +382,25 @@ export declare const agents: import("drizzle-orm/sqlite-core").SQLiteTableWithCo
|
|
|
382
382
|
}, {}, {
|
|
383
383
|
length: number | undefined;
|
|
384
384
|
}>;
|
|
385
|
+
grokHome: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
386
|
+
name: "grok_home";
|
|
387
|
+
tableName: "agents";
|
|
388
|
+
dataType: "string";
|
|
389
|
+
columnType: "SQLiteText";
|
|
390
|
+
data: string;
|
|
391
|
+
driverParam: string;
|
|
392
|
+
notNull: false;
|
|
393
|
+
hasDefault: false;
|
|
394
|
+
isPrimaryKey: false;
|
|
395
|
+
isAutoincrement: false;
|
|
396
|
+
hasRuntimeDefault: false;
|
|
397
|
+
enumValues: [string, ...string[]];
|
|
398
|
+
baseColumn: never;
|
|
399
|
+
identity: undefined;
|
|
400
|
+
generated: undefined;
|
|
401
|
+
}, {}, {
|
|
402
|
+
length: number | undefined;
|
|
403
|
+
}>;
|
|
385
404
|
herdrSessionName: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
386
405
|
name: "herdr_session_name";
|
|
387
406
|
tableName: "agents";
|
|
@@ -910,6 +929,133 @@ export declare const agentEvents: import("drizzle-orm/sqlite-core").SQLiteTableW
|
|
|
910
929
|
identity: undefined;
|
|
911
930
|
generated: undefined;
|
|
912
931
|
}, {}, {}>;
|
|
932
|
+
status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
933
|
+
name: "status";
|
|
934
|
+
tableName: "agent_events";
|
|
935
|
+
dataType: "string";
|
|
936
|
+
columnType: "SQLiteText";
|
|
937
|
+
data: string;
|
|
938
|
+
driverParam: string;
|
|
939
|
+
notNull: true;
|
|
940
|
+
hasDefault: true;
|
|
941
|
+
isPrimaryKey: false;
|
|
942
|
+
isAutoincrement: false;
|
|
943
|
+
hasRuntimeDefault: false;
|
|
944
|
+
enumValues: [string, ...string[]];
|
|
945
|
+
baseColumn: never;
|
|
946
|
+
identity: undefined;
|
|
947
|
+
generated: undefined;
|
|
948
|
+
}, {}, {
|
|
949
|
+
length: number | undefined;
|
|
950
|
+
}>;
|
|
951
|
+
deliveryAttempts: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
952
|
+
name: "delivery_attempts";
|
|
953
|
+
tableName: "agent_events";
|
|
954
|
+
dataType: "number";
|
|
955
|
+
columnType: "SQLiteInteger";
|
|
956
|
+
data: number;
|
|
957
|
+
driverParam: number;
|
|
958
|
+
notNull: true;
|
|
959
|
+
hasDefault: true;
|
|
960
|
+
isPrimaryKey: false;
|
|
961
|
+
isAutoincrement: false;
|
|
962
|
+
hasRuntimeDefault: false;
|
|
963
|
+
enumValues: undefined;
|
|
964
|
+
baseColumn: never;
|
|
965
|
+
identity: undefined;
|
|
966
|
+
generated: undefined;
|
|
967
|
+
}, {}, {}>;
|
|
968
|
+
lastAttemptAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
969
|
+
name: "last_attempt_at";
|
|
970
|
+
tableName: "agent_events";
|
|
971
|
+
dataType: "number";
|
|
972
|
+
columnType: "SQLiteInteger";
|
|
973
|
+
data: number;
|
|
974
|
+
driverParam: number;
|
|
975
|
+
notNull: false;
|
|
976
|
+
hasDefault: false;
|
|
977
|
+
isPrimaryKey: false;
|
|
978
|
+
isAutoincrement: false;
|
|
979
|
+
hasRuntimeDefault: false;
|
|
980
|
+
enumValues: undefined;
|
|
981
|
+
baseColumn: never;
|
|
982
|
+
identity: undefined;
|
|
983
|
+
generated: undefined;
|
|
984
|
+
}, {}, {}>;
|
|
985
|
+
nextAttemptAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
986
|
+
name: "next_attempt_at";
|
|
987
|
+
tableName: "agent_events";
|
|
988
|
+
dataType: "number";
|
|
989
|
+
columnType: "SQLiteInteger";
|
|
990
|
+
data: number;
|
|
991
|
+
driverParam: number;
|
|
992
|
+
notNull: false;
|
|
993
|
+
hasDefault: false;
|
|
994
|
+
isPrimaryKey: false;
|
|
995
|
+
isAutoincrement: false;
|
|
996
|
+
hasRuntimeDefault: false;
|
|
997
|
+
enumValues: undefined;
|
|
998
|
+
baseColumn: never;
|
|
999
|
+
identity: undefined;
|
|
1000
|
+
generated: undefined;
|
|
1001
|
+
}, {}, {}>;
|
|
1002
|
+
lastFailureCode: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1003
|
+
name: "last_failure_code";
|
|
1004
|
+
tableName: "agent_events";
|
|
1005
|
+
dataType: "string";
|
|
1006
|
+
columnType: "SQLiteText";
|
|
1007
|
+
data: string;
|
|
1008
|
+
driverParam: string;
|
|
1009
|
+
notNull: false;
|
|
1010
|
+
hasDefault: false;
|
|
1011
|
+
isPrimaryKey: false;
|
|
1012
|
+
isAutoincrement: false;
|
|
1013
|
+
hasRuntimeDefault: false;
|
|
1014
|
+
enumValues: [string, ...string[]];
|
|
1015
|
+
baseColumn: never;
|
|
1016
|
+
identity: undefined;
|
|
1017
|
+
generated: undefined;
|
|
1018
|
+
}, {}, {
|
|
1019
|
+
length: number | undefined;
|
|
1020
|
+
}>;
|
|
1021
|
+
invalidatedReason: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1022
|
+
name: "invalidated_reason";
|
|
1023
|
+
tableName: "agent_events";
|
|
1024
|
+
dataType: "string";
|
|
1025
|
+
columnType: "SQLiteText";
|
|
1026
|
+
data: string;
|
|
1027
|
+
driverParam: string;
|
|
1028
|
+
notNull: false;
|
|
1029
|
+
hasDefault: false;
|
|
1030
|
+
isPrimaryKey: false;
|
|
1031
|
+
isAutoincrement: false;
|
|
1032
|
+
hasRuntimeDefault: false;
|
|
1033
|
+
enumValues: [string, ...string[]];
|
|
1034
|
+
baseColumn: never;
|
|
1035
|
+
identity: undefined;
|
|
1036
|
+
generated: undefined;
|
|
1037
|
+
}, {}, {
|
|
1038
|
+
length: number | undefined;
|
|
1039
|
+
}>;
|
|
1040
|
+
deliveredToTerminalId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1041
|
+
name: "delivered_to_terminal_id";
|
|
1042
|
+
tableName: "agent_events";
|
|
1043
|
+
dataType: "string";
|
|
1044
|
+
columnType: "SQLiteText";
|
|
1045
|
+
data: string;
|
|
1046
|
+
driverParam: string;
|
|
1047
|
+
notNull: false;
|
|
1048
|
+
hasDefault: false;
|
|
1049
|
+
isPrimaryKey: false;
|
|
1050
|
+
isAutoincrement: false;
|
|
1051
|
+
hasRuntimeDefault: false;
|
|
1052
|
+
enumValues: [string, ...string[]];
|
|
1053
|
+
baseColumn: never;
|
|
1054
|
+
identity: undefined;
|
|
1055
|
+
generated: undefined;
|
|
1056
|
+
}, {}, {
|
|
1057
|
+
length: number | undefined;
|
|
1058
|
+
}>;
|
|
913
1059
|
terminalId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
914
1060
|
name: "terminal_id";
|
|
915
1061
|
tableName: "agent_events";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/db/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/db/schema.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOxB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkB3B,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BlB,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCvB,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcnC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkB7B,CAAC"}
|
package/dist/src/db/schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { integer, primaryKey, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
1
|
+
import { index, integer, primaryKey, sqliteTable, text, uniqueIndex, } from "drizzle-orm/sqlite-core";
|
|
2
2
|
const agentStatusValues = ["blocked", "done", "idle", "unknown", "working"];
|
|
3
3
|
export const herdrSessions = sqliteTable("herdr_sessions", {
|
|
4
4
|
lastScannedAt: integer("last_scanned_at", { mode: "timestamp_ms" }),
|
|
@@ -29,6 +29,7 @@ export const agents = sqliteTable("agents", {
|
|
|
29
29
|
firstSeenAt: integer("first_seen_at", { mode: "timestamp_ms" }).notNull(),
|
|
30
30
|
focused: integer("focused", { mode: "boolean" }).notNull(),
|
|
31
31
|
foregroundCwd: text("foreground_cwd"),
|
|
32
|
+
grokHome: text("grok_home"),
|
|
32
33
|
herdrSessionName: text("herdr_session_name")
|
|
33
34
|
.notNull()
|
|
34
35
|
.references(() => herdrSessions.name, { onDelete: "cascade" }),
|
|
@@ -69,12 +70,22 @@ export const agentEvents = sqliteTable("agent_events", {
|
|
|
69
70
|
paneId: text("pane_id"),
|
|
70
71
|
paneGeneration: text("pane_generation"),
|
|
71
72
|
payloadJson: text("payload_json").notNull(),
|
|
73
|
+
/** Compatibility mirror; status is authoritative for delivery queries. */
|
|
72
74
|
deliverable: integer("deliverable", { mode: "boolean" }).notNull().default(true),
|
|
75
|
+
status: text("status").notNull().default("pending"),
|
|
76
|
+
deliveryAttempts: integer("delivery_attempts").notNull().default(0),
|
|
77
|
+
lastAttemptAt: integer("last_attempt_at"),
|
|
78
|
+
nextAttemptAt: integer("next_attempt_at"),
|
|
79
|
+
lastFailureCode: text("last_failure_code"),
|
|
80
|
+
invalidatedReason: text("invalidated_reason"),
|
|
81
|
+
deliveredToTerminalId: text("delivered_to_terminal_id"),
|
|
73
82
|
terminalId: text("terminal_id"),
|
|
74
83
|
type: text("type").notNull(),
|
|
75
84
|
workspaceId: text("workspace_id"),
|
|
76
85
|
}, (table) => [
|
|
77
86
|
uniqueIndex("agent_events_session_idempotency_idx").on(table.herdrSessionName, table.idempotencyKey),
|
|
87
|
+
index("agent_events_delivery_scope_idx").on(table.herdrSessionName, table.workspaceId, table.status, table.id),
|
|
88
|
+
index("agent_events_delivery_retry_idx").on(table.status, table.nextAttemptAt),
|
|
78
89
|
]);
|
|
79
90
|
export const agentOrchestratorScopes = sqliteTable("agent_orchestrator_scopes", {
|
|
80
91
|
ackedEventId: integer("acked_event_id").notNull(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,IAAI,EACJ,WAAW,GACZ,MAAM,yBAAyB,CAAC;AAEjC,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAErF,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,gBAAgB,EAAE;IACzD,aAAa,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IACnE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE;IAC/B,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1D,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IACzC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IACzC,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;CACrE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CACxC,kBAAkB,EAClB;IACE,WAAW,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE;IACxE,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1D,gBAAgB,EAAE,IAAI,CA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{ AgentContextSnapshotRecord, AgentIndexRecord, AgentListItem, Agent
|
|
|
5
5
|
export type RefreshAgentContextInput = {
|
|
6
6
|
agent: AgentIndexRecord;
|
|
7
7
|
identityChanged: boolean;
|
|
8
|
+
forceRefresh?: boolean;
|
|
8
9
|
occupiedSessionPaths?: ReadonlySet<string>;
|
|
9
10
|
};
|
|
10
11
|
export type RefreshAgentContextResult = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-context-service.d.ts","sourceRoot":"","sources":["../../../src/observability/agent-context-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EACV,0BAA0B,EAG1B,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,UAAU,EACV,6BAA6B,EAE9B,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,gBAAgB,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,0BAA0B,CAAC;CACtC,CAAC;AAEF,qBAAa,mBAAmB;;gBAQlB,OAAO,EAAE;QACnB,OAAO,EAAE,mBAAmB,CAAC;QAC7B,MAAM,EAAE;YACN,qBAAqB,EAAE,yBAAyB,CAAC;YACjD,MAAM,EAAE,UAAU,CAAC;SACpB,CAAC;KACH;IAKK,YAAY,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-context-service.d.ts","sourceRoot":"","sources":["../../../src/observability/agent-context-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EACV,0BAA0B,EAG1B,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,UAAU,EACV,6BAA6B,EAE9B,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,gBAAgB,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,0BAA0B,CAAC;CACtC,CAAC;AAEF,qBAAa,mBAAmB;;gBAQlB,OAAO,EAAE;QACnB,OAAO,EAAE,mBAAmB,CAAC;QAC7B,MAAM,EAAE;YACN,qBAAqB,EAAE,yBAAyB,CAAC;YACjD,MAAM,EAAE,UAAU,CAAC;SACpB,CAAC;KACH;IAKK,YAAY,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IA+CvF,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS;IAIzE,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,aAAa,EAAE;IAUnD,iBAAiB,CACf,KAAK,EAAE,UAAU,GAAG;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,GAChD,6BAA6B,GAAG,IAAI;CAsBxC"}
|
|
@@ -20,15 +20,17 @@ export class AgentContextService {
|
|
|
20
20
|
const priorOccupiedFingerprint = this.#occupiedFingerprintByAgent.get(input.agent.id);
|
|
21
21
|
const occupiedChanged = priorOccupiedFingerprint !== undefined && priorOccupiedFingerprint !== occupiedFingerprint;
|
|
22
22
|
this.#occupiedFingerprintByAgent.set(input.agent.id, occupiedFingerprint);
|
|
23
|
-
const forceDiscovery =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
const forceDiscovery = input.forceRefresh ||
|
|
24
|
+
(await shouldForceDiscovery({
|
|
25
|
+
agent: input.agent,
|
|
26
|
+
directAuthoritativeRef,
|
|
27
|
+
identityChanged: input.identityChanged || occupiedChanged,
|
|
28
|
+
preferredRef,
|
|
29
|
+
previous,
|
|
30
|
+
}));
|
|
30
31
|
const resolved = bindAuthoritativeId(input.agent, await this.#history.resolveCompactHistory(historyLookup(input.agent, this.#stores.agents, occupiedSessionPaths), {
|
|
31
32
|
forceDiscovery,
|
|
33
|
+
...(input.forceRefresh === undefined ? {} : { forceRefresh: input.forceRefresh }),
|
|
32
34
|
...(preferredRef ? { preferredRef } : {}),
|
|
33
35
|
}));
|
|
34
36
|
const next = {
|
|
@@ -143,6 +145,9 @@ function historyLookup(agent, agents, occupiedSessionPaths) {
|
|
|
143
145
|
cwd: agent.cwd,
|
|
144
146
|
firstSeenAtMs: agent.firstSeenAt.getTime(),
|
|
145
147
|
foregroundCwd: agent.foregroundCwd,
|
|
148
|
+
...(agent.agent?.toLowerCase() === "grok" && agent.grokHome
|
|
149
|
+
? { grokHome: agent.grokHome }
|
|
150
|
+
: {}),
|
|
146
151
|
occupiedSessionPaths: occupiedSessionPaths ?? occupiedForAgent(agent, agents),
|
|
147
152
|
};
|
|
148
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-context-service.js","sourceRoot":"","sources":["../../../src/observability/agent-context-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BA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AC;AACJ,CAAC"}
|
|
@@ -8,6 +8,7 @@ import type { HerdrWorkspaceStore } from "../db/herdr-workspaces.js";
|
|
|
8
8
|
import { HerdrSocketClient } from "../herdr/socket-client.js";
|
|
9
9
|
import { AgentContextService } from "../observability/agent-context-service.js";
|
|
10
10
|
import { type AgentEventRecord, type AgentIndexRecord, type AgentScope, type AgentSessionRef } from "../observability/contracts.js";
|
|
11
|
+
import type { TurnCompletionRegistry } from "../observability/turn-completion.js";
|
|
11
12
|
export type AgentIndexRefreshResult = {
|
|
12
13
|
agents: AgentIndexRecord[];
|
|
13
14
|
contextChangedScopes: AgentScope[];
|
|
@@ -44,6 +45,7 @@ export declare class AgentIndexService {
|
|
|
44
45
|
context?: AgentContextService;
|
|
45
46
|
history?: AgentHistoryService;
|
|
46
47
|
stores: AgentIndexServiceStores;
|
|
48
|
+
turnCompletions?: TurnCompletionRegistry;
|
|
47
49
|
});
|
|
48
50
|
refreshHerdrSession(input: RefreshInput): Promise<AgentIndexRefreshResult>;
|
|
49
51
|
handleHerdrEvent(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-index-service.d.ts","sourceRoot":"","sources":["../../../src/observability/agent-index-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,mBAAmB,EAA6B,MAAM,4BAA4B,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,eAAe,EAGrB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-index-service.d.ts","sourceRoot":"","sources":["../../../src/observability/agent-index-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,mBAAmB,EAA6B,MAAM,4BAA4B,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,eAAe,EAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAGjF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,oBAAoB,EAAE,UAAU,EAAE,CAAC;IACnC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,oBAAoB,EAAE,UAAU,EAAE,CAAC;IACnC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC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,OAAO,CAAC,wBAAwB,CAAC;IAOrC,oBAAoB,CAAC,KAAK,EAAE;QAC1B,gBAAgB,EAAE,MAAM,CAAC;QACzB,UAAU,EAAE,eAAe,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,8BAA8B,CAAC;CA8a5C"}
|
|
@@ -4,6 +4,7 @@ import { normalizeHerdrSessionSnapshot } from "../herdr/session-snapshot.js";
|
|
|
4
4
|
import { HerdrSocketClient } from "../herdr/socket-client.js";
|
|
5
5
|
import { AgentContextService } from "../observability/agent-context-service.js";
|
|
6
6
|
import { parseAgentStatus, } from "../observability/contracts.js";
|
|
7
|
+
import { TURN_SIGNAL_WAIT_MS } from "../observability/turn-completion.js";
|
|
7
8
|
export class AgentIndexService {
|
|
8
9
|
#clientFactory;
|
|
9
10
|
#context;
|
|
@@ -12,9 +13,11 @@ export class AgentIndexService {
|
|
|
12
13
|
#pendingPiSessionRefs = new Map();
|
|
13
14
|
#refreshInFlightBySession = new Map();
|
|
14
15
|
#sessionOperationTail = new Map();
|
|
16
|
+
#turnCompletions;
|
|
15
17
|
constructor(options) {
|
|
16
18
|
this.#clientFactory = options.clientFactory ?? ((input) => new HerdrSocketClient(input));
|
|
17
19
|
this.#stores = options.stores;
|
|
20
|
+
this.#turnCompletions = options.turnCompletions;
|
|
18
21
|
if (options.context) {
|
|
19
22
|
this.#context = options.context;
|
|
20
23
|
}
|
|
@@ -62,7 +65,7 @@ export class AgentIndexService {
|
|
|
62
65
|
const client = this.#clientFactory({ socketPath: input.socketPath });
|
|
63
66
|
try {
|
|
64
67
|
const previous = this.#stores.agents.listForHerdrSession(input.herdrSessionName);
|
|
65
|
-
const previousByPane = new Map(previous.map((agent) => [agent.paneId, agent]));
|
|
68
|
+
const previousByPane = new Map(previous.map((agent) => [paneIdentityKey(agent.paneId, agent.paneGeneration), agent]));
|
|
66
69
|
const previousByTerminal = new Map(previous.flatMap((agent) => agent.terminalId ? [[agent.terminalId, agent]] : []));
|
|
67
70
|
const refreshEpoch = this.#mutationEpochBySession.get(input.herdrSessionName) ?? 0;
|
|
68
71
|
const snapshot = normalizeHerdrSessionSnapshot(await client.sessionSnapshot());
|
|
@@ -154,7 +157,7 @@ export class AgentIndexService {
|
|
|
154
157
|
addScope(scopes, scopeOf(agent));
|
|
155
158
|
}
|
|
156
159
|
if (prior && prior.agentStatus !== agent.agentStatus) {
|
|
157
|
-
const event = this.#appendStatusEvents({
|
|
160
|
+
const event = await this.#appendStatusEvents({
|
|
158
161
|
agent,
|
|
159
162
|
compactHistory: refreshed?.compactHistory ?? this.#context.getAgentSnapshot(agent.id)?.compactHistory,
|
|
160
163
|
from: prior.agentStatus,
|
|
@@ -181,23 +184,40 @@ export class AgentIndexService {
|
|
|
181
184
|
if (!paneId)
|
|
182
185
|
return { contextChangedScopes: [], events: [] };
|
|
183
186
|
if (event.type === "pane.closed") {
|
|
184
|
-
|
|
187
|
+
const closedGeneration = paneGenerationFromEvent(event);
|
|
188
|
+
this.#stores.agentEvents.invalidatePane({
|
|
189
|
+
herdrSessionName: input.herdrSessionName,
|
|
190
|
+
paneId,
|
|
191
|
+
paneGeneration: closedGeneration,
|
|
192
|
+
invalidatedReason: closedGeneration ? "PANE_CLOSED" : "LEGACY_CLOSE_WITHOUT_GENERATION",
|
|
193
|
+
});
|
|
194
|
+
if (!closedGeneration) {
|
|
195
|
+
console.warn("LEGACY_CLOSE_WITHOUT_GENERATION", {
|
|
196
|
+
sessionName: input.herdrSessionName,
|
|
197
|
+
paneId,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
185
200
|
const retired = this.#stores.agents.retirePane({
|
|
186
201
|
herdrSessionName: input.herdrSessionName,
|
|
187
202
|
paneId,
|
|
203
|
+
paneGeneration: closedGeneration,
|
|
188
204
|
});
|
|
189
205
|
const scopes = new Map();
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
const change = this.#stores.agentOrchestratorScopes
|
|
206
|
+
const closedTerminalId = stringValue(event.terminal_id) ?? stringValue(event.terminalId);
|
|
207
|
+
if (closedGeneration && closedTerminalId) {
|
|
208
|
+
for (const agent of retired) {
|
|
209
|
+
const scope = scopeOf(agent);
|
|
210
|
+
const change = this.#stores.agentOrchestratorScopes?.releaseIfOwnerIdentity({
|
|
195
211
|
...scope,
|
|
196
|
-
|
|
212
|
+
paneId,
|
|
213
|
+
terminalId: closedTerminalId,
|
|
197
214
|
});
|
|
198
|
-
if (change
|
|
215
|
+
if (change?.changed)
|
|
199
216
|
addScope(scopes, scope);
|
|
200
217
|
}
|
|
218
|
+
}
|
|
219
|
+
for (const agent of retired) {
|
|
220
|
+
const scope = scopeOf(agent);
|
|
201
221
|
addScope(scopes, scope);
|
|
202
222
|
}
|
|
203
223
|
return {
|
|
@@ -207,14 +227,20 @@ export class AgentIndexService {
|
|
|
207
227
|
}
|
|
208
228
|
if (event.type !== "pane.agent_status_changed")
|
|
209
229
|
return { contextChangedScopes: [], events: [] };
|
|
230
|
+
const eventGeneration = paneGenerationFromEvent(event);
|
|
210
231
|
let agent = this.#stores.agents.findByPane({
|
|
211
232
|
herdrSessionName: input.herdrSessionName,
|
|
212
233
|
paneId,
|
|
234
|
+
paneGeneration: eventGeneration,
|
|
213
235
|
});
|
|
214
236
|
let recovered;
|
|
215
237
|
if (!agent) {
|
|
216
238
|
recovered = await this.#refreshHerdrSessionNow(input);
|
|
217
|
-
agent = this.#stores.agents.findByPane({
|
|
239
|
+
agent = this.#stores.agents.findByPane({
|
|
240
|
+
herdrSessionName: input.herdrSessionName,
|
|
241
|
+
paneId,
|
|
242
|
+
paneGeneration: eventGeneration,
|
|
243
|
+
});
|
|
218
244
|
}
|
|
219
245
|
if (!agent) {
|
|
220
246
|
return recovered
|
|
@@ -228,6 +254,7 @@ export class AgentIndexService {
|
|
|
228
254
|
agentStatus: to,
|
|
229
255
|
herdrSessionName: input.herdrSessionName,
|
|
230
256
|
paneId,
|
|
257
|
+
paneGeneration: eventGeneration,
|
|
231
258
|
});
|
|
232
259
|
const current = updated ?? { ...agent, agentStatus: to };
|
|
233
260
|
const refreshed = await this.#context.refreshAgent({ agent: current, identityChanged: false });
|
|
@@ -241,7 +268,7 @@ export class AgentIndexService {
|
|
|
241
268
|
candidate.type === statusEventType(to) &&
|
|
242
269
|
candidate.payload.to === to);
|
|
243
270
|
if (!equivalent) {
|
|
244
|
-
const statusEvent = this.#appendStatusEvents({
|
|
271
|
+
const statusEvent = await this.#appendStatusEvents({
|
|
245
272
|
agent: current,
|
|
246
273
|
compactHistory: refreshed.snapshot.compactHistory,
|
|
247
274
|
from,
|
|
@@ -293,16 +320,64 @@ export class AgentIndexService {
|
|
|
293
320
|
});
|
|
294
321
|
return result;
|
|
295
322
|
}
|
|
296
|
-
#appendStatusEvents(input) {
|
|
323
|
+
async #appendStatusEvents(input) {
|
|
297
324
|
if (input.from === input.to || !input.compactHistory)
|
|
298
325
|
return undefined;
|
|
299
326
|
const latest = this.#stores.agentEvents.latestStatusTransition(input.agent.id, input.agent.herdrSessionName);
|
|
300
327
|
if (latest && statusTransitionMatches(latest, input.from, input.to))
|
|
301
328
|
return undefined;
|
|
302
329
|
const observationId = `transition:${latest?.id ?? 0}`;
|
|
303
|
-
let
|
|
330
|
+
let compactHistory = input.compactHistory;
|
|
331
|
+
if (this.#turnCompletions !== undefined &&
|
|
332
|
+
(input.to === "done" || input.to === "blocked") &&
|
|
333
|
+
input.agent.agent === "pi" &&
|
|
334
|
+
input.agent.terminalId !== null) {
|
|
335
|
+
const turn = await this.#turnCompletions.waitForSignal({
|
|
336
|
+
herdrSessionName: input.agent.herdrSessionName,
|
|
337
|
+
recordedAfterMs: Date.now() - TURN_SIGNAL_WAIT_MS,
|
|
338
|
+
terminalId: input.agent.terminalId,
|
|
339
|
+
});
|
|
340
|
+
if (turn.received) {
|
|
341
|
+
let refreshed = await this.#context.refreshAgent({
|
|
342
|
+
agent: input.agent,
|
|
343
|
+
identityChanged: false,
|
|
344
|
+
forceRefresh: true,
|
|
345
|
+
});
|
|
346
|
+
for (let attempt = 0; attempt < 3 && refreshed.snapshot.compactHistory.lastAssistantMessage === null; attempt += 1) {
|
|
347
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
348
|
+
refreshed = await this.#context.refreshAgent({
|
|
349
|
+
agent: input.agent,
|
|
350
|
+
identityChanged: false,
|
|
351
|
+
forceRefresh: true,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
compactHistory = refreshed.snapshot.compactHistory;
|
|
355
|
+
console.log(`Herdsman emitted pi agent.${input.to} after turn completion signal (confirmed=${turn.confirmed})`, {
|
|
356
|
+
agentId: input.agent.id,
|
|
357
|
+
herdrSessionName: input.agent.herdrSessionName,
|
|
358
|
+
terminalId: input.agent.terminalId,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
for (let attempt = 0; attempt < 3 && compactHistory.lastAssistantMessage === null; attempt += 1) {
|
|
363
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
364
|
+
const refreshed = await this.#context.refreshAgent({
|
|
365
|
+
agent: input.agent,
|
|
366
|
+
identityChanged: false,
|
|
367
|
+
forceRefresh: true,
|
|
368
|
+
});
|
|
369
|
+
compactHistory = refreshed.snapshot.compactHistory;
|
|
370
|
+
}
|
|
371
|
+
console.warn(`Herdsman emitted pi agent.${input.to} without a turn completion signal after ${TURN_SIGNAL_WAIT_MS}ms`, {
|
|
372
|
+
agentId: input.agent.id,
|
|
373
|
+
herdrSessionName: input.agent.herdrSessionName,
|
|
374
|
+
terminalId: input.agent.terminalId,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const lastEvent = this.#appendAndAckSelfEvent({
|
|
304
379
|
agentId: input.agent.id,
|
|
305
|
-
compactHistory
|
|
380
|
+
compactHistory,
|
|
306
381
|
herdrSessionName: input.agent.herdrSessionName,
|
|
307
382
|
idempotencyKey: idempotencyKey("agent.status.changed", input.agent, input.from, input.to, `${observationId}:${input.herdrEventKey ?? "legacy"}:agent.status.changed`),
|
|
308
383
|
paneId: input.agent.paneId,
|
|
@@ -314,12 +389,13 @@ export class AgentIndexService {
|
|
|
314
389
|
});
|
|
315
390
|
const statusType = statusEventType(input.to);
|
|
316
391
|
if (statusType) {
|
|
317
|
-
|
|
392
|
+
return this.#appendAndAckSelfEvent({
|
|
318
393
|
agentId: input.agent.id,
|
|
319
|
-
compactHistory
|
|
394
|
+
compactHistory,
|
|
320
395
|
herdrSessionName: input.agent.herdrSessionName,
|
|
321
396
|
idempotencyKey: idempotencyKey(statusType, input.agent, input.from, input.to, `${observationId}:${input.herdrEventKey ?? "legacy"}:${statusType}`),
|
|
322
397
|
paneId: input.agent.paneId,
|
|
398
|
+
paneGeneration: input.agent.paneGeneration ?? null,
|
|
323
399
|
payload: payload(input.agent, input.from, input.to),
|
|
324
400
|
terminalId: input.agent.terminalId,
|
|
325
401
|
type: statusType,
|
|
@@ -328,6 +404,18 @@ export class AgentIndexService {
|
|
|
328
404
|
}
|
|
329
405
|
return lastEvent;
|
|
330
406
|
}
|
|
407
|
+
#appendAndAckSelfEvent(input) {
|
|
408
|
+
const event = this.#stores.agentEvents.append(input);
|
|
409
|
+
const owner = this.#stores.agentOrchestratorScopes?.get({
|
|
410
|
+
herdrSessionName: input.herdrSessionName,
|
|
411
|
+
workspaceId: input.workspaceId ?? "",
|
|
412
|
+
});
|
|
413
|
+
if (owner?.owner?.paneId && owner.owner.paneId === input.paneId) {
|
|
414
|
+
this.#stores.agentEvents.markAcked(event.id);
|
|
415
|
+
return this.#stores.agentEvents.get(event.id);
|
|
416
|
+
}
|
|
417
|
+
return event;
|
|
418
|
+
}
|
|
331
419
|
}
|
|
332
420
|
function withPaneRevision(agent, revisionByPane) {
|
|
333
421
|
const raw = record(agent);
|
|
@@ -339,9 +427,12 @@ function withPaneRevision(agent, revisionByPane) {
|
|
|
339
427
|
}
|
|
340
428
|
function matchingPrior(agent, previousByTerminal, previousByPane) {
|
|
341
429
|
const terminalMatch = agent.terminalId ? previousByTerminal.get(agent.terminalId) : undefined;
|
|
342
|
-
const
|
|
430
|
+
const generationMatches = !agent.paneGeneration ||
|
|
431
|
+
!terminalMatch?.paneGeneration ||
|
|
432
|
+
terminalMatch.paneGeneration === agent.paneGeneration;
|
|
433
|
+
const paneMatch = previousByPane.get(paneIdentityKey(agent.paneId, agent.paneGeneration));
|
|
343
434
|
const canUsePaneFallback = paneMatch && (!agent.terminalId || !paneMatch.terminalId);
|
|
344
|
-
return terminalMatch ?? (canUsePaneFallback ? paneMatch : undefined);
|
|
435
|
+
return ((generationMatches ? terminalMatch : undefined) ?? (canUsePaneFallback ? paneMatch : undefined));
|
|
345
436
|
}
|
|
346
437
|
function sameIdentity(left, right) {
|
|
347
438
|
return (left.agent === right.agent &&
|
|
@@ -418,6 +509,12 @@ function statusTransitionMatches(event, from, to) {
|
|
|
418
509
|
function record(value) {
|
|
419
510
|
return typeof value === "object" && value !== null ? value : {};
|
|
420
511
|
}
|
|
512
|
+
function paneGenerationFromEvent(event) {
|
|
513
|
+
return stringValue(event.pane_generation) ?? stringValue(event.paneGeneration);
|
|
514
|
+
}
|
|
515
|
+
function paneIdentityKey(paneId, paneGeneration) {
|
|
516
|
+
return `${paneId}\0${paneGeneration ?? ""}`;
|
|
517
|
+
}
|
|
421
518
|
function stringValue(value) {
|
|
422
519
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
423
520
|
}
|