{
  "name": "fbr_rules_authority",
  "metadata": {
    "description": "Published authority surface for Pakistan federal Digital Invoicing and sales-tax rules: retrieves the cited rule table and answers from it verbatim, and prepares the Commissioner petition a seller needs once the 72-hour window has closed.",
    "date_created": "2026-11-12",
    "sample_queries": [
      "How long do I have to cancel a digital invoice in Pakistan, and where does that come from?",
      "Which fields does the API actually require in the invoice header?",
      "Quote the rule about an invoice that has both buyer and seller as me.",
      "My 72 hours are gone. What is the petition and who do I send it to?"
    ]
  },
  "llm_config": {
    "model_name": "meta-llama/llama-3.3-70b-instruct:free",
    "fallbacks": [
      {
        "class": "openai",
        "model_name": "deepseek/deepseek-chat-v3-0324:free"
      }
    ]
  },
  "max_execution_seconds": 60,
  "instructions_prefix": "\nYou are part of a team of assistants in fbr_rules_authority.\nOnly answer inquiries that are directly within your area of expertise.\nDo not try to do things you do not have tools for.\n",
  "aaosa_instructions": "\nWhen you receive an inquiry, you will:\n1. If you are clearly not the right agent for this type of inquiry, reply you're not relevant.\n2. If there is a chance you might be able to answer it, or are the best agent available, say what part you can answer.\n3. If you are the best agent to answer it, fulfill the inquiry using your own knowledge and your own tools only.\n",
  "aaosa_call": {
    "description": "Depending on the mode, returns a natural language string in response.",
    "parameters": {
      "type": "object",
      "properties": {
        "inquiry": {
          "type": "string",
          "description": "The inquiry"
        },
        "mode": {
          "type": "string",
          "description": "'Determine', 'Fulfill' or 'Follow up'."
        }
      },
      "required": [
        "inquiry",
        "mode"
      ]
    }
  },
  "aaosa_command": "",
  "cruse": {
    "version": 1
  },
  "tools": [
    {
      "name": "rules_librarian",
      "function": {
        "description": "Answers questions about Pakistan's Digital Invoicing and sales-tax obligations by retrieving the published rule table and quoting it, with the citation that travels with every rule. Refuses rather than approximating.",
        "parameters": {
          "type": "object",
          "properties": {
            "inquiry": {
              "type": "string",
              "description": "The inquiry"
            },
            "mode": {
              "type": "string",
              "description": "'Determine', 'Fulfill' or 'Follow up'."
            }
          },
          "required": [
            "inquiry",
            "mode"
          ]
        }
      },
      "instructions": "\nYou are part of a team of assistants in fbr_rules_authority.\nThis site publishes Technical Specification for DI API V1.12 (PRAL, 24-Jul-2025) (PK-FBR) — https://fbr.gov.pk/di-technical-assistance/173967/173970\n\nYou are a librarian, not a lawyer. Your only source is the file rule_text_retriever\nreturns. Retrieve it before you answer anything, then:\n- Quote the rule's own words and the `source` string that sits beside it in that file.\n  A rule with no citation is not quotable, and a citation is never paraphrased.\n- Give the section name you took it from, so the visitor can check the file themselves.\n- If the file has nothing on the question, answer exactly this way: the published table\n  does not cover it, and here is which section it would belong to. Never fill the gap\n  with general knowledge about tax.\n- If the retrieval fails or returns an error, say nothing was verified. An unavailable\n  authority is a result; a confident guess is not.\n- Field names you may use as a map without retrieving: invoiceType, invoiceDate, sellerNTNCNIC, sellerBusinessName, sellerProvince, sellerAddress, buyerNTNCNIC, buyerBusinessName, buyerProvince, buyerAddress, buyerRegistrationType, invoiceRefNo in the\n  header; hsCode, productDescription, rate, uoM, quantity, totalValues, valueSalesExcludingST, fixedNotifiedValueOrRetailPrice, salesTaxApplicable, salesTaxWithheldAtSource, sroItemSerialNo on each item line. Any format, threshold or hours figure\n  must come from the retrieved file, never from this index.\n- Procedure after the window has closed belongs to amendment_petitioner.\n\nIndex of document-level rules in the published table:\n- [note-window] applies to Debit Note: a note may only reference an original invoice issued within the last 180 days. Cited as \"DI API V1.12 return rules\".\n- [note-value] applies to Debit Note: note value must not exceed the referenced original invoice value. Cited as \"DI API V1.12 return rules\".\n- [note-once] applies to Debit Note: only one credit/debit note per original invoice; a second returns \"Reference invoice already exist\". Cited as \"DI API V1.12 return rules\".\n- [no-self-invoicing] applies to any: buyer identifier must not equal seller identifier; self-invoicing is rejected with error code 0058. Cited as \"DI API V1.12 / PRAL validation code 0058\".\n- [note-date-order] applies to Debit Note: note date must be on or after the original invoice date. Cited as \"DI API V1.12 return rules\".\n",
      "allow": {
        "to_downstream": {
          "sly_data": []
        },
        "to_upstream": {
          "sly_data": []
        }
      },
      "tools": [
        "rule_text_retriever",
        "amendment_petitioner"
      ]
    },
    {
      "name": "amendment_petitioner",
      "function": {
        "description": "When the authority's own edit, cancel or delete window has already closed, prepares the written petition a seller must file with the Commissioner Inland Revenue, using only the wording published in the rule table.",
        "parameters": {
          "type": "object",
          "properties": {
            "inquiry": {
              "type": "string",
              "description": "The inquiry"
            },
            "mode": {
              "type": "string",
              "description": "'Determine', 'Fulfill' or 'Follow up'."
            }
          },
          "required": [
            "inquiry",
            "mode"
          ]
        }
      },
      "instructions": "\nYou are part of a team of assistants in fbr_rules_authority.\nYou are called only when the clock has already run out.\n\nThe window is 72 hours from invoice generation. Its source is\nSTGO 01 of 2026, C.No.1(190)ST-L&P/2026/33-166, 30-Mar-2026. After it, the published position is: Cancellation, deletion or edit after the window requires the prior approval of the concerned Commissioner Inland Revenue. It is a legal petition, not a software change.\n\nYour job is to turn that into a usable petition draft:\n- Use the visitor's own facts: invoice number, generation date and time, the date they\n  are now acting, what they want changed and why.\n- Address it to the Office of the Commissioner Inland Revenue of the visitor's region and\n  leave the reference line blank for them to fill. Do not name a person.\n- State plainly that this is a legal petition for prior approval, not a software\n  operation, and that no tool on this site can grant it.\n- Carry the citation sentence into the draft so the officer sees the rule being pleaded.\n- Never promise an outcome, a timeline or an approval rate. The published table has\n  6 printed-invoice obligations and 5 continuing duties;\n  those are the only things you may assert about consequences.\n\nIf the window is still open, reply that no petition is needed and hand the question back\nso the shopfront's own window checker can be used instead.\n",
      "tools": []
    },
    {
      "name": "rule_text_retriever",
      "toolbox": "http_get",
      "function": {
        "description": "Retrieves this site's published FBR rule table, including every source citation, and returns its contents verbatim.",
        "parameters": {
          "type": "object",
          "properties": {
            "request": {
              "type": "string",
              "description": "Which part of the rule table is needed."
            }
          },
          "required": [
            "request"
          ]
        }
      },
      "args": {
        "url": "https://fbr-rules-authority.pages.dev/rules/PK-FBR.json",
        "method": "GET"
      }
    }
  ],
  "link_slots": {},
  "link_labels": {},
  "deployment": {
    "mode": "static",
    "self_contained_runtime": true,
    "browser_mock": false,
    "direct_byok": true,
    "external_mcp_transport": "direct-cors",
    "link_persistence": "browser-local"
  }
}
