{"_id":"@awrk/sdk","name":"@awrk/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@awrk/sdk","version":"0.1.0","description":"Typed client for the awrk shared context API","type":"module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jtomchak/awrk.git","directory":"packages/sdk"},"homepage":"https://github.com/jtomchak/awrk/tree/main/packages/sdk#readme","bugs":{"url":"https://github.com/jtomchak/awrk/issues"},"exports":{".":{"types":"./dist/sdk/index.d.ts","import":"./dist/sdk/index.js"}},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p ../../tsconfig.sdk.json"},"_id":"@awrk/sdk@0.1.0","_integrity":"sha512-LpuR64of/VZguKBAWKNEFIVDVcobjkfIIHgPswTYENHNE3n+vwaiIigeDWHXZIZHeVIBmVWvCcDzXsKcs46F2g==","_resolved":"/tmp/awrk-bootstrap.M5fDhl/artifact/awrk-sdk-0.1.0.tgz","_from":"file:/tmp/awrk-bootstrap.M5fDhl/artifact/awrk-sdk-0.1.0.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-LpuR64of/VZguKBAWKNEFIVDVcobjkfIIHgPswTYENHNE3n+vwaiIigeDWHXZIZHeVIBmVWvCcDzXsKcs46F2g==","shasum":"9efe621cd519840a7562a440b6106cbb617bf3fc","tarball":"https://registry.npmjs.org/@awrk/sdk/-/sdk-0.1.0.tgz","fileCount":12,"unpackedSize":97698,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBWfdlR2qgILuUpy1v+9jGoG0obgspBhMhdcIo5CGZHdAiASmEIkwPnlmwoLLaGwSlRphX+cpIfGfxMMN3Jsw5jZ3w=="}]},"_npmUser":{"name":"jtomchak","email":"jtomchak@gmail.com"},"directories":{},"maintainers":[{"name":"jtomchak","email":"jtomchak@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1784906934211_0.008619499411710141"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-24T15:28:54.029Z","0.1.0":"2026-07-24T15:28:54.359Z","modified":"2026-07-24T15:28:54.638Z"},"maintainers":[{"name":"jtomchak","email":"jtomchak@gmail.com"}],"description":"Typed client for the awrk shared context API","homepage":"https://github.com/jtomchak/awrk/tree/main/packages/sdk#readme","repository":{"type":"git","url":"git+https://github.com/jtomchak/awrk.git","directory":"packages/sdk"},"bugs":{"url":"https://github.com/jtomchak/awrk/issues"},"license":"MIT","readme":"# @awrk/sdk\n\nTyped client for the private awrk workspace API.\n\n```ts\nimport { WrkClient } from \"@awrk/sdk\";\n\nconst accessHeaders = process.env.CF_ACCESS_CLIENT_ID && process.env.CF_ACCESS_CLIENT_SECRET\n  ? {\n      \"CF-Access-Client-Id\": process.env.CF_ACCESS_CLIENT_ID,\n      \"CF-Access-Client-Secret\": process.env.CF_ACCESS_CLIENT_SECRET,\n    }\n  : undefined;\n\nconst awrk = new WrkClient({\n  baseUrl: \"https://wrk.example.com\",\n  token: process.env.WRK_API_TOKEN,\n  // Required with the workspace token when this host is protected by Access.\n  headers: accessHeaders,\n});\n\nconst profile = await awrk.profile();\nconst organizations = await awrk.organizations();\nconst team = await awrk.createOrganization({ name: \"Release engineering\", slug: \"release-engineering\" });\nconst invitation = await awrk.createOrganizationInvite(team.id, { email: \"reviewer@example.com\" });\nconsole.log(`Copy this one-use invitation token: ${invitation.token}`);\n\n// The canonical workspace ID is required; slugs are display metadata only.\nconst workspace = awrk.workspace(\"wrk_01JEXAMPLEWORKSPACEID\");\nconst packet = await workspace.checkoutContext({\n  intent: \"Fix the release check\",\n  runtime: \"codex\",\n  repository: \"owner/repository\",\n  limit: 20,\n});\nconst contribution = await workspace.commitContribution({\n  contextPacketId: packet.id,\n  runtime: \"codex\",\n  summary: \"Fixed the release check and verified the default branch.\",\n  outcome: \"completed\",\n  artifacts: [{ type: \"pull_request\", url: \"https://github.com/owner/repository/pull/42\" }],\n  evidence: [{ type: \"check_run\", url: \"https://github.com/owner/repository/actions/runs/7\" }],\n  reusableLearnings: [{\n    summary: \"The release check targets the default branch\",\n    detail: \"Feature-branch results did not predict readiness.\",\n    action: \"Run the release check against the default branch.\",\n    domains: [\"release-readiness\", \"ci\"],\n  }],\n  followups: [\"Backfill older release evidence.\"],\n  confidence: 0.9,\n}, { idempotencyKey: \"contribution-release-check-42\" });\nconst decisions = await workspace.search({ type: \"decision\", status: \"accepted\" });\nconst transactions = await workspace.transactions({ limit: 25 });\nconst settings = await workspace.settings();\nconst readiness = await workspace.releaseReadiness();\nconst repositories = await workspace.githubRepositories({ q: \"api\", selected: false, limit: 100 });\nconst incidentLead = await workspace.createAgent({\n  slug: \"incident-lead\",\n  name: \"Incident lead\",\n  capabilities: [\"objects:read\", \"agents:run\"],\n  approvalPolicy: { protected: [\"external:write\", \"production:write\"] },\n  modelPolicy: { class: \"fast\", fallback: \"deterministic\" },\n  budgetUsd: 3,\n});\nawait workspace.updateAgent(incidentLead.id, { status: \"paused\", budgetUsd: 1.5 });\nconst retention = await workspace.retention(); // read-only eligibility preview\nif (retention.eligible.total > 0) await workspace.runRetention({ idempotencyKey: \"retention-review-1\" });\nconst failedDispatches = await workspace.workflowDispatches({ state: \"failed\", limit: 25 });\nif (failedDispatches.results[0]) await workspace.retryWorkflowDispatch(failedDispatches.results[0].id);\nconst failedDeliveries = await workspace.eventDeliveries({ status: \"failed\", consumer: \"webhooks\" });\nif (failedDeliveries.results[0]) await workspace.retryEventDelivery(failedDeliveries.results[0].id);\nconst semantic = await workspace.semanticIndex();\nif (semantic.staleObjects) {\n  await workspace.backfillSemanticIndex({ staleOnly: true, objectTypes: [\"decision\"], limit: 25 }, { idempotencyKey: \"semantic-decisions-1\" });\n}\n\nawait workspace.updateGitHubRepository(\"ghr_123\", { selected: true });\nconst hydration = await workspace.hydrateGitHubEvidence(\n  \"ghr_123\",\n  { types: [\"pull_request\", \"issue\", \"check_run\", \"release\"], limitPerType: 25 },\n  { idempotencyKey: \"hydrate-pilot-repository-1\" },\n);\nawait workspace.githubEvidenceJob(hydration.id);\n\nif (repositories.nextCursor) {\n  await workspace.githubRepositories({ q: \"api\", selected: false, cursor: repositories.nextCursor });\n}\n\nfor (const blocker of readiness.blockers) {\n  console.log(blocker.type, blocker.title, blocker.version, blocker.freshness);\n}\nfor (const approval of readiness.approvals) {\n  console.log(approval.id, approval.risk, approval.transactionId);\n}\n\nawait workspace.updateSettings({\n  requireApprovalFor: [...settings.requireApprovalFor, \"objects:update\"],\n});\n\nconst object = await workspace.object(\"obj_123\");\nconst history = await workspace.objectVersions(object.id, { limit: 25 });\nconsole.log(history.results.map((version) => ({ version: version.version, actor: version.actorId, provenance: version.provenance })));\nawait workspace.updateObject(object.id, { status: \"accepted\" }, { baseVersion: object.version });\nawait workspace.grantObjectPermission(object.id, {\n  principalId: \"usr_123\",\n  capabilities: [\"objects:read\", \"objects:write\"],\n});\n\nif (transactions.nextCursor) {\n  await workspace.transactions({ limit: 25, cursor: transactions.nextCursor });\n}\n\nconst [approval] = (await workspace.bootstrap()).approvals;\nif (approval?.status === \"pending\") {\n  const assignees = await workspace.approvalAssignees();\n  console.log(assignees.results);\n  await workspace.commentOnApproval(approval.id, \"Release evidence checked.\");\n  await workspace.reassignApproval(approval.id, \"usr_approver\");\n  const discussion = await workspace.approvalComments(approval.id);\n  console.log(discussion);\n}\n```\n\nBrowser clients may omit `token` and authenticate through Cloudflare Access cookies. Use `idempotencyKey` on write methods when a caller may retry. GitHub writes are created with `createGitHubWriteIntent` and are not sent to GitHub until the related high-risk transaction is approved.\n\nEvery verified user has a personal organization and default workspace. `organizations()` and `workspaces()` return the accessible organization/workspace switcher data; workspace summaries include organization identity and `isDefault`. Team organization owners can inspect and update members, create or revoke email-bound invitations, and share the raw invitation token returned once by `createOrganizationInvite()`. Accept invitations with `acceptOrganizationInvite()`. `profile()` and `updateProfile()` expose only the editable display name and default organization; email and avatar remain provider-controlled.\n\n`checkoutContext()` requires `objects:read` and returns an ACL-filtered `workspaceContext`, approved CQ `guidance`, dependency impact, warnings, degraded sections, and retrieval metadata. `commitContribution()` requires `objects:write`; reusable learnings become pending CQ proposals and the response returns `proposedKnowledgeUnits`. Human review is required before guidance is returned to another agent. The SDK does not run or orchestrate the coding agent.\n\n`createGitHubWriteIntent` is a discriminated union for `comment`, `merge`, and `release`. Merge supports `mergeMethod` plus an optional expected head `sha`; release requires `tagName` and defaults to a draft on the server. Approval-time preflight rechecks repository selection, installation state, payload validity, and action-specific GitHub App permissions before any external request.\n\n`releaseReadiness()` returns `ReleaseReadinessReport`. Counts explicitly cover requirements, tasks, blockers, failing checks, open pull requests, and caller-visible pending approvals. Every source carries identity, type, title, status, version, update time, source URL, authority, and freshness; restricted sources and approvals are omitted unless the caller can read their canonical objects or transactions.\n\nApproval reassignment accepts an active approver or owner user ID. Resolved or expired approvals remain readable for audit, but their resolution, reassignment, and comment controls are closed.\n\nCanonical transaction changes include field-level `diffs`, and `objectVersions()` exposes ACL-protected immutable snapshots with actor and provenance metadata.\n\n`settings()` returns a typed, camelCase `WorkspaceSettings` object even though the pilot API's current `GET /settings` storage representation is snake_case and JSON-encodes `require_approval_for`. `updateSettings()` validates policy names and numeric limits before sending the camelCase PATCH contract. Supported policy names are exported as `APPROVAL_POLICY_NAMES`.\n\nWorkflow dispatch and event-delivery inspection/retry methods are owner-only and workspace-scoped. `webhooks()`, `createWebhook()`, and `revokeWebhook()` provide the same lifecycle controls as the owner administration browser.\n\nSemantic index methods separate canonical D1 search coverage from successful Vectorize coverage. Backfills are owner-only, stale-only by default, resumable through Queue job state, and consume Workers AI/Vectorize usage.\n","readmeFilename":"README.md","_rev":"1-0e57de574525ef653e967d3efd049784"}