@kenhkl/agent-gate 0.9.4 → 0.9.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.md +7 -2
- package/dist/v1/cli.js +23 -9
- package/dist/v1/server.js +23 -9
- package/dist/v3/cli.js +53 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -286,14 +286,19 @@ npm run build
|
|
|
286
286
|
| `session_id` | string | 是 | — | Session 标识 |
|
|
287
287
|
| `tool_name` | string | 否 | — | 工具名称(如 `bash`, `file_write`) |
|
|
288
288
|
| `command` | string | 否 | — | 工具命令或描述 |
|
|
289
|
-
| `a_next` | object | 否 | — | `{action_type, action_detail}`,Python API 兼容格式 |
|
|
289
|
+
| `a_next` | object | 否 | — | `{action_type, action_detail, called_at?}`,Python API 兼容格式 |
|
|
290
290
|
| `cwd` | string | 否 | `""` | 当前工作目录 |
|
|
291
291
|
| `description` | string | 否 | `""` | 描述 |
|
|
292
292
|
| `user_prompt` | string | 否 | `""` | 用户 prompt |
|
|
293
|
-
| `action_history` | array | 否 | `[]` | 历史动作(同 session
|
|
293
|
+
| `action_history` | array | 否 | `[]` | 历史动作(同 session 自动累积),元素形如 `{action_type, action_detail, output?, called_at?}` |
|
|
294
294
|
| `metadata` | object | 否 | — | 附加元数据 |
|
|
295
295
|
|
|
296
296
|
> `tool_name`/`command` 和 `a_next.action_type`/`a_next.action_detail` 两种格式均支持,前者优先。
|
|
297
|
+
>
|
|
298
|
+
> **`called_at`(ISO 8601,可选)**:动作发生时刻。用于两类时间判定:
|
|
299
|
+
> AgentMoss 的 L2 授权时效窗(`ask_user_question` 后多久内执行改密/删用户才算已授权,默认 300s)
|
|
300
|
+
> 与 P4「提权→外传」窗口。缺省时这两项退回「不校验时间」的旧行为;
|
|
301
|
+
> `a_next.called_at` 未上报时由 AgentGate 用当前时刻补齐。
|
|
297
302
|
|
|
298
303
|
### 响应格式
|
|
299
304
|
|
package/dist/v1/cli.js
CHANGED
|
@@ -1767,7 +1767,7 @@ var init_version = __esm({
|
|
|
1767
1767
|
"src/version.ts"() {
|
|
1768
1768
|
"use strict";
|
|
1769
1769
|
init_cjs_shims();
|
|
1770
|
-
_version = true ? "0.9.
|
|
1770
|
+
_version = true ? "0.9.6" : (() => {
|
|
1771
1771
|
try {
|
|
1772
1772
|
const require2 = createRequire(importMetaUrl);
|
|
1773
1773
|
const pkg = require2("../package.json");
|
|
@@ -1798,7 +1798,9 @@ var init_models = __esm({
|
|
|
1798
1798
|
command: import_zod.z.string().optional().describe("Tool command or description"),
|
|
1799
1799
|
a_next: import_zod.z.object({
|
|
1800
1800
|
action_type: import_zod.z.string(),
|
|
1801
|
-
action_detail: import_zod.z.string()
|
|
1801
|
+
action_detail: import_zod.z.string(),
|
|
1802
|
+
/** 当前动作发生时刻(ISO 8601),供 AgentMoss L2 授权规则算时效窗。 */
|
|
1803
|
+
called_at: import_zod.z.string().optional()
|
|
1802
1804
|
}).optional().describe("Next action (Python API format)"),
|
|
1803
1805
|
cwd: import_zod.z.string().default(""),
|
|
1804
1806
|
description: import_zod.z.string().default(""),
|
|
@@ -1808,7 +1810,8 @@ var init_models = __esm({
|
|
|
1808
1810
|
actions: import_zod.z.array(import_zod.z.object({
|
|
1809
1811
|
action_type: import_zod.z.string(),
|
|
1810
1812
|
action_detail: import_zod.z.string(),
|
|
1811
|
-
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743")
|
|
1813
|
+
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743"),
|
|
1814
|
+
called_at: import_zod.z.string().optional()
|
|
1812
1815
|
})).default([])
|
|
1813
1816
|
})).default([]),
|
|
1814
1817
|
action_history: import_zod.z.array(import_zod.z.object({
|
|
@@ -1816,14 +1819,17 @@ var init_models = __esm({
|
|
|
1816
1819
|
action_detail: import_zod.z.string(),
|
|
1817
1820
|
// 授权类规则(改密码 / 删用户)靠 ask_user_question 的 output 判断用户是否已确认。
|
|
1818
1821
|
// 此前 schema 里没有这个字段,Agent 传了也会被剥掉 → 必然判成「未授权」。
|
|
1819
|
-
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743")
|
|
1822
|
+
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743"),
|
|
1823
|
+
/** 动作发生时刻(ISO 8601):与 a_next.called_at 相减得授权时效窗是否超时。 */
|
|
1824
|
+
called_at: import_zod.z.string().optional()
|
|
1820
1825
|
})).default([]),
|
|
1821
1826
|
session_history: import_zod.z.array(import_zod.z.object({
|
|
1822
1827
|
session_id: import_zod.z.string(),
|
|
1823
1828
|
action_history: import_zod.z.array(import_zod.z.object({
|
|
1824
1829
|
action_type: import_zod.z.string(),
|
|
1825
1830
|
action_detail: import_zod.z.string(),
|
|
1826
|
-
output: import_zod.z.string().optional()
|
|
1831
|
+
output: import_zod.z.string().optional(),
|
|
1832
|
+
called_at: import_zod.z.string().optional()
|
|
1827
1833
|
})).default([])
|
|
1828
1834
|
})).default([]).describe("\u591A session \u5386\u53F2\u52A8\u4F5C\uFF08\u53EF\u9009\uFF09\uFF1A\u4F9B AgentMoss L2.4 \u5F62\u5F0F\u5316\u5F15\u64CE\u8DE8\u4F1A\u8BDD\u9A8C\u8BC1"),
|
|
1829
1835
|
metadata: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
@@ -1871,14 +1877,18 @@ function normalize(input, systemContext) {
|
|
|
1871
1877
|
const actionHistory = input.action_history.map((h) => ({
|
|
1872
1878
|
action_type: h.action_type,
|
|
1873
1879
|
action_detail: h.action_detail,
|
|
1874
|
-
output: h.output ?? ""
|
|
1880
|
+
output: h.output ?? "",
|
|
1881
|
+
// called_at 缺失时保持 undefined(不现造时间):伪造时刻会让 AgentMoss 的
|
|
1882
|
+
// 授权时效窗做出错误判断,缺失则退回「不校验时效窗」的旧行为。
|
|
1883
|
+
...h.called_at ? { called_at: h.called_at } : {}
|
|
1875
1884
|
}));
|
|
1876
1885
|
const sessionHistory = (input.session_history || []).map((s) => ({
|
|
1877
1886
|
session_id: s.session_id,
|
|
1878
1887
|
action_history: s.action_history.map((h) => ({
|
|
1879
1888
|
action_type: h.action_type,
|
|
1880
1889
|
action_detail: h.action_detail,
|
|
1881
|
-
output: h.output ?? ""
|
|
1890
|
+
output: h.output ?? "",
|
|
1891
|
+
...h.called_at ? { called_at: h.called_at } : {}
|
|
1882
1892
|
}))
|
|
1883
1893
|
}));
|
|
1884
1894
|
const promptHistory = input.prompt_history.map((t) => ({
|
|
@@ -1886,7 +1896,8 @@ function normalize(input, systemContext) {
|
|
|
1886
1896
|
actions: t.actions.map((a) => ({
|
|
1887
1897
|
action_type: a.action_type,
|
|
1888
1898
|
action_detail: a.action_detail,
|
|
1889
|
-
output: a.output ?? ""
|
|
1899
|
+
output: a.output ?? "",
|
|
1900
|
+
...a.called_at ? { called_at: a.called_at } : {}
|
|
1890
1901
|
}))
|
|
1891
1902
|
}));
|
|
1892
1903
|
const toolName = input.tool_name || input.a_next?.action_type || "unknown";
|
|
@@ -1899,7 +1910,10 @@ function normalize(input, systemContext) {
|
|
|
1899
1910
|
session_history: sessionHistory,
|
|
1900
1911
|
a_next: {
|
|
1901
1912
|
action_type: toolName,
|
|
1902
|
-
action_detail: command
|
|
1913
|
+
action_detail: command,
|
|
1914
|
+
// 当前动作就是此刻发生的:调用方没给就用当前时间,供 AgentMoss 把
|
|
1915
|
+
// 「用户先前确认」与「现在要执行」做时效窗比较。
|
|
1916
|
+
called_at: input.a_next?.called_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
1903
1917
|
},
|
|
1904
1918
|
reason: input.description || "",
|
|
1905
1919
|
os_type: "",
|
package/dist/v1/server.js
CHANGED
|
@@ -1643,7 +1643,7 @@ var import_zod = require("zod");
|
|
|
1643
1643
|
|
|
1644
1644
|
// src/version.ts
|
|
1645
1645
|
init_cjs_shims();
|
|
1646
|
-
var _version = true ? "0.9.
|
|
1646
|
+
var _version = true ? "0.9.6" : (() => {
|
|
1647
1647
|
try {
|
|
1648
1648
|
const require2 = createRequire(importMetaUrl);
|
|
1649
1649
|
const pkg = require2("../package.json");
|
|
@@ -1665,7 +1665,9 @@ var AgentGateInputSchema = import_zod.z.object({
|
|
|
1665
1665
|
command: import_zod.z.string().optional().describe("Tool command or description"),
|
|
1666
1666
|
a_next: import_zod.z.object({
|
|
1667
1667
|
action_type: import_zod.z.string(),
|
|
1668
|
-
action_detail: import_zod.z.string()
|
|
1668
|
+
action_detail: import_zod.z.string(),
|
|
1669
|
+
/** 当前动作发生时刻(ISO 8601),供 AgentMoss L2 授权规则算时效窗。 */
|
|
1670
|
+
called_at: import_zod.z.string().optional()
|
|
1669
1671
|
}).optional().describe("Next action (Python API format)"),
|
|
1670
1672
|
cwd: import_zod.z.string().default(""),
|
|
1671
1673
|
description: import_zod.z.string().default(""),
|
|
@@ -1675,7 +1677,8 @@ var AgentGateInputSchema = import_zod.z.object({
|
|
|
1675
1677
|
actions: import_zod.z.array(import_zod.z.object({
|
|
1676
1678
|
action_type: import_zod.z.string(),
|
|
1677
1679
|
action_detail: import_zod.z.string(),
|
|
1678
|
-
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743")
|
|
1680
|
+
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743"),
|
|
1681
|
+
called_at: import_zod.z.string().optional()
|
|
1679
1682
|
})).default([])
|
|
1680
1683
|
})).default([]),
|
|
1681
1684
|
action_history: import_zod.z.array(import_zod.z.object({
|
|
@@ -1683,14 +1686,17 @@ var AgentGateInputSchema = import_zod.z.object({
|
|
|
1683
1686
|
action_detail: import_zod.z.string(),
|
|
1684
1687
|
// 授权类规则(改密码 / 删用户)靠 ask_user_question 的 output 判断用户是否已确认。
|
|
1685
1688
|
// 此前 schema 里没有这个字段,Agent 传了也会被剥掉 → 必然判成「未授权」。
|
|
1686
|
-
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743")
|
|
1689
|
+
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743"),
|
|
1690
|
+
/** 动作发生时刻(ISO 8601):与 a_next.called_at 相减得授权时效窗是否超时。 */
|
|
1691
|
+
called_at: import_zod.z.string().optional()
|
|
1687
1692
|
})).default([]),
|
|
1688
1693
|
session_history: import_zod.z.array(import_zod.z.object({
|
|
1689
1694
|
session_id: import_zod.z.string(),
|
|
1690
1695
|
action_history: import_zod.z.array(import_zod.z.object({
|
|
1691
1696
|
action_type: import_zod.z.string(),
|
|
1692
1697
|
action_detail: import_zod.z.string(),
|
|
1693
|
-
output: import_zod.z.string().optional()
|
|
1698
|
+
output: import_zod.z.string().optional(),
|
|
1699
|
+
called_at: import_zod.z.string().optional()
|
|
1694
1700
|
})).default([])
|
|
1695
1701
|
})).default([]).describe("\u591A session \u5386\u53F2\u52A8\u4F5C\uFF08\u53EF\u9009\uFF09\uFF1A\u4F9B AgentMoss L2.4 \u5F62\u5F0F\u5316\u5F15\u64CE\u8DE8\u4F1A\u8BDD\u9A8C\u8BC1"),
|
|
1696
1702
|
metadata: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
@@ -1739,14 +1745,18 @@ function normalize(input, systemContext) {
|
|
|
1739
1745
|
const actionHistory = input.action_history.map((h) => ({
|
|
1740
1746
|
action_type: h.action_type,
|
|
1741
1747
|
action_detail: h.action_detail,
|
|
1742
|
-
output: h.output ?? ""
|
|
1748
|
+
output: h.output ?? "",
|
|
1749
|
+
// called_at 缺失时保持 undefined(不现造时间):伪造时刻会让 AgentMoss 的
|
|
1750
|
+
// 授权时效窗做出错误判断,缺失则退回「不校验时效窗」的旧行为。
|
|
1751
|
+
...h.called_at ? { called_at: h.called_at } : {}
|
|
1743
1752
|
}));
|
|
1744
1753
|
const sessionHistory = (input.session_history || []).map((s) => ({
|
|
1745
1754
|
session_id: s.session_id,
|
|
1746
1755
|
action_history: s.action_history.map((h) => ({
|
|
1747
1756
|
action_type: h.action_type,
|
|
1748
1757
|
action_detail: h.action_detail,
|
|
1749
|
-
output: h.output ?? ""
|
|
1758
|
+
output: h.output ?? "",
|
|
1759
|
+
...h.called_at ? { called_at: h.called_at } : {}
|
|
1750
1760
|
}))
|
|
1751
1761
|
}));
|
|
1752
1762
|
const promptHistory = input.prompt_history.map((t) => ({
|
|
@@ -1754,7 +1764,8 @@ function normalize(input, systemContext) {
|
|
|
1754
1764
|
actions: t.actions.map((a) => ({
|
|
1755
1765
|
action_type: a.action_type,
|
|
1756
1766
|
action_detail: a.action_detail,
|
|
1757
|
-
output: a.output ?? ""
|
|
1767
|
+
output: a.output ?? "",
|
|
1768
|
+
...a.called_at ? { called_at: a.called_at } : {}
|
|
1758
1769
|
}))
|
|
1759
1770
|
}));
|
|
1760
1771
|
const toolName = input.tool_name || input.a_next?.action_type || "unknown";
|
|
@@ -1767,7 +1778,10 @@ function normalize(input, systemContext) {
|
|
|
1767
1778
|
session_history: sessionHistory,
|
|
1768
1779
|
a_next: {
|
|
1769
1780
|
action_type: toolName,
|
|
1770
|
-
action_detail: command
|
|
1781
|
+
action_detail: command,
|
|
1782
|
+
// 当前动作就是此刻发生的:调用方没给就用当前时间,供 AgentMoss 把
|
|
1783
|
+
// 「用户先前确认」与「现在要执行」做时效窗比较。
|
|
1784
|
+
called_at: input.a_next?.called_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
1771
1785
|
},
|
|
1772
1786
|
reason: input.description || "",
|
|
1773
1787
|
os_type: "",
|
package/dist/v3/cli.js
CHANGED
|
@@ -50,7 +50,7 @@ var init_version = __esm({
|
|
|
50
50
|
"src/version.ts"() {
|
|
51
51
|
"use strict";
|
|
52
52
|
init_cjs_shims();
|
|
53
|
-
_version = true ? "0.9.
|
|
53
|
+
_version = true ? "0.9.6" : (() => {
|
|
54
54
|
try {
|
|
55
55
|
const require2 = createRequire(importMetaUrl);
|
|
56
56
|
const pkg = require2("../package.json");
|
|
@@ -1801,7 +1801,9 @@ var init_models = __esm({
|
|
|
1801
1801
|
command: import_zod.z.string().optional().describe("Tool command or description"),
|
|
1802
1802
|
a_next: import_zod.z.object({
|
|
1803
1803
|
action_type: import_zod.z.string(),
|
|
1804
|
-
action_detail: import_zod.z.string()
|
|
1804
|
+
action_detail: import_zod.z.string(),
|
|
1805
|
+
/** 当前动作发生时刻(ISO 8601),供 AgentMoss L2 授权规则算时效窗。 */
|
|
1806
|
+
called_at: import_zod.z.string().optional()
|
|
1805
1807
|
}).optional().describe("Next action (Python API format)"),
|
|
1806
1808
|
cwd: import_zod.z.string().default(""),
|
|
1807
1809
|
description: import_zod.z.string().default(""),
|
|
@@ -1811,7 +1813,8 @@ var init_models = __esm({
|
|
|
1811
1813
|
actions: import_zod.z.array(import_zod.z.object({
|
|
1812
1814
|
action_type: import_zod.z.string(),
|
|
1813
1815
|
action_detail: import_zod.z.string(),
|
|
1814
|
-
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743")
|
|
1816
|
+
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743"),
|
|
1817
|
+
called_at: import_zod.z.string().optional()
|
|
1815
1818
|
})).default([])
|
|
1816
1819
|
})).default([]),
|
|
1817
1820
|
action_history: import_zod.z.array(import_zod.z.object({
|
|
@@ -1819,14 +1822,17 @@ var init_models = __esm({
|
|
|
1819
1822
|
action_detail: import_zod.z.string(),
|
|
1820
1823
|
// 授权类规则(改密码 / 删用户)靠 ask_user_question 的 output 判断用户是否已确认。
|
|
1821
1824
|
// 此前 schema 里没有这个字段,Agent 传了也会被剥掉 → 必然判成「未授权」。
|
|
1822
|
-
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743")
|
|
1825
|
+
output: import_zod.z.string().optional().describe("\u5DE5\u5177\u8FD4\u56DE\u5185\u5BB9\uFF1Bask_user_question \u7684\u7528\u6237\u56DE\u7B54\u9760\u5B83\u4F20\u7ED9 AgentMoss \u5224\u6388\u6743"),
|
|
1826
|
+
/** 动作发生时刻(ISO 8601):与 a_next.called_at 相减得授权时效窗是否超时。 */
|
|
1827
|
+
called_at: import_zod.z.string().optional()
|
|
1823
1828
|
})).default([]),
|
|
1824
1829
|
session_history: import_zod.z.array(import_zod.z.object({
|
|
1825
1830
|
session_id: import_zod.z.string(),
|
|
1826
1831
|
action_history: import_zod.z.array(import_zod.z.object({
|
|
1827
1832
|
action_type: import_zod.z.string(),
|
|
1828
1833
|
action_detail: import_zod.z.string(),
|
|
1829
|
-
output: import_zod.z.string().optional()
|
|
1834
|
+
output: import_zod.z.string().optional(),
|
|
1835
|
+
called_at: import_zod.z.string().optional()
|
|
1830
1836
|
})).default([])
|
|
1831
1837
|
})).default([]).describe("\u591A session \u5386\u53F2\u52A8\u4F5C\uFF08\u53EF\u9009\uFF09\uFF1A\u4F9B AgentMoss L2.4 \u5F62\u5F0F\u5316\u5F15\u64CE\u8DE8\u4F1A\u8BDD\u9A8C\u8BC1"),
|
|
1832
1838
|
metadata: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
@@ -1874,14 +1880,18 @@ function normalize(input, systemContext) {
|
|
|
1874
1880
|
const actionHistory = input.action_history.map((h) => ({
|
|
1875
1881
|
action_type: h.action_type,
|
|
1876
1882
|
action_detail: h.action_detail,
|
|
1877
|
-
output: h.output ?? ""
|
|
1883
|
+
output: h.output ?? "",
|
|
1884
|
+
// called_at 缺失时保持 undefined(不现造时间):伪造时刻会让 AgentMoss 的
|
|
1885
|
+
// 授权时效窗做出错误判断,缺失则退回「不校验时效窗」的旧行为。
|
|
1886
|
+
...h.called_at ? { called_at: h.called_at } : {}
|
|
1878
1887
|
}));
|
|
1879
1888
|
const sessionHistory = (input.session_history || []).map((s) => ({
|
|
1880
1889
|
session_id: s.session_id,
|
|
1881
1890
|
action_history: s.action_history.map((h) => ({
|
|
1882
1891
|
action_type: h.action_type,
|
|
1883
1892
|
action_detail: h.action_detail,
|
|
1884
|
-
output: h.output ?? ""
|
|
1893
|
+
output: h.output ?? "",
|
|
1894
|
+
...h.called_at ? { called_at: h.called_at } : {}
|
|
1885
1895
|
}))
|
|
1886
1896
|
}));
|
|
1887
1897
|
const promptHistory = input.prompt_history.map((t) => ({
|
|
@@ -1889,7 +1899,8 @@ function normalize(input, systemContext) {
|
|
|
1889
1899
|
actions: t.actions.map((a) => ({
|
|
1890
1900
|
action_type: a.action_type,
|
|
1891
1901
|
action_detail: a.action_detail,
|
|
1892
|
-
output: a.output ?? ""
|
|
1902
|
+
output: a.output ?? "",
|
|
1903
|
+
...a.called_at ? { called_at: a.called_at } : {}
|
|
1893
1904
|
}))
|
|
1894
1905
|
}));
|
|
1895
1906
|
const toolName = input.tool_name || input.a_next?.action_type || "unknown";
|
|
@@ -1902,7 +1913,10 @@ function normalize(input, systemContext) {
|
|
|
1902
1913
|
session_history: sessionHistory,
|
|
1903
1914
|
a_next: {
|
|
1904
1915
|
action_type: toolName,
|
|
1905
|
-
action_detail: command
|
|
1916
|
+
action_detail: command,
|
|
1917
|
+
// 当前动作就是此刻发生的:调用方没给就用当前时间,供 AgentMoss 把
|
|
1918
|
+
// 「用户先前确认」与「现在要执行」做时效窗比较。
|
|
1919
|
+
called_at: input.a_next?.called_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
1906
1920
|
},
|
|
1907
1921
|
reason: input.description || "",
|
|
1908
1922
|
os_type: "",
|
|
@@ -29614,6 +29628,15 @@ var coordinator_exports = {};
|
|
|
29614
29628
|
__export(coordinator_exports, {
|
|
29615
29629
|
PhaseCoordinator: () => PhaseCoordinator
|
|
29616
29630
|
});
|
|
29631
|
+
function eventIso(evt) {
|
|
29632
|
+
const t = evt?.timestamp;
|
|
29633
|
+
if (typeof t === "string") return t;
|
|
29634
|
+
if (t && typeof t === "object") {
|
|
29635
|
+
const iso = t.iso;
|
|
29636
|
+
if (typeof iso === "string") return iso;
|
|
29637
|
+
}
|
|
29638
|
+
return "";
|
|
29639
|
+
}
|
|
29617
29640
|
var PhaseCoordinator;
|
|
29618
29641
|
var init_coordinator = __esm({
|
|
29619
29642
|
"src/v3/coordinator.ts"() {
|
|
@@ -30043,7 +30066,7 @@ var init_coordinator = __esm({
|
|
|
30043
30066
|
const command = String(target?.command ?? "");
|
|
30044
30067
|
const argsRaw = String(action?.argumentsRaw ?? "");
|
|
30045
30068
|
const detail = command || (typeof argsRaw === "string" ? argsRaw.slice(0, 200) : "");
|
|
30046
|
-
actionHistory.push({ action_type: toolName, action_detail: detail });
|
|
30069
|
+
actionHistory.push({ action_type: toolName, action_detail: detail, called_at: eventIso(evt) });
|
|
30047
30070
|
}
|
|
30048
30071
|
}
|
|
30049
30072
|
const promptHistory = [];
|
|
@@ -30083,7 +30106,13 @@ var init_coordinator = __esm({
|
|
|
30083
30106
|
payload_sequences: [],
|
|
30084
30107
|
action_history: actionHistory,
|
|
30085
30108
|
session_history: this._buildSessionHistory(session?.id || sessionId),
|
|
30086
|
-
a_next: {
|
|
30109
|
+
a_next: {
|
|
30110
|
+
action_type: nextActionType,
|
|
30111
|
+
action_detail: nextActionDetail,
|
|
30112
|
+
// 当前动作时刻:与历史里 ask_user_question 的 called_at 相减,
|
|
30113
|
+
// 判断用户确认是否还在时效窗内(AgentMoss CONSENT_TTL_SECONDS)。
|
|
30114
|
+
called_at: eventIso(event)
|
|
30115
|
+
},
|
|
30087
30116
|
reason: match0?.detail ?? "",
|
|
30088
30117
|
os_type: "",
|
|
30089
30118
|
cwd: "",
|
|
@@ -30132,8 +30161,9 @@ var init_coordinator = __esm({
|
|
|
30132
30161
|
} catch {
|
|
30133
30162
|
}
|
|
30134
30163
|
}
|
|
30164
|
+
const actionCalledAt = action.l2CapturedAt ? new Date(action.l2CapturedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
|
|
30135
30165
|
const actionHistory = [
|
|
30136
|
-
{ action_type: action.toolName, action_detail: action.l2Command.slice(0, 200) }
|
|
30166
|
+
{ action_type: action.toolName, action_detail: action.l2Command.slice(0, 200), called_at: actionCalledAt }
|
|
30137
30167
|
];
|
|
30138
30168
|
const promptHistory = [];
|
|
30139
30169
|
let currentPromptText = "";
|
|
@@ -30164,7 +30194,9 @@ var init_coordinator = __esm({
|
|
|
30164
30194
|
session_history: this._buildSessionHistory(session?.id || sessionId),
|
|
30165
30195
|
a_next: {
|
|
30166
30196
|
action_type: action.toolName || "unknown",
|
|
30167
|
-
action_detail: String(action.l2Command ?? "").slice(0, 2e3)
|
|
30197
|
+
action_detail: String(action.l2Command ?? "").slice(0, 2e3),
|
|
30198
|
+
// 与 action_history 里的 ask_user_question 时刻比较,判定授权是否超时。
|
|
30199
|
+
called_at: actionCalledAt
|
|
30168
30200
|
},
|
|
30169
30201
|
reason: "",
|
|
30170
30202
|
os_type: "",
|
|
@@ -30196,7 +30228,8 @@ var init_coordinator = __esm({
|
|
|
30196
30228
|
const t = evt.target;
|
|
30197
30229
|
actionHistory.push({
|
|
30198
30230
|
action_type: String(a?.toolName ?? "unknown"),
|
|
30199
|
-
action_detail: String(t?.command ?? "")
|
|
30231
|
+
action_detail: String(t?.command ?? ""),
|
|
30232
|
+
called_at: eventIso(evt)
|
|
30200
30233
|
});
|
|
30201
30234
|
}
|
|
30202
30235
|
}
|
|
@@ -30229,7 +30262,12 @@ var init_coordinator = __esm({
|
|
|
30229
30262
|
payload_sequences: [],
|
|
30230
30263
|
action_history: actionHistory,
|
|
30231
30264
|
session_history: this._buildSessionHistory(session?.id || sessionId),
|
|
30232
|
-
a_next: {
|
|
30265
|
+
a_next: {
|
|
30266
|
+
action_type: l3ActionType,
|
|
30267
|
+
action_detail: l3ActionDetail,
|
|
30268
|
+
// 与历史里 ask_user_question 的 called_at 相减判授权时效窗。
|
|
30269
|
+
called_at: eventIso(event)
|
|
30270
|
+
},
|
|
30233
30271
|
reason: "",
|
|
30234
30272
|
os_type: "",
|
|
30235
30273
|
cwd: "",
|