@geminixiang/mikan 1.0.0-beta.20 → 1.0.0-beta.21
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.
- package/CHANGELOG.md +34 -0
- package/README.md +18 -11
- package/dist/adapters/buffered-responder.d.ts +60 -0
- package/dist/adapters/buffered-responder.d.ts.map +1 -0
- package/dist/adapters/buffered-responder.js +201 -0
- package/dist/adapters/buffered-responder.js.map +1 -0
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +42 -177
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/github/bot.d.ts +14 -76
- package/dist/adapters/github/bot.d.ts.map +1 -1
- package/dist/adapters/github/bot.js +52 -443
- package/dist/adapters/github/bot.js.map +1 -1
- package/dist/adapters/github/client.d.ts +4 -0
- package/dist/adapters/github/client.d.ts.map +1 -1
- package/dist/adapters/github/client.js +5 -0
- package/dist/adapters/github/client.js.map +1 -1
- package/dist/adapters/github/context.d.ts.map +1 -1
- package/dist/adapters/github/context.js +32 -104
- package/dist/adapters/github/context.js.map +1 -1
- package/dist/adapters/github/github-ops.d.ts +90 -0
- package/dist/adapters/github/github-ops.d.ts.map +1 -0
- package/dist/adapters/github/github-ops.js +405 -0
- package/dist/adapters/github/github-ops.js.map +1 -0
- package/dist/adapters/github/repo.d.ts +2 -0
- package/dist/adapters/github/repo.d.ts.map +1 -1
- package/dist/adapters/github/repo.js +5 -0
- package/dist/adapters/github/repo.js.map +1 -1
- package/dist/adapters/github/tools/checks.d.ts.map +1 -1
- package/dist/adapters/github/tools/checks.js +6 -17
- package/dist/adapters/github/tools/checks.js.map +1 -1
- package/dist/adapters/github/tools/issue.d.ts.map +1 -1
- package/dist/adapters/github/tools/issue.js +6 -17
- package/dist/adapters/github/tools/issue.js.map +1 -1
- package/dist/adapters/github/tools/pr.d.ts.map +1 -1
- package/dist/adapters/github/tools/pr.js +6 -17
- package/dist/adapters/github/tools/pr.js.map +1 -1
- package/dist/adapters/github/tools/read.d.ts.map +1 -1
- package/dist/adapters/github/tools/read.js +6 -17
- package/dist/adapters/github/tools/read.js.map +1 -1
- package/dist/adapters/github/tools/review-reply.d.ts.map +1 -1
- package/dist/adapters/github/tools/review-reply.js +6 -17
- package/dist/adapters/github/tools/review-reply.js.map +1 -1
- package/dist/adapters/github/tools/sync.d.ts.map +1 -1
- package/dist/adapters/github/tools/sync.js +6 -17
- package/dist/adapters/github/tools/sync.js.map +1 -1
- package/dist/adapters/slack/bot.js +1 -1
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +33 -151
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/agent.d.ts +0 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +28 -32
- package/dist/agent.js.map +1 -1
- package/dist/cli/arg-grammar.d.ts +25 -0
- package/dist/cli/arg-grammar.d.ts.map +1 -0
- package/dist/cli/arg-grammar.js +59 -0
- package/dist/cli/arg-grammar.js.map +1 -0
- package/dist/cli/boot.d.ts +16 -0
- package/dist/cli/boot.d.ts.map +1 -0
- package/dist/cli/boot.js +119 -0
- package/dist/cli/boot.js.map +1 -0
- package/dist/cli/ext.js +9 -11
- package/dist/cli/ext.js.map +1 -1
- package/dist/commands/extensions.js +2 -2
- package/dist/commands/extensions.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +5 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +8 -8
- package/dist/commands/model.js.map +1 -1
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +7 -5
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/config.d.ts +0 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -41
- package/dist/config.js.map +1 -1
- package/dist/env-manifest.d.ts +35 -0
- package/dist/env-manifest.d.ts.map +1 -0
- package/dist/env-manifest.js +225 -0
- package/dist/env-manifest.js.map +1 -0
- package/dist/events.d.ts +0 -10
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +9 -82
- package/dist/events.js.map +1 -1
- package/dist/execution-resolver.d.ts +1 -0
- package/dist/execution-resolver.d.ts.map +1 -1
- package/dist/execution-resolver.js +33 -36
- package/dist/execution-resolver.js.map +1 -1
- package/dist/harness/event-format.d.ts +66 -0
- package/dist/harness/event-format.d.ts.map +1 -0
- package/dist/harness/event-format.js +112 -0
- package/dist/harness/event-format.js.map +1 -0
- package/dist/harness/extensions/loader.d.ts +9 -6
- package/dist/harness/extensions/loader.d.ts.map +1 -1
- package/dist/harness/extensions/loader.js +35 -50
- package/dist/harness/extensions/loader.js.map +1 -1
- package/dist/harness/extensions/types.d.ts +10 -14
- package/dist/harness/extensions/types.d.ts.map +1 -1
- package/dist/harness/extensions/types.js.map +1 -1
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +1 -0
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/runner.d.ts +16 -0
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +27 -1
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/subagent-runner.d.ts +18 -1
- package/dist/harness/subagent-runner.d.ts.map +1 -1
- package/dist/harness/subagent-runner.js +62 -30
- package/dist/harness/subagent-runner.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/main.js +69 -121
- package/dist/main.js.map +1 -1
- package/dist/observability/instrument.js +6 -4
- package/dist/observability/instrument.js.map +1 -1
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +3 -2
- package/dist/observability/sentry.js.map +1 -1
- package/dist/runtime/conversation-runtime.js +13 -3
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/types.d.ts +4 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts +1 -0
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +4 -1
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts +1 -0
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +4 -1
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/firecracker.d.ts +1 -0
- package/dist/sandbox/firecracker.d.ts.map +1 -1
- package/dist/sandbox/firecracker.js +4 -1
- package/dist/sandbox/firecracker.js.map +1 -1
- package/dist/sandbox/gondolin-bootstrap.d.ts +26 -0
- package/dist/sandbox/gondolin-bootstrap.d.ts.map +1 -0
- package/dist/sandbox/gondolin-bootstrap.js +27 -0
- package/dist/sandbox/gondolin-bootstrap.js.map +1 -0
- package/dist/sandbox/gondolin-contract.d.ts +125 -0
- package/dist/sandbox/gondolin-contract.d.ts.map +1 -0
- package/dist/sandbox/gondolin-contract.js +155 -0
- package/dist/sandbox/gondolin-contract.js.map +1 -0
- package/dist/sandbox/gondolin-fleet.d.ts +1 -1
- package/dist/sandbox/gondolin-fleet.d.ts.map +1 -1
- package/dist/sandbox/gondolin-fleet.js +1 -1
- package/dist/sandbox/gondolin-fleet.js.map +1 -1
- package/dist/sandbox/gondolin-gateway.d.ts +1 -0
- package/dist/sandbox/gondolin-gateway.d.ts.map +1 -1
- package/dist/sandbox/gondolin-gateway.js +13 -6
- package/dist/sandbox/gondolin-gateway.js.map +1 -1
- package/dist/sandbox/gondolin-inventory.d.ts +2 -16
- package/dist/sandbox/gondolin-inventory.d.ts.map +1 -1
- package/dist/sandbox/gondolin-inventory.js +2 -12
- package/dist/sandbox/gondolin-inventory.js.map +1 -1
- package/dist/sandbox/gondolin-placement.d.ts +0 -2
- package/dist/sandbox/gondolin-placement.d.ts.map +1 -1
- package/dist/sandbox/gondolin-placement.js +0 -6
- package/dist/sandbox/gondolin-placement.js.map +1 -1
- package/dist/sandbox/gondolin-recovery.d.ts +33 -0
- package/dist/sandbox/gondolin-recovery.d.ts.map +1 -0
- package/dist/sandbox/gondolin-recovery.js +39 -0
- package/dist/sandbox/gondolin-recovery.js.map +1 -0
- package/dist/sandbox/gondolin-remote.d.ts +2 -5
- package/dist/sandbox/gondolin-remote.d.ts.map +1 -1
- package/dist/sandbox/gondolin-remote.js +12 -39
- package/dist/sandbox/gondolin-remote.js.map +1 -1
- package/dist/sandbox/gondolin-worker-client.d.ts +8 -12
- package/dist/sandbox/gondolin-worker-client.d.ts.map +1 -1
- package/dist/sandbox/gondolin-worker-client.js +13 -15
- package/dist/sandbox/gondolin-worker-client.js.map +1 -1
- package/dist/sandbox/gondolin-worker.d.ts +2 -40
- package/dist/sandbox/gondolin-worker.d.ts.map +1 -1
- package/dist/sandbox/gondolin-worker.js.map +1 -1
- package/dist/sandbox/gondolin.d.ts +1 -0
- package/dist/sandbox/gondolin.d.ts.map +1 -1
- package/dist/sandbox/gondolin.js +8 -4
- package/dist/sandbox/gondolin.js.map +1 -1
- package/dist/sandbox/host.d.ts +1 -0
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +3 -0
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/index.d.ts +9 -1
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +14 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/types.d.ts +5 -0
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/sandbox/utils.d.ts +1 -0
- package/dist/sandbox/utils.d.ts.map +1 -1
- package/dist/sandbox/utils.js +5 -2
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts +32 -0
- package/dist/sessions/chat-history-sync.d.ts.map +1 -0
- package/dist/sessions/{agent-memory-file-manager.js → chat-history-sync.js} +24 -83
- package/dist/sessions/chat-history-sync.js.map +1 -0
- package/dist/sessions/conversation-log.d.ts +13 -0
- package/dist/sessions/conversation-log.d.ts.map +1 -0
- package/dist/sessions/conversation-log.js +47 -0
- package/dist/sessions/conversation-log.js.map +1 -0
- package/dist/sessions/rotation.d.ts +2 -0
- package/dist/sessions/rotation.d.ts.map +1 -0
- package/dist/sessions/rotation.js +39 -0
- package/dist/sessions/rotation.js.map +1 -0
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +4 -10
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +2 -2
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/settings-mutation.d.ts +23 -0
- package/dist/settings-mutation.d.ts.map +1 -0
- package/dist/settings-mutation.js +42 -0
- package/dist/settings-mutation.js.map +1 -0
- package/dist/tools/event.d.ts.map +1 -1
- package/dist/tools/event.js +27 -46
- package/dist/tools/event.js.map +1 -1
- package/dist/tools/host-fn-tool.d.ts +21 -0
- package/dist/tools/host-fn-tool.d.ts.map +1 -0
- package/dist/tools/host-fn-tool.js +32 -0
- package/dist/tools/host-fn-tool.js.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/react.d.ts.map +1 -1
- package/dist/tools/react.js +6 -17
- package/dist/tools/react.js.map +1 -1
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +7 -26
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +5 -2
- package/dist/tools/sandbox.js.map +1 -1
- package/dist/tools/subagent-slots.d.ts +28 -0
- package/dist/tools/subagent-slots.d.ts.map +1 -0
- package/dist/tools/subagent-slots.js +57 -0
- package/dist/tools/subagent-slots.js.map +1 -0
- package/dist/tools/subagent.d.ts +7 -2
- package/dist/tools/subagent.d.ts.map +1 -1
- package/dist/tools/subagent.js +160 -111
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/types.d.ts +10 -9
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/types.d.ts +5 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/date.d.ts +1 -1
- package/dist/utils/date.js +1 -1
- package/dist/utils/date.js.map +1 -1
- package/dist/vault/disabled.d.ts.map +1 -1
- package/dist/vault/disabled.js +0 -1
- package/dist/vault/disabled.js.map +1 -1
- package/dist/vault/index.d.ts +0 -2
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +0 -10
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/injection.d.ts +20 -0
- package/dist/vault/injection.d.ts.map +1 -0
- package/dist/vault/injection.js +27 -0
- package/dist/vault/injection.js.map +1 -0
- package/dist/vault/types.d.ts +0 -2
- package/dist/vault/types.d.ts.map +1 -1
- package/dist/vault/types.js.map +1 -1
- package/dist/web/admin/portal.d.ts +3 -3
- package/dist/web/admin/portal.d.ts.map +1 -1
- package/dist/web/admin/portal.js +41 -39
- package/dist/web/admin/portal.js.map +1 -1
- package/dist/web/admin/types.d.ts +3 -0
- package/dist/web/admin/types.d.ts.map +1 -1
- package/dist/web/admin/types.js.map +1 -1
- package/dist/web/agent-events/portal.d.ts.map +1 -1
- package/dist/web/agent-events/portal.js +2 -1
- package/dist/web/agent-events/portal.js.map +1 -1
- package/package.json +1 -1
- package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
- package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
- package/dist/sessions/agent-memory-file-manager.js.map +0 -1
- package/dist/vault/routing.d.ts +0 -4
- package/dist/vault/routing.d.ts.map +0 -1
- package/dist/vault/routing.js +0 -6
- package/dist/vault/routing.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,uEAAuE;YACvE,mEAAmE;KACtE,CAAC,CACH;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,8EAA8E;YAC9E,6EAA6E;KAChF,CAAC,CACH;IACD,QAAQ,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,+EAA+E;YAC/E,4EAA4E;KAC/E,CAAC,CACH;CACF,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;AAE9F,SAAS,eAAe,CAAC,GAAuB;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IACtF,MAAM,MAAM,GACV,GAAG,CAAC,UAAU,KAAK,IAAI;QACrB,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;YACvC,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,GAAG,CAAC,UAAU,KAAK,SAAS;gB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EAAE,CAAC,GAAG,CAAC,UAAU,KAAK,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAC5E,CAAC;YACF,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,cAAc,SAAS,CAAC,MAAM,eAAe,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,aAAa,OAAO,CAAC,MAAM,UAAU,CAAC;YAC/I,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;qBACzD;iBACF;gBACD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\nimport type { GithubCheckSummary } from \"../types.js\";\n\nconst githubChecksSchema = Type.Object({\n branch: Type.Optional(\n Type.String({\n description:\n \"Branch whose CI checks to read (e.g. a pi/<name> branch you pushed). \" +\n \"Omit in a pull-request conversation to read the PR head's checks.\",\n }),\n ),\n job_id: Type.Optional(\n Type.Number({\n description:\n \"A [job …] id from the summary output (GitHub Actions checks) — returns that \" +\n \"CI job's log (tail) instead of the summary, for diagnosing a failing check.\",\n }),\n ),\n build_id: Type.Optional(\n Type.String({\n description:\n \"A [build …] uuid from the summary output (Cloud Build checks) — returns that \" +\n \"build's log (tail) instead of the summary. Mutually exclusive with job_id.\",\n }),\n ),\n});\n\n/** Conclusions that mean \"this check did not pass and needs attention\". */\nconst FAILING_CONCLUSIONS = new Set([\"failure\", \"timed_out\", \"action_required\", \"cancelled\"]);\n\nfunction formatCheckLine(run: GithubCheckSummary): string {\n const state = run.status === \"completed\" ? (run.conclusion ?? \"unknown\") : run.status;\n const marker =\n run.conclusion === null\n ? \"…\"\n : FAILING_CONCLUSIONS.has(run.conclusion)\n ? \"✗\"\n : run.conclusion === \"success\"\n ? \"✓\"\n : \"−\";\n // GitHub Actions logs fetch via job_id; Cloud Build logs via build_id when\n // the host has GCP credentials. Other external CI keeps logs on its own\n // service, so advertising an id there would only invite doomed fetches.\n const handle =\n run.appSlug === \"github-actions\"\n ? `[job ${run.id}]`\n : run.buildLogAvailable && run.externalId\n ? `[build ${run.externalId}]`\n : `[external CI: ${run.appSlug ?? \"unknown\"} — logs not on GitHub]`;\n const line = `${marker} ${run.name}: ${state} ${handle}${run.url ? ` (${run.url})` : \"\"}`;\n const failed = run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion);\n return failed && run.outputSummary\n ? `${line}\\n ↳ ${run.outputSummary.replace(/\\s*\\n\\s*/g, \" \")}`\n : line;\n}\n\nexport interface GithubChecksFns {\n getChecks: (branch?: string) => Promise<GithubCheckSummary[]>;\n getJobLog: (jobId: number) => Promise<string>;\n getBuildLog: (buildId: string) => Promise<string>;\n}\n\n/**\n * The `github_checks` tool reads CI check runs (GitHub Actions and other\n * check-reporting apps) for a branch or the conversation's PR head, and can\n * fetch one job's log tail so the agent can diagnose failures and iterate.\n * Read-only, host-side; wired per run and only for GitHub conversations.\n */\nexport function createGithubChecksTool(): {\n tool: AgentTool<typeof githubChecksSchema>;\n setGithubChecksFunction: (fns: GithubChecksFns | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubChecksFns, typeof githubChecksSchema>({\n name: \"github_checks\",\n description:\n \"Read CI status (check runs) for a branch you pushed with github_pr, or for this \" +\n \"conversation's pull request when branch is omitted. Pass job_id (a [job …] id, \" +\n \"GitHub Actions) or build_id (a [build …] uuid, Cloud Build) from the summary to \" +\n \"fetch that run's log. Other external CI checks keep logs on their own service: use \" +\n \"their summary/url, or reproduce the failure locally in ./repo. Only available in \" +\n \"GitHub conversations.\",\n parameters: githubChecksSchema,\n unavailable: \"github_checks is only available in GitHub conversations.\",\n run: async (checksFns, args) => {\n if (args.job_id !== undefined && args.build_id !== undefined) {\n throw new Error(\"Pass either job_id or build_id, not both.\");\n }\n\n if (args.job_id !== undefined) {\n const logText = await checksFns.getJobLog(args.job_id);\n return {\n content: [{ type: \"text\" as const, text: logText || \"(empty log)\" }],\n details: undefined,\n };\n }\n\n if (args.build_id !== undefined) {\n const logText = await checksFns.getBuildLog(args.build_id);\n return {\n content: [{ type: \"text\" as const, text: logText || \"(empty log)\" }],\n details: undefined,\n };\n }\n\n const runs = await checksFns.getChecks(args.branch);\n if (runs.length === 0) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: \"No check runs found — CI may not have started yet; try again shortly.\",\n },\n ],\n details: undefined,\n };\n }\n const completed = runs.filter((run) => run.status === \"completed\");\n const failing = completed.filter(\n (run) => run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion),\n );\n const summary = `${runs.length} check(s): ${completed.length} completed, ${runs.length - completed.length} running, ${failing.length} failing`;\n return {\n content: [\n {\n type: \"text\" as const,\n text: [summary, ...runs.map(formatCheckLine)].join(\"\\n\"),\n },\n ],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubChecksFunction: setFn };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,iBAAiB;;;;;;;EA+BrB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,IAAI,EAAE,SAAS,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC1C,sBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;CAC5D,CAoBA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
|
|
2
3
|
const githubIssueSchema = Type.Object({
|
|
3
4
|
action: Type.Union([
|
|
4
5
|
Type.Literal("add_labels"),
|
|
@@ -26,34 +27,22 @@ const githubIssueSchema = Type.Object({
|
|
|
26
27
|
* the App; wired per run and only for GitHub conversations.
|
|
27
28
|
*/
|
|
28
29
|
export function createGithubIssueTool() {
|
|
29
|
-
|
|
30
|
-
const tool = {
|
|
30
|
+
const { tool, setFn } = defineHostFnTool({
|
|
31
31
|
name: "github_issue",
|
|
32
|
-
label: "github_issue",
|
|
33
32
|
description: "Manage issues in this repo: add/remove labels, add/remove assignees, close " +
|
|
34
33
|
"(optionally with state_reason) or reopen. number defaults to this conversation's " +
|
|
35
34
|
"issue; any issue number in this repo works for triage. Only available in GitHub " +
|
|
36
35
|
"conversations.",
|
|
37
36
|
parameters: githubIssueSchema,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
throw new Error("github_issue is only available in GitHub conversations.");
|
|
41
|
-
}
|
|
42
|
-
if (signal?.aborted) {
|
|
43
|
-
throw new Error("Operation aborted");
|
|
44
|
-
}
|
|
37
|
+
unavailable: "github_issue is only available in GitHub conversations.",
|
|
38
|
+
run: async (issueFn, args) => {
|
|
45
39
|
const report = await issueFn(args);
|
|
46
40
|
return {
|
|
47
41
|
content: [{ type: "text", text: report }],
|
|
48
42
|
details: undefined,
|
|
49
43
|
};
|
|
50
44
|
},
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
tool,
|
|
54
|
-
setGithubIssueFunction: (fn) => {
|
|
55
|
-
issueFn = fn;
|
|
56
|
-
},
|
|
57
|
-
};
|
|
45
|
+
});
|
|
46
|
+
return { tool, setGithubIssueFunction: setFn };
|
|
58
47
|
}
|
|
59
48
|
//# sourceMappingURL=issue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/issue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/issue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,IAAI,CAAC,KAAK,CAChB;QACE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;KACvB,EACD,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAC5C;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EAAE,iEAAiE;KAC/E,CAAC,CACH;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE,CAAC,CAC9E;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC,CAAC;IAC7F,SAAS,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QACxB,WAAW,EAAE,kDAAkD;KAChE,CAAC,CACH;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE;QACnE,WAAW,EAAE,uCAAuC;KACrD,CAAC,CACH;CACF,CAAC,CAAC;AAIH;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IAInC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAA0C;QAChF,IAAI,EAAE,cAAc;QACpB,WAAW,EACT,6EAA6E;YAC7E,mFAAmF;YACnF,kFAAkF;YAClF,gBAAgB;QAClB,UAAU,EAAE,iBAAiB;QAC7B,WAAW,EAAE,yDAAyD;QACtE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAA0B,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAClD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\nimport type { GithubIssueRequest } from \"../types.js\";\n\nconst githubIssueSchema = Type.Object({\n action: Type.Union(\n [\n Type.Literal(\"add_labels\"),\n Type.Literal(\"remove_label\"),\n Type.Literal(\"add_assignees\"),\n Type.Literal(\"remove_assignees\"),\n Type.Literal(\"close\"),\n Type.Literal(\"reopen\"),\n ],\n { description: \"Issue management action.\" },\n ),\n number: Type.Optional(\n Type.Number({\n description: \"Issue/PR number in this repo; omit for this conversation's own.\",\n }),\n ),\n labels: Type.Optional(\n Type.Array(Type.String(), { description: \"add_labels: label names to add.\" }),\n ),\n label: Type.Optional(Type.String({ description: \"remove_label: the label name to remove.\" })),\n assignees: Type.Optional(\n Type.Array(Type.String(), {\n description: \"add_assignees / remove_assignees: GitHub logins.\",\n }),\n ),\n state_reason: Type.Optional(\n Type.Union([Type.Literal(\"completed\"), Type.Literal(\"not_planned\")], {\n description: \"close: why the issue is being closed.\",\n }),\n ),\n});\n\nexport type GithubIssueFn = (request: GithubIssueRequest) => Promise<string>;\n\n/**\n * The `github_issue` tool manages labels, assignees, and open/closed state of\n * issues in the conversation's repo (any issue number — triage). Host-side as\n * the App; wired per run and only for GitHub conversations.\n */\nexport function createGithubIssueTool(): {\n tool: AgentTool<typeof githubIssueSchema>;\n setGithubIssueFunction: (fn: GithubIssueFn | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubIssueFn, typeof githubIssueSchema>({\n name: \"github_issue\",\n description:\n \"Manage issues in this repo: add/remove labels, add/remove assignees, close \" +\n \"(optionally with state_reason) or reopen. number defaults to this conversation's \" +\n \"issue; any issue number in this repo works for triage. Only available in GitHub \" +\n \"conversations.\",\n parameters: githubIssueSchema,\n unavailable: \"github_issue is only available in GitHub conversations.\",\n run: async (issueFn, args) => {\n const report = await issueFn(args as GithubIssueRequest);\n return {\n content: [{ type: \"text\" as const, text: report }],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubIssueFunction: setFn };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnE,QAAA,MAAM,cAAc;;;;;;EAalB,CAAC;AAIH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,IAAI,EAAE,SAAS,CAAC,OAAO,cAAc,CAAC,CAAC;IACvC,mBAAmB,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CACnG,CA+BA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
|
|
2
3
|
const githubPrSchema = Type.Object({
|
|
3
4
|
branch: Type.String({
|
|
4
5
|
description: 'Local branch inside ./repo to push. Must be named pi/<something> (e.g. "pi/fix-42"); ' +
|
|
@@ -18,23 +19,16 @@ const githubPrSchema = Type.Object({
|
|
|
18
19
|
* for GitHub conversations.
|
|
19
20
|
*/
|
|
20
21
|
export function createGithubPrTool() {
|
|
21
|
-
|
|
22
|
-
const tool = {
|
|
22
|
+
const { tool, setFn } = defineHostFnTool({
|
|
23
23
|
name: "github_pr",
|
|
24
|
-
label: "github_pr",
|
|
25
24
|
description: "Push a pi/<name> branch you committed inside ./repo and open a GitHub pull request " +
|
|
26
25
|
"(or draft) for it. Pushing a branch that already has an open PR — including this " +
|
|
27
26
|
"conversation's own PR head — updates that PR instead of opening a new one. Only " +
|
|
28
27
|
"available in GitHub issue/PR conversations. You cannot push to the default branch " +
|
|
29
28
|
"and you cannot merge — humans review and merge the PR.",
|
|
30
29
|
parameters: githubPrSchema,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
throw new Error("github_pr is only available in GitHub conversations.");
|
|
34
|
-
}
|
|
35
|
-
if (signal?.aborted) {
|
|
36
|
-
throw new Error("Operation aborted");
|
|
37
|
-
}
|
|
30
|
+
unavailable: "github_pr is only available in GitHub conversations.",
|
|
31
|
+
run: async (prFn, args) => {
|
|
38
32
|
const result = await prFn(args);
|
|
39
33
|
return {
|
|
40
34
|
content: [
|
|
@@ -48,12 +42,7 @@ export function createGithubPrTool() {
|
|
|
48
42
|
details: undefined,
|
|
49
43
|
};
|
|
50
44
|
},
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
tool,
|
|
54
|
-
setGithubPrFunction: (fn) => {
|
|
55
|
-
prFn = fn;
|
|
56
|
-
},
|
|
57
|
-
};
|
|
45
|
+
});
|
|
46
|
+
return { tool, setGithubPrFunction: setFn };
|
|
58
47
|
}
|
|
59
48
|
//# sourceMappingURL=pr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/pr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"pr.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/pr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EACT,uFAAuF;YACvF,uFAAuF;YACvF,+BAA+B;KAClC,CAA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,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\nimport type { GithubPrRequest, GithubPrResult } from \"../types.js\";\n\nconst githubPrSchema = Type.Object({\n branch: Type.String({\n description:\n 'Local branch inside ./repo to push. Must be named pi/<something> (e.g. \"pi/fix-42\"); ' +\n \"the default branch is never pushable. To update this conversation's own PR, pass its \" +\n \"checked-out pi/* head branch.\",\n }),\n title: Type.String({ description: \"Pull request title.\" }),\n body: Type.Optional(Type.String({ description: \"Pull request description (Markdown).\" })),\n base: Type.Optional(\n Type.String({ description: \"Target branch; defaults to the repository's default branch.\" }),\n ),\n draft: Type.Optional(Type.Boolean({ description: \"Open as a draft pull request.\" })),\n});\n\ntype GithubPrArgs = GithubPrRequest;\n\n/**\n * The `github_pr` tool pushes a branch the agent prepared in the\n * conversation's ./repo clone and opens a pull request as the GitHub App.\n * The push and API calls run host-side with an ephemeral repo-scoped token;\n * the sandbox never holds credentials. Wired per run via the setter, and only\n * for GitHub conversations.\n */\nexport function createGithubPrTool(): {\n tool: AgentTool<typeof githubPrSchema>;\n setGithubPrFunction: (fn: ((request: GithubPrRequest) => Promise<GithubPrResult>) | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<\n (request: GithubPrRequest) => Promise<GithubPrResult>,\n typeof githubPrSchema\n >({\n name: \"github_pr\",\n description:\n \"Push a pi/<name> branch you committed inside ./repo and open a GitHub pull request \" +\n \"(or draft) for it. Pushing a branch that already has an open PR — including this \" +\n \"conversation's own PR head — updates that PR instead of opening a new one. Only \" +\n \"available in GitHub issue/PR conversations. You cannot push to the default branch \" +\n \"and you cannot merge — humans review and merge the PR.\",\n parameters: githubPrSchema,\n unavailable: \"github_pr is only available in GitHub conversations.\",\n run: async (prFn, args: GithubPrArgs) => {\n const result = await prFn(args);\n return {\n content: [\n {\n type: \"text\" as const,\n text: result.updatedExisting\n ? `Pushed to existing PR #${result.number}: ${result.url}`\n : `Opened ${args.draft ? \"draft \" : \"\"}PR #${result.number}: ${result.url}`,\n },\n ],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubPrFunction: setFn };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,QAAA,MAAM,gBAAgB;;;;;;EA8BpB,CAAC;AAoGH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,IAAI,EAAE,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACzC,qBAAqB,EAAE,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1D,CAoBA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
|
|
2
3
|
const githubReadSchema = Type.Object({
|
|
3
4
|
action: Type.Union([
|
|
4
5
|
Type.Literal("pr"),
|
|
@@ -119,34 +120,22 @@ function formatResult(result) {
|
|
|
119
120
|
* construction; wired per run and only for GitHub conversations.
|
|
120
121
|
*/
|
|
121
122
|
export function createGithubReadTool() {
|
|
122
|
-
|
|
123
|
-
const tool = {
|
|
123
|
+
const { tool, setFn } = defineHostFnTool({
|
|
124
124
|
name: "github_read",
|
|
125
|
-
label: "github_read",
|
|
126
125
|
description: "Read GitHub metadata for this repo: PR state/diff stats (pr), changed files " +
|
|
127
126
|
"(pr_files), reviews and open inline threads (pr_reviews), issue metadata (issue), " +
|
|
128
127
|
"recent comments (comments), or a filtered issue/PR listing (list). number defaults " +
|
|
129
128
|
"to this conversation's issue/PR. Only available in GitHub conversations.",
|
|
130
129
|
parameters: githubReadSchema,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
throw new Error("github_read is only available in GitHub conversations.");
|
|
134
|
-
}
|
|
135
|
-
if (signal?.aborted) {
|
|
136
|
-
throw new Error("Operation aborted");
|
|
137
|
-
}
|
|
130
|
+
unavailable: "github_read is only available in GitHub conversations.",
|
|
131
|
+
run: async (readFn, args) => {
|
|
138
132
|
const result = await readFn(args);
|
|
139
133
|
return {
|
|
140
134
|
content: [{ type: "text", text: formatResult(result) }],
|
|
141
135
|
details: undefined,
|
|
142
136
|
};
|
|
143
137
|
},
|
|
144
|
-
};
|
|
145
|
-
return {
|
|
146
|
-
tool,
|
|
147
|
-
setGithubReadFunction: (fn) => {
|
|
148
|
-
readFn = fn;
|
|
149
|
-
},
|
|
150
|
-
};
|
|
138
|
+
});
|
|
139
|
+
return { tool, setGithubReadFunction: setFn };
|
|
151
140
|
}
|
|
152
141
|
//# sourceMappingURL=read.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,IAAI,CAAC,KAAK,CAChB;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,UAAU,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IAEF,OAAO;QACL,IAAI;QACJ,qBAAqB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC5B,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport type { GithubReadRequest, GithubReadResult } from \"../types.js\";\n\nconst githubReadSchema = Type.Object({\n action: Type.Union(\n [\n Type.Literal(\"pr\"),\n Type.Literal(\"pr_files\"),\n Type.Literal(\"pr_reviews\"),\n Type.Literal(\"issue\"),\n Type.Literal(\"comments\"),\n Type.Literal(\"list\"),\n ],\n {\n description:\n \"pr: PR metadata (state, base/head, diff stats). pr_files: changed files. \" +\n \"pr_reviews: submitted reviews + open inline threads (with rc- ids for \" +\n \"github_review_reply). issue: issue metadata. comments: recent conversation \" +\n \"comments. list: issues/PRs in this repo.\",\n },\n ),\n number: Type.Optional(\n Type.Number({\n description: \"Issue/PR number to read; omit for this conversation's own.\",\n }),\n ),\n state: Type.Optional(\n Type.String({ description: \"list only: open | closed | all (default open).\" }),\n ),\n labels: Type.Optional(\n Type.String({ description: \"list only: comma-separated label names to filter by.\" }),\n ),\n creator: Type.Optional(Type.String({ description: \"list only: filter by author login.\" })),\n});\n\nconst MAX_BODY_CHARS = 1000;\nconst MAX_COMMENT_CHARS = 500;\nconst MAX_REVIEW_BODY_CHARS = 300;\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? `${text.slice(0, max)}…` : text;\n}\n\nfunction formatResult(result: GithubReadResult): string {\n switch (result.kind) {\n case \"pr\": {\n const pr = result.pr;\n const flags = [\n pr.state ?? \"unknown\",\n pr.draft ? \"draft\" : null,\n pr.merged ? \"merged\" : null,\n pr.mergeable_state ? `mergeable_state: ${pr.mergeable_state}` : null,\n ].filter(Boolean);\n return [\n `PR #${pr.number}: ${pr.title ?? \"\"} [${flags.join(\", \")}]`,\n `${pr.head?.ref ?? \"?\"} → ${pr.base?.ref ?? \"?\"} | ${pr.changed_files ?? \"?\"} files, +${pr.additions ?? \"?\"} -${pr.deletions ?? \"?\"}`,\n pr.user ? `author: @${pr.user.login}` : null,\n pr.body ? truncate(pr.body, MAX_BODY_CHARS) : \"(no description)\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n case \"pr_files\": {\n if (result.files.length === 0) return \"No changed files.\";\n const lines = result.files.map(\n (file) => `${file.status.padEnd(8)} ${file.filename} +${file.additions} -${file.deletions}`,\n );\n return [`${result.files.length} changed file(s):`, ...lines].join(\"\\n\");\n }\n case \"pr_reviews\": {\n const reviewLines = result.reviews\n .filter((review) => review.state !== \"PENDING\")\n .map((review) => {\n const body = review.body?.trim()\n ? ` — ${truncate(review.body, MAX_REVIEW_BODY_CHARS)}`\n : \"\";\n return `@${review.user.login}: ${review.state}${body}`;\n });\n // Thread roots only: replies belong to their root's thread. The rc- id\n // is what github_review_reply takes.\n const rootThreads = result.threads.filter((comment) => comment.in_reply_to_id === undefined);\n const threadLines = rootThreads.map((comment) => {\n const location = comment.line !== null ? `${comment.path}:${comment.line}` : comment.path;\n const replies = result.threads.filter((reply) => reply.in_reply_to_id === comment.id);\n const replyNote =\n replies.length > 0\n ? ` (${replies.length} repl${replies.length === 1 ? \"y\" : \"ies\"})`\n : \"\";\n return `rc-${comment.id} ${location} @${comment.user.login}${replyNote}: ${truncate(comment.body, MAX_REVIEW_BODY_CHARS)}`;\n });\n return [\n reviewLines.length > 0 ? `Reviews:\\n${reviewLines.join(\"\\n\")}` : \"No submitted reviews.\",\n threadLines.length > 0\n ? `Inline threads (reply with github_review_reply):\\n${threadLines.join(\"\\n\")}`\n : \"No inline review threads.\",\n ].join(\"\\n\\n\");\n }\n case \"issue\": {\n const issue = result.issue;\n const labels = (issue.labels ?? []).map((label) => label.name).join(\", \");\n const assignees = (issue.assignees ?? []).map((assignee) => `@${assignee.login}`).join(\", \");\n return [\n `#${issue.number}: ${issue.title} [${issue.state ?? \"unknown\"}${issue.pull_request ? \", PR\" : \"\"}]`,\n labels ? `labels: ${labels}` : null,\n assignees ? `assignees: ${assignees}` : null,\n `author: @${issue.user.login}`,\n issue.body ? truncate(issue.body, MAX_BODY_CHARS) : \"(no body)\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n case \"comments\": {\n if (result.comments.length === 0) return \"No comments.\";\n return result.comments\n .map(\n (comment) =>\n `@${comment.user.login} (${comment.created_at}): ${truncate(comment.body, MAX_COMMENT_CHARS)}`,\n )\n .join(\"\\n\");\n }\n case \"list\": {\n if (result.issues.length === 0) return \"No matching issues.\";\n return result.issues\n .map((issue) => {\n const labels = (issue.labels ?? []).map((label) => label.name).join(\", \");\n const kind = issue.pull_request ? \"PR\" : \"issue\";\n return `#${issue.number} [${issue.state ?? \"?\"} ${kind}] ${issue.title}${labels ? ` (${labels})` : \"\"}`;\n })\n .join(\"\\n\");\n }\n }\n}\n\nexport type GithubReadFn = (request: GithubReadRequest) => Promise<GithubReadResult>;\n\n/**\n * The `github_read` tool reads what the ./repo clone cannot show: PR diff\n * stats and changed files, review state with open inline threads, and other\n * issues/PRs in this repo for triage. Read-only, host-side, same-repo by\n * construction; wired per run and only for GitHub conversations.\n */\nexport function createGithubReadTool(): {\n tool: AgentTool<typeof githubReadSchema>;\n setGithubReadFunction: (fn: GithubReadFn | null) => void;\n} {\n let readFn: GithubReadFn | null = null;\n\n const tool: AgentTool<typeof githubReadSchema> = {\n name: \"github_read\",\n label: \"github_read\",\n description:\n \"Read GitHub metadata for this repo: PR state/diff stats (pr), changed files \" +\n \"(pr_files), reviews and open inline threads (pr_reviews), issue metadata (issue), \" +\n \"recent comments (comments), or a filtered issue/PR listing (list). number defaults \" +\n \"to this conversation's issue/PR. Only available in GitHub conversations.\",\n parameters: githubReadSchema,\n execute: async (_toolCallId: string, args: GithubReadRequest, signal?: AbortSignal) => {\n if (!readFn) {\n throw new Error(\"github_read is only available in GitHub conversations.\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n const result = await readFn(args);\n return {\n content: [{ type: \"text\" as const, text: formatResult(result) }],\n details: undefined,\n };\n },\n };\n\n return {\n tool,\n setGithubReadFunction: (fn) => {\n readFn = fn;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,IAAI,CAAC,KAAK,CAChB;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;KACrB,EACD;QACE,WAAW,EACT,2EAA2E;YAC3E,wEAAwE;YACxE,6EAA6E;YAC7E,0CAA0C;KAC7C,CACF;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EAAE,4DAA4D;KAC1E,CAAC,CACH;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,CAC/E;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sDAAsD,EAAE,CAAC,CACrF;IACD,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC,CAAC;CAC3F,CAAC,CAAC;AAEH,MAAM,c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EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAyB,CAAC,CAAC;YACvD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChE,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\nimport type { GithubReadRequest, GithubReadResult } from \"../types.js\";\n\nconst githubReadSchema = Type.Object({\n action: Type.Union(\n [\n Type.Literal(\"pr\"),\n Type.Literal(\"pr_files\"),\n Type.Literal(\"pr_reviews\"),\n Type.Literal(\"issue\"),\n Type.Literal(\"comments\"),\n Type.Literal(\"list\"),\n ],\n {\n description:\n \"pr: PR metadata (state, base/head, diff stats). pr_files: changed files. \" +\n \"pr_reviews: submitted reviews + open inline threads (with rc- ids for \" +\n \"github_review_reply). issue: issue metadata. comments: recent conversation \" +\n \"comments. list: issues/PRs in this repo.\",\n },\n ),\n number: Type.Optional(\n Type.Number({\n description: \"Issue/PR number to read; omit for this conversation's own.\",\n }),\n ),\n state: Type.Optional(\n Type.String({ description: \"list only: open | closed | all (default open).\" }),\n ),\n labels: Type.Optional(\n Type.String({ description: \"list only: comma-separated label names to filter by.\" }),\n ),\n creator: Type.Optional(Type.String({ description: \"list only: filter by author login.\" })),\n});\n\nconst MAX_BODY_CHARS = 1000;\nconst MAX_COMMENT_CHARS = 500;\nconst MAX_REVIEW_BODY_CHARS = 300;\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? `${text.slice(0, max)}…` : text;\n}\n\nfunction formatResult(result: GithubReadResult): string {\n switch (result.kind) {\n case \"pr\": {\n const pr = result.pr;\n const flags = [\n pr.state ?? \"unknown\",\n pr.draft ? \"draft\" : null,\n pr.merged ? \"merged\" : null,\n pr.mergeable_state ? `mergeable_state: ${pr.mergeable_state}` : null,\n ].filter(Boolean);\n return [\n `PR #${pr.number}: ${pr.title ?? \"\"} [${flags.join(\", \")}]`,\n `${pr.head?.ref ?? \"?\"} → ${pr.base?.ref ?? \"?\"} | ${pr.changed_files ?? \"?\"} files, +${pr.additions ?? \"?\"} -${pr.deletions ?? \"?\"}`,\n pr.user ? `author: @${pr.user.login}` : null,\n pr.body ? truncate(pr.body, MAX_BODY_CHARS) : \"(no description)\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n case \"pr_files\": {\n if (result.files.length === 0) return \"No changed files.\";\n const lines = result.files.map(\n (file) => `${file.status.padEnd(8)} ${file.filename} +${file.additions} -${file.deletions}`,\n );\n return [`${result.files.length} changed file(s):`, ...lines].join(\"\\n\");\n }\n case \"pr_reviews\": {\n const reviewLines = result.reviews\n .filter((review) => review.state !== \"PENDING\")\n .map((review) => {\n const body = review.body?.trim()\n ? ` — ${truncate(review.body, MAX_REVIEW_BODY_CHARS)}`\n : \"\";\n return `@${review.user.login}: ${review.state}${body}`;\n });\n // Thread roots only: replies belong to their root's thread. The rc- id\n // is what github_review_reply takes.\n const rootThreads = result.threads.filter((comment) => comment.in_reply_to_id === undefined);\n const threadLines = rootThreads.map((comment) => {\n const location = comment.line !== null ? `${comment.path}:${comment.line}` : comment.path;\n const replies = result.threads.filter((reply) => reply.in_reply_to_id === comment.id);\n const replyNote =\n replies.length > 0\n ? ` (${replies.length} repl${replies.length === 1 ? \"y\" : \"ies\"})`\n : \"\";\n return `rc-${comment.id} ${location} @${comment.user.login}${replyNote}: ${truncate(comment.body, MAX_REVIEW_BODY_CHARS)}`;\n });\n return [\n reviewLines.length > 0 ? `Reviews:\\n${reviewLines.join(\"\\n\")}` : \"No submitted reviews.\",\n threadLines.length > 0\n ? `Inline threads (reply with github_review_reply):\\n${threadLines.join(\"\\n\")}`\n : \"No inline review threads.\",\n ].join(\"\\n\\n\");\n }\n case \"issue\": {\n const issue = result.issue;\n const labels = (issue.labels ?? []).map((label) => label.name).join(\", \");\n const assignees = (issue.assignees ?? []).map((assignee) => `@${assignee.login}`).join(\", \");\n return [\n `#${issue.number}: ${issue.title} [${issue.state ?? \"unknown\"}${issue.pull_request ? \", PR\" : \"\"}]`,\n labels ? `labels: ${labels}` : null,\n assignees ? `assignees: ${assignees}` : null,\n `author: @${issue.user.login}`,\n issue.body ? truncate(issue.body, MAX_BODY_CHARS) : \"(no body)\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n case \"comments\": {\n if (result.comments.length === 0) return \"No comments.\";\n return result.comments\n .map(\n (comment) =>\n `@${comment.user.login} (${comment.created_at}): ${truncate(comment.body, MAX_COMMENT_CHARS)}`,\n )\n .join(\"\\n\");\n }\n case \"list\": {\n if (result.issues.length === 0) return \"No matching issues.\";\n return result.issues\n .map((issue) => {\n const labels = (issue.labels ?? []).map((label) => label.name).join(\", \");\n const kind = issue.pull_request ? \"PR\" : \"issue\";\n return `#${issue.number} [${issue.state ?? \"?\"} ${kind}] ${issue.title}${labels ? ` (${labels})` : \"\"}`;\n })\n .join(\"\\n\");\n }\n }\n}\n\nexport type GithubReadFn = (request: GithubReadRequest) => Promise<GithubReadResult>;\n\n/**\n * The `github_read` tool reads what the ./repo clone cannot show: PR diff\n * stats and changed files, review state with open inline threads, and other\n * issues/PRs in this repo for triage. Read-only, host-side, same-repo by\n * construction; wired per run and only for GitHub conversations.\n */\nexport function createGithubReadTool(): {\n tool: AgentTool<typeof githubReadSchema>;\n setGithubReadFunction: (fn: GithubReadFn | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubReadFn, typeof githubReadSchema>({\n name: \"github_read\",\n description:\n \"Read GitHub metadata for this repo: PR state/diff stats (pr), changed files \" +\n \"(pr_files), reviews and open inline threads (pr_reviews), issue metadata (issue), \" +\n \"recent comments (comments), or a filtered issue/PR listing (list). number defaults \" +\n \"to this conversation's issue/PR. Only available in GitHub conversations.\",\n parameters: githubReadSchema,\n unavailable: \"github_read is only available in GitHub conversations.\",\n run: async (readFn, args) => {\n const result = await readFn(args as GithubReadRequest);\n return {\n content: [{ type: \"text\" as const, text: formatResult(result) }],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubReadFunction: setFn };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-reply.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/review-reply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"review-reply.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/review-reply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,QAAA,MAAM,uBAAuB;;;EAO3B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEhG;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI;IAC7C,IAAI,EAAE,SAAS,CAAC,OAAO,uBAAuB,CAAC,CAAC;IAChD,4BAA4B,EAAE,CAAC,EAAE,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC;CACxE,CAwBA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
|
|
2
3
|
const githubReviewReplySchema = Type.Object({
|
|
3
4
|
comment_id: Type.Number({
|
|
4
5
|
description: "Numeric id from an [PR review comment rc-<id> …] message in this conversation " +
|
|
@@ -12,21 +13,14 @@ const githubReviewReplySchema = Type.Object({
|
|
|
12
13
|
* host-side as the App; wired per run and only for GitHub conversations.
|
|
13
14
|
*/
|
|
14
15
|
export function createGithubReviewReplyTool() {
|
|
15
|
-
|
|
16
|
-
const tool = {
|
|
16
|
+
const { tool, setFn } = defineHostFnTool({
|
|
17
17
|
name: "github_review_reply",
|
|
18
|
-
label: "github_review_reply",
|
|
19
18
|
description: "Reply inside a specific PR review thread. Use the numeric id from an " +
|
|
20
19
|
"[PR review comment rc-<id> …] message as comment_id; a plain response would post " +
|
|
21
20
|
"as a normal PR comment instead of in-thread. Only available in GitHub PR conversations.",
|
|
22
21
|
parameters: githubReviewReplySchema,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
throw new Error("github_review_reply is only available in GitHub conversations.");
|
|
26
|
-
}
|
|
27
|
-
if (signal?.aborted) {
|
|
28
|
-
throw new Error("Operation aborted");
|
|
29
|
-
}
|
|
22
|
+
unavailable: "github_review_reply is only available in GitHub conversations.",
|
|
23
|
+
run: async (replyFn, args) => {
|
|
30
24
|
const result = await replyFn(args.comment_id, args.body);
|
|
31
25
|
return {
|
|
32
26
|
content: [
|
|
@@ -38,12 +32,7 @@ export function createGithubReviewReplyTool() {
|
|
|
38
32
|
details: undefined,
|
|
39
33
|
};
|
|
40
34
|
},
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
tool,
|
|
44
|
-
setGithubReviewReplyFunction: (fn) => {
|
|
45
|
-
replyFn = fn;
|
|
46
|
-
},
|
|
47
|
-
};
|
|
35
|
+
});
|
|
36
|
+
return { tool, setGithubReviewReplyFunction: setFn };
|
|
48
37
|
}
|
|
49
38
|
//# sourceMappingURL=review-reply.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-reply.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/review-reply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"review-reply.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/review-reply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1C,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;QACtB,WAAW,EACT,gFAAgF;YAChF,wEAAwE;KAC3E,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;CAC7D,CAAC,CAAC;AAIH;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IAIzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAsD;QAC5F,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,uEAAuE;YACvE,mFAAmF;YACnF,yFAAyF;QAC3F,UAAU,EAAE,uBAAuB;QACnC,WAAW,EAAE,gEAAgE;QAC7E,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,+BAA+B,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC,GAAG,EAAE;qBACtE;iBACF;gBACD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\n\nconst githubReviewReplySchema = Type.Object({\n comment_id: Type.Number({\n description:\n \"Numeric id from an [PR review comment rc-<id> …] message in this conversation \" +\n \"(e.g. 8001 for rc-8001). The reply lands inside that comment's thread.\",\n }),\n body: Type.String({ description: \"Reply text (Markdown).\" }),\n});\n\nexport type GithubReviewReplyFn = (commentId: number, body: string) => Promise<{ url: string }>;\n\n/**\n * The `github_review_reply` tool answers inside one inline PR review thread\n * (the responder's normal replies post as plain PR comments instead). Runs\n * host-side as the App; wired per run and only for GitHub conversations.\n */\nexport function createGithubReviewReplyTool(): {\n tool: AgentTool<typeof githubReviewReplySchema>;\n setGithubReviewReplyFunction: (fn: GithubReviewReplyFn | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubReviewReplyFn, typeof githubReviewReplySchema>({\n name: \"github_review_reply\",\n description:\n \"Reply inside a specific PR review thread. Use the numeric id from an \" +\n \"[PR review comment rc-<id> …] message as comment_id; a plain response would post \" +\n \"as a normal PR comment instead of in-thread. Only available in GitHub PR conversations.\",\n parameters: githubReviewReplySchema,\n unavailable: \"github_review_reply is only available in GitHub conversations.\",\n run: async (replyFn, args) => {\n const result = await replyFn(args.comment_id, args.body);\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Replied in review thread rc-${args.comment_id}: ${result.url}`,\n },\n ],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubReviewReplyFunction: setFn };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,QAAA,MAAM,gBAAgB;;EAQpB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,IAAI,EAAE,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACzC,qBAAqB,EAAE,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1D,CAoBA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
|
|
2
3
|
const githubSyncSchema = Type.Object({
|
|
3
4
|
branch: Type.Optional(Type.String({
|
|
4
5
|
description: "Remote branch to fetch. Omit to fetch this PR's latest head (or the default " +
|
|
@@ -12,34 +13,22 @@ const githubSyncSchema = Type.Object({
|
|
|
12
13
|
* the checkout whenever that could lose the agent's local work.
|
|
13
14
|
*/
|
|
14
15
|
export function createGithubSyncTool() {
|
|
15
|
-
|
|
16
|
-
const tool = {
|
|
16
|
+
const { tool, setFn } = defineHostFnTool({
|
|
17
17
|
name: "github_sync",
|
|
18
|
-
label: "github_sync",
|
|
19
18
|
description: "Update ./repo from GitHub: fetches this PR's latest head (or the default branch, " +
|
|
20
19
|
"or a named branch) and fast-forwards the checkout when that cannot lose your work; " +
|
|
21
20
|
"otherwise it fetches to FETCH_HEAD and reports so you can merge or rebase yourself. " +
|
|
22
21
|
"Only available in GitHub conversations.",
|
|
23
22
|
parameters: githubSyncSchema,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throw new Error("github_sync is only available in GitHub conversations.");
|
|
27
|
-
}
|
|
28
|
-
if (signal?.aborted) {
|
|
29
|
-
throw new Error("Operation aborted");
|
|
30
|
-
}
|
|
23
|
+
unavailable: "github_sync is only available in GitHub conversations.",
|
|
24
|
+
run: async (syncFn, args) => {
|
|
31
25
|
const report = await syncFn(args.branch);
|
|
32
26
|
return {
|
|
33
27
|
content: [{ type: "text", text: report }],
|
|
34
28
|
details: undefined,
|
|
35
29
|
};
|
|
36
30
|
},
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
tool,
|
|
40
|
-
setGithubSyncFunction: (fn) => {
|
|
41
|
-
syncFn = fn;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
31
|
+
});
|
|
32
|
+
return { tool, setGithubSyncFunction: setFn };
|
|
44
33
|
}
|
|
45
34
|
//# sourceMappingURL=sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/sync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/sync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,8EAA8E;YAC9E,wCAAwC;KAC3C,CAAC,CACH;CACF,CAAC,CAAC;AAIH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAIlC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAwC;QAC9E,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,mFAAmF;YACnF,qFAAqF;YACrF,sFAAsF;YACtF,yCAAyC;QAC3C,UAAU,EAAE,gBAAgB;QAC5B,WAAW,EAAE,wDAAwD;QACrE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACzC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAClD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\n\nconst githubSyncSchema = Type.Object({\n branch: Type.Optional(\n Type.String({\n description:\n \"Remote branch to fetch. Omit to fetch this PR's latest head (or the default \" +\n \"branch in a plain-issue conversation).\",\n }),\n ),\n});\n\nexport type GithubSyncFn = (branch?: string) => Promise<string>;\n\n/**\n * The `github_sync` tool refreshes the conversation's ./repo clone — a\n * first-contact snapshot the sandbox cannot update itself (no credentials).\n * Host-side fetch with an ephemeral read token; it reports instead of moving\n * the checkout whenever that could lose the agent's local work.\n */\nexport function createGithubSyncTool(): {\n tool: AgentTool<typeof githubSyncSchema>;\n setGithubSyncFunction: (fn: GithubSyncFn | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubSyncFn, typeof githubSyncSchema>({\n name: \"github_sync\",\n description:\n \"Update ./repo from GitHub: fetches this PR's latest head (or the default branch, \" +\n \"or a named branch) and fast-forwards the checkout when that cannot lose your work; \" +\n \"otherwise it fetches to FETCH_HEAD and reports so you can merge or rebase yourself. \" +\n \"Only available in GitHub conversations.\",\n parameters: githubSyncSchema,\n unavailable: \"github_sync is only available in GitHub conversations.\",\n run: async (syncFn, args) => {\n const report = await syncFn(args.branch);\n return {\n content: [{ type: \"text\" as const, text: report }],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubSyncFunction: setFn };\n}\n"]}
|
|
@@ -10,7 +10,7 @@ import { PRODUCT_NAME, formatForceStopped } from "../../platform-messages.js";
|
|
|
10
10
|
import { appendBotResponseLog, appendChannelLog, MessagingEventQueue, withRetry, } from "../shared.js";
|
|
11
11
|
import { processMessageIntake } from "../intake.js";
|
|
12
12
|
import { createSlackAdapters } from "./context.js";
|
|
13
|
-
import { hasMaterializedChatSession, registerThreadSession, } from "../../sessions/
|
|
13
|
+
import { hasMaterializedChatSession, registerThreadSession, } from "../../sessions/chat-history-sync.js";
|
|
14
14
|
import { conversationIdOf } from "../../sessions/session-key.js";
|
|
15
15
|
import { isSlackThreadSessionKey, planSlackAdapterSession, planSlackEventAnchorRun, resolveSlackSessionKey, } from "./session.js";
|
|
16
16
|
import { reportUserFacingError } from "../../observability/sentry.js";
|