qoder-agent-sdk 1.0.15__tar.gz → 1.0.17__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.
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/PKG-INFO +29 -1
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/README.md +28 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/pyproject.toml +1 -1
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/__init__.py +117 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_cli_version.py +1 -1
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/client.py +59 -11
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/_internal/daemon_connection.py +832 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/message_parser.py +26 -8
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/_internal/plugin_reports.py +116 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/query.py +419 -63
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/transport/__init__.py +4 -0
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/_internal/transport/daemon_process.py +222 -0
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/_internal/transport/daemon_session.py +392 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/transport/subprocess_cli.py +89 -85
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/_tool_results.py +38 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_version.py +1 -1
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/client.py +125 -9
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/daemon.py +963 -0
- qoder_agent_sdk-1.0.17/src/qoder_agent_sdk/daemon_types.py +348 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/plugins.py +44 -110
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/types.py +101 -3
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/.gitignore +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/LICENSE +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_brand.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_bundled/.gitignore +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_errors.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/__init__.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/auth_helpers.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/cloud_agent.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/mcp_handler.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/mcp_serialize.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/memory.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/sdk_mcp_transport.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/session_mutations.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/session_storage.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/sessions.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/_internal/skill_evolution.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/auth.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/memory.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/py.typed +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/query.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/session_import.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/session_store.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/settings.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/store_sessions.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/testing/__init__.py +0 -0
- {qoder_agent_sdk-1.0.15 → qoder_agent_sdk-1.0.17}/src/qoder_agent_sdk/testing/session_store_conformance.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: qoder-agent-sdk
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.17
|
|
4
4
|
Summary: Python SDK for Qoder Agent
|
|
5
5
|
Author: Qoder
|
|
6
6
|
License: Copyright (c) 2026 Qoder
|
|
@@ -315,6 +315,34 @@ cancellation, and do not reuse UUIDs within a session.
|
|
|
315
315
|
`await client.cancel_async_message(message_uuid)` returns `True` when the
|
|
316
316
|
queued message is cancelled and `False` when it can no longer be cancelled.
|
|
317
317
|
|
|
318
|
+
Manage background tasks from a connected `QoderSDKClient`:
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
await client.background_tasks(tool_use_id) # ToolUseBlock.id; omit for bulk conversion
|
|
322
|
+
await client.stop_task(task_id) # TaskStartedMessage.task_id
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
`background_tasks()` moves running foreground Bash / Agent executions into the
|
|
326
|
+
background; it does not list tasks. A targeted call returns whether the execution
|
|
327
|
+
moved; bulk `True` acknowledges the request without guaranteeing a transition.
|
|
328
|
+
`stop_task()` returns `None` and leaves the main turn and other independent tasks
|
|
329
|
+
running. Unknown IDs and repeated stops are safe no-ops. Both methods require the
|
|
330
|
+
CLI capability `background_tasks_v1` (otherwise `UnsupportedCliCapabilityError`)
|
|
331
|
+
and are unavailable in Cloud Agent sessions.
|
|
332
|
+
|
|
333
|
+
`interrupt()` does not stop existing background tasks. To clean them up, continue
|
|
334
|
+
consuming `receive_messages()` after the main `ResultMessage`, replace the roster
|
|
335
|
+
on each `BackgroundTasksChangedMessage`, and stop each task separately. Bulk
|
|
336
|
+
conversion can detach an Agent's Bash execution as an independent task.
|
|
337
|
+
|
|
338
|
+
Use `AgentDefinition(background=True, ...)` to launch delegated agents in the
|
|
339
|
+
background. Merge `TaskUpdatedMessage.patch` into stored task state. Task events
|
|
340
|
+
retain raw `data`; optional metadata depends on the CLI. Missing progress `usage`
|
|
341
|
+
is `None`, and `total_tokens` can be absent within usage.
|
|
342
|
+
|
|
343
|
+
For event fields, launch result types, the Bash result guard, and examples, see
|
|
344
|
+
[Python SDK Reference](https://docs.qoder.com/cli/sdk/references-python#clientstop-task).
|
|
345
|
+
|
|
318
346
|
## External Session Storage
|
|
319
347
|
|
|
320
348
|
Use `session_store` when a host needs durable transcripts outside the local
|
|
@@ -273,6 +273,34 @@ cancellation, and do not reuse UUIDs within a session.
|
|
|
273
273
|
`await client.cancel_async_message(message_uuid)` returns `True` when the
|
|
274
274
|
queued message is cancelled and `False` when it can no longer be cancelled.
|
|
275
275
|
|
|
276
|
+
Manage background tasks from a connected `QoderSDKClient`:
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
await client.background_tasks(tool_use_id) # ToolUseBlock.id; omit for bulk conversion
|
|
280
|
+
await client.stop_task(task_id) # TaskStartedMessage.task_id
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
`background_tasks()` moves running foreground Bash / Agent executions into the
|
|
284
|
+
background; it does not list tasks. A targeted call returns whether the execution
|
|
285
|
+
moved; bulk `True` acknowledges the request without guaranteeing a transition.
|
|
286
|
+
`stop_task()` returns `None` and leaves the main turn and other independent tasks
|
|
287
|
+
running. Unknown IDs and repeated stops are safe no-ops. Both methods require the
|
|
288
|
+
CLI capability `background_tasks_v1` (otherwise `UnsupportedCliCapabilityError`)
|
|
289
|
+
and are unavailable in Cloud Agent sessions.
|
|
290
|
+
|
|
291
|
+
`interrupt()` does not stop existing background tasks. To clean them up, continue
|
|
292
|
+
consuming `receive_messages()` after the main `ResultMessage`, replace the roster
|
|
293
|
+
on each `BackgroundTasksChangedMessage`, and stop each task separately. Bulk
|
|
294
|
+
conversion can detach an Agent's Bash execution as an independent task.
|
|
295
|
+
|
|
296
|
+
Use `AgentDefinition(background=True, ...)` to launch delegated agents in the
|
|
297
|
+
background. Merge `TaskUpdatedMessage.patch` into stored task state. Task events
|
|
298
|
+
retain raw `data`; optional metadata depends on the CLI. Missing progress `usage`
|
|
299
|
+
is `None`, and `total_tokens` can be absent within usage.
|
|
300
|
+
|
|
301
|
+
For event fields, launch result types, the Bash result guard, and examples, see
|
|
302
|
+
[Python SDK Reference](https://docs.qoder.com/cli/sdk/references-python#clientstop-task).
|
|
303
|
+
|
|
276
304
|
## External Session Storage
|
|
277
305
|
|
|
278
306
|
Use `session_store` when a host needs durable transcripts outside the local
|
|
@@ -50,6 +50,7 @@ from ._internal.sessions import (
|
|
|
50
50
|
project_key_for_directory,
|
|
51
51
|
)
|
|
52
52
|
from ._internal.transport import Transport
|
|
53
|
+
from ._tool_results import is_bash_tool_background_launch_result
|
|
53
54
|
from ._version import __version__
|
|
54
55
|
from .auth import (
|
|
55
56
|
DEFAULT_ACCESS_TOKEN_ENV_VAR,
|
|
@@ -78,6 +79,58 @@ from .auth import (
|
|
|
78
79
|
service_account_from_env,
|
|
79
80
|
)
|
|
80
81
|
from .client import QoderSDKClient
|
|
82
|
+
from .daemon import (
|
|
83
|
+
Daemon,
|
|
84
|
+
DaemonOptions,
|
|
85
|
+
init_daemon,
|
|
86
|
+
shutdown_daemon,
|
|
87
|
+
start_daemon,
|
|
88
|
+
)
|
|
89
|
+
from .daemon_types import (
|
|
90
|
+
DAEMON_HEARTBEAT_TIMEOUT_MS,
|
|
91
|
+
DAEMON_PROXY_CAPABILITY,
|
|
92
|
+
DAEMON_VALIDATE_PLUGINS_CAPABILITY,
|
|
93
|
+
AccountInfo,
|
|
94
|
+
ByokConfigCheckDetails,
|
|
95
|
+
ByokConfigCheckResult,
|
|
96
|
+
ByokConfigInfo,
|
|
97
|
+
ByokConfigReference,
|
|
98
|
+
ByokModelConfigInfo,
|
|
99
|
+
ByokModelConfigInput,
|
|
100
|
+
ByokModelConfigReference,
|
|
101
|
+
BYOKModelValidationInput,
|
|
102
|
+
ByokProtocol,
|
|
103
|
+
CheckByokConfigInput,
|
|
104
|
+
CreateByokConfigInput,
|
|
105
|
+
CustomByokProviderConfigInfo,
|
|
106
|
+
CustomByokProviderConfigInput,
|
|
107
|
+
CustomByokProviderConfigReference,
|
|
108
|
+
CustomByokProviderModelCapabilitiesInput,
|
|
109
|
+
CustomByokProviderModelConfigInfo,
|
|
110
|
+
CustomByokProviderModelInput,
|
|
111
|
+
CustomByokProviderReasoningEffortLevel,
|
|
112
|
+
CustomByokProviderThinkingCapabilitiesInput,
|
|
113
|
+
CustomByokProviderThinkingMode,
|
|
114
|
+
DaemonConfigurationConflictError,
|
|
115
|
+
DaemonDirectResult,
|
|
116
|
+
DaemonFallbackReason,
|
|
117
|
+
DaemonGetModelsParams,
|
|
118
|
+
DaemonHeartbeatTimeoutError,
|
|
119
|
+
DaemonInitResult,
|
|
120
|
+
DaemonProtocolError,
|
|
121
|
+
DaemonProtocolVersionMismatchError,
|
|
122
|
+
DaemonReadyResult,
|
|
123
|
+
DaemonRpcError,
|
|
124
|
+
DaemonSessionAlreadyOpenError,
|
|
125
|
+
DaemonSessionInfo,
|
|
126
|
+
DaemonState,
|
|
127
|
+
DaemonValidateByokModelParams,
|
|
128
|
+
DeleteByokConfigInput,
|
|
129
|
+
SessionRuntimeState,
|
|
130
|
+
UpdateByokConfigInput,
|
|
131
|
+
UpdateByokModelConfigInput,
|
|
132
|
+
UpdateCustomByokProviderConfigInput,
|
|
133
|
+
)
|
|
81
134
|
from .memory import (
|
|
82
135
|
EffectiveMemoryConfig,
|
|
83
136
|
EffectiveMemoryRoot,
|
|
@@ -129,10 +182,14 @@ from .types import (
|
|
|
129
182
|
MAX_SKILL_EVOLUTION_REVIEW_THRESHOLD,
|
|
130
183
|
AgentCreateParams,
|
|
131
184
|
AgentDefinition,
|
|
185
|
+
AgentToolBackgroundLaunchResult,
|
|
132
186
|
AssistantMessage,
|
|
133
187
|
AssistantMessageWithRequestId,
|
|
134
188
|
AsyncHookJSONOutput,
|
|
189
|
+
BackgroundTask,
|
|
190
|
+
BackgroundTasksChangedMessage,
|
|
135
191
|
BaseHookInput,
|
|
192
|
+
BashToolBackgroundLaunchResult,
|
|
136
193
|
BetaManagedAgentsAgentToolName,
|
|
137
194
|
BetaManagedAgentsAgentToolset20260401Params,
|
|
138
195
|
BetaManagedAgentsCustomSkillParams,
|
|
@@ -331,6 +388,9 @@ from .types import (
|
|
|
331
388
|
TaskNotificationStatus,
|
|
332
389
|
TaskProgressMessage,
|
|
333
390
|
TaskStartedMessage,
|
|
391
|
+
TaskStatus,
|
|
392
|
+
TaskUpdatedMessage,
|
|
393
|
+
TaskUpdatePatch,
|
|
334
394
|
TaskUsage,
|
|
335
395
|
TextBlock,
|
|
336
396
|
ThinkingBlock,
|
|
@@ -901,6 +961,55 @@ __all__ = [
|
|
|
901
961
|
# Main exports
|
|
902
962
|
"query",
|
|
903
963
|
"__version__",
|
|
964
|
+
"Daemon",
|
|
965
|
+
"DaemonOptions",
|
|
966
|
+
"start_daemon",
|
|
967
|
+
"init_daemon",
|
|
968
|
+
"shutdown_daemon",
|
|
969
|
+
# daemon_types.__all__
|
|
970
|
+
"AccountInfo",
|
|
971
|
+
"DaemonState",
|
|
972
|
+
"SessionRuntimeState",
|
|
973
|
+
"DaemonFallbackReason",
|
|
974
|
+
"DaemonSessionInfo",
|
|
975
|
+
"DaemonReadyResult",
|
|
976
|
+
"DaemonDirectResult",
|
|
977
|
+
"DaemonInitResult",
|
|
978
|
+
"DaemonRpcError",
|
|
979
|
+
"DaemonProtocolError",
|
|
980
|
+
"DaemonProtocolVersionMismatchError",
|
|
981
|
+
"DaemonConfigurationConflictError",
|
|
982
|
+
"DaemonHeartbeatTimeoutError",
|
|
983
|
+
"DaemonSessionAlreadyOpenError",
|
|
984
|
+
"DAEMON_HEARTBEAT_TIMEOUT_MS",
|
|
985
|
+
"DAEMON_PROXY_CAPABILITY",
|
|
986
|
+
"DAEMON_VALIDATE_PLUGINS_CAPABILITY",
|
|
987
|
+
"DaemonGetModelsParams",
|
|
988
|
+
"BYOKModelValidationInput",
|
|
989
|
+
"DaemonValidateByokModelParams",
|
|
990
|
+
"ByokProtocol",
|
|
991
|
+
"ByokModelConfigInfo",
|
|
992
|
+
"CustomByokProviderConfigInfo",
|
|
993
|
+
"CustomByokProviderModelConfigInfo",
|
|
994
|
+
"CustomByokProviderThinkingMode",
|
|
995
|
+
"CustomByokProviderReasoningEffortLevel",
|
|
996
|
+
"ByokConfigInfo",
|
|
997
|
+
"ByokModelConfigInput",
|
|
998
|
+
"CustomByokProviderThinkingCapabilitiesInput",
|
|
999
|
+
"CustomByokProviderModelCapabilitiesInput",
|
|
1000
|
+
"CustomByokProviderModelInput",
|
|
1001
|
+
"CustomByokProviderConfigInput",
|
|
1002
|
+
"CreateByokConfigInput",
|
|
1003
|
+
"CheckByokConfigInput",
|
|
1004
|
+
"UpdateByokModelConfigInput",
|
|
1005
|
+
"UpdateCustomByokProviderConfigInput",
|
|
1006
|
+
"UpdateByokConfigInput",
|
|
1007
|
+
"ByokModelConfigReference",
|
|
1008
|
+
"CustomByokProviderConfigReference",
|
|
1009
|
+
"ByokConfigReference",
|
|
1010
|
+
"DeleteByokConfigInput",
|
|
1011
|
+
"ByokConfigCheckDetails",
|
|
1012
|
+
"ByokConfigCheckResult",
|
|
904
1013
|
# Auth helpers
|
|
905
1014
|
"DEFAULT_ACCESS_TOKEN_ENV_VAR",
|
|
906
1015
|
"DEFAULT_SERVICE_ACCOUNT_ENV_VAR",
|
|
@@ -983,6 +1092,14 @@ __all__ = [
|
|
|
983
1092
|
"TaskNotificationMessage",
|
|
984
1093
|
"TaskNotificationStatus",
|
|
985
1094
|
"TaskUsage",
|
|
1095
|
+
"TaskStatus",
|
|
1096
|
+
"TaskUpdatePatch",
|
|
1097
|
+
"TaskUpdatedMessage",
|
|
1098
|
+
"BackgroundTask",
|
|
1099
|
+
"BackgroundTasksChangedMessage",
|
|
1100
|
+
"BashToolBackgroundLaunchResult",
|
|
1101
|
+
"AgentToolBackgroundLaunchResult",
|
|
1102
|
+
"is_bash_tool_background_launch_result",
|
|
986
1103
|
"ResultMessage",
|
|
987
1104
|
"StreamEvent",
|
|
988
1105
|
"CloudAgentEventMessage",
|
|
@@ -27,6 +27,7 @@ from .skill_evolution import (
|
|
|
27
27
|
prepare_evolution_options,
|
|
28
28
|
)
|
|
29
29
|
from .transport import Transport
|
|
30
|
+
from .transport.daemon_session import validate_daemon_session_options
|
|
30
31
|
from .transport.subprocess_cli import SubprocessCLITransport
|
|
31
32
|
|
|
32
33
|
|
|
@@ -62,6 +63,14 @@ class InternalClient:
|
|
|
62
63
|
) -> AsyncIterator[Message]:
|
|
63
64
|
"""Process a query through transport and Query."""
|
|
64
65
|
|
|
66
|
+
if options.daemon is not None:
|
|
67
|
+
if transport is not None:
|
|
68
|
+
raise ValueError("daemon cannot be combined with a custom transport")
|
|
69
|
+
if options.experimental_cloud_agent is not None:
|
|
70
|
+
raise ValueError(
|
|
71
|
+
"daemon cannot be combined with experimental_cloud_agent"
|
|
72
|
+
)
|
|
73
|
+
|
|
65
74
|
# Validate and configure permission settings (matching TypeScript SDK logic)
|
|
66
75
|
configured_options = options
|
|
67
76
|
normalized_evolution, normalized_skill_evolution = prepare_evolution_options(
|
|
@@ -94,7 +103,9 @@ class InternalClient:
|
|
|
94
103
|
)
|
|
95
104
|
|
|
96
105
|
# Automatically set permission_prompt_tool_name to "stdio" for control protocol
|
|
97
|
-
configured_options = replace(
|
|
106
|
+
configured_options = replace(
|
|
107
|
+
configured_options, permission_prompt_tool_name="stdio"
|
|
108
|
+
)
|
|
98
109
|
|
|
99
110
|
on_auth_expired = once_callback(configured_options.on_auth_expired)
|
|
100
111
|
if on_auth_expired is not None:
|
|
@@ -102,6 +113,9 @@ class InternalClient:
|
|
|
102
113
|
configured_options, on_auth_expired=on_auth_expired
|
|
103
114
|
)
|
|
104
115
|
|
|
116
|
+
# Fail fast on invalid daemon session options before touching the Store.
|
|
117
|
+
if configured_options.daemon is not None:
|
|
118
|
+
validate_daemon_session_options(configured_options)
|
|
105
119
|
prepared_memory = prepare_memory_options(configured_options.memory)
|
|
106
120
|
requires_store_resume = configured_options.session_store is not None and (
|
|
107
121
|
configured_options.resume is not None
|
|
@@ -120,18 +134,43 @@ class InternalClient:
|
|
|
120
134
|
else None
|
|
121
135
|
)
|
|
122
136
|
if materialized_session is not None:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
updates: dict[str, Any] = {
|
|
138
|
+
"resume": materialized_session.session_id,
|
|
139
|
+
"continue_conversation": False,
|
|
140
|
+
}
|
|
141
|
+
if configured_options.daemon is None:
|
|
142
|
+
# Daemon sessions carry the config dir per session in
|
|
143
|
+
# open_session; a shared process env cannot express it.
|
|
144
|
+
updates["env"] = {
|
|
128
145
|
**configured_options.env,
|
|
129
146
|
CONFIG_DIR_ENV: str(materialized_session.config_dir),
|
|
130
|
-
}
|
|
147
|
+
}
|
|
148
|
+
configured_options = replace(configured_options, **updates)
|
|
149
|
+
elif requires_store_resume and configured_options.continue_conversation:
|
|
150
|
+
# The Store resolved no restorable transcript: start fresh instead
|
|
151
|
+
# of consulting local continue history (explicit resume stays for
|
|
152
|
+
# the CLI's local-transcript fallback).
|
|
153
|
+
configured_options = replace(
|
|
154
|
+
configured_options, continue_conversation=False
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
daemon_transport = (
|
|
158
|
+
configured_options.daemon._create_transport(
|
|
159
|
+
configured_options,
|
|
160
|
+
config_dir=(
|
|
161
|
+
str(materialized_session.config_dir)
|
|
162
|
+
if materialized_session is not None
|
|
163
|
+
else None
|
|
164
|
+
),
|
|
131
165
|
)
|
|
166
|
+
if configured_options.daemon is not None
|
|
167
|
+
else None
|
|
168
|
+
)
|
|
132
169
|
|
|
133
|
-
# Use
|
|
134
|
-
if
|
|
170
|
+
# Use the selected daemon, custom, or legacy subprocess transport.
|
|
171
|
+
if daemon_transport is not None:
|
|
172
|
+
chosen_transport = daemon_transport
|
|
173
|
+
elif transport is not None:
|
|
135
174
|
chosen_transport = transport
|
|
136
175
|
else:
|
|
137
176
|
chosen_transport = SubprocessCLITransport(
|
|
@@ -201,6 +240,7 @@ class InternalClient:
|
|
|
201
240
|
session_store_flush=configured_options.session_store_flush,
|
|
202
241
|
default_custom_context=configured_options.custom_context,
|
|
203
242
|
skill_evolution=normalized_skill_evolution,
|
|
243
|
+
finite_input=True,
|
|
204
244
|
)
|
|
205
245
|
except BaseException:
|
|
206
246
|
await chosen_transport.close()
|
|
@@ -226,10 +266,18 @@ class InternalClient:
|
|
|
226
266
|
"parent_tool_use_id": None,
|
|
227
267
|
}
|
|
228
268
|
await query.write_user_message(user_message)
|
|
229
|
-
|
|
269
|
+
if configured_options.daemon is not None:
|
|
270
|
+
query.spawn_task(
|
|
271
|
+
query.wait_for_result_and_end_input(), input_task=True
|
|
272
|
+
)
|
|
273
|
+
else:
|
|
274
|
+
query.spawn_task(query.wait_for_result_and_end_input())
|
|
230
275
|
elif isinstance(prompt, AsyncIterable):
|
|
231
276
|
# Stream input in background for async iterables
|
|
232
|
-
|
|
277
|
+
if configured_options.daemon is not None:
|
|
278
|
+
query.spawn_task(query.stream_input(prompt), input_task=True)
|
|
279
|
+
else:
|
|
280
|
+
query.spawn_task(query.stream_input(prompt))
|
|
233
281
|
|
|
234
282
|
# Yield parsed messages, skipping unknown message types
|
|
235
283
|
async for data in query.receive_messages():
|