mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor: consolidate utility functions into shared package
Move duplicate isObject, asString, asNumber, and safeStringify functions from multiple modules into a centralized shared/src/utils.ts module and update imports across cli, server, and web packages. This eliminates code duplication and improves maintainability.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { AgentMessage, PlanItem } from '@/agent/types';
|
||||
import { asString, deriveToolName, isObject } from '@/agent/utils';
|
||||
import { asString, isObject } from '@hapi/protocol';
|
||||
import { deriveToolName } from '@/agent/utils';
|
||||
import { ACP_SESSION_UPDATE_TYPES } from './constants';
|
||||
|
||||
function normalizeStatus(status: unknown): 'pending' | 'in_progress' | 'completed' | 'failed' {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { AgentBackend, AgentMessage, AgentSessionConfig, PermissionRequest, PermissionResponse, PromptContent } from '@/agent/types';
|
||||
import { asString, isObject } from '@/agent/utils';
|
||||
import { asString, isObject } from '@hapi/protocol';
|
||||
import { AcpStdioTransport, type AcpStderrError } from './AcpStdioTransport';
|
||||
import { AcpMessageHandler } from './AcpMessageHandler';
|
||||
import { logger } from '@/ui/logger';
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
export function isObject(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === 'object';
|
||||
}
|
||||
|
||||
export function asString(value: unknown): string | null {
|
||||
return typeof value === 'string' ? value : null;
|
||||
}
|
||||
import { isObject } from '@hapi/protocol';
|
||||
|
||||
export function deriveToolName(input: {
|
||||
title?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user