|
13 | 13 | AGENT_BACKEND_CLAUDE_CODE, |
14 | 14 | AGENT_BACKEND_DYNACONF_ENV_VAR, |
15 | 15 | AGENT_BACKEND_ENV_VAR, |
16 | | - AUTOSKILLIT_APPLICABLE_GUARDS, |
17 | | - AUTOSKILLIT_WRITE_GUARD_TOOL_NAMES, |
18 | 16 | CAMPAIGN_ID_ENV_VAR, |
19 | 17 | CLAUDE_CODE_CAPABILITIES, |
20 | 18 | CONTEXT_EXHAUSTION_MARKER, |
| 19 | + NON_VARIADIC_CLAUDE_FLAGS, |
21 | 20 | ORCHESTRATOR_SESSION_REQUIRED_ENV, |
22 | 21 | SESSION_TYPE_ORCHESTRATOR, |
23 | 22 | SESSION_TYPE_SKILL, |
24 | 23 | SKILL_SESSION_REQUIRED_ENV, |
| 24 | + VARIADIC_CLAUDE_FLAGS, |
25 | 25 | AgentSessionResult, |
26 | 26 | BackendCapabilities, |
27 | 27 | BackendConventions, |
@@ -285,17 +285,8 @@ def _env_policy(self) -> ClaudeEnvPolicy: |
285 | 285 |
|
286 | 286 | def _flag_vocabulary(self) -> FlagVocabulary: |
287 | 287 | return FlagVocabulary( |
288 | | - variadic_flags=frozenset( |
289 | | - {ClaudeFlags.ADD_DIR, ClaudeFlags.PLUGIN_DIR, ClaudeFlags.TOOLS} |
290 | | - ), |
291 | | - non_variadic_flags=frozenset( |
292 | | - { |
293 | | - ClaudeFlags.PRINT, |
294 | | - ClaudeFlags.MODEL, |
295 | | - ClaudeFlags.RESUME, |
296 | | - ClaudeFlags.DANGEROUSLY_SKIP_PERMISSIONS, |
297 | | - } |
298 | | - ), |
| 288 | + variadic_flags=VARIADIC_CLAUDE_FLAGS, |
| 289 | + non_variadic_flags=NON_VARIADIC_CLAUDE_FLAGS, |
299 | 290 | model_flag=ClaudeFlags.MODEL, |
300 | 291 | add_dir_flag=ClaudeFlags.ADD_DIR, |
301 | 292 | resume_flag=ClaudeFlags.RESUME, |
@@ -534,71 +525,25 @@ def build_skill_session_cmd( |
534 | 525 | resume_message: str | None = None, |
535 | 526 | ) -> CmdSpec: |
536 | 527 | if config is not None: |
537 | | - return self._build_skill_session_cmd_impl( |
538 | | - skill_command, |
539 | | - cwd=cwd, |
540 | | - completion_marker=config.completion_marker, |
541 | | - model=config.model, |
542 | | - plugin_source=config.plugin_source, |
543 | | - output_format=config.output_format, |
544 | | - add_dirs=config.add_dirs, |
545 | | - exit_after_stop_delay_ms=config.exit_after_stop_delay_ms, |
546 | | - stream_idle_timeout_ms=config.stream_idle_timeout_ms, |
547 | | - scenario_step_name=config.scenario_step_name, |
548 | | - temp_dir_relpath=config.temp_dir_relpath, |
549 | | - allowed_write_prefix=config.allowed_write_prefix, |
550 | | - allowed_write_prefixes=config.allowed_write_prefixes, |
551 | | - provider_extras=config.provider_extras, |
552 | | - profile_name=config.profile_name, |
553 | | - resume_session_id=config.resume_session_id, |
554 | | - resume_checkpoint=config.resume_checkpoint, |
555 | | - resume_message=config.resume_message, |
556 | | - sandbox_mode=config.sandbox_mode, |
557 | | - ) |
558 | | - return self._build_skill_session_cmd_impl( |
559 | | - skill_command, |
560 | | - cwd=cwd, |
561 | | - completion_marker=completion_marker, |
562 | | - model=model, |
563 | | - plugin_source=plugin_source, |
564 | | - output_format=output_format, |
565 | | - add_dirs=add_dirs, |
566 | | - exit_after_stop_delay_ms=exit_after_stop_delay_ms, |
567 | | - stream_idle_timeout_ms=stream_idle_timeout_ms, |
568 | | - scenario_step_name=scenario_step_name, |
569 | | - temp_dir_relpath=temp_dir_relpath, |
570 | | - allowed_write_prefix=allowed_write_prefix, |
571 | | - allowed_write_prefixes=allowed_write_prefixes, |
572 | | - provider_extras=provider_extras, |
573 | | - profile_name=profile_name, |
574 | | - resume_session_id=resume_session_id, |
575 | | - resume_checkpoint=resume_checkpoint, |
576 | | - resume_message=resume_message, |
577 | | - ) |
| 528 | + cfg = self._apply_config(config) |
| 529 | + completion_marker = cfg["completion_marker"] |
| 530 | + model = cfg["model"] |
| 531 | + plugin_source = cfg["plugin_source"] |
| 532 | + output_format = cfg["output_format"] |
| 533 | + add_dirs = cfg["add_dirs"] |
| 534 | + exit_after_stop_delay_ms = cfg["exit_after_stop_delay_ms"] |
| 535 | + stream_idle_timeout_ms = cfg["stream_idle_timeout_ms"] |
| 536 | + scenario_step_name = cfg["scenario_step_name"] |
| 537 | + temp_dir_relpath = cfg["temp_dir_relpath"] |
| 538 | + allowed_write_prefix = cfg["allowed_write_prefix"] |
| 539 | + allowed_write_prefixes = cfg["allowed_write_prefixes"] |
| 540 | + provider_extras = cfg["provider_extras"] |
| 541 | + profile_name = cfg["profile_name"] |
| 542 | + resume_session_id = cfg["resume_session_id"] |
| 543 | + resume_checkpoint = cfg["resume_checkpoint"] |
| 544 | + resume_message = cfg["resume_message"] |
| 545 | + sandbox_mode = cfg["sandbox_mode"] # noqa: F841 |
578 | 546 |
|
579 | | - def _build_skill_session_cmd_impl( |
580 | | - self, |
581 | | - skill_command: str, |
582 | | - *, |
583 | | - cwd: str, |
584 | | - completion_marker: str, |
585 | | - model: str | None, |
586 | | - plugin_source: PluginSource | None, |
587 | | - output_format: OutputFormat, |
588 | | - add_dirs: Sequence[ValidatedAddDir] = (), |
589 | | - exit_after_stop_delay_ms: int = 0, |
590 | | - stream_idle_timeout_ms: int = 0, |
591 | | - scenario_step_name: str = "", |
592 | | - temp_dir_relpath: str | None = None, |
593 | | - allowed_write_prefix: str = "", |
594 | | - allowed_write_prefixes: tuple[str, ...] = (), |
595 | | - provider_extras: Mapping[str, str] | None = None, |
596 | | - profile_name: str = "", |
597 | | - resume_session_id: str = "", |
598 | | - resume_checkpoint: SessionCheckpoint | None = None, |
599 | | - resume_message: str | None = None, |
600 | | - sandbox_mode: str = "workspace-write", |
601 | | - ) -> CmdSpec: |
602 | 547 | _has_prefix = ( |
603 | 548 | bool(profile_name) |
604 | 549 | and skill_command.strip().startswith("/") |
@@ -632,28 +577,21 @@ def _build_skill_session_cmd_impl( |
632 | 577 | profile_name=profile_name, |
633 | 578 | ), |
634 | 579 | ) |
635 | | - extras: dict[str, str] = { |
636 | | - "AUTOSKILLIT_HEADLESS": "1", |
637 | | - "AUTOSKILLIT_SESSION_TYPE": SESSION_TYPE_SKILL, |
638 | | - AGENT_BACKEND_ENV_VAR: AGENT_BACKEND_CLAUDE_CODE, |
639 | | - AGENT_BACKEND_DYNACONF_ENV_VAR: AGENT_BACKEND_CLAUDE_CODE, |
640 | | - AUTOSKILLIT_APPLICABLE_GUARDS: ",".join(sorted(self.capabilities.applicable_guards)), |
641 | | - AUTOSKILLIT_WRITE_GUARD_TOOL_NAMES: ",".join( |
642 | | - sorted(self.capabilities.write_guard_tool_names) |
643 | | - ), |
644 | | - } |
| 580 | + extras = self._assemble_shared_env_extras( |
| 581 | + session_type=SESSION_TYPE_SKILL, |
| 582 | + applicable_guards=self.capabilities.applicable_guards, |
| 583 | + write_guard_tool_names=self.capabilities.write_guard_tool_names, |
| 584 | + write_prefix=allowed_write_prefix, |
| 585 | + write_prefixes=allowed_write_prefixes, |
| 586 | + cwd=cwd, |
| 587 | + scenario_step_name=scenario_step_name, |
| 588 | + ) |
| 589 | + extras[AGENT_BACKEND_DYNACONF_ENV_VAR] = AGENT_BACKEND_CLAUDE_CODE |
| 590 | + extras[AGENT_BACKEND_ENV_VAR] = AGENT_BACKEND_CLAUDE_CODE |
645 | 591 | if exit_after_stop_delay_ms > 0: |
646 | 592 | extras["CLAUDE_CODE_EXIT_AFTER_STOP_DELAY"] = str(exit_after_stop_delay_ms) |
647 | 593 | if stream_idle_timeout_ms > 0: |
648 | 594 | extras["CLAUDE_STREAM_IDLE_TIMEOUT_MS"] = str(stream_idle_timeout_ms) |
649 | | - extras.update( |
650 | | - self._assemble_shared_env_extras( |
651 | | - write_prefix=allowed_write_prefix, |
652 | | - write_prefixes=allowed_write_prefixes, |
653 | | - cwd=cwd, |
654 | | - scenario_step_name=scenario_step_name, |
655 | | - ) |
656 | | - ) |
657 | 595 | extras["AUTOSKILLIT_SKILL_NAME"] = extract_skill_name(skill_command) or "" |
658 | 596 | if provider_extras: |
659 | 597 | for k, v in provider_extras.items(): |
@@ -729,28 +667,21 @@ def build_food_truck_cmd( |
729 | 667 | ), |
730 | 668 | ) |
731 | 669 |
|
732 | | - extras: dict[str, str] = { |
733 | | - "AUTOSKILLIT_HEADLESS": "1", |
734 | | - "AUTOSKILLIT_SESSION_TYPE": SESSION_TYPE_ORCHESTRATOR, |
735 | | - AGENT_BACKEND_ENV_VAR: AGENT_BACKEND_CLAUDE_CODE, |
736 | | - AGENT_BACKEND_DYNACONF_ENV_VAR: AGENT_BACKEND_CLAUDE_CODE, |
737 | | - AUTOSKILLIT_APPLICABLE_GUARDS: ",".join(sorted(self.capabilities.applicable_guards)), |
738 | | - AUTOSKILLIT_WRITE_GUARD_TOOL_NAMES: ",".join( |
739 | | - sorted(self.capabilities.write_guard_tool_names) |
740 | | - ), |
741 | | - } |
| 670 | + extras = self._assemble_shared_env_extras( |
| 671 | + session_type=SESSION_TYPE_ORCHESTRATOR, |
| 672 | + applicable_guards=self.capabilities.applicable_guards, |
| 673 | + write_guard_tool_names=self.capabilities.write_guard_tool_names, |
| 674 | + write_prefix=allowed_write_prefix, |
| 675 | + write_prefixes=allowed_write_prefixes, |
| 676 | + cwd=cwd, |
| 677 | + scenario_step_name=scenario_step_name, |
| 678 | + ) |
| 679 | + extras[AGENT_BACKEND_ENV_VAR] = AGENT_BACKEND_CLAUDE_CODE |
| 680 | + extras[AGENT_BACKEND_DYNACONF_ENV_VAR] = AGENT_BACKEND_CLAUDE_CODE |
742 | 681 | if exit_after_stop_delay_ms > 0: |
743 | 682 | extras["CLAUDE_CODE_EXIT_AFTER_STOP_DELAY"] = str(exit_after_stop_delay_ms) |
744 | 683 | if stream_idle_timeout_ms > 0: |
745 | 684 | extras["CLAUDE_STREAM_IDLE_TIMEOUT_MS"] = str(stream_idle_timeout_ms) |
746 | | - extras.update( |
747 | | - self._assemble_shared_env_extras( |
748 | | - write_prefix=allowed_write_prefix, |
749 | | - write_prefixes=allowed_write_prefixes, |
750 | | - cwd=cwd, |
751 | | - scenario_step_name=scenario_step_name, |
752 | | - ) |
753 | | - ) |
754 | 685 | extras.pop(CAMPAIGN_ID_ENV_VAR, None) # food truck does not propagate campaign ID |
755 | 686 | if env_extras: |
756 | 687 | for k, v in env_extras.items(): |
|
0 commit comments