ai-functions
Version:
Core AI primitives for building intelligent applications
40 lines • 1.33 kB
JavaScript
/**
* Core types for AI functions
*/
// ============================================================================
// Human Function Pending Types
// ============================================================================
/**
* Symbol used to identify pending human function results
*/
export const PENDING_HUMAN_RESULT_SYMBOL = Symbol.for('HumanFunctionPending');
/**
* Type guard to check if a result is a pending human function result.
*
* Use this to safely handle cases where human input is not yet available.
*
* @param value - The value to check
* @returns True if the value is a HumanFunctionPending object
*
* @example
* ```ts
* const result = await reviewDocument({ docId: '123' })
*
* if (isPendingHumanResult(result)) {
* // result is HumanFunctionPending - human input needed
* console.warn('Human review pending:', result.channel)
* return { status: 'pending', channel: result.channel }
* }
*
* // result is ReviewResult - actual human response
* return { status: 'reviewed', approved: result.approved }
* ```
*/
export function isPendingHumanResult(value) {
return (value !== null &&
typeof value === 'object' &&
'_pending' in value &&
value._pending === true &&
PENDING_HUMAN_RESULT_SYMBOL in value);
}
//# sourceMappingURL=types.js.map