Class: PromptObjects::Universal::DeleteEnvData
- Inherits:
-
Primitive
show all
- Defined in:
- lib/prompt_objects/universal/delete_env_data.rb
Overview
Universal capability to delete a key from the shared environment data.
Instance Attribute Summary
Attributes inherited from Capability
#state
Instance Method Summary
collapse
Methods inherited from Primitive
#initialize
Methods inherited from Capability
#descriptor, execution_policy, execution_policy_definition, #execution_policy_definition, #execution_policy_signature, #initialize, #resolved_execution_policy
Instance Method Details
#description ⇒ Object
20
21
22
|
# File 'lib/prompt_objects/universal/delete_env_data.rb', line 20
def description
"Delete a key from the shared environment data for this delegation chain."
end
|
#name ⇒ Object
16
17
18
|
# File 'lib/prompt_objects/universal/delete_env_data.rb', line 16
def name
"delete_env_data"
end
|
#parameters ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/prompt_objects/universal/delete_env_data.rb', line 24
def parameters
{
type: "object",
properties: {
key: {
type: "string",
description: "The key to delete"
}
},
required: ["key"]
}
end
|
#receive(message, context:) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/prompt_objects/universal/delete_env_data.rb', line 37
def receive(message, context:)
key = message[:key] || message["key"]
return "Error: 'key' is required" unless key
root_thread_id = context.env_data_scope
return "Error: Could not resolve thread scope (no active session)" unless root_thread_id
store = context.env.session_store
return "Error: Session store not available" unless store
deleted = if context.env.respond_to?(:delete_environment_data)
context.env.delete_environment_data(key: key, context: context)
else
store.delete_env_data(root_thread_id: root_thread_id, key: key)
end
unless deleted
return "Key '#{key}' not found in environment data."
end
stored_by = context.calling_po || "unknown"
context.bus.publish(
from: stored_by,
to: "env_data",
message: { action: "delete", key: key }
)
unless context.env.respond_to?(:delete_environment_data)
context.env.notify_env_data_changed(
action: "delete",
root_thread_id: root_thread_id,
key: key,
stored_by: stored_by
)
end
"Deleted '#{key}' from environment data."
end
|