UI: approval detail page, agent hiring UX, costs breakdown, sidebar badges, and dashboard improvements
Add ApprovalDetail page with comment thread, revision request/resubmit flow,
and ApprovalPayload component for structured payload display. Extend AgentDetail
with permissions management, config revision history, and duplicate action.
Add agent hire dialog with permission-gated access. Rework Costs page with
per-agent breakdown table and period filtering. Add sidebar badge counts for
pending approvals and inbox items. Enhance Dashboard with live metrics and
sparkline trends. Extend Agents list with pending_approval status and bulk
actions. Update IssueDetail with approval linking. Various component improvements
to MetricCard, InlineEditor, CommentThread, and StatusBadge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:03:08 -06:00
|
|
|
import type {
|
|
|
|
|
Agent,
|
2026-03-19 08:14:29 -05:00
|
|
|
AgentDetail,
|
2026-03-17 13:42:00 -05:00
|
|
|
AgentInstructionsBundle,
|
|
|
|
|
AgentInstructionsFileDetail,
|
2026-03-13 22:49:42 -05:00
|
|
|
AgentSkillSnapshot,
|
2026-02-20 12:50:23 -06:00
|
|
|
AdapterEnvironmentTestResult,
|
UI: approval detail page, agent hiring UX, costs breakdown, sidebar badges, and dashboard improvements
Add ApprovalDetail page with comment thread, revision request/resubmit flow,
and ApprovalPayload component for structured payload display. Extend AgentDetail
with permissions management, config revision history, and duplicate action.
Add agent hire dialog with permission-gated access. Rework Costs page with
per-agent breakdown table and period filtering. Add sidebar badge counts for
pending approvals and inbox items. Enhance Dashboard with live metrics and
sparkline trends. Extend Agents list with pending_approval status and bulk
actions. Update IssueDetail with approval linking. Various component improvements
to MetricCard, InlineEditor, CommentThread, and StatusBadge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:03:08 -06:00
|
|
|
AgentKeyCreated,
|
|
|
|
|
AgentRuntimeState,
|
2026-02-19 14:02:29 -06:00
|
|
|
AgentTaskSession,
|
2026-04-02 11:45:15 -05:00
|
|
|
AgentWakeupResponse,
|
UI: approval detail page, agent hiring UX, costs breakdown, sidebar badges, and dashboard improvements
Add ApprovalDetail page with comment thread, revision request/resubmit flow,
and ApprovalPayload component for structured payload display. Extend AgentDetail
with permissions management, config revision history, and duplicate action.
Add agent hire dialog with permission-gated access. Rework Costs page with
per-agent breakdown table and period filtering. Add sidebar badge counts for
pending approvals and inbox items. Enhance Dashboard with live metrics and
sparkline trends. Extend Agents list with pending_approval status and bulk
actions. Update IssueDetail with approval linking. Various component improvements
to MetricCard, InlineEditor, CommentThread, and StatusBadge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:03:08 -06:00
|
|
|
HeartbeatRun,
|
|
|
|
|
Approval,
|
|
|
|
|
AgentConfigRevision,
|
2026-03-03 08:45:26 -06:00
|
|
|
} from "@paperclipai/shared";
|
|
|
|
|
import { isUuidLike, normalizeAgentUrlKey } from "@paperclipai/shared";
|
2026-03-02 16:44:03 -06:00
|
|
|
import { ApiError, api } from "./client";
|
2026-02-16 13:32:04 -06:00
|
|
|
|
2026-02-17 20:46:12 -06:00
|
|
|
export interface AgentKey {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
createdAt: Date;
|
|
|
|
|
revokedAt: Date | null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-17 13:24:33 -06:00
|
|
|
export interface AdapterModel {
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-28 01:34:48 +01:00
|
|
|
export interface DetectedAdapterModel {
|
2026-03-28 11:35:58 +01:00
|
|
|
model: string;
|
|
|
|
|
provider: string;
|
|
|
|
|
source: string;
|
2026-03-31 20:21:13 +01:00
|
|
|
candidates?: string[];
|
2026-03-28 01:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-23 14:41:21 -06:00
|
|
|
export interface ClaudeLoginResult {
|
|
|
|
|
exitCode: number | null;
|
|
|
|
|
signal: string | null;
|
|
|
|
|
timedOut: boolean;
|
|
|
|
|
loginUrl: string | null;
|
|
|
|
|
stdout: string;
|
|
|
|
|
stderr: string;
|
|
|
|
|
}
|
|
|
|
|
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
export interface OrgNode {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
role: string;
|
|
|
|
|
status: string;
|
|
|
|
|
reports: OrgNode[];
|
|
|
|
|
}
|
|
|
|
|
|
UI: approval detail page, agent hiring UX, costs breakdown, sidebar badges, and dashboard improvements
Add ApprovalDetail page with comment thread, revision request/resubmit flow,
and ApprovalPayload component for structured payload display. Extend AgentDetail
with permissions management, config revision history, and duplicate action.
Add agent hire dialog with permission-gated access. Rework Costs page with
per-agent breakdown table and period filtering. Add sidebar badge counts for
pending approvals and inbox items. Enhance Dashboard with live metrics and
sparkline trends. Extend Agents list with pending_approval status and bulk
actions. Update IssueDetail with approval linking. Various component improvements
to MetricCard, InlineEditor, CommentThread, and StatusBadge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:03:08 -06:00
|
|
|
export interface AgentHireResponse {
|
|
|
|
|
agent: Agent;
|
|
|
|
|
approval: Approval | null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-19 08:14:29 -05:00
|
|
|
export interface AgentPermissionUpdate {
|
|
|
|
|
canCreateAgents: boolean;
|
|
|
|
|
canAssignTasks: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 16:44:03 -06:00
|
|
|
function withCompanyScope(path: string, companyId?: string) {
|
|
|
|
|
if (!companyId) return path;
|
|
|
|
|
const separator = path.includes("?") ? "&" : "?";
|
|
|
|
|
return `${path}${separator}companyId=${encodeURIComponent(companyId)}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function agentPath(id: string, companyId?: string, suffix = "") {
|
|
|
|
|
return withCompanyScope(`/agents/${encodeURIComponent(id)}${suffix}`, companyId);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 13:32:04 -06:00
|
|
|
export const agentsApi = {
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
list: (companyId: string) => api.get<Agent[]>(`/companies/${companyId}/agents`),
|
|
|
|
|
org: (companyId: string) => api.get<OrgNode[]>(`/companies/${companyId}/org`),
|
UI: approval detail page, agent hiring UX, costs breakdown, sidebar badges, and dashboard improvements
Add ApprovalDetail page with comment thread, revision request/resubmit flow,
and ApprovalPayload component for structured payload display. Extend AgentDetail
with permissions management, config revision history, and duplicate action.
Add agent hire dialog with permission-gated access. Rework Costs page with
per-agent breakdown table and period filtering. Add sidebar badge counts for
pending approvals and inbox items. Enhance Dashboard with live metrics and
sparkline trends. Extend Agents list with pending_approval status and bulk
actions. Update IssueDetail with approval linking. Various component improvements
to MetricCard, InlineEditor, CommentThread, and StatusBadge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:03:08 -06:00
|
|
|
listConfigurations: (companyId: string) =>
|
|
|
|
|
api.get<Record<string, unknown>[]>(`/companies/${companyId}/agent-configurations`),
|
2026-03-02 16:44:03 -06:00
|
|
|
get: async (id: string, companyId?: string) => {
|
|
|
|
|
try {
|
2026-03-19 08:14:29 -05:00
|
|
|
return await api.get<AgentDetail>(agentPath(id, companyId));
|
2026-03-02 16:44:03 -06:00
|
|
|
} catch (error) {
|
|
|
|
|
// Backward-compat fallback: if backend shortname lookup reports ambiguity,
|
|
|
|
|
// resolve using company agent list while ignoring terminated agents.
|
|
|
|
|
if (
|
|
|
|
|
!(error instanceof ApiError) ||
|
|
|
|
|
error.status !== 409 ||
|
|
|
|
|
!companyId ||
|
|
|
|
|
isUuidLike(id)
|
|
|
|
|
) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const urlKey = normalizeAgentUrlKey(id);
|
|
|
|
|
if (!urlKey) throw error;
|
|
|
|
|
|
|
|
|
|
const agents = await api.get<Agent[]>(`/companies/${companyId}/agents`);
|
|
|
|
|
const matches = agents.filter(
|
|
|
|
|
(agent) => agent.status !== "terminated" && normalizeAgentUrlKey(agent.urlKey) === urlKey,
|
|
|
|
|
);
|
|
|
|
|
if (matches.length !== 1) throw error;
|
2026-03-19 08:14:29 -05:00
|
|
|
return api.get<AgentDetail>(agentPath(matches[0]!.id, companyId));
|
2026-03-02 16:44:03 -06:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getConfiguration: (id: string, companyId?: string) =>
|
|
|
|
|
api.get<Record<string, unknown>>(agentPath(id, companyId, "/configuration")),
|
|
|
|
|
listConfigRevisions: (id: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentConfigRevision[]>(agentPath(id, companyId, "/config-revisions")),
|
|
|
|
|
getConfigRevision: (id: string, revisionId: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentConfigRevision>(agentPath(id, companyId, `/config-revisions/${revisionId}`)),
|
|
|
|
|
rollbackConfigRevision: (id: string, revisionId: string, companyId?: string) =>
|
|
|
|
|
api.post<Agent>(agentPath(id, companyId, `/config-revisions/${revisionId}/rollback`), {}),
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
create: (companyId: string, data: Record<string, unknown>) =>
|
|
|
|
|
api.post<Agent>(`/companies/${companyId}/agents`, data),
|
UI: approval detail page, agent hiring UX, costs breakdown, sidebar badges, and dashboard improvements
Add ApprovalDetail page with comment thread, revision request/resubmit flow,
and ApprovalPayload component for structured payload display. Extend AgentDetail
with permissions management, config revision history, and duplicate action.
Add agent hire dialog with permission-gated access. Rework Costs page with
per-agent breakdown table and period filtering. Add sidebar badge counts for
pending approvals and inbox items. Enhance Dashboard with live metrics and
sparkline trends. Extend Agents list with pending_approval status and bulk
actions. Update IssueDetail with approval linking. Various component improvements
to MetricCard, InlineEditor, CommentThread, and StatusBadge.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:03:08 -06:00
|
|
|
hire: (companyId: string, data: Record<string, unknown>) =>
|
|
|
|
|
api.post<AgentHireResponse>(`/companies/${companyId}/agent-hires`, data),
|
2026-03-02 16:44:03 -06:00
|
|
|
update: (id: string, data: Record<string, unknown>, companyId?: string) =>
|
|
|
|
|
api.patch<Agent>(agentPath(id, companyId), data),
|
2026-03-19 08:14:29 -05:00
|
|
|
updatePermissions: (id: string, data: AgentPermissionUpdate, companyId?: string) =>
|
|
|
|
|
api.patch<AgentDetail>(agentPath(id, companyId, "/permissions"), data),
|
2026-03-17 13:42:00 -05:00
|
|
|
instructionsBundle: (id: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentInstructionsBundle>(agentPath(id, companyId, "/instructions-bundle")),
|
|
|
|
|
updateInstructionsBundle: (
|
|
|
|
|
id: string,
|
|
|
|
|
data: {
|
|
|
|
|
mode?: "managed" | "external";
|
|
|
|
|
rootPath?: string | null;
|
|
|
|
|
entryFile?: string;
|
|
|
|
|
clearLegacyPromptTemplate?: boolean;
|
|
|
|
|
},
|
|
|
|
|
companyId?: string,
|
|
|
|
|
) => api.patch<AgentInstructionsBundle>(agentPath(id, companyId, "/instructions-bundle"), data),
|
|
|
|
|
instructionsFile: (id: string, relativePath: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentInstructionsFileDetail>(
|
|
|
|
|
agentPath(id, companyId, `/instructions-bundle/file?path=${encodeURIComponent(relativePath)}`),
|
|
|
|
|
),
|
|
|
|
|
saveInstructionsFile: (
|
|
|
|
|
id: string,
|
|
|
|
|
data: { path: string; content: string; clearLegacyPromptTemplate?: boolean },
|
|
|
|
|
companyId?: string,
|
|
|
|
|
) => api.put<AgentInstructionsFileDetail>(agentPath(id, companyId, "/instructions-bundle/file"), data),
|
|
|
|
|
deleteInstructionsFile: (id: string, relativePath: string, companyId?: string) =>
|
|
|
|
|
api.delete<AgentInstructionsBundle>(
|
|
|
|
|
agentPath(id, companyId, `/instructions-bundle/file?path=${encodeURIComponent(relativePath)}`),
|
|
|
|
|
),
|
2026-03-02 16:44:03 -06:00
|
|
|
pause: (id: string, companyId?: string) => api.post<Agent>(agentPath(id, companyId, "/pause"), {}),
|
|
|
|
|
resume: (id: string, companyId?: string) => api.post<Agent>(agentPath(id, companyId, "/resume"), {}),
|
[codex] Improve agent runtime recovery and governance (#4086)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies.
> - The heartbeat runtime, agent import path, and agent configuration
defaults determine whether work is dispatched safely and predictably.
> - Several accumulated fixes all touched agent execution recovery, wake
routing, import behavior, and runtime concurrency defaults.
> - Those changes need to land together so the heartbeat service and
agent creation defaults stay internally consistent.
> - This pull request groups the runtime/governance changes from the
split branch into one standalone branch.
> - The benefit is safer recovery for stranded runs, bounded high-volume
reads, imported-agent approval correctness, skill-template support, and
a clearer default concurrency policy.
## What Changed
- Fixed stranded continuation recovery so successful automatic retries
are requeued instead of incorrectly blocking the issue.
- Bounded high-volume issue/log reads across issue, heartbeat, agent,
project, and workspace paths.
- Fixed imported-agent approval and instruction-path permission
handling.
- Quarantined seeded worktree execution state during worktree
provisioning.
- Queued approval follow-up wakes and hardened SQL_ASCII heartbeat
output handling.
- Added reusable agent instruction templates for hiring flows.
- Set the default max concurrent agent runs to five and updated related
UI/tests/docs.
## Verification
- `pnpm install --frozen-lockfile`
- `pnpm exec vitest run server/src/__tests__/company-portability.test.ts
server/src/__tests__/heartbeat-process-recovery.test.ts
server/src/__tests__/heartbeat-comment-wake-batching.test.ts
server/src/__tests__/heartbeat-list.test.ts
server/src/__tests__/issues-service.test.ts
server/src/__tests__/agent-permissions-routes.test.ts
packages/adapter-utils/src/server-utils.test.ts
ui/src/lib/new-agent-runtime-config.test.ts`
- Split integration check: merged this branch first, followed by the
other [PAP-1614](/PAP/issues/PAP-1614) branches, with no merge
conflicts.
- Confirmed this branch does not include `pnpm-lock.yaml`.
## Risks
- Medium risk: touches heartbeat recovery, queueing, and issue list
bounds in central runtime paths.
- Imported-agent and concurrency default behavior changes may affect
existing automation that assumes one-at-a-time default runs.
- No database migrations are included.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- OpenAI Codex, GPT-5.4 tool-enabled coding model, agentic
code-editing/runtime with local shell and GitHub CLI access; exact
context window and reasoning mode are not exposed by the Paperclip
harness.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-20 06:19:48 -05:00
|
|
|
approve: (id: string, companyId?: string) => api.post<Agent>(agentPath(id, companyId, "/approve"), {}),
|
2026-03-02 16:44:03 -06:00
|
|
|
terminate: (id: string, companyId?: string) => api.post<Agent>(agentPath(id, companyId, "/terminate"), {}),
|
|
|
|
|
remove: (id: string, companyId?: string) => api.delete<{ ok: true }>(agentPath(id, companyId)),
|
|
|
|
|
listKeys: (id: string, companyId?: string) => api.get<AgentKey[]>(agentPath(id, companyId, "/keys")),
|
2026-03-13 22:49:42 -05:00
|
|
|
skills: (id: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentSkillSnapshot>(agentPath(id, companyId, "/skills")),
|
|
|
|
|
syncSkills: (id: string, desiredSkills: string[], companyId?: string) =>
|
|
|
|
|
api.post<AgentSkillSnapshot>(agentPath(id, companyId, "/skills/sync"), { desiredSkills }),
|
2026-03-02 16:44:03 -06:00
|
|
|
createKey: (id: string, name: string, companyId?: string) =>
|
|
|
|
|
api.post<AgentKeyCreated>(agentPath(id, companyId, "/keys"), { name }),
|
|
|
|
|
revokeKey: (agentId: string, keyId: string, companyId?: string) =>
|
|
|
|
|
api.delete<{ ok: true }>(agentPath(agentId, companyId, `/keys/${encodeURIComponent(keyId)}`)),
|
|
|
|
|
runtimeState: (id: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentRuntimeState>(agentPath(id, companyId, "/runtime-state")),
|
|
|
|
|
taskSessions: (id: string, companyId?: string) =>
|
|
|
|
|
api.get<AgentTaskSession[]>(agentPath(id, companyId, "/task-sessions")),
|
|
|
|
|
resetSession: (id: string, taskKey?: string | null, companyId?: string) =>
|
|
|
|
|
api.post<void>(agentPath(id, companyId, "/runtime-state/reset-session"), { taskKey: taskKey ?? null }),
|
[codex] Improve transient recovery and Codex model refresh (#4383)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Adapter execution and retry classification decide whether agent work
pauses, retries, or recovers automatically
> - Transient provider failures need to be classified precisely so
Paperclip does not convert retryable upstream conditions into false hard
failures
> - At the same time, operators need an up-to-date model list for
Codex-backed agents and prompts should nudge agents toward targeted
verification instead of repo-wide sweeps
> - This pull request tightens transient recovery classification for
Claude and Codex, updates the agent prompt guidance, and adds Codex
model refresh support end-to-end
> - The benefit is better automatic retry behavior plus fresher
operator-facing model configuration
## What Changed
- added Codex usage-limit retry-window parsing and Claude extra-usage
transient classification
- normalized the heartbeat transient-recovery contract across adapter
executions and heartbeat scheduling
- documented that deferred comment wakes only reopen completed issues
for human/comment-reopen interactions, while system follow-ups leave
closed work closed
- updated adapter-utils prompt guidance to prefer targeted verification
- added Codex model refresh support in the server route, registry,
shared types, and agent config form
- added adapter/server tests covering the new parsing, retry scheduling,
and model-refresh behavior
## Verification
- `pnpm exec vitest run --project @paperclipai/adapter-utils
packages/adapter-utils/src/server-utils.test.ts`
- `pnpm exec vitest run --project @paperclipai/adapter-claude-local
packages/adapters/claude-local/src/server/parse.test.ts`
- `pnpm exec vitest run --project @paperclipai/adapter-codex-local
packages/adapters/codex-local/src/server/parse.test.ts`
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/adapter-model-refresh-routes.test.ts
server/src/__tests__/adapter-models.test.ts
server/src/__tests__/claude-local-execute.test.ts
server/src/__tests__/codex-local-execute.test.ts
server/src/__tests__/heartbeat-process-recovery.test.ts
server/src/__tests__/heartbeat-retry-scheduling.test.ts`
## Risks
- Moderate behavior risk: retry classification affects whether runs
auto-recover or block, so mistakes here could either suppress needed
retries or over-retry real failures
- Low workflow risk: deferred comment wake reopening is intentionally
scoped to human/comment-reopen interactions so system follow-ups do not
revive completed issues unexpectedly
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- OpenAI Codex GPT-5-based coding agent with tool use and code execution
in the Codex CLI environment
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-24 09:40:40 -05:00
|
|
|
adapterModels: (companyId: string, type: string, options?: { refresh?: boolean }) =>
|
2026-03-05 15:52:59 +01:00
|
|
|
api.get<AdapterModel[]>(
|
[codex] Improve transient recovery and Codex model refresh (#4383)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Adapter execution and retry classification decide whether agent work
pauses, retries, or recovers automatically
> - Transient provider failures need to be classified precisely so
Paperclip does not convert retryable upstream conditions into false hard
failures
> - At the same time, operators need an up-to-date model list for
Codex-backed agents and prompts should nudge agents toward targeted
verification instead of repo-wide sweeps
> - This pull request tightens transient recovery classification for
Claude and Codex, updates the agent prompt guidance, and adds Codex
model refresh support end-to-end
> - The benefit is better automatic retry behavior plus fresher
operator-facing model configuration
## What Changed
- added Codex usage-limit retry-window parsing and Claude extra-usage
transient classification
- normalized the heartbeat transient-recovery contract across adapter
executions and heartbeat scheduling
- documented that deferred comment wakes only reopen completed issues
for human/comment-reopen interactions, while system follow-ups leave
closed work closed
- updated adapter-utils prompt guidance to prefer targeted verification
- added Codex model refresh support in the server route, registry,
shared types, and agent config form
- added adapter/server tests covering the new parsing, retry scheduling,
and model-refresh behavior
## Verification
- `pnpm exec vitest run --project @paperclipai/adapter-utils
packages/adapter-utils/src/server-utils.test.ts`
- `pnpm exec vitest run --project @paperclipai/adapter-claude-local
packages/adapters/claude-local/src/server/parse.test.ts`
- `pnpm exec vitest run --project @paperclipai/adapter-codex-local
packages/adapters/codex-local/src/server/parse.test.ts`
- `pnpm exec vitest run --project @paperclipai/server
server/src/__tests__/adapter-model-refresh-routes.test.ts
server/src/__tests__/adapter-models.test.ts
server/src/__tests__/claude-local-execute.test.ts
server/src/__tests__/codex-local-execute.test.ts
server/src/__tests__/heartbeat-process-recovery.test.ts
server/src/__tests__/heartbeat-retry-scheduling.test.ts`
## Risks
- Moderate behavior risk: retry classification affects whether runs
auto-recover or block, so mistakes here could either suppress needed
retries or over-retry real failures
- Low workflow risk: deferred comment wake reopening is intentionally
scoped to human/comment-reopen interactions so system follow-ups do not
revive completed issues unexpectedly
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- OpenAI Codex GPT-5-based coding agent with tool use and code execution
in the Codex CLI environment
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-24 09:40:40 -05:00
|
|
|
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/models${options?.refresh ? "?refresh=1" : ""}`,
|
2026-03-05 15:52:59 +01:00
|
|
|
),
|
2026-03-28 01:34:48 +01:00
|
|
|
detectModel: (companyId: string, type: string) =>
|
2026-03-28 11:35:58 +01:00
|
|
|
api.get<DetectedAdapterModel | null>(
|
2026-03-28 01:34:48 +01:00
|
|
|
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/detect-model`,
|
|
|
|
|
),
|
2026-02-20 12:50:23 -06:00
|
|
|
testEnvironment: (
|
|
|
|
|
companyId: string,
|
|
|
|
|
type: string,
|
|
|
|
|
data: { adapterConfig: Record<string, unknown> },
|
|
|
|
|
) =>
|
|
|
|
|
api.post<AdapterEnvironmentTestResult>(
|
|
|
|
|
`/companies/${companyId}/adapters/${type}/test-environment`,
|
|
|
|
|
data,
|
|
|
|
|
),
|
2026-03-02 16:44:03 -06:00
|
|
|
invoke: (id: string, companyId?: string) => api.post<HeartbeatRun>(agentPath(id, companyId, "/heartbeat/invoke"), {}),
|
2026-02-17 12:24:48 -06:00
|
|
|
wakeup: (
|
|
|
|
|
id: string,
|
|
|
|
|
data: {
|
|
|
|
|
source?: "timer" | "assignment" | "on_demand" | "automation";
|
|
|
|
|
triggerDetail?: "manual" | "ping" | "callback" | "system";
|
|
|
|
|
reason?: string | null;
|
|
|
|
|
payload?: Record<string, unknown> | null;
|
|
|
|
|
idempotencyKey?: string | null;
|
|
|
|
|
},
|
2026-03-02 16:44:03 -06:00
|
|
|
companyId?: string,
|
2026-04-02 11:45:15 -05:00
|
|
|
) => api.post<AgentWakeupResponse>(agentPath(id, companyId, "/wakeup"), data),
|
2026-03-02 16:44:03 -06:00
|
|
|
loginWithClaude: (id: string, companyId?: string) =>
|
|
|
|
|
api.post<ClaudeLoginResult>(agentPath(id, companyId, "/claude-login"), {}),
|
2026-03-17 09:10:40 -05:00
|
|
|
availableSkills: () =>
|
|
|
|
|
api.get<{ skills: AvailableSkill[] }>("/skills/available"),
|
2026-02-16 13:32:04 -06:00
|
|
|
};
|
2026-03-17 09:10:40 -05:00
|
|
|
|
|
|
|
|
export interface AvailableSkill {
|
|
|
|
|
name: string;
|
|
|
|
|
description: string;
|
|
|
|
|
isPaperclipManaged: boolean;
|
|
|
|
|
}
|