agentlink-cli 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (84) hide show
  1. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/PKG-INFO +1 -1
  2. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/capabilities.py +20 -0
  3. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/codex/adapter.py +54 -1
  4. agentlink_cli-0.1.1/connector/codex/collaboration.py +67 -0
  5. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/codex/reducer.py +46 -0
  6. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/runtime.py +2 -0
  7. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/pyproject.toml +1 -1
  8. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_codex_adapter.py +95 -0
  9. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/uv.lock +1 -1
  10. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/.gitignore +0 -0
  11. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/README.md +0 -0
  12. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/__init__.py +0 -0
  13. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/__init__.py +0 -0
  14. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/adapter.py +0 -0
  15. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/config_options.py +0 -0
  16. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/discovery.py +0 -0
  17. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/manifest.py +0 -0
  18. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/manifests/__init__.py +0 -0
  19. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/manifests/codebuddy.json +0 -0
  20. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/manifests/cursor.json +0 -0
  21. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/manifests/gemini.json +0 -0
  22. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/manifests/grok_build.json +0 -0
  23. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/reducer.py +0 -0
  24. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/acp/rpc.py +0 -0
  25. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/adapter.py +0 -0
  26. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/attachments.py +0 -0
  27. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/__init__.py +0 -0
  28. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/history_adapter.py +0 -0
  29. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/normalized.py +0 -0
  30. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/normalizers.py +0 -0
  31. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/path_utils.py +0 -0
  32. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/preferences.py +0 -0
  33. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/sdk_adapter.py +0 -0
  34. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/timeline_identity.py +0 -0
  35. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/timeline_reducer.py +0 -0
  36. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/claude/trust.py +0 -0
  37. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/cli.py +0 -0
  38. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/codex/__init__.py +0 -0
  39. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/codex/history.py +0 -0
  40. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/codex/rpc.py +0 -0
  41. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/control.py +0 -0
  42. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/json_rpc.py +0 -0
  43. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/launch.py +0 -0
  44. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local/__init__.py +0 -0
  45. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local/common.py +0 -0
  46. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local/file_ops.py +0 -0
  47. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local/ops.py +0 -0
  48. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local/shell.py +0 -0
  49. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local/terminal.py +0 -0
  50. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local_ops.py +0 -0
  51. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/local_runtime.py +0 -0
  52. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/logging.py +0 -0
  53. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/perf.py +0 -0
  54. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/protocol.py +0 -0
  55. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/registry.py +0 -0
  56. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/sync_state.py +0 -0
  57. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/time.py +0 -0
  58. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/connector/version.py +0 -0
  59. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/run.sh +0 -0
  60. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/__init__.py +0 -0
  61. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/acp/__init__.py +0 -0
  62. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/acp/fake_agent/__init__.py +0 -0
  63. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/acp/fake_agent/__main__.py +0 -0
  64. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/acp/test_acp_adapter_fake.py +0 -0
  65. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/acp/test_acp_reducer_golden.py +0 -0
  66. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/acp/test_config_options.py +0 -0
  67. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/contract/__init__.py +0 -0
  68. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/contract/helpers.py +0 -0
  69. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_claude_history_adapter.py +0 -0
  70. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_claude_preferences.py +0 -0
  71. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_claude_sdk_adapter.py +0 -0
  72. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_claude_timeline_parity.py +0 -0
  73. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_claude_trust.py +0 -0
  74. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_connector_capabilities.py +0 -0
  75. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_connector_cli.py +0 -0
  76. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_connector_control.py +0 -0
  77. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_connector_json_rpc.py +0 -0
  78. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_connector_logging.py +0 -0
  79. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_connector_runtime.py +0 -0
  80. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_launch_command.py +0 -0
  81. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_local_runtime.py +0 -0
  82. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_perf.py +0 -0
  83. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_terminal_backend.py +0 -0
  84. {agentlink_cli-0.1.0 → agentlink_cli-0.1.1}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentlink-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Local runtime connector for AgentLink
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: claude-agent-sdk
@@ -13,6 +13,7 @@ from typing import Any
13
13
 
14
14
  from connector.acp.discovery import discover_acp_manifest
15
15
  from connector.acp.manifest import AgentManifest, load_builtin_manifests
16
+ from connector.codex.collaboration import normalize_collaboration_modes
16
17
  from connector.codex.rpc import JsonRpcStdioClient, codex_candidate_paths
17
18
  from connector.launch import (
18
19
  LaunchCommand,
@@ -257,6 +258,10 @@ async def _check_codex_candidate(candidate: dict[str, str] | LaunchTarget | Laun
257
258
  _read_codex_model_options(client),
258
259
  timeout=_CODEX_CHECK_TIMEOUT_S,
259
260
  )
261
+ collaboration_mode_options = await asyncio.wait_for(
262
+ _read_codex_collaboration_mode_options(client),
263
+ timeout=_CODEX_CHECK_TIMEOUT_S,
264
+ )
260
265
  except Exception as exc:
261
266
  stage = "model-list" if "model_options" in locals() or _is_model_list_error(exc) else "app-server"
262
267
  return {
@@ -278,6 +283,7 @@ async def _check_codex_candidate(candidate: dict[str, str] | LaunchTarget | Laun
278
283
  "version": version.get("stdout"),
279
284
  "threadListKeys": sorted(list_result.keys()),
280
285
  "modelOptions": model_options,
286
+ "collaborationModeOptions": collaboration_mode_options,
281
287
  }
282
288
 
283
289
 
@@ -303,6 +309,9 @@ async def prepare_codex_launch(
303
309
  model_options = await asyncio.wait_for(
304
310
  _read_codex_model_options(client), timeout=_CODEX_CHECK_TIMEOUT_S
305
311
  )
312
+ collaboration_mode_options = await asyncio.wait_for(
313
+ _read_codex_collaboration_mode_options(client), timeout=_CODEX_CHECK_TIMEOUT_S
314
+ )
306
315
  except Exception:
307
316
  await client.close()
308
317
  raise
@@ -313,6 +322,7 @@ async def prepare_codex_launch(
313
322
  "version": version.get("stdout"),
314
323
  "threadListKeys": sorted(list_result.keys()),
315
324
  "modelOptions": model_options,
325
+ "collaborationModeOptions": collaboration_mode_options,
316
326
  }
317
327
  return _codex_report_from_check(result, command), client
318
328
 
@@ -332,6 +342,8 @@ def _codex_report_from_check(
332
342
  }
333
343
  if isinstance(result.get("modelOptions"), list):
334
344
  report["modelOptions"] = result["modelOptions"]
345
+ if isinstance(result.get("collaborationModeOptions"), list):
346
+ report["collaborationModeOptions"] = result["collaborationModeOptions"]
335
347
  return report
336
348
 
337
349
 
@@ -444,6 +456,14 @@ def _is_model_list_error(exc: BaseException) -> bool:
444
456
  return "model/list" in str(exc)
445
457
 
446
458
 
459
+ async def _read_codex_collaboration_mode_options(client: JsonRpcStdioClient) -> list[dict[str, Any]]:
460
+ try:
461
+ result = await client.request("collaborationMode/list", {})
462
+ except Exception:
463
+ return []
464
+ return normalize_collaboration_modes(result)
465
+
466
+
447
467
  async def _check_claude_candidate(candidate: dict[str, str] | LaunchTarget) -> dict[str, Any]:
448
468
  target = _target_from_candidate(candidate)
449
469
  path = target.path
@@ -13,6 +13,7 @@ from connector.logging import logger
13
13
 
14
14
  from connector.attachments import attachment_target
15
15
  from connector.codex.reducer import CODEX_APPROVAL_METHODS, ReductionResult, TimelineReducer
16
+ from connector.codex.collaboration import collaboration_mode_payload, normalize_collaboration_modes
16
17
  from connector.codex.rpc import JsonRpcStdioClient
17
18
  from connector.sync_state import SyncStateStore
18
19
  from connector.time import utc_now
@@ -93,6 +94,7 @@ class CodexAdapter:
93
94
  _existing_thread_sync_markers: dict[str, str] = field(default_factory=dict)
94
95
  _existing_thread_names: dict[str, str | None] = field(default_factory=dict)
95
96
  _token_usage_by_thread: dict[str, dict[str, Any]] = field(default_factory=dict)
97
+ _collaboration_modes: list[dict[str, Any]] = field(default_factory=list)
96
98
  _start_lock: asyncio.Lock = field(default_factory=asyncio.Lock, init=False, repr=False)
97
99
 
98
100
  def __post_init__(self) -> None:
@@ -433,6 +435,34 @@ class CodexAdapter:
433
435
  "effort": params.get("effort"),
434
436
  "approvalsReviewer": params.get("approvalsReviewer"),
435
437
  }
438
+ requested_collaboration_mode = _optional_string(params.get("collaborationMode"))
439
+ if requested_collaboration_mode is not None and not self._collaboration_modes:
440
+ try:
441
+ self._collaboration_modes = normalize_collaboration_modes(
442
+ await self.rpc.request("collaborationMode/list", {})
443
+ )
444
+ except Exception:
445
+ self._collaboration_modes = []
446
+ collaboration = (
447
+ collaboration_mode_payload(
448
+ requested_collaboration_mode,
449
+ self._collaboration_modes,
450
+ model=_optional_string(params.get("model")) or "gpt-5.6-sol",
451
+ effort=_optional_string(params.get("effort")),
452
+ )
453
+ if requested_collaboration_mode is not None
454
+ else None
455
+ )
456
+ if collaboration is None and requested_collaboration_mode == "plan":
457
+ raise ValueError("Plan mode is not supported by this Codex installation")
458
+ if collaboration is not None:
459
+ await self.rpc.request(
460
+ "thread/settings/update",
461
+ {"threadId": thread_id, "collaborationMode": collaboration},
462
+ )
463
+ settings = collaboration["settings"]
464
+ turn_params["model"] = settings["model"]
465
+ turn_params["effort"] = settings["reasoning_effort"]
436
466
  try:
437
467
  result = await self.rpc.request("turn/start", turn_params)
438
468
  except RuntimeError as exc:
@@ -448,6 +478,11 @@ class CodexAdapter:
448
478
  backend_notifications.extend(extra_notifications)
449
479
  self.reducer.bind_session(session_id, thread_id)
450
480
  turn_params["threadId"] = thread_id
481
+ if collaboration is not None:
482
+ await self.rpc.request(
483
+ "thread/settings/update",
484
+ {"threadId": thread_id, "collaborationMode": collaboration},
485
+ )
451
486
  if client_message_id:
452
487
  self.reducer.register_client_message(
453
488
  session_id=session_id,
@@ -675,6 +710,24 @@ class CodexAdapter:
675
710
  )
676
711
  return {"resolved": True}
677
712
 
713
+ async def respond_to_input(self, params: dict[str, Any]) -> dict[str, Any]:
714
+ await self.start()
715
+ assert self.rpc is not None
716
+ request_id = params.get("requestId")
717
+ if request_id is None:
718
+ raise ValueError("requestId is required to respond to Codex user input")
719
+ answers = params.get("answers")
720
+ if not isinstance(answers, dict):
721
+ raise ValueError("answers are required to respond to Codex user input")
722
+ await self.rpc.respond(request_id, {"answers": answers})
723
+ logger.info(
724
+ "codex user input resolved request_id={} approval_id={} question_count={}",
725
+ request_id,
726
+ params.get("approvalId"),
727
+ len(answers),
728
+ )
729
+ return {"resolved": True}
730
+
678
731
  async def handle_notification(self, message: dict[str, Any]) -> None:
679
732
  if message.get("method") == "thread/tokenUsage/updated":
680
733
  params = message.get("params") if isinstance(message.get("params"), dict) else {}
@@ -801,7 +854,7 @@ class CodexAdapter:
801
854
  ("thread/loaded/list", None),
802
855
  ):
803
856
  try:
804
- await self.rpc.request(method, params)
857
+ result = await self.rpc.request(method, params)
805
858
  except Exception as exc: # pragma: no cover - defensive against version drift
806
859
  logger.debug("codex bootstrap read failed method={} error={}", method, exc)
807
860
 
@@ -0,0 +1,67 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+
6
+ PLAN_MODE_DEVELOPER_INSTRUCTIONS = """# Plan Mode (Conversational)
7
+
8
+ Work with the user to produce a decision-complete implementation plan before any implementation.
9
+
10
+ - Explore the repository and other available context before asking questions.
11
+ - Do not edit files or perform other implementation mutations while in Plan Mode.
12
+ - Ask only questions that materially change the plan and cannot be answered by inspection.
13
+ - Use request_user_input for meaningful choices when it is available.
14
+ - Cover interfaces, data flow, edge cases, compatibility, testing, and acceptance criteria.
15
+ - When the plan is complete, return exactly one self-contained Markdown plan wrapped in
16
+ `<proposed_plan>` and `</proposed_plan>` tags. Do not ask whether to proceed.
17
+ """
18
+
19
+
20
+ def normalize_collaboration_modes(value: Any) -> list[dict[str, Any]]:
21
+ if not isinstance(value, dict) or not isinstance(value.get("data"), list):
22
+ return []
23
+ result: list[dict[str, Any]] = []
24
+ seen: set[str] = set()
25
+ for raw in value["data"]:
26
+ if not isinstance(raw, dict):
27
+ continue
28
+ mode = raw.get("mode")
29
+ if mode not in {"default", "plan"} or mode in seen:
30
+ continue
31
+ seen.add(mode)
32
+ item: dict[str, Any] = {
33
+ "value": mode,
34
+ "label": str(raw.get("name") or mode.title()),
35
+ }
36
+ if isinstance(raw.get("model"), str) and raw["model"]:
37
+ item["model"] = raw["model"]
38
+ effort = raw.get("reasoning_effort") or raw.get("reasoningEffort")
39
+ if isinstance(effort, str) and effort:
40
+ item["reasoningEffort"] = effort
41
+ result.append(item)
42
+ result.sort(key=lambda item: 0 if item["value"] == "default" else 1)
43
+ return result
44
+
45
+
46
+ def collaboration_mode_payload(
47
+ mode: str,
48
+ options: list[dict[str, Any]],
49
+ *,
50
+ model: str,
51
+ effort: str | None,
52
+ ) -> dict[str, Any] | None:
53
+ option = next((item for item in options if item.get("value") == mode), None)
54
+ if option is None:
55
+ return None
56
+ selected_model = option.get("model") if isinstance(option.get("model"), str) else model
57
+ selected_effort = option.get("reasoningEffort")
58
+ if not isinstance(selected_effort, str):
59
+ selected_effort = effort
60
+ return {
61
+ "mode": mode,
62
+ "settings": {
63
+ "model": selected_model,
64
+ "reasoning_effort": selected_effort,
65
+ "developer_instructions": PLAN_MODE_DEVELOPER_INSTRUCTIONS if mode == "plan" else None,
66
+ },
67
+ }
@@ -13,6 +13,7 @@ CODEX_APPROVAL_METHODS = {
13
13
  "item/fileChange/requestApproval",
14
14
  "item/permissions/requestApproval",
15
15
  }
16
+ CODEX_INPUT_REQUEST_METHOD = "item/tool/requestUserInput"
16
17
 
17
18
  OUTPUT_PREVIEW_CHARS = 4000
18
19
 
@@ -343,6 +344,18 @@ class TimelineReducer:
343
344
  approvals=[approval],
344
345
  )
345
346
 
347
+ if method == CODEX_INPUT_REQUEST_METHOD:
348
+ approval = self._input_request_from_request(message, params, session_id, thread_id, turn_id)
349
+ blocking = params.get("isBlocking") is not False
350
+ return ReductionResult(
351
+ session_update=self._session_update(
352
+ session_id=session_id,
353
+ thread_id=thread_id,
354
+ status="waiting_approval" if blocking else "running",
355
+ ),
356
+ approvals=[approval],
357
+ )
358
+
346
359
  if method == "item/agentMessage/delta":
347
360
  item_id = _string_value(params.get("itemId")) or _nested_string(params, "item", "id")
348
361
  item = self._append_text_item(
@@ -836,6 +849,39 @@ class TimelineReducer:
836
849
  event=method,
837
850
  )
838
851
 
852
+ def _input_request_from_request(
853
+ self,
854
+ message: dict[str, Any],
855
+ params: dict[str, Any],
856
+ session_id: str,
857
+ thread_id: str | None,
858
+ turn_id: str | None,
859
+ ) -> dict[str, Any]:
860
+ item_id = _string_value(params.get("itemId"))
861
+ questions = [item for item in _list_value(params.get("questions")) if isinstance(item, dict)]
862
+ first = questions[0] if questions else {}
863
+ approval_id = f"appr_{_short_hash([session_id, thread_id, turn_id, item_id, CODEX_INPUT_REQUEST_METHOD, message.get('id')])}"
864
+ return {
865
+ "id": approval_id,
866
+ "sessionId": session_id,
867
+ "turnId": turn_id,
868
+ "status": "pending",
869
+ "kind": "input_request",
870
+ "targetItemId": None,
871
+ "title": _string_value(first.get("header")) or "Codex needs your input",
872
+ "description": _string_value(first.get("question")),
873
+ "payload": params,
874
+ "choices": [],
875
+ "source": {
876
+ "runtime": "codex",
877
+ "requestId": message.get("id"),
878
+ "sessionId": thread_id,
879
+ "turnId": turn_id,
880
+ "itemId": item_id,
881
+ "method": CODEX_INPUT_REQUEST_METHOD,
882
+ },
883
+ }
884
+
839
885
  def _upsert_item(
840
886
  self,
841
887
  *,
@@ -422,6 +422,8 @@ class BackendRpcClient:
422
422
  return await self._resolve_adapter(params).interrupt_turn(params)
423
423
  if method == "approval.resolve":
424
424
  return await self._resolve_adapter(params).resolve_approval(params)
425
+ if method == "input.respond":
426
+ return await self._resolve_adapter(params).respond_to_input(params)
425
427
  if method == "fs.prepareDownload":
426
428
  return await self.local_ops.prepare_download(params)
427
429
  if method == "fs.uploadPreparedDownload":
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentlink-cli"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "Local runtime connector for AgentLink"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -11,6 +11,7 @@ from connector.codex.adapter import (
11
11
  CodexAdapter,
12
12
  stable_session_id,
13
13
  )
14
+ from connector.codex.collaboration import collaboration_mode_payload, normalize_collaboration_modes
14
15
  from connector.codex.history import read_timeline_history, read_tool_history
15
16
  from connector.codex.reducer import TimelineReducer
16
17
  from connector.codex.rpc import APP_SERVER_STREAM_LIMIT, JsonRpcStdioClient
@@ -77,6 +78,19 @@ class FakeCodexRpc:
77
78
  self.responses.append((request_id, result))
78
79
 
79
80
 
81
+ class CollaborationCodexRpc(FakeCodexRpc):
82
+ async def request(self, method: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
83
+ if method == "collaborationMode/list":
84
+ self.requests.append((method, params))
85
+ return {
86
+ "data": [
87
+ {"name": "Plan", "mode": "plan", "model": None, "reasoning_effort": "medium"},
88
+ {"name": "Default", "mode": "default", "model": None, "reasoning_effort": None},
89
+ ]
90
+ }
91
+ return await super().request(method, params)
92
+
93
+
80
94
  class InterruptThreadNotFoundRpc(FakeCodexRpc):
81
95
  async def request(self, method: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
82
96
  if method == "turn/interrupt":
@@ -187,6 +201,87 @@ def test_stdio_client_stream_limit_is_large_enough_for_codex_jsonl() -> None:
187
201
  assert APP_SERVER_STREAM_LIMIT >= 64 * 1024 * 1024
188
202
 
189
203
 
204
+ def test_collaboration_modes_normalize_and_build_plan_settings() -> None:
205
+ options = normalize_collaboration_modes(
206
+ {
207
+ "data": [
208
+ {"name": "Plan", "mode": "plan", "model": None, "reasoning_effort": "medium"},
209
+ {"name": "Default", "mode": "default", "model": None, "reasoning_effort": None},
210
+ ]
211
+ }
212
+ )
213
+ assert [option["value"] for option in options] == ["default", "plan"]
214
+ plan = collaboration_mode_payload("plan", options, model="gpt-test", effort="high")
215
+ assert plan is not None
216
+ assert plan["mode"] == "plan"
217
+ assert plan["settings"]["model"] == "gpt-test"
218
+ assert plan["settings"]["reasoning_effort"] == "medium"
219
+ assert "Plan Mode" in plan["settings"]["developer_instructions"]
220
+
221
+
222
+ def test_reducer_maps_codex_input_request() -> None:
223
+ reducer = TimelineReducer()
224
+ reducer.bind_session("sess_1", "thr_1")
225
+ params = {
226
+ "threadId": "thr_1",
227
+ "turnId": "turn_1",
228
+ "itemId": "item_1",
229
+ "questions": [
230
+ {
231
+ "id": "strategy",
232
+ "header": "Strategy",
233
+ "question": "Which strategy?",
234
+ "options": [{"label": "Safe", "description": "Prefer compatibility"}],
235
+ "isOther": True,
236
+ "isSecret": False,
237
+ }
238
+ ],
239
+ "isBlocking": True,
240
+ }
241
+ reduced = reducer.reduce_notification(
242
+ {"id": 42, "method": "item/tool/requestUserInput", "params": params}
243
+ )
244
+ assert reduced.session_update["status"] == "waiting_approval"
245
+ assert reduced.approvals[0]["kind"] == "input_request"
246
+ assert reduced.approvals[0]["payload"] == params
247
+ assert reduced.approvals[0]["source"]["requestId"] == 42
248
+
249
+
250
+ def test_adapter_applies_plan_mode_and_responds_to_input() -> None:
251
+ async def exercise() -> None:
252
+ async def sink(_method: str, _params: dict[str, Any]) -> None:
253
+ return None
254
+
255
+ rpc = CollaborationCodexRpc()
256
+ adapter = CodexAdapter(rpc=rpc, notification_sink=sink) # type: ignore[arg-type]
257
+ adapter.reducer.bind_session("sess_1", "thr_1")
258
+ await adapter.start_turn(
259
+ {
260
+ "sessionId": "sess_1",
261
+ "externalSessionId": "thr_1",
262
+ "content": "plan this",
263
+ "model": "gpt-test",
264
+ "effort": "high",
265
+ "collaborationMode": "plan",
266
+ }
267
+ )
268
+ settings_request = next(
269
+ params for method, params in rpc.requests if method == "thread/settings/update"
270
+ )
271
+ assert settings_request["collaborationMode"]["mode"] == "plan"
272
+ assert settings_request["collaborationMode"]["settings"]["reasoning_effort"] == "medium"
273
+ turn_request = next(params for method, params in rpc.requests if method == "turn/start")
274
+ assert turn_request["model"] == "gpt-test"
275
+ assert turn_request["effort"] == "medium"
276
+
277
+ await adapter.respond_to_input(
278
+ {"requestId": 42, "answers": {"strategy": {"answers": ["Safe"]}}}
279
+ )
280
+ assert rpc.responses[-1] == (42, {"answers": {"strategy": {"answers": ["Safe"]}}})
281
+
282
+ asyncio.run(exercise())
283
+
284
+
190
285
  def test_stdio_client_preserves_numeric_server_request_ids() -> None:
191
286
  client = JsonRpcStdioClient(command=["codex"])
192
287
  client._server_request_ids.add(0) # noqa: SLF001
@@ -8,7 +8,7 @@ resolution-markers = [
8
8
 
9
9
  [[package]]
10
10
  name = "agentlink-cli"
11
- version = "0.1.0"
11
+ version = "0.1.1"
12
12
  source = { editable = "." }
13
13
  dependencies = [
14
14
  { name = "claude-agent-sdk" },
File without changes
File without changes
File without changes