agent-office-cli 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-office-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Run and manage AI agent sessions locally, with optional relay to agentoffice.top",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,6 +1,31 @@
1
1
  const { GenericProvider } = require("./generic");
2
2
  const { findManagedCodexSessionFile, summarizeCodexSession } = require("./codex-transcript");
3
3
 
4
+ const APPROVAL_PATTERNS = [
5
+ "approval requested:",
6
+ "approval requested by ",
7
+ "tool call needs your approval",
8
+ "requires approval by policy",
9
+ "requires approval:"
10
+ ];
11
+
12
+ const IDLE_PATTERNS = [
13
+ "conversation interrupted - tell the model what to do differently",
14
+ "something went wrong? hit `/feedback` to",
15
+ "something went wrong? hit /feedback to"
16
+ ];
17
+
18
+ const ATTENTION_PATTERNS = [
19
+ "stream disconnected before completion",
20
+ "error sending request for url",
21
+ "network error",
22
+ "connection timeout",
23
+ "timed out",
24
+ "failed to send request",
25
+ "failed to submit",
26
+ "panic"
27
+ ];
28
+
4
29
  function activeOverlayPatch(session, nextLifecycleState) {
5
30
  if (!session || !["approval", "attention"].includes(session.displayState)) {
6
31
  return null;
@@ -48,19 +73,19 @@ class CodexProvider extends GenericProvider {
48
73
 
49
74
  classifyOutput(chunk) {
50
75
  const text = String(chunk).toLowerCase();
51
- if (text.includes("approval") || text.includes("press enter") || text.includes("confirm")) {
76
+
77
+ if (IDLE_PATTERNS.some((pattern) => text.includes(pattern))) {
78
+ return "idle";
79
+ }
80
+
81
+ if (APPROVAL_PATTERNS.some((pattern) => text.includes(pattern))) {
52
82
  return "approval";
53
83
  }
54
- if (
55
- text.includes("network error") ||
56
- text.includes("connection timeout") ||
57
- text.includes("timed out") ||
58
- text.includes("error") ||
59
- text.includes("failed") ||
60
- text.includes("panic")
61
- ) {
84
+
85
+ if (ATTENTION_PATTERNS.some((pattern) => text.includes(pattern))) {
62
86
  return "attention";
63
87
  }
88
+
64
89
  return null;
65
90
  }
66
91
 
@@ -72,3 +72,39 @@ test("classifyOutput can raise attention for transcript-backed sessions", () =>
72
72
 
73
73
  assert.equal(nextState, "attention");
74
74
  });
75
+
76
+ test("classifyOutput treats user interrupted Codex screens as idle", () => {
77
+ const provider = new CodexProvider();
78
+ const nextState = provider.classifyOutput(
79
+ "Conversation interrupted - tell the model what to do differently. Something went wrong? Hit `/feedback` to report the issue."
80
+ );
81
+
82
+ assert.equal(nextState, "idle");
83
+ });
84
+
85
+ test("classifyOutput treats stream disconnects as attention", () => {
86
+ const provider = new CodexProvider();
87
+ const nextState = provider.classifyOutput(
88
+ "stream disconnected before completion: error sending request for url (http://54.255.64.152:3000/openai/responses)"
89
+ );
90
+
91
+ assert.equal(nextState, "attention");
92
+ });
93
+
94
+ test("classifyOutput does not treat plain explanatory approval text as a real approval prompt", () => {
95
+ const provider = new CodexProvider();
96
+ const nextState = provider.classifyOutput(
97
+ "只有真实审批提示才归到 approval"
98
+ );
99
+
100
+ assert.equal(nextState, null);
101
+ });
102
+
103
+ test("classifyOutput recognizes real Codex approval prompts", () => {
104
+ const provider = new CodexProvider();
105
+ const nextState = provider.classifyOutput(
106
+ "Approval requested: Codex wants to edit files"
107
+ );
108
+
109
+ assert.equal(nextState, "approval");
110
+ });