Skip to content

Conversation

@rupertsworld
Copy link
Contributor

  • change event names from runtime
  • improve process container wrapping
  • remove deprecated files in CLI
  • add constants file
  • improve documentation
  • small refactor of message types

Copilot AI review requested due to automatic review settings August 1, 2025 01:53
@rupertsworld rupertsworld merged commit 244c40a into main Aug 1, 2025
1 check failed
@rupertsworld rupertsworld deleted the feat/improved-processes branch August 1, 2025 01:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refines the kernel processes and messaging system with updated APIs and improved architecture. The changes modernize the message creation pattern, enhance process management capabilities, and clean up deprecated code.

  • Updated message creation API to use a type-first approach with createMessage(type, options)
  • Enhanced process container architecture with better lifecycle management and serialization
  • Refined event naming convention from snake_case to dot notation for better organization

Reviewed Changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/messages.ts Updated createMessage function to use type-first parameter approach
src/processes.ts Enhanced ProcessContainer with improved lifecycle and serialization capabilities
src/runtime.ts Refactored with dotted event names and added process restoration functionality
src/tools.ts Simplified tool creation with relaxed type constraints
src/stream.ts Updated to use new message creation API and renamed MessageMetadata to BaseMessage
src/kernel.ts Integrated new runtime events and simplified message creation calls
test/*.test.ts Updated all tests to use new createMessage API
cli/src/hooks/useKernel.ts Modified to use Interpreter instead of Kernel (appears incomplete)
docs/* Removed several documentation files and updated introduction with comprehensive examples
cli/deprecated/* Removed deprecated files
Comments suppressed due to low confidence (1)

package.json:50

  • Zod version 3.25.76 does not exist. The latest stable version of Zod is in the 3.23.x range. This version should be corrected to an actual released version.
    "zod": "^3.25.76"

Comment on lines +33 to +41
// export function createTool<TSchema extends ZodType<any, ZodTypeDef, any>>(tool: {
// name: string;
// type?: string;
// description?: string;
// parameters: TSchema;
// execute?: (
// args: z.infer<TSchema>
// ) => JSONValue | Promise<JSONValue> | Process | void;
// }): Tool<TSchema>;
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented-out function overload should be removed if it's no longer needed, or properly implemented if it's still required. Commented code reduces maintainability.

Suggested change
// export function createTool<TSchema extends ZodType<any, ZodTypeDef, any>>(tool: {
// name: string;
// type?: string;
// description?: string;
// parameters: TSchema;
// execute?: (
// args: z.infer<TSchema>
// ) => JSONValue | Promise<JSONValue> | Process | void;
// }): Tool<TSchema>;

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 49
export function createTool(tool: {
name: string;
type?: string;
description?: string;
execute?: (
args: Record<string, never>
) => JSONValue | Promise<JSONValue> | Process;
parameters: any;
execute?: (args: any) => JSONValue | Promise<JSONValue> | Process | void;
}): Tool<undefined>;
export function createTool(tool: any): any {
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'any' type for parameters removes type safety. Consider using a more specific type or generic constraint to maintain type checking benefits.

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 48
export function createTool(tool: {
name: string;
type?: string;
description?: string;
execute?: (
args: Record<string, never>
) => JSONValue | Promise<JSONValue> | Process;
parameters: any;
execute?: (args: any) => JSONValue | Promise<JSONValue> | Process | void;
}): Tool<undefined>;
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'any' type for args parameter removes type safety. The execute function should maintain proper typing based on the parameters schema.

Copilot uses AI. Check for mistakes.
Comment on lines +158 to +159
// TODO
suspend() {}
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty TODO comment should either be removed or include specific details about what needs to be implemented in the suspend method.

Suggested change
// TODO
suspend() {}
suspend() {
this.handleSuspend();
}

Copilot uses AI. Check for mistakes.
this._process?.deactivate();
this.emit('suspend');
}

Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty resume method should either have an implementation or include documentation explaining why it's empty and what the handleResume method does instead.

Suggested change
/**
* The `resume` method is intentionally left empty. It serves as a placeholder
* for subclasses to override if needed. The actual resumption logic is handled
* by the `handleResume` method, which activates the process and emits a 'resume' event.
*/

Copilot uses AI. Check for mistakes.
this._process?.activate();
this.emit('resume');
}

Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty exit method should either have an implementation or include documentation explaining why it's empty and what the handleExit method does instead.

Suggested change
/**
* The `exit` method is intentionally left empty because the actual exit logic
* is handled by the `handleExit` method. This method serves as a placeholder
* or entry point for external calls to trigger the exit process.
*/

Copilot uses AI. Check for mistakes.
Comment on lines +177 to +178
return;
// throw new Error(`Unknown or invalid tool: ${name}`);
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently returning when a tool is not found or lacks execute function could mask configuration errors. Consider logging this condition or providing feedback that the tool call was ignored.

Suggested change
return;
// throw new Error(`Unknown or invalid tool: ${name}`);
console.warn(`Tool "${name}" not found or lacks an execute function. Ignoring this tool call.`);
continue;

Copilot uses AI. Check for mistakes.
Message,
ProcessContainer,
} from '@unternet/kernel';
import { Interpreter, Message, ProcessContainer } from '@unternet/kernel';
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Interpreter import appears to be incorrect since the interpreter.ts file was deleted in this PR. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
ProcessContainer,
} from '@unternet/kernel';
import { Interpreter, Message, ProcessContainer } from '@unternet/kernel';
import { Runtime } from 'inspector/promises';
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import appears to be importing Node.js inspector Runtime instead of the local Runtime class. Should likely be 'import { Runtime } from '@unternet/kernel';'

Suggested change
import { Runtime } from 'inspector/promises';
import { Runtime } from '@unternet/kernel';

Copilot uses AI. Check for mistakes.
import { Runtime } from 'inspector/promises';
import { useState, useEffect, useRef } from 'react';

export function useKernel(opts: KernelOpts) {
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KernelOpts type is referenced but not imported, which will cause a compilation error.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants