forgexa-cli 1.96.0__tar.gz → 1.96.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 (35) hide show
  1. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/PKG-INFO +1 -1
  2. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/__init__.py +1 -1
  3. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/agent_core.py +15 -0
  4. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/component_runtime.py +151 -35
  5. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/daemon.py +71 -5
  6. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/zcode_protocol.py +20 -1
  7. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli.egg-info/PKG-INFO +1 -1
  8. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/pyproject.toml +1 -1
  9. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/README.md +0 -0
  10. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/_build_config.py +0 -0
  11. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/_local_bind.py +0 -0
  12. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/autoupgrade.py +0 -0
  13. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/aws_evidence.py +0 -0
  14. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/aws_logs_evidence.py +0 -0
  15. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/main.py +0 -0
  16. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/observability_contract.py +0 -0
  17. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/observability_evidence.py +0 -0
  18. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/py.typed +0 -0
  19. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli/runtime_evidence.py +0 -0
  20. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli.egg-info/SOURCES.txt +0 -0
  21. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli.egg-info/dependency_links.txt +0 -0
  22. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli.egg-info/entry_points.txt +0 -0
  23. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli.egg-info/requires.txt +0 -0
  24. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/forgexa_cli.egg-info/top_level.txt +0 -0
  25. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/setup.cfg +0 -0
  26. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_auth_and_runtime_commands.py +0 -0
  27. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_autoupgrade.py +0 -0
  28. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_check_command.py +0 -0
  29. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_expiry_warnings_and_revoke.py +0 -0
  30. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_local_bind_commands.py +0 -0
  31. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_publish_script.py +0 -0
  32. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_runtime_credentials.py +0 -0
  33. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_session_credentials.py +0 -0
  34. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_silent_install.py +0 -0
  35. {forgexa_cli-1.96.0 → forgexa_cli-1.96.1}/tests/test_upgrade_observability.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: forgexa-cli
3
- Version: 1.96.0
3
+ Version: 1.96.1
4
4
  Summary: Forgexa CLI — command-line client and AI agent runtime for the Forgexa platform
5
5
  Author-email: Jason Sun <dev.winds@gmail.com>
6
6
  License-Expression: MIT
@@ -1,2 +1,2 @@
1
1
  """forgexa-cli — Forgexa command-line client."""
2
- __version__ = "1.96.0"
2
+ __version__ = "1.96.1"
@@ -1294,6 +1294,8 @@ class DiscoveredAgent:
1294
1294
  compatibility_level: str
1295
1295
  min_version_ok: bool = True
1296
1296
  version_warning: str = ""
1297
+ installation_id: str | None = None
1298
+ selection_revision: int | None = None
1297
1299
 
1298
1300
 
1299
1301
  def _prepare_agent_command(
@@ -2277,6 +2279,8 @@ class AgentDiscovery:
2277
2279
  compatibility_level=spec["compatibility_level"],
2278
2280
  min_version_ok=min_version_ok,
2279
2281
  version_warning=version_warning,
2282
+ installation_id=managed.receipt["installation_id"] if managed is not None else None,
2283
+ selection_revision=managed.selection_revision if managed is not None else None,
2280
2284
  )
2281
2285
  logger.info("Discovered agent: %s v%s (%s)", agent_id, version, resolved)
2282
2286
  if managed is not None:
@@ -2302,6 +2306,15 @@ class AgentDiscovery:
2302
2306
  probe_dir = None
2303
2307
  proc = None
2304
2308
  try:
2309
+ active_component = component_runtime.current_execution()
2310
+ if (
2311
+ managed is None
2312
+ and active_component is not None
2313
+ and executable == active_component.argv_prefix[-1]
2314
+ ):
2315
+ managed = active_component
2316
+ if managed is not None:
2317
+ await asyncio.to_thread(managed.verify)
2305
2318
  parts = detect_cmd.split()
2306
2319
  if executable:
2307
2320
  parts[0] = executable
@@ -2337,6 +2350,8 @@ class AgentDiscovery:
2337
2350
  cwd=probe_dir.name if managed is not None else None,
2338
2351
  **_agent_process_group_kwargs(),
2339
2352
  )
2353
+ if managed is not None and managed is component_runtime.current_execution():
2354
+ managed.process_started = True
2340
2355
  stdout, stderr = await asyncio.wait_for(proc.communicate(), timeout=10)
2341
2356
  if proc.returncode != 0:
2342
2357
  logger.warning(
@@ -2,17 +2,25 @@ from __future__ import annotations
2
2
 
3
3
  import hashlib
4
4
  import json
5
+ import math
5
6
  import os
6
7
  import platform
7
8
  import re
8
9
  import stat
10
+ import struct
9
11
  import sys
12
+ from contextlib import contextmanager
13
+ from contextvars import ContextVar
10
14
  from pathlib import Path
11
15
  from typing import Any
12
16
 
13
17
  RECORD_LIMIT = 8 * 1024 * 1024
14
18
  IDENTIFIER = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$")
15
19
  DIGEST = re.compile(r"^[0-9a-f]{64}$")
20
+ _EXECUTION_LEASE: ContextVar[ManagedComponentLease | None] = ContextVar(
21
+ "forgexa_component_execution_lease",
22
+ default=None,
23
+ )
16
24
 
17
25
 
18
26
  class ComponentRuntimeError(RuntimeError):
@@ -118,6 +126,7 @@ class ManagedComponentLease:
118
126
  self.descriptor = descriptor
119
127
  self.lease_id = os.urandom(32).hex()
120
128
  self.owner_nonce = os.urandom(32).hex()
129
+ self.process_started = False
121
130
  self.record_path = root / "leases" / f"{self.lease_id}.json"
122
131
  digest = _digest(receipt["installation_id"].removeprefix("install-"))
123
132
  self.directory = root / "versions" / digest
@@ -286,6 +295,15 @@ class ManagedComponentLease:
286
295
  os.close(self.descriptor)
287
296
  self.descriptor = -1
288
297
 
298
+ def retain_unknown_usage(self) -> None:
299
+ if self.descriptor < 0:
300
+ return
301
+ import fcntl
302
+
303
+ fcntl.flock(self.descriptor, fcntl.LOCK_UN)
304
+ os.close(self.descriptor)
305
+ self.descriptor = -1
306
+
289
307
  def __enter__(self) -> ManagedComponentLease:
290
308
  return self
291
309
 
@@ -330,6 +348,85 @@ class _ComponentManagerLock:
330
348
  os.close(self.descriptor)
331
349
 
332
350
 
351
+ def _component_target(root: Path) -> dict[str, Any]:
352
+ target = _record(
353
+ root / "target.json",
354
+ {
355
+ "schema_version",
356
+ "target_id",
357
+ "kind",
358
+ "os",
359
+ "arch",
360
+ "os_user_id",
361
+ "store_id",
362
+ "generation",
363
+ },
364
+ )
365
+ if target is None:
366
+ raise ComponentRuntimeError("component_target_invalid")
367
+ metadata = root.stat()
368
+ identity = f"{root.resolve()}\n{os.getuid()}\n{metadata.st_dev}\n{metadata.st_ino}"
369
+ target_os = (
370
+ "macos"
371
+ if sys.platform == "darwin"
372
+ else "linux"
373
+ if sys.platform == "linux"
374
+ else "unsupported"
375
+ )
376
+ target_arch = "aarch64" if platform.machine().lower() in {"arm64", "aarch64"} else "x86_64"
377
+ _identifier(target["target_id"])
378
+ _identifier(target["generation"])
379
+ if (
380
+ target["kind"] != "native"
381
+ or target["os"] != target_os
382
+ or target["arch"] != target_arch
383
+ or target["os_user_id"] != str(os.getuid())
384
+ or target["store_id"] != hashlib.sha256(identity.encode()).hexdigest()
385
+ ):
386
+ raise ComponentRuntimeError("component_target_changed")
387
+ return target
388
+
389
+
390
+ def _process_start_identity(process_id: int) -> str:
391
+ try:
392
+ import psutil
393
+ except ImportError as error:
394
+ raise ComponentRuntimeError("component_process_identity_unverified") from error
395
+ try:
396
+ created = psutil.Process(process_id).create_time()
397
+ except (psutil.Error, OSError) as error:
398
+ raise ComponentRuntimeError("component_process_identity_unverified") from error
399
+ if not math.isfinite(created) or created <= 0:
400
+ raise ComponentRuntimeError("component_process_identity_unverified")
401
+ return f"process-{process_id}-{struct.pack('!d', created).hex()}"
402
+
403
+
404
+ def runtime_capabilities(
405
+ runtime_instance_id: str, root: Path | None = None
406
+ ) -> dict[str, Any] | None:
407
+ _identifier(runtime_instance_id)
408
+ root = default_store_root() if root is None else root
409
+ if root.is_symlink():
410
+ raise ComponentRuntimeError("component_storage_invalid")
411
+ if not root.exists():
412
+ return None
413
+ if os.name != "posix" or os.environ.get("WSL_DISTRO_NAME"):
414
+ raise ComponentRuntimeError("component_platform_unverified")
415
+ with _ComponentManagerLock(root):
416
+ target = _component_target(root)
417
+ process_id = os.getpid()
418
+ return {
419
+ "schema_version": 1,
420
+ "target": target,
421
+ "runtime_instance_id": runtime_instance_id,
422
+ "process_id": process_id,
423
+ "process_start_identity": _process_start_identity(process_id),
424
+ "managed_instance_resolution": True,
425
+ "version_usage_leases": True,
426
+ "usage_recovery": False,
427
+ }
428
+
429
+
333
430
  def _acquire_component(
334
431
  component_id: str, root: Path | None = None, override: str | None = None
335
432
  ) -> ManagedComponentLease | None:
@@ -344,41 +441,7 @@ def _acquire_component(
344
441
  import fcntl
345
442
 
346
443
  with _ComponentManagerLock(root):
347
- target = _record(
348
- root / "target.json",
349
- {
350
- "schema_version",
351
- "target_id",
352
- "kind",
353
- "os",
354
- "arch",
355
- "os_user_id",
356
- "store_id",
357
- "generation",
358
- },
359
- )
360
- if target is None:
361
- raise ComponentRuntimeError("component_target_invalid")
362
- metadata = root.stat()
363
- identity = f"{root.resolve()}\n{os.getuid()}\n{metadata.st_dev}\n{metadata.st_ino}"
364
- target_os = (
365
- "macos"
366
- if sys.platform == "darwin"
367
- else "linux"
368
- if sys.platform == "linux"
369
- else "unsupported"
370
- )
371
- target_arch = "aarch64" if platform.machine().lower() in {"arm64", "aarch64"} else "x86_64"
372
- _identifier(target["target_id"])
373
- _identifier(target["generation"])
374
- if (
375
- target["kind"] != "native"
376
- or target["os"] != target_os
377
- or target["arch"] != target_arch
378
- or target["os_user_id"] != str(os.getuid())
379
- or target["store_id"] != hashlib.sha256(identity.encode()).hexdigest()
380
- ):
381
- raise ComponentRuntimeError("component_target_changed")
444
+ target = _component_target(root)
382
445
  selection = _record(
383
446
  root / "selections" / f"{component_id}.json",
384
447
  {
@@ -516,3 +579,56 @@ def acquire_component(
516
579
  return _acquire_component(component_id, root, override)
517
580
  except OSError as error:
518
581
  raise ComponentRuntimeError("component_storage_unavailable") from error
582
+
583
+
584
+ def admit_execution(
585
+ component_id: str,
586
+ binary_path: str,
587
+ installation_id: str | None = None,
588
+ selection_revision: int | None = None,
589
+ root: Path | None = None,
590
+ override: str | None = None,
591
+ ) -> ManagedComponentLease | None:
592
+ lease = acquire_component(component_id, root=root, override=override)
593
+ if lease is None:
594
+ if installation_id is not None or selection_revision is not None:
595
+ raise ComponentRuntimeError("component_instance_missing")
596
+ return None
597
+ try:
598
+ if binary_path != lease.argv_prefix[-1]:
599
+ raise ComponentRuntimeError("component_instance_changed")
600
+ if installation_id is not None and installation_id != lease.receipt["installation_id"]:
601
+ raise ComponentRuntimeError("component_instance_changed")
602
+ if selection_revision is not None and selection_revision != lease.selection_revision:
603
+ raise ComponentRuntimeError("component_selection_changed")
604
+ return lease
605
+ except Exception:
606
+ lease.close()
607
+ raise
608
+
609
+
610
+ @contextmanager
611
+ def execution_scope(lease: ManagedComponentLease | None):
612
+ token = _EXECUTION_LEASE.set(lease)
613
+ try:
614
+ yield
615
+ finally:
616
+ _EXECUTION_LEASE.reset(token)
617
+
618
+
619
+ def current_execution() -> ManagedComponentLease | None:
620
+ return _EXECUTION_LEASE.get()
621
+
622
+
623
+ def execution_command(command: list[str], environment: dict[str, str] | None):
624
+ lease = current_execution()
625
+ if lease is None or not command or command[0] != lease.argv_prefix[-1]:
626
+ return command, environment
627
+ lease.verify()
628
+ command = lease.wrap_command(command)
629
+ environment = {
630
+ **(os.environ if environment is None else environment),
631
+ "DISABLE_UPDATES": "1",
632
+ "DISABLE_AUTOUPDATER": "1",
633
+ }
634
+ return command, environment
@@ -108,6 +108,7 @@ except ImportError:
108
108
  # of truth lives in agent_core.
109
109
  DiscoveredAgent = agent_core.DiscoveredAgent
110
110
  AgentDiscovery = agent_core.AgentDiscovery
111
+ component_runtime = agent_core.component_runtime
111
112
  _prepare_agent_command = agent_core._prepare_agent_command
112
113
  _windows_agent_needs_task_file_redirect = agent_core._windows_agent_needs_task_file_redirect
113
114
  _redirect_prompt_through_task_file = agent_core._redirect_prompt_through_task_file
@@ -131,12 +132,21 @@ _MANAGED_WSL_POLICY = getattr(_wsl_policy_module, "ACTIVE_POLICY", None)
131
132
 
132
133
 
133
134
  async def _create_subprocess_exec(*command, **kwargs):
135
+ original_command = command
136
+ prepared, environment = component_runtime.execution_command(list(command), kwargs.get("env"))
137
+ if environment is not kwargs.get("env"):
138
+ kwargs["env"] = environment
139
+ command = prepared
134
140
  if _MANAGED_WSL_POLICY is not None:
135
141
  return await _MANAGED_WSL_POLICY.spawn(*command, **kwargs)
136
142
  # Desktop stdin is its parent-liveness control pipe, never child input.
137
143
  # Agent callers that need prompt input explicitly pass subprocess.PIPE.
138
144
  kwargs.setdefault("stdin", asyncio.subprocess.DEVNULL)
139
- return await asyncio.create_subprocess_exec(*command, **kwargs)
145
+ process = await asyncio.create_subprocess_exec(*command, **kwargs)
146
+ lease = component_runtime.current_execution()
147
+ if lease is not None and original_command and original_command[0] == lease.argv_prefix[-1]:
148
+ lease.process_started = True
149
+ return process
140
150
 
141
151
 
142
152
  def _materialize_performance_evidence(workspace_path, input_context):
@@ -1381,7 +1391,7 @@ except (ImportError, ModuleNotFoundError):
1381
1391
  # DAEMON_VERSION is the protocol/logic version of the daemon code.
1382
1392
  # Kept in sync with pyproject.toml version via bump-version.sh.
1383
1393
  # CLIENT_TYPE identifies which packaging/distribution this daemon runs in.
1384
- DAEMON_VERSION = "1.96.0"
1394
+ DAEMON_VERSION = "1.96.1"
1385
1395
 
1386
1396
 
1387
1397
  def _detect_client_type() -> str:
@@ -6911,6 +6921,35 @@ class ProcessManager:
6911
6921
  workspace_path: Path,
6912
6922
  on_progress: Any = None,
6913
6923
  on_chunk: Any = None,
6924
+ ) -> TaskResult:
6925
+ existing = component_runtime.current_execution()
6926
+ lease = existing
6927
+ owned = False
6928
+ try:
6929
+ if lease is None or lease.receipt["release"]["component_id"] != agent.agent_id:
6930
+ lease = await asyncio.to_thread(
6931
+ component_runtime.admit_execution, agent.agent_id, agent.command,
6932
+ getattr(agent, "installation_id", None), getattr(agent, "selection_revision", None),
6933
+ None, os.environ.get(AgentDiscovery.AGENT_REGISTRY.get(agent.agent_id, {}).get("env_path_override", "")),
6934
+ )
6935
+ owned = lease is not None
6936
+ elif lease.argv_prefix[-1] != agent.command:
6937
+ raise component_runtime.ComponentRuntimeError("component_instance_changed")
6938
+ with component_runtime.execution_scope(lease):
6939
+ return await self._run_admitted_agent(agent, task, workspace_path, on_progress, on_chunk)
6940
+ except component_runtime.ComponentRuntimeError as exc:
6941
+ return TaskResult(status="failed", exit_code=-1, stdout="", stderr="", error=exc.code,
6942
+ failure_code=exc.code, execution_attempt_id=task.execution_attempt_id)
6943
+ finally:
6944
+ if owned and lease is not None:
6945
+ if lease.process_started:
6946
+ lease.retain_unknown_usage()
6947
+ else:
6948
+ await asyncio.to_thread(lease.close)
6949
+
6950
+ async def _run_admitted_agent(
6951
+ self, agent: DiscoveredAgent, task: TaskInfo, workspace_path: Path,
6952
+ on_progress: Any = None, on_chunk: Any = None,
6914
6953
  ) -> TaskResult:
6915
6954
  """Execute an agent CLI and collect results."""
6916
6955
  if isinstance(getattr(task, "input_data", None), dict) and task.input_data.get("requires_capture_images") and agent.agent_id != "claude":
@@ -8278,6 +8317,7 @@ class ProcessManager:
8278
8317
  env=await asyncio.to_thread(agent_core.zcode_base_env, os.environ.copy()),
8279
8318
  on_event=on_event,
8280
8319
  permission_handler=agent_core.zcode_permission_response,
8320
+ component_lease=component_runtime.current_execution(),
8281
8321
  )
8282
8322
  await client.start()
8283
8323
  if client.process is not None:
@@ -8350,9 +8390,11 @@ class ProcessManager:
8350
8390
  finally:
8351
8391
  self.active_zcode_sessions.pop(task_id, None)
8352
8392
  self.active_processes.pop(task_id, None)
8353
- if client is not None:
8354
- await client.close()
8355
- agent_core.release_file_lock(profile_lock)
8393
+ try:
8394
+ if client is not None:
8395
+ await client.close()
8396
+ finally:
8397
+ agent_core.release_file_lock(profile_lock)
8356
8398
 
8357
8399
  async def _run_gemini(
8358
8400
  self, agent: DiscoveredAgent, prompt: str, cwd: Path, timeout: int, task_id: str,
@@ -13271,6 +13313,30 @@ class RuntimeDaemon:
13271
13313
  result.lines_removed = git_info.get("lines_removed", 0)
13272
13314
 
13273
13315
  async def _execute_task(self, task: TaskInfo, conn: ServerConnection):
13316
+ agent = self._select_agent(task.agent_type, task.fallback_chain)
13317
+ lease = None
13318
+ try:
13319
+ if agent is not None:
13320
+ lease = await asyncio.to_thread(
13321
+ component_runtime.admit_execution, agent.agent_id, agent.command,
13322
+ getattr(agent, "installation_id", None), getattr(agent, "selection_revision", None),
13323
+ None, os.environ.get(AgentDiscovery.AGENT_REGISTRY.get(agent.agent_id, {}).get("env_path_override", "")),
13324
+ )
13325
+ with component_runtime.execution_scope(lease):
13326
+ return await self._execute_admitted_task(task, conn)
13327
+ except component_runtime.ComponentRuntimeError as exc:
13328
+ await conn.reporter.report_complete(task.task_id, TaskResult(
13329
+ status="failed", exit_code=-1, stdout="", stderr="", error=exc.code,
13330
+ failure_code=exc.code, execution_attempt_id=task.execution_attempt_id,
13331
+ ))
13332
+ finally:
13333
+ if lease is not None:
13334
+ if lease.process_started:
13335
+ lease.retain_unknown_usage()
13336
+ else:
13337
+ await asyncio.to_thread(lease.close)
13338
+
13339
+ async def _execute_admitted_task(self, task: TaskInfo, conn: ServerConnection):
13274
13340
  """Execute a single task, reporting to the originating server connection."""
13275
13341
  reporter = conn.reporter
13276
13342
  # Forgexa IDE local-bind (Phase 0): several cloud-worktree-only steps
@@ -11,6 +11,7 @@ import asyncio
11
11
  import inspect
12
12
  import json
13
13
  import logging
14
+ import os
14
15
  import re
15
16
  import uuid
16
17
  from collections import deque
@@ -147,12 +148,14 @@ class ZCodeProtocolSession:
147
148
  env: dict[str, str] | None = None,
148
149
  on_event: EventHandler | None = None,
149
150
  permission_handler: PermissionHandler | None = None,
151
+ component_lease: agent_core.component_runtime.ManagedComponentLease | None = None,
150
152
  ) -> None:
151
153
  self.command = list(command)
152
154
  self.cwd = str(cwd)
153
155
  self.env = dict(env) if env is not None else None
154
156
  self.on_event = on_event
155
157
  self.permission_handler = permission_handler
158
+ self.component_lease = component_lease
156
159
  self.session_id: str | None = None
157
160
  self.protocol_version: int | None = None
158
161
  self._process: asyncio.subprocess.Process | None = None
@@ -182,8 +185,18 @@ class ZCodeProtocolSession:
182
185
  if self._process is not None:
183
186
  raise ZCodeProtocolError("ZCode Protocol process is already running")
184
187
  process_env = self.env
188
+ command = self.command
189
+ if self.component_lease is not None:
190
+ if self.component_lease.receipt["release"]["component_id"] != "zcode":
191
+ raise agent_core.component_runtime.ComponentRuntimeError(
192
+ "component_instance_changed"
193
+ )
194
+ await asyncio.to_thread(self.component_lease.verify)
195
+ command = self.component_lease.wrap_command(command)
196
+ process_env = {**(process_env if process_env is not None else os.environ),
197
+ "DISABLE_UPDATES": "1", "DISABLE_AUTOUPDATER": "1"}
185
198
  self._process = await asyncio.create_subprocess_exec(
186
- *self.command,
199
+ *command,
187
200
  stdin=asyncio.subprocess.PIPE,
188
201
  stdout=asyncio.subprocess.PIPE,
189
202
  stderr=asyncio.subprocess.PIPE,
@@ -192,6 +205,8 @@ class ZCodeProtocolSession:
192
205
  limit=1_048_576,
193
206
  **agent_core._agent_process_group_kwargs(),
194
207
  )
208
+ if self.component_lease is not None:
209
+ self.component_lease.process_started = True
195
210
  self._reader_task = asyncio.create_task(self._read_loop())
196
211
  self._stderr_task = asyncio.create_task(self._read_stderr())
197
212
 
@@ -365,6 +380,10 @@ class ZCodeProtocolSession:
365
380
  for task in (self._reader_task, self._stderr_task):
366
381
  if task is not None and not task.done():
367
382
  task.cancel()
383
+ if self.component_lease is not None and process is not None and process.returncode is None:
384
+ raise agent_core.component_runtime.ComponentRuntimeError(
385
+ "component_process_cleanup_unconfirmed"
386
+ )
368
387
  self._process = None
369
388
 
370
389
  async def _request(self, method: str, params: dict[str, Any], timeout: float = 30.0) -> Any:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: forgexa-cli
3
- Version: 1.96.0
3
+ Version: 1.96.1
4
4
  Summary: Forgexa CLI — command-line client and AI agent runtime for the Forgexa platform
5
5
  Author-email: Jason Sun <dev.winds@gmail.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "forgexa-cli"
3
- version = "1.96.0"
3
+ version = "1.96.1"
4
4
  description = "Forgexa CLI — command-line client and AI agent runtime for the Forgexa platform"
5
5
  requires-python = ">=3.9"
6
6
  license = "MIT"
File without changes
File without changes