fsr-agentic-toolkit 0.3.2__tar.gz → 0.3.3__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.
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/PKG-INFO +1 -1
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/pyproject.toml +1 -1
- fsr_agentic_toolkit-0.3.3/src/fsr_agentic_toolkit/skills/module-building/SKILL.md +41 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/playbook-authoring/SKILL.md +42 -0
- fsr_agentic_toolkit-0.3.3/src/fsr_agentic_toolkit/skills_cmd.py +201 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/tools.py +48 -1
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/debug.py +5 -1
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/provision.py +21 -1
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_diagnose_run.py +2 -2
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_provision_publish_and_probe.py +21 -0
- fsr_agentic_toolkit-0.3.3/tests/test_query_picklist_labels.py +25 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_run_verify_chain.py +1 -1
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_skills_cmd.py +28 -1
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/uv.lock +9 -9
- fsr_agentic_toolkit-0.3.2/src/fsr_agentic_toolkit/skills_cmd.py +0 -104
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/.github/workflows/publish.yml +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/.github/workflows/tests.yml +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/.gitignore +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/AGENTS.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/Makefile +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/README.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/__init__.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/cli.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/init_cmd.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/reference/AUTHORING.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/alert-investigation/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/box-onboarding/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/connector-building/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/connector-secrets/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/debug-and-repair/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/prove-the-work/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/use-case-building/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/skills/widget-building/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/spec.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/__init__.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/__init__.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/harvest.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/record.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/router.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/seed/.gitkeep +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/seed/reconcile-and-report.json +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/archetypes/store.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/hints.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/mcp.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/mcp_http.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/widget_kit.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/widget_tools.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflow_tools.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/__init__.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/access.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/build.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/connector.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/connector_setup.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/investigate.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/orient.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/repair.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/result.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/run.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/verify.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/conftest.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/fixtures/widget_edit_closes_without_wid.js +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/fixtures/workflows/heist_intake.yaml +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/silent_noop_scenario.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_accuracy_guards.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_agent_safety.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_archetypes.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_build_connector.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_cli_agent_init.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_compile_is_the_gate.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_connector_verbs.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_debug_doubled_iri.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_debug_reference_fix.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_debug_static_prerun.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_find_and_bulk_update.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_init_codex_snippet.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_mcp.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_mcp_http.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_mcp_multi_instance.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_nested_cap.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_paging.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_picklist_dispatch.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_playbook_reference.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_provision_coerces_fields.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_register_arg_gate.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_registered_mcp_tools.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_related_comments_count.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_run_playbook_yaml.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_schedules.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_search_fallback.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_setup_connector.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_silent_noop_scenario.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_tool_deadline.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_tool_hints.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_tool_name_aliases.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_tools.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_whoami_auth_mode.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_widget_kit.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_widget_tools.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_workflow_debug_verify.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_workflow_first_surface.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_workflow_result.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_workflow_scenario.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_workflow_t2.py +0 -0
- {fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/workflow_scenario.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fsr-agentic-toolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: The agent layer for FortiSOAR: workflows and tools behind one safety gate, served as an MCP server, CLI, and Python API, on pyfsr and fsr-playbooks.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.11
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fsr-agentic-toolkit"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.3"
|
|
8
8
|
description = "The agent layer for FortiSOAR: workflows and tools behind one safety gate, served as an MCP server, CLI, and Python API, on pyfsr and fsr-playbooks."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: module-building
|
|
3
|
+
description: >-
|
|
4
|
+
Create or change a FortiSOAR custom module (its fields, picklists, role
|
|
5
|
+
permissions) and prove records can be written to it. Use when asked to add a
|
|
6
|
+
module, add fields to one, or when a new module rejects record writes.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Building a FortiSOAR module
|
|
10
|
+
|
|
11
|
+
## The loop
|
|
12
|
+
|
|
13
|
+
1. `survey_box(goal=..., modules=[<name>])`: does the module exist, is anything else
|
|
14
|
+
staged, which picklists exist. Reuse an existing picklist (Severity, Status...)
|
|
15
|
+
over inventing values.
|
|
16
|
+
2. `provision_module(module=..., label=..., fields=[...])` with no `confirm`. It
|
|
17
|
+
changes nothing and returns `confirmation_required` with the plan. Show the user
|
|
18
|
+
the fields and the roles it will grant.
|
|
19
|
+
3. Call again with `confirm=true` only after the user agrees. One call creates,
|
|
20
|
+
publishes, grants and proves read and create. Never hand-roll create_module +
|
|
21
|
+
publish_module_changes + a role grant: a module without a grant looks created and
|
|
22
|
+
answers 403 to every record write.
|
|
23
|
+
4. Read the result: `status: answered` with "the caller can create ... records" is
|
|
24
|
+
the proof. Then create the user's own first record and read it back.
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
|
|
28
|
+
- **Publish is box-wide.** It ships every staged schema change, not only yours.
|
|
29
|
+
provision_module refuses when other changes are staged: tell the user whose they
|
|
30
|
+
are, never publish them yourself.
|
|
31
|
+
- **Field specs:** `{"name": "hostname", "type": "text", "required": true}`. Types:
|
|
32
|
+
text, richtext, integer, decimal, boolean, date, picklist (with `"picklist":
|
|
33
|
+
"Severity"`), lookup. Names are lowercase with underscores.
|
|
34
|
+
- **Roles:** the default grant is Full App Permissions. Pass `roles=[...]` when the
|
|
35
|
+
user's login uses another role; `whoami` shows it.
|
|
36
|
+
- **Already exists:** call provision_module with just the module name. It skips the
|
|
37
|
+
create, grants and re-proves access. Use `check_only=true` to read the state without
|
|
38
|
+
changing anything.
|
|
39
|
+
- **Status partial:** follow its `next_action`. "publish did not make the module live"
|
|
40
|
+
means re-check with `check_only=true`; do not create the module again.
|
|
41
|
+
- **Picklist values in records:** pass the label ("High"); the record tools resolve it.
|
|
@@ -20,6 +20,48 @@ description: >-
|
|
|
20
20
|
5. Prove it: create a test record that should trigger it, `wait_for_playbook_run`,
|
|
21
21
|
then read the record back. The read-back is the proof, not the run status.
|
|
22
22
|
|
|
23
|
+
## A complete playbook to start from
|
|
24
|
+
|
|
25
|
+
This compiles as is. Change the module, the filter and the step; keep the shape.
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
collection: Agent Lab
|
|
29
|
+
description: Agent Lab playbooks
|
|
30
|
+
visible: true
|
|
31
|
+
playbooks:
|
|
32
|
+
- name: Tag Agent Lab Alerts
|
|
33
|
+
description: Append a note to alerts whose name starts with "Agent Lab".
|
|
34
|
+
is_active: true
|
|
35
|
+
steps:
|
|
36
|
+
- name: On Alert Created
|
|
37
|
+
type: start_on_create # also: start_on_update, start_manual, start_scheduled
|
|
38
|
+
module: alerts
|
|
39
|
+
when:
|
|
40
|
+
logic: AND
|
|
41
|
+
filters:
|
|
42
|
+
- field: name
|
|
43
|
+
op: like # eq, neq, in, like ("%" is the wildcard), ...
|
|
44
|
+
value: "Agent Lab%"
|
|
45
|
+
next: Tag Alert
|
|
46
|
+
- name: Tag Alert
|
|
47
|
+
type: update_record
|
|
48
|
+
module: alerts
|
|
49
|
+
record: "{{ vars.input.records[0]['@id'] }}" # the triggering record
|
|
50
|
+
fields:
|
|
51
|
+
description: "{{ vars.input.records[0].description }}\nTriaged by the playbook"
|
|
52
|
+
next: Done
|
|
53
|
+
- name: Done
|
|
54
|
+
type: end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `vars.input.records[0]` is the record that triggered the run; an earlier step's
|
|
58
|
+
output is `vars.steps.<Step_Name>` (spaces become underscores).
|
|
59
|
+
- Every step but the last names its `next`; a step with no path to it never runs.
|
|
60
|
+
- Look up only what this example lacks, by exact topic: `playbook_yaml_reference(topic=
|
|
61
|
+
"<step type>")` for a step type you have not used (create_record, find_record,
|
|
62
|
+
code_snippet, connector, decision, set_variable, manual_input...), "Variables and
|
|
63
|
+
Jinja" for expressions. Do not read the whole reference first.
|
|
64
|
+
|
|
23
65
|
## Traps that compile clean and fail on the box
|
|
24
66
|
|
|
25
67
|
The compile check flags these; know why so you fix them right:
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""``fsr-agentic-toolkit skills``: put the toolkit's agent skills where an agent reads them.
|
|
2
|
+
|
|
3
|
+
The skills ship inside the package (``fsr_agentic_toolkit/skills/<name>/SKILL.md``).
|
|
4
|
+
Claude Code loads a skill folder from ``.claude/skills``; agents that read
|
|
5
|
+
``AGENTS.md`` (Codex, OpenCode) get a marked block that lists each skill and
|
|
6
|
+
points at its installed file. FortiAgent keeps skills in its own engine: they are
|
|
7
|
+
filed through the engine's skill import (the route its Skills dialog uses) and applied.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import re
|
|
15
|
+
import shutil
|
|
16
|
+
import sys
|
|
17
|
+
import urllib.error
|
|
18
|
+
import urllib.request
|
|
19
|
+
from importlib import resources
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
_BEGIN = "<!-- fsr-agentic-toolkit skills: begin -->"
|
|
23
|
+
_END = "<!-- fsr-agentic-toolkit skills: end -->"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def bundled() -> dict[str, Path]:
|
|
27
|
+
"""Skill name -> its packaged folder."""
|
|
28
|
+
root = Path(str(resources.files("fsr_agentic_toolkit") / "skills"))
|
|
29
|
+
return {p.name: p for p in sorted(root.iterdir()) if (p / "SKILL.md").is_file()}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _description(skill_md: Path) -> str:
|
|
33
|
+
text = skill_md.read_text(encoding="utf-8")
|
|
34
|
+
m = re.search(r"^description:\s*>?-?\s*\n((?:\s+.+\n)+)", text, re.MULTILINE)
|
|
35
|
+
if m:
|
|
36
|
+
return " ".join(line.strip() for line in m.group(1).splitlines())
|
|
37
|
+
m = re.search(r"^description:\s*(.+)$", text, re.MULTILINE)
|
|
38
|
+
return m.group(1).strip() if m else ""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def install(dest: Path, *, force: bool = False) -> list[str]:
|
|
42
|
+
"""Copy every bundled skill into ``dest``; returns one status line per skill.
|
|
43
|
+
|
|
44
|
+
A skill folder that exists and differs is left alone unless ``force``, so a
|
|
45
|
+
team's local edits are never overwritten silently.
|
|
46
|
+
"""
|
|
47
|
+
out = []
|
|
48
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
49
|
+
for name, src in bundled().items():
|
|
50
|
+
target = dest / name
|
|
51
|
+
new = (src / "SKILL.md").read_text(encoding="utf-8")
|
|
52
|
+
if target.exists():
|
|
53
|
+
current = (target / "SKILL.md").read_text(encoding="utf-8") if (target / "SKILL.md").exists() else ""
|
|
54
|
+
if current == new:
|
|
55
|
+
out.append(f"unchanged {name}")
|
|
56
|
+
continue
|
|
57
|
+
if not force:
|
|
58
|
+
out.append(f"kept {name} (differs from the bundled copy; --force to replace)")
|
|
59
|
+
continue
|
|
60
|
+
shutil.rmtree(target)
|
|
61
|
+
shutil.copytree(src, target)
|
|
62
|
+
out.append(f"installed {name}")
|
|
63
|
+
return out
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def agents_md_block(skills_dir: Path) -> str:
|
|
67
|
+
lines = [_BEGIN, "## FortiSOAR skills", "",
|
|
68
|
+
"Before a FortiSOAR task, read the matching skill file and follow it:", ""]
|
|
69
|
+
for name, src in bundled().items():
|
|
70
|
+
lines.append(f"- **{name}** (`{skills_dir / name / 'SKILL.md'}`): {_description(src / 'SKILL.md')}")
|
|
71
|
+
lines.append(_END)
|
|
72
|
+
return "\n".join(lines) + "\n"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def write_agents_md(path: Path, skills_dir: Path) -> str:
|
|
76
|
+
"""Add or refresh the marked block in ``path``; text outside it is untouched."""
|
|
77
|
+
block = agents_md_block(skills_dir)
|
|
78
|
+
text = path.read_text(encoding="utf-8") if path.exists() else ""
|
|
79
|
+
if _BEGIN in text and _END in text:
|
|
80
|
+
start, end = text.index(_BEGIN), text.index(_END) + len(_END)
|
|
81
|
+
text = text[:start] + block.rstrip("\n") + text[end:]
|
|
82
|
+
verb = "updated"
|
|
83
|
+
else:
|
|
84
|
+
text = (text.rstrip("\n") + "\n\n" if text else "") + block
|
|
85
|
+
verb = "added"
|
|
86
|
+
path.write_text(text, encoding="utf-8")
|
|
87
|
+
return f"{verb} the skills block in {path}"
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _fortiagent_runtime() -> Path:
|
|
91
|
+
"""The engine's runtime file (host, port, token). FORTIAGENT_RUNTIME overrides."""
|
|
92
|
+
if os.environ.get("FORTIAGENT_RUNTIME"):
|
|
93
|
+
return Path(os.environ["FORTIAGENT_RUNTIME"]).expanduser()
|
|
94
|
+
home = Path.home()
|
|
95
|
+
if sys.platform == "darwin":
|
|
96
|
+
base = home / "Library" / "Application Support"
|
|
97
|
+
elif sys.platform.startswith("win"):
|
|
98
|
+
base = Path(os.environ.get("APPDATA") or home / "AppData" / "Roaming")
|
|
99
|
+
else:
|
|
100
|
+
base = Path(os.environ.get("XDG_CONFIG_HOME") or home / ".config")
|
|
101
|
+
return base / "ftnt-ai-agent-harness" / "engine" / "runtime.json"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _engine(rt: dict, method: str, path: str, body: dict | None = None) -> dict:
|
|
105
|
+
req = urllib.request.Request(
|
|
106
|
+
f"http://{rt['host']}:{rt['port']}/v1{path}", method=method,
|
|
107
|
+
data=None if body is None else json.dumps(body).encode(),
|
|
108
|
+
headers={"Authorization": f"Bearer {rt['token']}", "content-type": "application/json"})
|
|
109
|
+
try:
|
|
110
|
+
with urllib.request.urlopen(req, timeout=30) as r:
|
|
111
|
+
text = r.read().decode()
|
|
112
|
+
except urllib.error.HTTPError as exc:
|
|
113
|
+
raise RuntimeError(f"{method} {path} answered {exc.code}: {exc.read().decode()[:900]}") from None
|
|
114
|
+
return json.loads(text) if text else {}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def install_fortiagent(*, force: bool = False) -> list[str]:
|
|
118
|
+
"""File and apply every bundled skill in the running FortiAgent engine.
|
|
119
|
+
|
|
120
|
+
Each one is tagged with the toolkit version. A skill already filed by this version
|
|
121
|
+
is left alone; one filed by an older toolkit is updated; a skill of the same id that
|
|
122
|
+
the toolkit did not file (the user's own) is kept unless ``force``."""
|
|
123
|
+
rf = _fortiagent_runtime()
|
|
124
|
+
if not rf.is_file():
|
|
125
|
+
raise SystemExit(f"FortiAgent is not running here (no {rf}). Start FortiAgent, then run this again.")
|
|
126
|
+
rt = json.loads(rf.read_text(encoding="utf-8"))
|
|
127
|
+
have = {}
|
|
128
|
+
for s in (_engine(rt, "GET", "/skills").get("skills") or []):
|
|
129
|
+
if isinstance(s, dict) and s.get("id"):
|
|
130
|
+
have[s["id"]] = s
|
|
131
|
+
try:
|
|
132
|
+
from importlib.metadata import version
|
|
133
|
+
ver = version("fsr-agentic-toolkit")
|
|
134
|
+
except Exception: # noqa: BLE001
|
|
135
|
+
ver = "dev"
|
|
136
|
+
mine, this = "fsr-toolkit", "fsr-toolkit-v" + re.sub(r"[^a-z0-9]+", "-", ver.lower()).strip("-")
|
|
137
|
+
out = []
|
|
138
|
+
for name, src in bundled().items():
|
|
139
|
+
md = (src / "SKILL.md").read_text(encoding="utf-8")
|
|
140
|
+
cur = have.get(name)
|
|
141
|
+
tags = set((cur or {}).get("tags") or [])
|
|
142
|
+
if cur is not None and this in tags and not force:
|
|
143
|
+
out.append(f"unchanged {name}")
|
|
144
|
+
continue
|
|
145
|
+
if cur is not None and mine not in tags and not force:
|
|
146
|
+
out.append(f"kept {name} (not installed by this toolkit; --force to replace)")
|
|
147
|
+
continue
|
|
148
|
+
meta = {"id": name, "name": name, "description": _description(src / "SKILL.md"),
|
|
149
|
+
"autoLoad": True, "requires": {"devices": [], "mcpServers": []},
|
|
150
|
+
"tags": ["fortisoar", mine, this]}
|
|
151
|
+
try:
|
|
152
|
+
res = _engine(rt, "POST", "/skills/import", {"skillMd": md, "metadata": meta})
|
|
153
|
+
if res.get("status") == "pending":
|
|
154
|
+
_engine(rt, "POST", f"/skills/proposals/{res['proposalId']}/apply",
|
|
155
|
+
{"expectedRevision": res["revision"]})
|
|
156
|
+
out.append(f"{'updated' if cur else 'installed':10} {name}")
|
|
157
|
+
except Exception as exc: # noqa: BLE001 - report each skill, keep going
|
|
158
|
+
out.append(f"failed {name}: {str(exc)[:160]}")
|
|
159
|
+
return out
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
_CLIENT_DIRS = {"claude": ".claude/skills", "codex": ".agents/skills", "opencode": ".agents/skills"}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def cmd_skills(args: argparse.Namespace) -> int:
|
|
166
|
+
client = getattr(args, "client", None)
|
|
167
|
+
if client == "fortiagent":
|
|
168
|
+
lines = install_fortiagent(force=args.force)
|
|
169
|
+
print("\n".join(lines))
|
|
170
|
+
print("Open a new FortiAgent chat to use them (Skills in the sidebar lists them).")
|
|
171
|
+
return 1 if any(x.startswith("failed") for x in lines) else 0
|
|
172
|
+
if client in ("codex", "opencode"):
|
|
173
|
+
args.install = True
|
|
174
|
+
args.dir = args.dir if args.dir != ".claude/skills" else _CLIENT_DIRS[client]
|
|
175
|
+
args.agents_md = args.agents_md or "AGENTS.md"
|
|
176
|
+
elif client == "claude":
|
|
177
|
+
args.install = True
|
|
178
|
+
|
|
179
|
+
if not args.install and not args.agents_md:
|
|
180
|
+
for name, src in bundled().items():
|
|
181
|
+
print(f"{name:22} {_description(src / 'SKILL.md')}")
|
|
182
|
+
return 0
|
|
183
|
+
dest = Path(args.dir).expanduser()
|
|
184
|
+
if args.install:
|
|
185
|
+
for line in install(dest, force=args.force):
|
|
186
|
+
print(line)
|
|
187
|
+
if args.agents_md:
|
|
188
|
+
print(write_agents_md(Path(args.agents_md).expanduser(), dest))
|
|
189
|
+
return 0
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def build_subparser(sub: argparse._SubParsersAction) -> None:
|
|
193
|
+
p = sub.add_parser("skills", help="list the agent skills, or install them for your coding agent")
|
|
194
|
+
p.add_argument("--install", action="store_true", help="copy the skills into --dir")
|
|
195
|
+
p.add_argument("--dir", default=".claude/skills", help="skills folder (default .claude/skills, Claude Code)")
|
|
196
|
+
p.add_argument("--force", action="store_true", help="replace installed skills that differ")
|
|
197
|
+
p.add_argument("--client", choices=["claude", "codex", "opencode", "fortiagent"],
|
|
198
|
+
help="install for this agent: claude (.claude/skills), codex/opencode "
|
|
199
|
+
"(.agents/skills + AGENTS.md), fortiagent (into the running FortiAgent)")
|
|
200
|
+
p.add_argument("--agents-md", metavar="PATH", help="add/refresh a skills block in this AGENTS.md (Codex, OpenCode)")
|
|
201
|
+
p.set_defaults(func=cmd_skills)
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/tools.py
RENAMED
|
@@ -185,11 +185,52 @@ def _h_search_records(client, *, module, term="", limit=30, fields=None, summary
|
|
|
185
185
|
return to_jsonable(out) | {"search": ran}
|
|
186
186
|
|
|
187
187
|
|
|
188
|
+
def _picklist_fields(client, module) -> set[str]:
|
|
189
|
+
try:
|
|
190
|
+
desc = client.describe_module(module)
|
|
191
|
+
except Exception: # noqa: BLE001 - no schema: leave the filters as given
|
|
192
|
+
return set()
|
|
193
|
+
rows = getattr(desc, "fields", None) or (desc.get("fields") if isinstance(desc, dict) else None) or []
|
|
194
|
+
out = set()
|
|
195
|
+
for f in rows:
|
|
196
|
+
get = f.get if isinstance(f, dict) else (lambda k, f=f: getattr(f, k, None))
|
|
197
|
+
if "picklist" in str(get("type") or "").lower() or "picklist" in str(get("form_type") or "").lower():
|
|
198
|
+
out.add(get("name"))
|
|
199
|
+
return out
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _friendly_picklist_filters(client, module, filters):
|
|
203
|
+
"""Point a picklist filter with a label value ("Open", ["High", "Critical"]) at
|
|
204
|
+
``<field>.itemValue``. Live-verified: ``criticality in [High, Critical]`` matched 0
|
|
205
|
+
rows while ``criticality.itemValue`` matched 2, with no error either way. An IRI
|
|
206
|
+
value (/api/3/picklists/...) is left on the field itself."""
|
|
207
|
+
if not filters:
|
|
208
|
+
return filters
|
|
209
|
+
names = None
|
|
210
|
+
out = []
|
|
211
|
+
for f in filters:
|
|
212
|
+
if isinstance(f, dict) and isinstance(f.get("filters"), list):
|
|
213
|
+
out.append({**f, "filters": _friendly_picklist_filters(client, module, f["filters"])})
|
|
214
|
+
continue
|
|
215
|
+
field = f.get("field") if isinstance(f, dict) else None
|
|
216
|
+
vals = f.get("value") if isinstance(f, dict) else None
|
|
217
|
+
vlist = vals if isinstance(vals, list) else [vals]
|
|
218
|
+
labels = all(isinstance(v, str) and v and not v.startswith("/api/") for v in vlist)
|
|
219
|
+
if field and "." not in field and labels:
|
|
220
|
+
if names is None:
|
|
221
|
+
names = _picklist_fields(client, module)
|
|
222
|
+
if field in names:
|
|
223
|
+
f = {**f, "field": f"{field}.itemValue"}
|
|
224
|
+
out.append(f)
|
|
225
|
+
return out
|
|
226
|
+
|
|
227
|
+
|
|
188
228
|
def _h_query_records(
|
|
189
229
|
client, *, module, filters=None, logic="AND", sort=None, limit=30, fields=None, summary=True
|
|
190
230
|
) -> Any:
|
|
191
231
|
# pyfsr's records().query refuses filters the box would widen or 500 on.
|
|
192
|
-
body: dict[str, Any] = {"logic": logic,
|
|
232
|
+
body: dict[str, Any] = {"logic": logic,
|
|
233
|
+
"filters": _friendly_picklist_filters(client, module, filters or [])}
|
|
193
234
|
if sort:
|
|
194
235
|
body["sort"] = sort
|
|
195
236
|
if limit:
|
|
@@ -206,6 +247,7 @@ def _h_find_records(client, *, module, where="", sort=None, limit=30, fields=Non
|
|
|
206
247
|
knows the Hydra schema. Empty ``where`` lists the module.
|
|
207
248
|
"""
|
|
208
249
|
body = client.records(module).where_body(where, sort=sort)
|
|
250
|
+
body["filters"] = _friendly_picklist_filters(client, module, body.get("filters") or [])
|
|
209
251
|
if limit:
|
|
210
252
|
body["limit"] = limit
|
|
211
253
|
return project(client.records(module).query(body), fields=fields, summary=summary)
|
|
@@ -3066,6 +3108,11 @@ def _add_next_action(exc: Exception, err: dict[str, Any]) -> None:
|
|
|
3066
3108
|
err["retry_after_seconds"] = after
|
|
3067
3109
|
elif isinstance(exc, TypeError):
|
|
3068
3110
|
err["next_action"] = "The arguments do not match the tool's schema. Re-read it and fix the call."
|
|
3111
|
+
elif isinstance(exc, TimeoutError) and "has no runs" in text:
|
|
3112
|
+
err["next_action"] = ("No run of this playbook started in that time; the box answered. "
|
|
3113
|
+
"Check the trigger matches the record you made (list_playbook_runs, "
|
|
3114
|
+
"diagnose_playbook_run). Right after a publish the first trigger can "
|
|
3115
|
+
"take a minute or two, so one retry with a longer timeout is reasonable.")
|
|
3069
3116
|
elif isinstance(exc, (TimeoutError, ConnectionError)) or "timed out" in text:
|
|
3070
3117
|
err["next_action"] = "The appliance did not answer in time. Wait, then retry once."
|
|
3071
3118
|
err["retry_after_seconds"] = 30
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/debug.py
RENAMED
|
@@ -27,7 +27,11 @@ _BAD_RENDER = frozenset({"render_error", "render_threw", "empty_render", "step_m
|
|
|
27
27
|
# from the published library). These -- and only these -- warrant reading the
|
|
28
28
|
# failure straight off the run record by name. Terminal codes like
|
|
29
29
|
# `no_failed_runs` mean there is nothing to debug and must block.
|
|
30
|
-
|
|
30
|
+
# `no_failed_run_provider`: the MCP server never registers fsr_playbooks' by-name
|
|
31
|
+
# run lookup, so "debug the 'X' playbook" blocked and the agent had to find the pk
|
|
32
|
+
# itself (live: FortiAgent on 0.3.1). The by-name read below needs no provider.
|
|
33
|
+
_DECOMPILE_UNUSABLE_CODES = frozenset({"decompile_import_failed", "decompile_failed",
|
|
34
|
+
"no_failed_run_provider"})
|
|
31
35
|
|
|
32
36
|
|
|
33
37
|
_DOUBLE_IRI = re.compile(r"/api/3/[A-Za-z0-9_]+/+/?api/3/")
|
|
@@ -53,6 +53,23 @@ def _default_probe(fields: list[dict] | None) -> dict:
|
|
|
53
53
|
return probe or {"name": "provision probe"}
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
def _schema_fields(client: Any, module: str) -> list[dict] | None:
|
|
57
|
+
"""The live module's fields as probe specs, for a call that passed no ``fields``
|
|
58
|
+
(an existing module). Without them the probe cannot satisfy a required field such
|
|
59
|
+
as ``hostname`` and a usable module reports "cannot create" (HTTP 400)."""
|
|
60
|
+
try:
|
|
61
|
+
desc = client.describe_module(module)
|
|
62
|
+
except Exception: # noqa: BLE001 - the probe falls back to its default
|
|
63
|
+
return None
|
|
64
|
+
rows = getattr(desc, "fields", None) or (desc.get("fields") if isinstance(desc, dict) else None) or []
|
|
65
|
+
out = []
|
|
66
|
+
for f in rows:
|
|
67
|
+
get = (lambda k, f=f: f.get(k)) if isinstance(f, dict) else (lambda k, f=f: getattr(f, k, None))
|
|
68
|
+
out.append({"name": get("name"), "type": get("form_type") or get("type"),
|
|
69
|
+
"required": bool(get("required"))})
|
|
70
|
+
return out
|
|
71
|
+
|
|
72
|
+
|
|
56
73
|
def provision_module(module: str, label: str = "", plural: str = "",
|
|
57
74
|
fields: list[dict] | None = None, roles: list[str] | None = None,
|
|
58
75
|
probe_record: dict | None = None, check_only: bool = False
|
|
@@ -126,6 +143,9 @@ def provision_module(module: str, label: str = "", plural: str = "",
|
|
|
126
143
|
run.finding(f"published {module}" if ok else f"publish did not make {module} live",
|
|
127
144
|
[pev, run.evidence("module", module, f"published={ok}")], "high")
|
|
128
145
|
if not ok:
|
|
146
|
+
run.next(f"provision_module(module='{module}', check_only=true)",
|
|
147
|
+
"re-read the module state; the publish reported success but the module "
|
|
148
|
+
"was not live yet. Do not re-create it", 2)
|
|
129
149
|
return run.result("partial")
|
|
130
150
|
|
|
131
151
|
# 3. grant
|
|
@@ -149,7 +169,7 @@ def provision_module(module: str, label: str = "", plural: str = "",
|
|
|
149
169
|
else:
|
|
150
170
|
run.finding(f"the caller still cannot read {module}: {acc}. Fix: {A.fix_for(acc)}",
|
|
151
171
|
[rev], "high")
|
|
152
|
-
record = probe_record or _default_probe(fields)
|
|
172
|
+
record = probe_record or _default_probe(fields if fields else _schema_fields(client, module))
|
|
153
173
|
cacc, ccode, cexcerpt = A.probe_create(module, record, client)
|
|
154
174
|
cev = run.evidence("permission", f"create /api/3/{module}", f"HTTP {ccode}: {cexcerpt[:120]}")
|
|
155
175
|
if cacc == "ok":
|
|
@@ -107,7 +107,7 @@ class DiagnoseClient:
|
|
|
107
107
|
def test_dispatch_diagnose_run():
|
|
108
108
|
client = DiagnoseClient(
|
|
109
109
|
definition=_definition(
|
|
110
|
-
"
|
|
110
|
+
"5f0e2b1c-3d4a-4e6f-8a9b-0c1d2e3f4a5b",
|
|
111
111
|
"Block IP",
|
|
112
112
|
[_step("Start", "cybersponse.abstract_trigger"), _step("Block", "Connectors")],
|
|
113
113
|
),
|
|
@@ -123,7 +123,7 @@ def test_dispatch_diagnose_run():
|
|
|
123
123
|
)
|
|
124
124
|
},
|
|
125
125
|
)
|
|
126
|
-
out = tools.dispatch(client, "diagnose_playbook_run", {"playbook_uuid": "
|
|
126
|
+
out = tools.dispatch(client, "diagnose_playbook_run", {"playbook_uuid": "5f0e2b1c-3d4a-4e6f-8a9b-0c1d2e3f4a5b"})
|
|
127
127
|
assert out["verdict"] == "failed"
|
|
128
128
|
assert out["failing_step"] == "Block"
|
|
129
129
|
assert out["error_message"] == "boom"
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_provision_publish_and_probe.py
RENAMED
|
@@ -29,3 +29,24 @@ def test_default_probe_fills_required_fields():
|
|
|
29
29
|
def test_default_probe_falls_back_when_no_required_fields():
|
|
30
30
|
assert provision._default_probe([{"name": "note", "type": "text"}]) == {"name": "provision probe"}
|
|
31
31
|
assert provision._default_probe(None) == {"name": "provision probe"}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_probe_uses_live_schema_required_fields_when_no_fields_passed():
|
|
35
|
+
from fsr_agentic_toolkit.workflows import provision
|
|
36
|
+
|
|
37
|
+
class C:
|
|
38
|
+
def describe_module(self, module):
|
|
39
|
+
return {"fields": [{"name": "hostname", "form_type": "text", "required": True},
|
|
40
|
+
{"name": "notes", "form_type": "richtext", "required": False}]}
|
|
41
|
+
|
|
42
|
+
assert provision._default_probe(provision._schema_fields(C(), "m")) == {"hostname": "provision-probe"}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_schema_fields_tolerates_a_failing_describe():
|
|
46
|
+
from fsr_agentic_toolkit.workflows import provision
|
|
47
|
+
|
|
48
|
+
class C:
|
|
49
|
+
def describe_module(self, module):
|
|
50
|
+
raise RuntimeError("403")
|
|
51
|
+
|
|
52
|
+
assert provision._default_probe(provision._schema_fields(C(), "m")) == {"name": "provision probe"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from fsr_agentic_toolkit.verbs.tools import _friendly_picklist_filters
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class C:
|
|
5
|
+
def describe_module(self, module):
|
|
6
|
+
return {"fields": [{"name": "status", "type": "picklists"}, {"name": "name", "type": "string"}]}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_label_values_on_a_picklist_go_to_item_value():
|
|
10
|
+
out = _friendly_picklist_filters(C(), "alerts", [
|
|
11
|
+
{"field": "status", "operator": "in", "value": ["Open", "Closed"]},
|
|
12
|
+
{"field": "name", "operator": "eq", "value": "x"},
|
|
13
|
+
{"field": "status", "operator": "eq", "value": "/api/3/picklists/abc"},
|
|
14
|
+
{"logic": "OR", "filters": [{"field": "status", "operator": "eq", "value": "Open"}]},
|
|
15
|
+
])
|
|
16
|
+
assert out[0]["field"] == "status.itemValue"
|
|
17
|
+
assert out[1]["field"] == "name"
|
|
18
|
+
assert out[2]["field"] == "status"
|
|
19
|
+
assert out[3]["filters"][0]["field"] == "status.itemValue"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_no_run_timeout_is_not_called_an_unanswering_appliance():
|
|
23
|
+
from fsr_agentic_toolkit.verbs.tools import _agent_error
|
|
24
|
+
err = _agent_error(TimeoutError("playbook 'X' has no runs newer than 'T' within 5s"), tool="wait_for_playbook_run")["error"]
|
|
25
|
+
assert "No run of this playbook started" in err["next_action"]
|
|
@@ -22,7 +22,7 @@ from pyfsr.records import RecordSet
|
|
|
22
22
|
from fsr_agentic_toolkit.verbs import tools
|
|
23
23
|
from fsr_agentic_toolkit.workflows.verify import verify_effect
|
|
24
24
|
|
|
25
|
-
_PB_UUID = "
|
|
25
|
+
_PB_UUID = "0b5c6a4e-1f2d-4c3b-9a8e-7d6f5e4c3b2a"
|
|
26
26
|
_PB_NAME = "Create Alert On Demand"
|
|
27
27
|
|
|
28
28
|
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
from fsr_agentic_toolkit import skills_cmd as S
|
|
5
5
|
|
|
6
6
|
EXPECTED = {"alert-investigation", "box-onboarding", "connector-building", "connector-secrets",
|
|
7
|
-
"debug-and-repair", "playbook-authoring", "prove-the-work", "use-case-building",
|
|
7
|
+
"debug-and-repair", "module-building", "playbook-authoring", "prove-the-work", "use-case-building",
|
|
8
8
|
"widget-building"}
|
|
9
9
|
|
|
10
10
|
|
|
@@ -48,3 +48,30 @@ def test_agents_md_block_is_added_once_and_refreshed(tmp_path):
|
|
|
48
48
|
text = md.read_text()
|
|
49
49
|
assert text.count(S._BEGIN) == 1 and "Keep this." in text
|
|
50
50
|
assert "playbook-authoring" in text
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_fortiagent_install_keeps_user_skills_and_updates_old_toolkit_copies(monkeypatch, tmp_path):
|
|
54
|
+
import json
|
|
55
|
+
|
|
56
|
+
from fsr_agentic_toolkit import skills_cmd
|
|
57
|
+
|
|
58
|
+
rt = tmp_path / "runtime.json"
|
|
59
|
+
rt.write_text(json.dumps({"host": "127.0.0.1", "port": 1, "token": "t"}))
|
|
60
|
+
monkeypatch.setenv("FORTIAGENT_RUNTIME", str(rt))
|
|
61
|
+
calls = []
|
|
62
|
+
|
|
63
|
+
def fake(_rt, method, path, body=None):
|
|
64
|
+
calls.append((method, path, body))
|
|
65
|
+
if path == "/skills":
|
|
66
|
+
return {"skills": [{"id": "prove-the-work", "tags": ["fsr-toolkit", "fsr-toolkit-v0-0-1"]},
|
|
67
|
+
{"id": "box-onboarding", "tags": ["mine"]}]}
|
|
68
|
+
if path == "/skills/import":
|
|
69
|
+
return {"proposalId": "p1", "status": "pending", "revision": 1}
|
|
70
|
+
return {}
|
|
71
|
+
|
|
72
|
+
monkeypatch.setattr(skills_cmd, "_engine", fake)
|
|
73
|
+
out = {line.split()[1]: line.split()[0] for line in skills_cmd.install_fortiagent()}
|
|
74
|
+
assert out["prove-the-work"] == "updated"
|
|
75
|
+
assert out["box-onboarding"] == "kept"
|
|
76
|
+
assert out["module-building"] == "installed"
|
|
77
|
+
assert ("POST", "/skills/proposals/p1/apply", {"expectedRevision": 1}) in calls
|
|
@@ -381,7 +381,7 @@ wheels = [
|
|
|
381
381
|
|
|
382
382
|
[[package]]
|
|
383
383
|
name = "fsr-agentic-toolkit"
|
|
384
|
-
version = "0.3.
|
|
384
|
+
version = "0.3.3"
|
|
385
385
|
source = { editable = "." }
|
|
386
386
|
dependencies = [
|
|
387
387
|
{ name = "fsr-playbooks" },
|
|
@@ -402,10 +402,10 @@ test = [
|
|
|
402
402
|
|
|
403
403
|
[package.metadata]
|
|
404
404
|
requires-dist = [
|
|
405
|
-
{ name = "fsr-playbooks", specifier = ">=0.
|
|
406
|
-
{ name = "mcp", specifier = ">=2.
|
|
405
|
+
{ name = "fsr-playbooks", specifier = ">=0.14.0" },
|
|
406
|
+
{ name = "mcp", specifier = ">=2.3,<3" },
|
|
407
407
|
{ name = "pydantic", specifier = ">=2" },
|
|
408
|
-
{ name = "pyfsr", specifier = ">=0.
|
|
408
|
+
{ name = "pyfsr", specifier = ">=0.37.0" },
|
|
409
409
|
{ name = "pytest", marker = "extra == 'dev'", specifier = ">=8" },
|
|
410
410
|
{ name = "pytest", marker = "extra == 'test'", specifier = ">=8" },
|
|
411
411
|
{ name = "pyyaml", specifier = ">=6" },
|
|
@@ -415,7 +415,7 @@ provides-extras = ["test", "dev"]
|
|
|
415
415
|
|
|
416
416
|
[[package]]
|
|
417
417
|
name = "fsr-playbooks"
|
|
418
|
-
version = "0.
|
|
418
|
+
version = "0.14.0"
|
|
419
419
|
source = { registry = "https://pypi.org/simple" }
|
|
420
420
|
dependencies = [
|
|
421
421
|
{ name = "jinja2" },
|
|
@@ -424,7 +424,7 @@ dependencies = [
|
|
|
424
424
|
{ name = "ruamel-yaml" },
|
|
425
425
|
]
|
|
426
426
|
wheels = [
|
|
427
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
427
|
+
{ url = "https://files.pythonhosted.org/packages/fd/2a/fa222fc4594772435b22ef53e198bb5b80eeaff9ae4a7975d1ef449ba4c7/fsr_playbooks-0.14.0-py3-none-any.whl", hash = "sha256:3581b2c68a17bb4b430b80ed426ea1076de7dc1bc8a5859ad17f4f2d74ccf412", size = 1667784, upload-time = "2026-11-27T21:49:37.868Z" },
|
|
428
428
|
]
|
|
429
429
|
|
|
430
430
|
[[package]]
|
|
@@ -887,16 +887,16 @@ wheels = [
|
|
|
887
887
|
|
|
888
888
|
[[package]]
|
|
889
889
|
name = "pyfsr"
|
|
890
|
-
version = "0.
|
|
890
|
+
version = "0.37.0"
|
|
891
891
|
source = { registry = "https://pypi.org/simple" }
|
|
892
892
|
dependencies = [
|
|
893
893
|
{ name = "pydantic" },
|
|
894
894
|
{ name = "pyyaml" },
|
|
895
895
|
{ name = "requests" },
|
|
896
896
|
]
|
|
897
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
897
|
+
sdist = { url = "https://files.pythonhosted.org/packages/3e/9e/dff4cae4e45ccc102889ea0ed7ecb8c0ad3f0bfb37d43535978fbb483056/pyfsr-0.37.0.tar.gz", hash = "sha256:d32d08a103762cc8e2ece123441eb79cb6109b72492d489a62d96800e2ce6dd0", size = 2410599, upload-time = "2026-12-02T22:58:46.197Z" }
|
|
898
898
|
wheels = [
|
|
899
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
899
|
+
{ url = "https://files.pythonhosted.org/packages/8b/f5/4d173c75cf5bc0a4578fb63fa56d2207756eb3536098f4841833759d43ef/pyfsr-0.37.0-py3-none-any.whl", hash = "sha256:8ddae0298027f6b22cdb3fd2549553d83a441ebf058b9349b81bf0edf08db69c", size = 1186743, upload-time = "2026-12-02T22:58:44.096Z" },
|
|
900
900
|
]
|
|
901
901
|
|
|
902
902
|
[[package]]
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"""``fsr-agentic-toolkit skills``: put the toolkit's agent skills where an agent reads them.
|
|
2
|
-
|
|
3
|
-
The skills ship inside the package (``fsr_agentic_toolkit/skills/<name>/SKILL.md``).
|
|
4
|
-
Claude Code loads a skill folder from ``.claude/skills``; agents that read
|
|
5
|
-
``AGENTS.md`` (Codex, OpenCode) get a marked block that lists each skill and
|
|
6
|
-
points at its installed file.
|
|
7
|
-
"""
|
|
8
|
-
from __future__ import annotations
|
|
9
|
-
|
|
10
|
-
import argparse
|
|
11
|
-
import re
|
|
12
|
-
import shutil
|
|
13
|
-
from importlib import resources
|
|
14
|
-
from pathlib import Path
|
|
15
|
-
|
|
16
|
-
_BEGIN = "<!-- fsr-agentic-toolkit skills: begin -->"
|
|
17
|
-
_END = "<!-- fsr-agentic-toolkit skills: end -->"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def bundled() -> dict[str, Path]:
|
|
21
|
-
"""Skill name -> its packaged folder."""
|
|
22
|
-
root = Path(str(resources.files("fsr_agentic_toolkit") / "skills"))
|
|
23
|
-
return {p.name: p for p in sorted(root.iterdir()) if (p / "SKILL.md").is_file()}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _description(skill_md: Path) -> str:
|
|
27
|
-
text = skill_md.read_text(encoding="utf-8")
|
|
28
|
-
m = re.search(r"^description:\s*>?-?\s*\n((?:\s+.+\n)+)", text, re.MULTILINE)
|
|
29
|
-
if m:
|
|
30
|
-
return " ".join(line.strip() for line in m.group(1).splitlines())
|
|
31
|
-
m = re.search(r"^description:\s*(.+)$", text, re.MULTILINE)
|
|
32
|
-
return m.group(1).strip() if m else ""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def install(dest: Path, *, force: bool = False) -> list[str]:
|
|
36
|
-
"""Copy every bundled skill into ``dest``; returns one status line per skill.
|
|
37
|
-
|
|
38
|
-
A skill folder that exists and differs is left alone unless ``force``, so a
|
|
39
|
-
team's local edits are never overwritten silently.
|
|
40
|
-
"""
|
|
41
|
-
out = []
|
|
42
|
-
dest.mkdir(parents=True, exist_ok=True)
|
|
43
|
-
for name, src in bundled().items():
|
|
44
|
-
target = dest / name
|
|
45
|
-
new = (src / "SKILL.md").read_text(encoding="utf-8")
|
|
46
|
-
if target.exists():
|
|
47
|
-
current = (target / "SKILL.md").read_text(encoding="utf-8") if (target / "SKILL.md").exists() else ""
|
|
48
|
-
if current == new:
|
|
49
|
-
out.append(f"unchanged {name}")
|
|
50
|
-
continue
|
|
51
|
-
if not force:
|
|
52
|
-
out.append(f"kept {name} (differs from the bundled copy; --force to replace)")
|
|
53
|
-
continue
|
|
54
|
-
shutil.rmtree(target)
|
|
55
|
-
shutil.copytree(src, target)
|
|
56
|
-
out.append(f"installed {name}")
|
|
57
|
-
return out
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def agents_md_block(skills_dir: Path) -> str:
|
|
61
|
-
lines = [_BEGIN, "## FortiSOAR skills", "",
|
|
62
|
-
"Before a FortiSOAR task, read the matching skill file and follow it:", ""]
|
|
63
|
-
for name, src in bundled().items():
|
|
64
|
-
lines.append(f"- **{name}** (`{skills_dir / name / 'SKILL.md'}`): {_description(src / 'SKILL.md')}")
|
|
65
|
-
lines.append(_END)
|
|
66
|
-
return "\n".join(lines) + "\n"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def write_agents_md(path: Path, skills_dir: Path) -> str:
|
|
70
|
-
"""Add or refresh the marked block in ``path``; text outside it is untouched."""
|
|
71
|
-
block = agents_md_block(skills_dir)
|
|
72
|
-
text = path.read_text(encoding="utf-8") if path.exists() else ""
|
|
73
|
-
if _BEGIN in text and _END in text:
|
|
74
|
-
start, end = text.index(_BEGIN), text.index(_END) + len(_END)
|
|
75
|
-
text = text[:start] + block.rstrip("\n") + text[end:]
|
|
76
|
-
verb = "updated"
|
|
77
|
-
else:
|
|
78
|
-
text = (text.rstrip("\n") + "\n\n" if text else "") + block
|
|
79
|
-
verb = "added"
|
|
80
|
-
path.write_text(text, encoding="utf-8")
|
|
81
|
-
return f"{verb} the skills block in {path}"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def cmd_skills(args: argparse.Namespace) -> int:
|
|
85
|
-
if not args.install and not args.agents_md:
|
|
86
|
-
for name, src in bundled().items():
|
|
87
|
-
print(f"{name:22} {_description(src / 'SKILL.md')}")
|
|
88
|
-
return 0
|
|
89
|
-
dest = Path(args.dir).expanduser()
|
|
90
|
-
if args.install:
|
|
91
|
-
for line in install(dest, force=args.force):
|
|
92
|
-
print(line)
|
|
93
|
-
if args.agents_md:
|
|
94
|
-
print(write_agents_md(Path(args.agents_md).expanduser(), dest))
|
|
95
|
-
return 0
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def build_subparser(sub: argparse._SubParsersAction) -> None:
|
|
99
|
-
p = sub.add_parser("skills", help="list the agent skills, or install them for your coding agent")
|
|
100
|
-
p.add_argument("--install", action="store_true", help="copy the skills into --dir")
|
|
101
|
-
p.add_argument("--dir", default=".claude/skills", help="skills folder (default .claude/skills, Claude Code)")
|
|
102
|
-
p.add_argument("--force", action="store_true", help="replace installed skills that differ")
|
|
103
|
-
p.add_argument("--agents-md", metavar="PATH", help="add/refresh a skills block in this AGENTS.md (Codex, OpenCode)")
|
|
104
|
-
p.set_defaults(func=cmd_skills)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/hints.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/mcp.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/verbs/mcp_http.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/widget_kit.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/widget_tools.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflow_tools.py
RENAMED
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/access.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/build.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/orient.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/repair.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/result.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/run.py
RENAMED
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/src/fsr_agentic_toolkit/workflows/verify.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/fixtures/workflows/heist_intake.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_provision_coerces_fields.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_related_comments_count.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fsr_agentic_toolkit-0.3.2 → fsr_agentic_toolkit-0.3.3}/tests/test_workflow_first_surface.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|