개발자 가이드

에이전트 위임장 작성 및 검증

위임장은 유효한 집행 필드를 통해서만 경계를 나타냅니다. 유효하지 않은 위임장은 모든 행위 검사가 error를 돌려주게 합니다.

템플릿에서 시작하기

이 파일 샌드박스 항목은 public/try.1.js에 내장된 템플릿과 정확히 같습니다. 첫 번째 조항은 민감한 접두사를 거부하고, 두 번째 조항은 하나의 작업 공간 접두사 아래에서 파일 읽기와 쓰기를 허용하며, 기본값은 일치하지 않는 모든 것을 거부합니다.

  {
    "name": "file-sandbox",
    "title": "File sandbox",
    "description": "Deny sensitive directories and permit reads and writes under one bounded directory.",
    "mandate": {
      "schema_version": "0.2-draft",
      "mandate_id": "template-file-sandbox",
      "purpose": "Confine file reads and writes to one working directory.",
      "default": "deny",
      "clauses": [
        { "id": "deny-sensitive", "effect": "deny", "match": { "kind": ["file"], "target_prefix": ["~/.ssh/", "/etc/"] } },
        { "id": "permit-workspace", "effect": "permit", "match": { "kind": ["file"], "verb": ["read", "write"], "target_prefix": ["/workspace/project/"] } }
      ]
    },
    "action": {
      "schema_version": "0.1-draft",
      "requested_by": { "agent": "template-agent" },
      "operation": { "kind": "file", "verb": "write", "target": "/workspace/project/report.txt" },
      "justification": "Write the report inside the bounded workspace."
    },
    "outcome": "permit"
  },

추적을 위해 위임장 식별자를 바꾸고 의도한 권한에 맞게 집행 필드를 바꾸세요. purpose, note, justification은 설명문이며 행위를 제한하지 않습니다. 조항 일치 필드와 not_valid_after, requires_human및 default 만 제한합니다. 처음 일치하는 조항이 결정을 정하므로 좁은 거부를 넓은 허용보다 앞에 두세요. 위임장에 비밀, 개인 데이터 또는 기밀 정책을 넣지 마세요.

위임장 검증하기

양식은 public/try.1.js의 이 검증 흐름을 그대로 사용합니다. MCP를 초기화하고 validate_mandate을 호출하며 구조화된 내용이나 텍스트 대체 경로를 받아들입니다.

export async function validateMandate(mandateText, fetchImpl = fetch) {
  const mandate = parseDocument(mandateText, "mandate");
  const initialized = await postJson(MCP_URL, {
    jsonrpc: "2.0",
    id: 1,
    method: "initialize",
    params: {
      protocolVersion: "2025-11-25",
      capabilities: {},
      clientInfo: { name: "hanria.ai-try-it", version: "1" }
    }
  }, fetchImpl);
  if (initialized.error) throw new Error(initialized.error.message || "initialize failed", { cause: "response" });
  const called = await postJson(MCP_URL, {
    jsonrpc: "2.0",
    id: 2,
    method: "tools/call",
    params: { name: "validate_mandate", arguments: { mandate } }
  }, fetchImpl);
  if (called.error) throw new Error(called.error.message || "validate_mandate failed", { cause: "response" });
  const structured = called.result?.structuredContent;
  if (structured && typeof structured === "object") return structured;
  const text = called.result?.content?.find((item) => item.type === "text")?.text;
  if (typeof text === "string") {
    try {
      return JSON.parse(text);
    } catch {
      throw new Error("invalid validate_mandate result", { cause: "response" });
    }
  }
  throw new Error("missing validate_mandate result", { cause: "response" });
}

실행하기

  1. 양식 열기

    직접 해보기 양식 으로 이동해 File sandbox를 선택하세요.

  2. 위임장 편집하기

    예시 식별자와 경계를 의도한 구조화된 한계로 바꾸세요.

  3. 검증만 하기

    위임장만 검증을 선택하세요. 결과가 valid: true 이면 검증기가 문서를 받아들였다는 뜻입니다. 결과가 valid: false 이면 검증 문제를 알려 줍니다. 위임장을 사용하기 전에 고치세요.

  4. 행위 검사하기

    대표 행위에 위임장을 사용하고 결과, 판단을 정한 조항, 서명된 영수증을 살펴보세요.

모든 결과 처리하기

행위 검사는 permit, deny, 또는 escalate 를 판단을 정한 조항 및 서명된 영수증과 함께 돌려줍니다. 검사는 조언형이며 행위를 거부하는 것은 통합입니다. 호스팅 검사는 요청을 메모리에서 평가하고 요청 내용을 보관하지 않습니다.

유효하지 않은 위임장은 모든 행위 검사가 error를 돌려주며 통합은 이를 deny로 취급해야 합니다. 유효하지 않은 위임장은 경계를 나타내지 않습니다. 검증이 위임장을 집행 경계로 바꾸는 것도 아닙니다.

참고 자료

검사 사용해 보기 · 서명된 영수증 검증하기 · OpenAPI 문서 · 에이전트용 요약