jg-agent-hq 4.0.2 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +4 -4
- package/api/README.md +20 -12
- package/dist/cli/cli.js +23 -2
- package/dist/contracts/agent-tools/types.d.ts +2 -0
- package/dist/contracts/browser/types.d.ts +11 -0
- package/dist/contracts/constants.d.ts +1 -0
- package/dist/contracts/constants.js +2 -0
- package/dist/contracts/evidence/types.d.ts +4 -0
- package/dist/contracts/evidence/types.js +2 -1
- package/dist/contracts/index.d.ts +5 -5
- package/dist/contracts/index.js +3 -3
- package/dist/contracts/sessions/index.d.ts +2 -2
- package/dist/contracts/sessions/index.js +1 -1
- package/dist/contracts/sessions/types.d.ts +5 -0
- package/dist/contracts/sessions/types.js +2 -0
- package/dist/contracts/types.d.ts +242 -0
- package/dist/contracts/types.js +37 -5
- package/dist/providers/claude/agents/agents.d.ts +7 -3
- package/dist/providers/claude/agents/agents.js +33 -19
- package/dist/providers/claude/agents/constants.d.ts +2 -1
- package/dist/providers/claude/agents/constants.js +3 -2
- package/dist/providers/claude/claude.js +80 -30
- package/dist/providers/claude/control/control.d.ts +44 -5
- package/dist/providers/claude/control/control.js +425 -228
- package/dist/providers/claude/control/stream.js +22 -6
- package/dist/providers/claude/control/types.d.ts +7 -0
- package/dist/providers/claude/history/history.model.js +44 -27
- package/dist/providers/claude/history/types.d.ts +88 -0
- package/dist/providers/claude/history/types.js +15 -0
- package/dist/providers/claude/history/utilities.d.ts +6 -4
- package/dist/providers/claude/history/utilities.js +146 -52
- package/dist/providers/codex/adapter.js +33 -4
- package/dist/providers/codex/codex.js +5 -4
- package/dist/providers/codex/events.js +3 -1
- package/dist/providers/codex/transformers.d.ts +4 -2
- package/dist/providers/codex/transformers.js +80 -21
- package/dist/providers/codex/types.d.ts +4 -3
- package/dist/providers/registry/registry.js +12 -9
- package/dist/providers/registry/types.d.ts +1 -1
- package/dist/providers/registry/validations.js +7 -0
- package/dist/providers/types.d.ts +7 -1
- package/dist/runtime/runtime.js +20 -4
- package/dist/sessions/evidence/utilities.js +3 -1
- package/dist/sessions/index.d.ts +2 -2
- package/dist/sessions/index.js +3 -3
- package/dist/sessions/sessions.d.ts +11 -1
- package/dist/sessions/sessions.js +89 -7
- package/dist/sessions/utilities.d.ts +15 -0
- package/dist/sessions/utilities.js +19 -0
- package/dist/store/schema.sql +1 -1
- package/dist/store/sessions/index.d.ts +2 -0
- package/dist/store/sessions/index.js +2 -0
- package/dist/store/sessions/sessions.model.d.ts +9 -0
- package/dist/store/sessions/sessions.model.js +55 -0
- package/dist/store/sessions/types.d.ts +67 -0
- package/dist/store/sessions/types.js +36 -0
- package/dist/store/store.js +4 -0
- package/dist/store/store.worker.js +3 -0
- package/dist/store/types.d.ts +40 -0
- package/dist/store/types.js +1 -0
- package/package.json +1 -1
|
@@ -77,6 +77,7 @@ export declare const HqRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
77
77
|
tool: "tool";
|
|
78
78
|
"agent-message": "agent-message";
|
|
79
79
|
"file-change": "file-change";
|
|
80
|
+
notice: "notice";
|
|
80
81
|
}>>>;
|
|
81
82
|
taskId: z.ZodUUID;
|
|
82
83
|
}, z.core.$strict>;
|
|
@@ -886,6 +887,7 @@ export declare const HqRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
886
887
|
tool: "tool";
|
|
887
888
|
"agent-message": "agent-message";
|
|
888
889
|
"file-change": "file-change";
|
|
890
|
+
notice: "notice";
|
|
889
891
|
}>>>;
|
|
890
892
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
891
893
|
cursor: z.ZodOptional<z.ZodString>;
|
|
@@ -1178,6 +1180,8 @@ export declare const HqRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1178
1180
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
1179
1181
|
cursor: z.ZodOptional<z.ZodString>;
|
|
1180
1182
|
turnId: z.ZodOptional<z.ZodString>;
|
|
1183
|
+
nativeItemId: z.ZodOptional<z.ZodString>;
|
|
1184
|
+
textLimit: z.ZodDefault<z.ZodNumber>;
|
|
1181
1185
|
provider: z.ZodString;
|
|
1182
1186
|
workspaceRoot: z.ZodString;
|
|
1183
1187
|
nativeId: z.ZodString;
|
|
@@ -1536,6 +1540,14 @@ export declare const HqRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1536
1540
|
kind: z.ZodLiteral<"session-states">;
|
|
1537
1541
|
afterSequence: z.ZodDefault<z.ZodNumber>;
|
|
1538
1542
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
1543
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1544
|
+
kind: z.ZodLiteral<"active-sessions">;
|
|
1545
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1546
|
+
kind: z.ZodLiteral<"observation-pace">;
|
|
1547
|
+
pace: z.ZodEnum<{
|
|
1548
|
+
live: "live";
|
|
1549
|
+
background: "background";
|
|
1550
|
+
}>;
|
|
1539
1551
|
}, z.core.$strict>], "kind">;
|
|
1540
1552
|
export type IHqRequest = z.infer<typeof HqRequestSchema>;
|
|
1541
1553
|
export type IHqRequestInput = z.input<typeof HqRequestSchema>;
|
|
@@ -1578,6 +1590,48 @@ export declare const ThreadSummarySchema: z.ZodObject<{
|
|
|
1578
1590
|
}>;
|
|
1579
1591
|
}, z.core.$strip>;
|
|
1580
1592
|
export type IThreadSummary = z.infer<typeof ThreadSummarySchema>;
|
|
1593
|
+
export declare const ActiveSessionsSchema: z.ZodObject<{
|
|
1594
|
+
data: z.ZodArray<z.ZodObject<{
|
|
1595
|
+
provider: z.ZodString;
|
|
1596
|
+
nativeId: z.ZodString;
|
|
1597
|
+
nativeLineage: z.ZodNullable<z.ZodObject<{
|
|
1598
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
1599
|
+
parentThreadId: z.ZodNullable<z.ZodString>;
|
|
1600
|
+
forkedFromId: z.ZodNullable<z.ZodString>;
|
|
1601
|
+
}, z.core.$strip>>;
|
|
1602
|
+
workspaceRoot: z.ZodString;
|
|
1603
|
+
name: z.ZodNullable<z.ZodString>;
|
|
1604
|
+
createdAt: z.ZodNumber;
|
|
1605
|
+
updatedAt: z.ZodNumber;
|
|
1606
|
+
nativeState: z.ZodEnum<{
|
|
1607
|
+
unknown: "unknown";
|
|
1608
|
+
idle: "idle";
|
|
1609
|
+
active: "active";
|
|
1610
|
+
notLoaded: "notLoaded";
|
|
1611
|
+
systemError: "systemError";
|
|
1612
|
+
}>;
|
|
1613
|
+
state: z.ZodEnum<{
|
|
1614
|
+
unknown: "unknown";
|
|
1615
|
+
idle: "idle";
|
|
1616
|
+
failed: "failed";
|
|
1617
|
+
running: "running";
|
|
1618
|
+
waiting: "waiting";
|
|
1619
|
+
closed: "closed";
|
|
1620
|
+
}>;
|
|
1621
|
+
ownership: z.ZodEnum<{
|
|
1622
|
+
external: "external";
|
|
1623
|
+
managed: "managed";
|
|
1624
|
+
uncertain: "uncertain";
|
|
1625
|
+
}>;
|
|
1626
|
+
managedId: z.ZodNullable<z.ZodUUID>;
|
|
1627
|
+
historyState: z.ZodEnum<{
|
|
1628
|
+
unavailable: "unavailable";
|
|
1629
|
+
available: "available";
|
|
1630
|
+
}>;
|
|
1631
|
+
}, z.core.$strip>>;
|
|
1632
|
+
isTruncated: z.ZodBoolean;
|
|
1633
|
+
}, z.core.$strip>;
|
|
1634
|
+
export type IActiveSessions = z.infer<typeof ActiveSessionsSchema>;
|
|
1581
1635
|
export declare const TurnSummarySchema: z.ZodObject<{
|
|
1582
1636
|
nativeId: z.ZodString;
|
|
1583
1637
|
state: z.ZodEnum<{
|
|
@@ -1591,6 +1645,12 @@ export declare const TurnSummarySchema: z.ZodObject<{
|
|
|
1591
1645
|
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
1592
1646
|
}, z.core.$strip>;
|
|
1593
1647
|
export type ITurnSummary = z.infer<typeof TurnSummarySchema>;
|
|
1648
|
+
export declare const HistoryFileSchema: z.ZodObject<{
|
|
1649
|
+
path: z.ZodString;
|
|
1650
|
+
added: z.ZodNumber;
|
|
1651
|
+
removed: z.ZodNumber;
|
|
1652
|
+
}, z.core.$strip>;
|
|
1653
|
+
export type IHistoryFile = z.infer<typeof HistoryFileSchema>;
|
|
1594
1654
|
export declare const HistoryItemSchema: z.ZodObject<{
|
|
1595
1655
|
nativeId: z.ZodString;
|
|
1596
1656
|
turnId: z.ZodString;
|
|
@@ -1602,6 +1662,7 @@ export declare const HistoryItemSchema: z.ZodObject<{
|
|
|
1602
1662
|
tool: "tool";
|
|
1603
1663
|
"agent-message": "agent-message";
|
|
1604
1664
|
"file-change": "file-change";
|
|
1665
|
+
notice: "notice";
|
|
1605
1666
|
}>;
|
|
1606
1667
|
provenance: z.ZodObject<{
|
|
1607
1668
|
origin: z.ZodEnum<{
|
|
@@ -1625,6 +1686,16 @@ export declare const HistoryItemSchema: z.ZodObject<{
|
|
|
1625
1686
|
}, z.core.$strip>;
|
|
1626
1687
|
text: z.ZodString;
|
|
1627
1688
|
isTruncated: z.ZodBoolean;
|
|
1689
|
+
callId: z.ZodNullable<z.ZodString>;
|
|
1690
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
1691
|
+
failed: "failed";
|
|
1692
|
+
succeeded: "succeeded";
|
|
1693
|
+
}>>;
|
|
1694
|
+
files: z.ZodArray<z.ZodObject<{
|
|
1695
|
+
path: z.ZodString;
|
|
1696
|
+
added: z.ZodNumber;
|
|
1697
|
+
removed: z.ZodNumber;
|
|
1698
|
+
}, z.core.$strip>>;
|
|
1628
1699
|
}, z.core.$strip>;
|
|
1629
1700
|
export type IHistoryItem = z.infer<typeof HistoryItemSchema>;
|
|
1630
1701
|
export declare const LiveItemsSchema: z.ZodObject<{
|
|
@@ -1641,6 +1712,7 @@ export declare const LiveItemsSchema: z.ZodObject<{
|
|
|
1641
1712
|
tool: "tool";
|
|
1642
1713
|
"agent-message": "agent-message";
|
|
1643
1714
|
"file-change": "file-change";
|
|
1715
|
+
notice: "notice";
|
|
1644
1716
|
}>;
|
|
1645
1717
|
provenance: z.ZodObject<{
|
|
1646
1718
|
origin: z.ZodEnum<{
|
|
@@ -1664,6 +1736,16 @@ export declare const LiveItemsSchema: z.ZodObject<{
|
|
|
1664
1736
|
}, z.core.$strip>;
|
|
1665
1737
|
text: z.ZodString;
|
|
1666
1738
|
isTruncated: z.ZodBoolean;
|
|
1739
|
+
callId: z.ZodNullable<z.ZodString>;
|
|
1740
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
1741
|
+
failed: "failed";
|
|
1742
|
+
succeeded: "succeeded";
|
|
1743
|
+
}>>;
|
|
1744
|
+
files: z.ZodArray<z.ZodObject<{
|
|
1745
|
+
path: z.ZodString;
|
|
1746
|
+
added: z.ZodNumber;
|
|
1747
|
+
removed: z.ZodNumber;
|
|
1748
|
+
}, z.core.$strip>>;
|
|
1667
1749
|
state: z.ZodEnum<{
|
|
1668
1750
|
active: "active";
|
|
1669
1751
|
"awaiting-flush": "awaiting-flush";
|
|
@@ -1812,6 +1894,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1812
1894
|
tool: "tool";
|
|
1813
1895
|
"agent-message": "agent-message";
|
|
1814
1896
|
"file-change": "file-change";
|
|
1897
|
+
notice: "notice";
|
|
1815
1898
|
}>;
|
|
1816
1899
|
nativeType: z.ZodString;
|
|
1817
1900
|
provenance: z.ZodObject<{
|
|
@@ -5702,6 +5785,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
5702
5785
|
tool: "tool";
|
|
5703
5786
|
"agent-message": "agent-message";
|
|
5704
5787
|
"file-change": "file-change";
|
|
5788
|
+
notice: "notice";
|
|
5705
5789
|
}>;
|
|
5706
5790
|
provenance: z.ZodObject<{
|
|
5707
5791
|
origin: z.ZodEnum<{
|
|
@@ -5725,6 +5809,16 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
5725
5809
|
}, z.core.$strip>;
|
|
5726
5810
|
text: z.ZodString;
|
|
5727
5811
|
isTruncated: z.ZodBoolean;
|
|
5812
|
+
callId: z.ZodNullable<z.ZodString>;
|
|
5813
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
5814
|
+
failed: "failed";
|
|
5815
|
+
succeeded: "succeeded";
|
|
5816
|
+
}>>;
|
|
5817
|
+
files: z.ZodArray<z.ZodObject<{
|
|
5818
|
+
path: z.ZodString;
|
|
5819
|
+
added: z.ZodNumber;
|
|
5820
|
+
removed: z.ZodNumber;
|
|
5821
|
+
}, z.core.$strip>>;
|
|
5728
5822
|
}, z.core.$strip>>;
|
|
5729
5823
|
}, z.core.$strip>;
|
|
5730
5824
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -6454,6 +6548,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
6454
6548
|
tool: "tool";
|
|
6455
6549
|
"agent-message": "agent-message";
|
|
6456
6550
|
"file-change": "file-change";
|
|
6551
|
+
notice: "notice";
|
|
6457
6552
|
}>;
|
|
6458
6553
|
provenance: z.ZodObject<{
|
|
6459
6554
|
origin: z.ZodEnum<{
|
|
@@ -6477,6 +6572,16 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
6477
6572
|
}, z.core.$strip>;
|
|
6478
6573
|
text: z.ZodString;
|
|
6479
6574
|
isTruncated: z.ZodBoolean;
|
|
6575
|
+
callId: z.ZodNullable<z.ZodString>;
|
|
6576
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
6577
|
+
failed: "failed";
|
|
6578
|
+
succeeded: "succeeded";
|
|
6579
|
+
}>>;
|
|
6580
|
+
files: z.ZodArray<z.ZodObject<{
|
|
6581
|
+
path: z.ZodString;
|
|
6582
|
+
added: z.ZodNumber;
|
|
6583
|
+
removed: z.ZodNumber;
|
|
6584
|
+
}, z.core.$strip>>;
|
|
6480
6585
|
state: z.ZodEnum<{
|
|
6481
6586
|
active: "active";
|
|
6482
6587
|
"awaiting-flush": "awaiting-flush";
|
|
@@ -6527,6 +6632,57 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
6527
6632
|
}, z.core.$strip>>;
|
|
6528
6633
|
hasMore: z.ZodBoolean;
|
|
6529
6634
|
}, z.core.$strip>;
|
|
6635
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6636
|
+
kind: z.ZodLiteral<"active-sessions">;
|
|
6637
|
+
result: z.ZodObject<{
|
|
6638
|
+
data: z.ZodArray<z.ZodObject<{
|
|
6639
|
+
provider: z.ZodString;
|
|
6640
|
+
nativeId: z.ZodString;
|
|
6641
|
+
nativeLineage: z.ZodNullable<z.ZodObject<{
|
|
6642
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
6643
|
+
parentThreadId: z.ZodNullable<z.ZodString>;
|
|
6644
|
+
forkedFromId: z.ZodNullable<z.ZodString>;
|
|
6645
|
+
}, z.core.$strip>>;
|
|
6646
|
+
workspaceRoot: z.ZodString;
|
|
6647
|
+
name: z.ZodNullable<z.ZodString>;
|
|
6648
|
+
createdAt: z.ZodNumber;
|
|
6649
|
+
updatedAt: z.ZodNumber;
|
|
6650
|
+
nativeState: z.ZodEnum<{
|
|
6651
|
+
unknown: "unknown";
|
|
6652
|
+
idle: "idle";
|
|
6653
|
+
active: "active";
|
|
6654
|
+
notLoaded: "notLoaded";
|
|
6655
|
+
systemError: "systemError";
|
|
6656
|
+
}>;
|
|
6657
|
+
state: z.ZodEnum<{
|
|
6658
|
+
unknown: "unknown";
|
|
6659
|
+
idle: "idle";
|
|
6660
|
+
failed: "failed";
|
|
6661
|
+
running: "running";
|
|
6662
|
+
waiting: "waiting";
|
|
6663
|
+
closed: "closed";
|
|
6664
|
+
}>;
|
|
6665
|
+
ownership: z.ZodEnum<{
|
|
6666
|
+
external: "external";
|
|
6667
|
+
managed: "managed";
|
|
6668
|
+
uncertain: "uncertain";
|
|
6669
|
+
}>;
|
|
6670
|
+
managedId: z.ZodNullable<z.ZodUUID>;
|
|
6671
|
+
historyState: z.ZodEnum<{
|
|
6672
|
+
unavailable: "unavailable";
|
|
6673
|
+
available: "available";
|
|
6674
|
+
}>;
|
|
6675
|
+
}, z.core.$strip>>;
|
|
6676
|
+
isTruncated: z.ZodBoolean;
|
|
6677
|
+
}, z.core.$strip>;
|
|
6678
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6679
|
+
kind: z.ZodLiteral<"observation-pace">;
|
|
6680
|
+
result: z.ZodObject<{
|
|
6681
|
+
pace: z.ZodEnum<{
|
|
6682
|
+
live: "live";
|
|
6683
|
+
background: "background";
|
|
6684
|
+
}>;
|
|
6685
|
+
}, z.core.$strip>;
|
|
6530
6686
|
}, z.core.$strip>], "kind">;
|
|
6531
6687
|
export type IHqResponse = z.infer<typeof HqResponseSchema>;
|
|
6532
6688
|
export declare const ErrorKindSchema: z.ZodEnum<{
|
|
@@ -6621,6 +6777,7 @@ export declare const IpcRequestSchema: z.ZodObject<{
|
|
|
6621
6777
|
tool: "tool";
|
|
6622
6778
|
"agent-message": "agent-message";
|
|
6623
6779
|
"file-change": "file-change";
|
|
6780
|
+
notice: "notice";
|
|
6624
6781
|
}>>>;
|
|
6625
6782
|
taskId: z.ZodUUID;
|
|
6626
6783
|
}, z.core.$strict>;
|
|
@@ -7430,6 +7587,7 @@ export declare const IpcRequestSchema: z.ZodObject<{
|
|
|
7430
7587
|
tool: "tool";
|
|
7431
7588
|
"agent-message": "agent-message";
|
|
7432
7589
|
"file-change": "file-change";
|
|
7590
|
+
notice: "notice";
|
|
7433
7591
|
}>>>;
|
|
7434
7592
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
7435
7593
|
cursor: z.ZodOptional<z.ZodString>;
|
|
@@ -7722,6 +7880,8 @@ export declare const IpcRequestSchema: z.ZodObject<{
|
|
|
7722
7880
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
7723
7881
|
cursor: z.ZodOptional<z.ZodString>;
|
|
7724
7882
|
turnId: z.ZodOptional<z.ZodString>;
|
|
7883
|
+
nativeItemId: z.ZodOptional<z.ZodString>;
|
|
7884
|
+
textLimit: z.ZodDefault<z.ZodNumber>;
|
|
7725
7885
|
provider: z.ZodString;
|
|
7726
7886
|
workspaceRoot: z.ZodString;
|
|
7727
7887
|
nativeId: z.ZodString;
|
|
@@ -8080,6 +8240,14 @@ export declare const IpcRequestSchema: z.ZodObject<{
|
|
|
8080
8240
|
kind: z.ZodLiteral<"session-states">;
|
|
8081
8241
|
afterSequence: z.ZodDefault<z.ZodNumber>;
|
|
8082
8242
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
8243
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
8244
|
+
kind: z.ZodLiteral<"active-sessions">;
|
|
8245
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
8246
|
+
kind: z.ZodLiteral<"observation-pace">;
|
|
8247
|
+
pace: z.ZodEnum<{
|
|
8248
|
+
live: "live";
|
|
8249
|
+
background: "background";
|
|
8250
|
+
}>;
|
|
8083
8251
|
}, z.core.$strict>], "kind">;
|
|
8084
8252
|
}, z.core.$strict>;
|
|
8085
8253
|
export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -8113,6 +8281,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
8113
8281
|
tool: "tool";
|
|
8114
8282
|
"agent-message": "agent-message";
|
|
8115
8283
|
"file-change": "file-change";
|
|
8284
|
+
notice: "notice";
|
|
8116
8285
|
}>;
|
|
8117
8286
|
nativeType: z.ZodString;
|
|
8118
8287
|
provenance: z.ZodObject<{
|
|
@@ -12003,6 +12172,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
12003
12172
|
tool: "tool";
|
|
12004
12173
|
"agent-message": "agent-message";
|
|
12005
12174
|
"file-change": "file-change";
|
|
12175
|
+
notice: "notice";
|
|
12006
12176
|
}>;
|
|
12007
12177
|
provenance: z.ZodObject<{
|
|
12008
12178
|
origin: z.ZodEnum<{
|
|
@@ -12026,6 +12196,16 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
12026
12196
|
}, z.core.$strip>;
|
|
12027
12197
|
text: z.ZodString;
|
|
12028
12198
|
isTruncated: z.ZodBoolean;
|
|
12199
|
+
callId: z.ZodNullable<z.ZodString>;
|
|
12200
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
12201
|
+
failed: "failed";
|
|
12202
|
+
succeeded: "succeeded";
|
|
12203
|
+
}>>;
|
|
12204
|
+
files: z.ZodArray<z.ZodObject<{
|
|
12205
|
+
path: z.ZodString;
|
|
12206
|
+
added: z.ZodNumber;
|
|
12207
|
+
removed: z.ZodNumber;
|
|
12208
|
+
}, z.core.$strip>>;
|
|
12029
12209
|
}, z.core.$strip>>;
|
|
12030
12210
|
}, z.core.$strip>;
|
|
12031
12211
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -12755,6 +12935,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
12755
12935
|
tool: "tool";
|
|
12756
12936
|
"agent-message": "agent-message";
|
|
12757
12937
|
"file-change": "file-change";
|
|
12938
|
+
notice: "notice";
|
|
12758
12939
|
}>;
|
|
12759
12940
|
provenance: z.ZodObject<{
|
|
12760
12941
|
origin: z.ZodEnum<{
|
|
@@ -12778,6 +12959,16 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
12778
12959
|
}, z.core.$strip>;
|
|
12779
12960
|
text: z.ZodString;
|
|
12780
12961
|
isTruncated: z.ZodBoolean;
|
|
12962
|
+
callId: z.ZodNullable<z.ZodString>;
|
|
12963
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
12964
|
+
failed: "failed";
|
|
12965
|
+
succeeded: "succeeded";
|
|
12966
|
+
}>>;
|
|
12967
|
+
files: z.ZodArray<z.ZodObject<{
|
|
12968
|
+
path: z.ZodString;
|
|
12969
|
+
added: z.ZodNumber;
|
|
12970
|
+
removed: z.ZodNumber;
|
|
12971
|
+
}, z.core.$strip>>;
|
|
12781
12972
|
state: z.ZodEnum<{
|
|
12782
12973
|
active: "active";
|
|
12783
12974
|
"awaiting-flush": "awaiting-flush";
|
|
@@ -12828,6 +13019,57 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
12828
13019
|
}, z.core.$strip>>;
|
|
12829
13020
|
hasMore: z.ZodBoolean;
|
|
12830
13021
|
}, z.core.$strip>;
|
|
13022
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
13023
|
+
kind: z.ZodLiteral<"active-sessions">;
|
|
13024
|
+
result: z.ZodObject<{
|
|
13025
|
+
data: z.ZodArray<z.ZodObject<{
|
|
13026
|
+
provider: z.ZodString;
|
|
13027
|
+
nativeId: z.ZodString;
|
|
13028
|
+
nativeLineage: z.ZodNullable<z.ZodObject<{
|
|
13029
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
13030
|
+
parentThreadId: z.ZodNullable<z.ZodString>;
|
|
13031
|
+
forkedFromId: z.ZodNullable<z.ZodString>;
|
|
13032
|
+
}, z.core.$strip>>;
|
|
13033
|
+
workspaceRoot: z.ZodString;
|
|
13034
|
+
name: z.ZodNullable<z.ZodString>;
|
|
13035
|
+
createdAt: z.ZodNumber;
|
|
13036
|
+
updatedAt: z.ZodNumber;
|
|
13037
|
+
nativeState: z.ZodEnum<{
|
|
13038
|
+
unknown: "unknown";
|
|
13039
|
+
idle: "idle";
|
|
13040
|
+
active: "active";
|
|
13041
|
+
notLoaded: "notLoaded";
|
|
13042
|
+
systemError: "systemError";
|
|
13043
|
+
}>;
|
|
13044
|
+
state: z.ZodEnum<{
|
|
13045
|
+
unknown: "unknown";
|
|
13046
|
+
idle: "idle";
|
|
13047
|
+
failed: "failed";
|
|
13048
|
+
running: "running";
|
|
13049
|
+
waiting: "waiting";
|
|
13050
|
+
closed: "closed";
|
|
13051
|
+
}>;
|
|
13052
|
+
ownership: z.ZodEnum<{
|
|
13053
|
+
external: "external";
|
|
13054
|
+
managed: "managed";
|
|
13055
|
+
uncertain: "uncertain";
|
|
13056
|
+
}>;
|
|
13057
|
+
managedId: z.ZodNullable<z.ZodUUID>;
|
|
13058
|
+
historyState: z.ZodEnum<{
|
|
13059
|
+
unavailable: "unavailable";
|
|
13060
|
+
available: "available";
|
|
13061
|
+
}>;
|
|
13062
|
+
}, z.core.$strip>>;
|
|
13063
|
+
isTruncated: z.ZodBoolean;
|
|
13064
|
+
}, z.core.$strip>;
|
|
13065
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
13066
|
+
kind: z.ZodLiteral<"observation-pace">;
|
|
13067
|
+
result: z.ZodObject<{
|
|
13068
|
+
pace: z.ZodEnum<{
|
|
13069
|
+
live: "live";
|
|
13070
|
+
background: "background";
|
|
13071
|
+
}>;
|
|
13072
|
+
}, z.core.$strip>;
|
|
12831
13073
|
}, z.core.$strip>], "kind">;
|
|
12832
13074
|
}, z.core.$strip>, z.ZodObject<{
|
|
12833
13075
|
schemaVersion: z.ZodLiteral<1>;
|
package/dist/contracts/types.js
CHANGED
|
@@ -5,12 +5,12 @@ import { EvidenceRequestSchema, SessionDiscoveryRequestSchema, EvidencePageSchem
|
|
|
5
5
|
import { AccountRequestSchema, AccountObservationSchema, LoginRequestSchema, LoginObservationSchema, } from './accounts/index.js';
|
|
6
6
|
import { McpRequestSchema, McpServerPageSchema, McpToolPageSchema, McpResourcePageSchema, } from './extensions/index.js';
|
|
7
7
|
import { MAX_PROVIDERS, ProviderCapabilitiesSchema, ProviderIdSchema, ProviderStatusSchema, } from './providers/index.js';
|
|
8
|
-
import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, PUBLIC_ERROR_MESSAGES } from './constants.js';
|
|
8
|
+
import { DEFAULT_PAGE_SIZE, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_MESSAGES, } from './constants.js';
|
|
9
9
|
import { SkillIdSchema, SkillPageSchema, SkillPreviewSchema } from './skills/index.js';
|
|
10
10
|
import { NativeIdSchema, CursorSchema, NativeLineageSchema } from './identities/index.js';
|
|
11
11
|
import { ProviderModelPageSchema, ProviderModelsRequestSchema } from './models/index.js';
|
|
12
12
|
import { ConfigurationRequestSchema, SessionConfigurationSchema } from './configuration/index.js';
|
|
13
|
-
import { SessionStateSchema, SessionTransitionPageSchema } from './sessions/index.js';
|
|
13
|
+
import { ObservationPaceSchema, SessionStateSchema, SessionTransitionPageSchema, } from './sessions/index.js';
|
|
14
14
|
import { PlanCommandSchema, PlanResultSchema } from './plans/index.js';
|
|
15
15
|
import { ActionPlanContextSchema, ActionEnvelopeSchema, ActionReceiptSchema, ActionSummarySchema, ManagedThreadSchema, NativeApprovalSchema, LifecycleEventSchema, } from './actions/index.js';
|
|
16
16
|
// pagination is validated before adapters receive a native continuation
|
|
@@ -50,12 +50,18 @@ export const HqRequestSchema = z.discriminatedUnion('kind', [
|
|
|
50
50
|
}),
|
|
51
51
|
z.strictObject({ kind: z.literal('thread'), ...TargetFields }),
|
|
52
52
|
z.strictObject({ kind: z.literal('turns'), ...TargetFields, ...PageFields }),
|
|
53
|
-
|
|
53
|
+
// newest first: a page toward older items, or one item by its native ID within its turn
|
|
54
|
+
z
|
|
55
|
+
.strictObject({
|
|
54
56
|
kind: z.literal('items'),
|
|
55
57
|
...TargetFields,
|
|
56
58
|
turnId: NativeIdSchema.optional(),
|
|
59
|
+
nativeItemId: NativeIdSchema.optional(),
|
|
60
|
+
textLimit: z.number().int().min(1).max(MAX_ITEM_TEXT_LENGTH).default(MAX_ITEM_TEXT_LENGTH),
|
|
57
61
|
...PageFields,
|
|
58
|
-
})
|
|
62
|
+
})
|
|
63
|
+
.refine((command) => command.nativeItemId === undefined ||
|
|
64
|
+
(command.turnId !== undefined && command.cursor === undefined), { message: 'One item is read within its turn, without a cursor', path: ['nativeItemId'] }),
|
|
59
65
|
z.strictObject({ kind: z.literal('usage'), provider: TargetFields.provider }),
|
|
60
66
|
z.strictObject({
|
|
61
67
|
kind: z.literal('skills'),
|
|
@@ -112,6 +118,8 @@ export const HqRequestSchema = z.discriminatedUnion('kind', [
|
|
|
112
118
|
afterSequence: z.number().int().nonnegative().default(0),
|
|
113
119
|
limit: z.number().int().min(1).max(128).default(32),
|
|
114
120
|
}),
|
|
121
|
+
z.strictObject({ kind: z.literal('active-sessions') }),
|
|
122
|
+
z.strictObject({ kind: z.literal('observation-pace'), pace: ObservationPaceSchema }),
|
|
115
123
|
]);
|
|
116
124
|
// native discovery is external/read-only until explicitly adopted for control
|
|
117
125
|
export const ThreadSummarySchema = z.object({
|
|
@@ -128,13 +136,29 @@ export const ThreadSummarySchema = z.object({
|
|
|
128
136
|
managedId: z.uuid().nullable(),
|
|
129
137
|
historyState: z.enum(['available', 'unavailable']),
|
|
130
138
|
});
|
|
139
|
+
// every running and waiting session, newest state change first, with whether more are active
|
|
140
|
+
export const ActiveSessionsSchema = z.object({
|
|
141
|
+
data: z.array(ThreadSummarySchema).max(MAX_PAGE_SIZE),
|
|
142
|
+
isTruncated: z.boolean(),
|
|
143
|
+
});
|
|
131
144
|
export const TurnSummarySchema = z.object({
|
|
132
145
|
nativeId: NativeIdSchema,
|
|
133
146
|
state: z.enum(['completed', 'interrupted', 'failed', 'inProgress', 'unknown']),
|
|
134
147
|
startedAt: z.number().int().nullable(),
|
|
135
148
|
completedAt: z.number().int().nullable(),
|
|
136
149
|
});
|
|
137
|
-
//
|
|
150
|
+
// one file a file change touched, with the lines it added and removed
|
|
151
|
+
export const HistoryFileSchema = z.object({
|
|
152
|
+
path: z.string().min(1).max(4096),
|
|
153
|
+
added: z.number().int().nonnegative(),
|
|
154
|
+
removed: z.number().int().nonnegative(),
|
|
155
|
+
});
|
|
156
|
+
/*
|
|
157
|
+
* Explicit presentation fields; unknown native item kinds are labeled unsupported. `callId` pairs
|
|
158
|
+
* a tool call with its result, `outcome` is what the provider recorded, null when unknown or
|
|
159
|
+
* running, and `files` lists a file change's files; both come from the full record, so cutting
|
|
160
|
+
* the text never changes them.
|
|
161
|
+
*/
|
|
138
162
|
export const HistoryItemSchema = z.object({
|
|
139
163
|
nativeId: NativeIdSchema,
|
|
140
164
|
turnId: NativeIdSchema,
|
|
@@ -143,6 +167,9 @@ export const HistoryItemSchema = z.object({
|
|
|
143
167
|
provenance: HistoryProvenanceSchema,
|
|
144
168
|
text: z.string(),
|
|
145
169
|
isTruncated: z.boolean(),
|
|
170
|
+
callId: z.string().min(1).max(4096).nullable(),
|
|
171
|
+
outcome: z.enum(['succeeded', 'failed']).nullable(),
|
|
172
|
+
files: z.array(HistoryFileSchema).max(MAX_PAGE_SIZE),
|
|
146
173
|
});
|
|
147
174
|
export const LiveItemsSchema = z.object({
|
|
148
175
|
revision: z.number().int().nonnegative(),
|
|
@@ -295,6 +322,11 @@ export const HqResponseSchema = z.discriminatedUnion('kind', [
|
|
|
295
322
|
}),
|
|
296
323
|
z.object({ kind: z.literal('live-items'), result: LiveItemsSchema }),
|
|
297
324
|
z.object({ kind: z.literal('session-states'), result: SessionTransitionPageSchema }),
|
|
325
|
+
z.object({ kind: z.literal('active-sessions'), result: ActiveSessionsSchema }),
|
|
326
|
+
z.object({
|
|
327
|
+
kind: z.literal('observation-pace'),
|
|
328
|
+
result: z.object({ pace: ObservationPaceSchema }),
|
|
329
|
+
}),
|
|
298
330
|
]);
|
|
299
331
|
export const ErrorKindSchema = z.enum(Object.keys(PUBLIC_ERROR_MESSAGES));
|
|
300
332
|
export const IpcRequestSchema = z.strictObject({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ISessionState } from '../../../contracts/index.js';
|
|
1
|
+
import type { IObservationPace, ISessionState } from '../../../contracts/index.js';
|
|
2
2
|
import { type IClaudeAgent } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Maps a native report to the shared session state: an interactive session reports `waiting` on a
|
|
@@ -8,12 +8,16 @@ export declare const toAgentState: (agent: IClaudeAgent) => ISessionState;
|
|
|
8
8
|
/**
|
|
9
9
|
* Polls `claude agents --json` while the runtime runs and records the complete list of active
|
|
10
10
|
* sessions inside the allowed workspaces, so a session missing from a run is closed. A failed,
|
|
11
|
-
* late, oversized or malformed run changes nothing.
|
|
12
|
-
*
|
|
11
|
+
* late, oversized or malformed run changes nothing. Runs follow one another at the `background`
|
|
12
|
+
* pace until `setPace` selects another, which takes effect with an immediate run.
|
|
13
|
+
* @returns A handle that sets the pace, reports each listed session's `cwd` from the latest run,
|
|
14
|
+
* and whose close stops polling and waits for a run in progress.
|
|
13
15
|
*/
|
|
14
16
|
export declare const observeClaudeAgents: (record: (sessions: {
|
|
15
17
|
nativeId: string;
|
|
16
18
|
state: ISessionState;
|
|
17
19
|
}[]) => Promise<void>, allowedRoots: string[]) => {
|
|
20
|
+
setPace(pace: IObservationPace): void;
|
|
21
|
+
workspaceOf(nativeId: string): string | undefined;
|
|
18
22
|
close(): Promise<void>;
|
|
19
23
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
+
import { delay } from 'jg-utilities';
|
|
3
4
|
import { resolveWorkspaceTarget } from '../../../runtime/state/index.js';
|
|
4
|
-
import { AGENTS_DEADLINE_MS, AGENTS_OUTPUT_BYTES,
|
|
5
|
+
import { AGENTS_BACKGROUND_SECONDS, AGENTS_DEADLINE_MS, AGENTS_LIVE_SECONDS, AGENTS_OUTPUT_BYTES, } from './constants.js';
|
|
5
6
|
import { ClaudeAgentsSchema } from './types.js';
|
|
6
7
|
const run = promisify(execFile);
|
|
7
8
|
/**
|
|
@@ -21,14 +22,19 @@ export const toAgentState = (agent) => {
|
|
|
21
22
|
/**
|
|
22
23
|
* Polls `claude agents --json` while the runtime runs and records the complete list of active
|
|
23
24
|
* sessions inside the allowed workspaces, so a session missing from a run is closed. A failed,
|
|
24
|
-
* late, oversized or malformed run changes nothing.
|
|
25
|
-
*
|
|
25
|
+
* late, oversized or malformed run changes nothing. Runs follow one another at the `background`
|
|
26
|
+
* pace until `setPace` selects another, which takes effect with an immediate run.
|
|
27
|
+
* @returns A handle that sets the pace, reports each listed session's `cwd` from the latest run,
|
|
28
|
+
* and whose close stops polling and waits for a run in progress.
|
|
26
29
|
*/
|
|
27
30
|
export const observeClaudeAgents = (record, allowedRoots) => {
|
|
28
31
|
const lifetime = new AbortController();
|
|
29
32
|
// whether each session directory is inside an allowed workspace, checked once per directory
|
|
30
33
|
const allowedDirectories = new Map();
|
|
31
|
-
|
|
34
|
+
// the cwd of each session the latest run listed, which no other source reports
|
|
35
|
+
let workspaces = new Map();
|
|
36
|
+
let pace = 'background';
|
|
37
|
+
let wait = new AbortController();
|
|
32
38
|
const isAllowed = async (directory) => {
|
|
33
39
|
let isInside = allowedDirectories.get(directory);
|
|
34
40
|
if (isInside === undefined) {
|
|
@@ -55,27 +61,35 @@ export const observeClaudeAgents = (record, allowedRoots) => {
|
|
|
55
61
|
return;
|
|
56
62
|
}
|
|
57
63
|
const sessions = [];
|
|
64
|
+
const listed = new Map();
|
|
58
65
|
for (const agent of agents)
|
|
59
|
-
if (await isAllowed(agent.cwd))
|
|
66
|
+
if (await isAllowed(agent.cwd)) {
|
|
60
67
|
sessions.push({ nativeId: agent.sessionId, state: toAgentState(agent) });
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const start = () => {
|
|
65
|
-
if (running || lifetime.signal.aborted)
|
|
68
|
+
listed.set(agent.sessionId, agent.cwd);
|
|
69
|
+
}
|
|
70
|
+
if (lifetime.signal.aborted)
|
|
66
71
|
return;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.finally(() => {
|
|
70
|
-
running = undefined;
|
|
71
|
-
});
|
|
72
|
+
workspaces = listed;
|
|
73
|
+
await record(sessions);
|
|
72
74
|
};
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const running = (async () => {
|
|
76
|
+
while (!lifetime.signal.aborted) {
|
|
77
|
+
await poll().catch(() => undefined);
|
|
78
|
+
wait = new AbortController();
|
|
79
|
+
await delay(pace === 'live' ? AGENTS_LIVE_SECONDS : AGENTS_BACKGROUND_SECONDS, {
|
|
80
|
+
signal: AbortSignal.any([lifetime.signal, wait.signal]),
|
|
81
|
+
}).catch(() => undefined);
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
76
84
|
return {
|
|
85
|
+
setPace(next) {
|
|
86
|
+
if (next === pace)
|
|
87
|
+
return;
|
|
88
|
+
pace = next;
|
|
89
|
+
wait.abort();
|
|
90
|
+
},
|
|
91
|
+
workspaceOf: (nativeId) => workspaces.get(nativeId),
|
|
77
92
|
async close() {
|
|
78
|
-
clearInterval(timer);
|
|
79
93
|
lifetime.abort();
|
|
80
94
|
await running;
|
|
81
95
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// claude agents --json runs
|
|
2
|
-
export const
|
|
1
|
+
// claude agents --json runs at the live or background pace, each run bounded in time and output
|
|
2
|
+
export const AGENTS_LIVE_SECONDS = 5;
|
|
3
|
+
export const AGENTS_BACKGROUND_SECONDS = 30;
|
|
3
4
|
export const AGENTS_DEADLINE_MS = 10_000;
|
|
4
5
|
export const AGENTS_OUTPUT_BYTES = 65_536;
|