Skip to content
English

同步调用、取消和回执的边界 ​

策略的具体实现如下。

ts
export function executeInvocation<Input, Context>(
  invocation: InvocationHandler<Input, Context>,
  input: Input,
  context: Context,
  ports: ToolInvocationPorts<Context> = {},
): void {
  let logger: import('../structs/debug.js').SubFlowLogger | undefined;
  try {
    logger = ports.logger?.(context);
  } catch {
    /* Optional recording cannot block execution. */
  }
  const callId = invocationId();
  return nativeSubFlowSync(
    {
      logger,
      invocationId: callId,
      get signal() {
        return ports.signal?.(context);
      },
    },
    'invocation',
    invocation.id,
    (scopedLogger) => runInvocation(invocation, input, context, ports, scopedLogger, callId),
  );
}

接口参考、使用示例与开发指南。