Factory
Object Hierarchy:
Description:
public class Factory : Object
Base class for agent factories.
Provides common functionality for loading resource sections based on agent name. Can be used directly as a default implementation that
returns empty system prompt and passes through user input.
Example
// Use as default (no modifications)
var factory = new Agent.Factory();
// Generate system and user prompts
string system_prompt = factory.system_message(null);
string user_prompt = factory.generate_user_prompt("User question");
// Or create custom factory
public class MyFactory : Agent.Factory {
public override string system_message(Base? handler = null) throws Error {
return "You are a helpful assistant.";
}
}
Content:
Properties:
- public string name { get; protected set; }
The name of the agent (e.g., "code-assistant"). Used to derive the
resource path.
- public string shell { get; set; }
User's shell (optional, can be set after construction).
- public string title { get; protected set; }
Display name for UI (e.g., "Code Assistant", "Just Ask").
Creation methods:
Methods:
- public virtual void configure_tools (Chat call)
Configures tools for the chat call.
- public virtual Base create_agent (SessionBase session)
Creates an agent instance for a specific request.
- public virtual string generate_user_prompt (string user_input) throws Error
Generates the user prompt sent to the API. Default implementation
returns the input as-is. Override to add context (e.g. current file, attached files, selection) via generate_context_section().
- public virtual string get_current_cursor_position ()
Gets the cursor position for the currently active file.
- public virtual string get_current_line_content (string cursor_pos)
Gets the content of a specific line in the currently active file.
- public virtual string get_file_contents (string file)
Gets the full contents of a file.
- public virtual ArrayList<string> get_open_files ()
Gets the list of currently open files.
- protected string get_os_version ()
Gets OS version directly (implemented here, not a signal).
- public virtual string get_selected_code ()
Gets the currently selected code from the active file.
- public virtual async Object? get_widget ()
Gets the UI widget for this agent, if any.
- public virtual string get_working_directory ()
Gets the working directory for command execution.
- public virtual string get_workspace_path ()
Gets the workspace path.
- protected string load_section (string section_name) throws Error
Loads a static section from resources.
- public virtual string system_message (Base? handler = null) throws Error
Generates the system message for the agent.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref